1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
| #include <Windows.h>
#include <stdio.h>
#include <xmmintrin.h>
#include <iphlpapi.h>
#include <Rpc.h>
static void GetMACaddress(void);
static void uuidGetMACaddress(void);
int main(){
SYSTEM_INFO SysInfo;
GetSystemInfo(&SysInfo);
printf("Processors - %d\
" , SysInfo.dwNumberOfProcessors);
DWORD a , b , c , d , e;
DWORD BasicLeaves;
char* VendorID = (char*)malloc(20);
char* message = (char*)malloc(20);
_asm {
pusha
pushfd
pop eax
push eax
xor eax , 0x00200000
push eax
popfd
pushfd
pop ecx
pop eax
xor eax , ecx
mov [a] , eax
}
if(a & 0x00200000){
printf("CPUID opcode supported.\
");
} else {
printf("CPUID opcode not supported, exiting...\
");
return 0;
}
//DWORD* pa = &a[0];
//DWORD* pb = &a[1];
//DWORD* pc = &a[2];
//DWORD* pd = &a[3];
//a[4] = 0;
e = 0;
__asm {
mov eax , 0
cpuid
mov [BasicLeaves] , eax;
mov [b] , ebx;
mov [c] , ecx;
mov [d] , edx;
}
memcpy(&VendorID[0] , &b , 4);
memcpy(&VendorID[4] , &d , 4);
memcpy(&VendorID[8] , &c , 4);
VendorID[12] = 0;
printf("%d Basic Leaves\
VendorID - %s\
" , BasicLeaves , VendorID);
__asm {
mov eax , 1
cpuid
mov [a] , eax;
mov [b] , ebx;
mov [c] , ecx;
mov [d] , edx;
}
if(d & 0x00000001) printf("FPU\
");
if(d & 0x00000200) printf("APIC On-Chip\
");
if(d & 0x00040000) printf("Processor Serial Number Present\
");
if(d & 0x00800000) printf("MMX\
");
if(d & 0x01000000) printf("SSE\
");
if(d & 0x02000000) printf("SSE2\
");
if(d & 0x08000000) printf("Hyperthreading (HTT)\
");
if(c & 0x00000001) printf("SSE3\
");
if(c & 0x00000200) printf("SSSE3\
");
if(c & 0x00080000) printf("SSE4.1\
");
if(c & 0x00100000) printf("SSE4.2\
");
if(c & 0x02000000) printf("AES\
");
__asm {
mov eax , 0x80000000
cpuid
and eax , 0x7fffffff;
mov [a] , eax;
mov [b] , ebx;
mov [c] , ecx;
mov [d] , edx;
}
printf("%d Extended Leaves\
" , a);
printf("Processor Brand String -");
__asm {
mov eax , 0x80000002
cpuid
mov [a] , eax;
mov [b] , ebx;
mov [c] , ecx;
mov [d] , edx;
}
memcpy(&message[0] , &a , 4);
memcpy(&message[4] , &b , 4);
memcpy(&message[8] , &c , 4);
memcpy(&message[12] , &d , 4);
message[16] = 0;
printf("%s" , message);
__asm {
mov eax , 0x80000003
cpuid
mov [a] , eax;
mov [b] , ebx;
mov [c] , ecx;
mov [d] , edx;
}
memcpy(&message[0] , &a , 4);
memcpy(&message[4] , &b , 4);
memcpy(&message[8] , &c , 4);
memcpy(&message[12] , &d , 4);
message[16] = 0;
printf("%s" , message);
__asm {
mov eax , 0x80000004
cpuid
mov [a] , eax;
mov [b] , ebx;
mov [c] , ecx;
mov [d] , edx;
popa
}
memcpy(&message[0] , &a , 4);
memcpy(&message[4] , &b , 4);
memcpy(&message[8] , &c , 4);
memcpy(&message[12] , &d , 4);
message[16] = 0;
printf("%s\
" , message);
char VolumeName[256]; DWORD VolumeSerialNumber; DWORD MaxComponentLength; DWORD FileSystemFlags; char FileSystemNameBuffer[256];
GetVolumeInformationA("c:\\\" , VolumeName , 256 , &VolumeSerialNumber , &MaxComponentLength , &FileSystemFlags , (LPSTR)&FileSystemNameBuffer , 256);
printf("Serialnumber - %X\
" , VolumeSerialNumber);
GetMACaddress();
uuidGetMACaddress();
return 0;
}
// Fetches the MAC address and prints it
static void GetMACaddress(void){
IP_ADAPTER_INFO AdapterInfo[16]; // Allocate information
// for up to 16 NICs
DWORD dwBufLen = sizeof(AdapterInfo); // Save memory size of buffer
DWORD dwStatus = GetAdaptersInfo( // Call GetAdapterInfo
AdapterInfo, // [out] buffer to receive data
&dwBufLen); // [in] size of receive data buffer
//assert(dwStatus == ERROR_SUCCESS); // Verify return value is
// valid, no buffer overflow
PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to
// current adapter info
do {
printf("Adapter MAC Address - %X-%X-%X-%X-%X-%X\
" , pAdapterInfo->Address[0] , pAdapterInfo->Address[1] , pAdapterInfo->Address[2] , pAdapterInfo->Address[3] , pAdapterInfo->Address[4] , pAdapterInfo->Address[5]);
printf("Adapter IP Address - %s\
" , pAdapterInfo->CurrentIpAddress);
printf("Adapter Type - %d\
" , pAdapterInfo->Type);
printf("Adapter Name - %s\
" , pAdapterInfo->AdapterName);
printf("Adapter Description - %s\
" , pAdapterInfo->Description);
uuidGetMACaddress();
printf("\
");
//PrintMACaddress(pAdapterInfo->Address); // Print MAC address
pAdapterInfo = pAdapterInfo->Next; // Progress through
// linked list
} while(pAdapterInfo); // Terminate if last adapter
}
// Fetches the MAC address and prints it
static void uuidGetMACaddress(void)
{
unsigned char MACData[6];
UUID uuid;
UuidCreateSequential( &uuid ); // Ask OS to create UUID
for (int i=2; i<8; i++) // Bytes 2 through 7 inclusive
// are MAC address
MACData[i - 2] = uuid.Data4[i];
printf("UUID MAC Address - %X-%X-%X-%X-%X-%X\
" , MACData[0] , MACData[1] , MACData[2] , MACData[3] , MACData[4] , MACData[5]);
}//*/ |