00001
00007 #include "Cpuid.h"
00008
00009
00010
00011 __declspec(naked) int __stdcall CpuInfo(PCPUINFOS pcpuinf)
00012 {
00013 __asm {
00014 push ebx
00015 xor eax, eax
00016 cpuid
00017 test eax, eax
00018 mov eax, [esp+8]
00019 jne short cpuidOK ; PAS BON ON SORT
00020 pop ebx
00021 ret 4
00022 cpuidOK:
00023 push ebp
00024 push edi
00025 mov ebp, [eax] ; EBP = *pszVendorId
00026 mov edi, eax ; EDI = pcpuinf
00027 test ebp, ebp
00028 jz short GO_CpuName
00029 xor eax, eax
00030 mov [ebp], ebx
00031 mov [ebp+4], edx
00032 mov [ebp+8], ecx
00033 mov dword ptr[ebp+12], eax
00034 GO_CpuName:
00035 mov ebp, [edi+4] ; EBP = pszCpuName
00036 mov eax, 80000000h
00037 test ebp, ebp
00038 jz short GO_EAX1
00039 cpuid
00040 xor edx, edx
00041 cmp eax, 80000004h
00042 jae short cpunameOK
00043 mov [ebp], edx
00044 jmp short GO_EAX1
00045 cpunameOK:
00046 mov eax, 80000002h
00047 cpuid ; 1ere PASSE
00048 mov [ebp], eax
00049 mov [ebp+4], ebx
00050 mov [ebp+8], ecx
00051 mov [ebp+12], edx
00052 mov eax, 80000003h
00053 add ebp, 16
00054 cpuid ; 2eme PASSE
00055 mov [ebp], eax
00056 mov [ebp+4], ebx
00057 mov [ebp+8], ecx
00058 mov [ebp+12], edx
00059 mov eax, 80000004h
00060 add ebp, 16
00061 cpuid ; 3eme PASSE
00062 mov [ebp+4], ebx
00063 mov [ebp+12], edx
00064 lea ebx, [ebp-32]
00065 mov [ebp], eax
00066 lea edx, [ebx-1]
00067 mov [ebp+8], ecx
00068 trimL:
00069 inc edx
00070 cmp byte ptr[edx], 32
00071 je short trimL
00072 cmp edx, ebx
00073 je short GO_EAX1 ; PAS DE TRIML A FAIRE
00074 goName:
00075 mov al, [edx]
00076 mov [ebx], al
00077 inc edx
00078 inc ebx
00079 test al, al
00080 jne short goName
00081 GO_EAX1:
00082 mov eax, 1
00083 cpuid
00084 mov edx, eax
00085 shr ebx, 16
00086 mov ecx, eax
00087 and edx, 0Fh
00088 test bl, bl
00089 jne short countOK
00090 inc bl
00091 countOK:
00092 shr eax, 4
00093 mov [edi+8], bl ; CountOfLogicalProcessors
00094 mov [edi+11], dl ; SteppingID
00095 and ecx, 0F00h
00096 and eax, 0Fh
00097 mov [edi+9], ch ; FamilyCode
00098 mov [edi+10], al ; ModelNumber
00099 infoExit:
00100 pop edi
00101 pop ebp
00102 pop ebx
00103 ret 4
00104 }
00105 }