Project

General

Profile

SO3Engine
Cpuid.cpp
Go to the documentation of this file.
1
8#if defined(_WIN32) && !defined(_WIN64)
9#include "SCOLBasic/Cpuid.h"
10
11__declspec(naked) int __stdcall CpuInfo(PCPUINFOS pcpuinf)
12{
13 __asm {
14 push ebx
15 xor eax, eax
16 cpuid
17 test eax, eax
18 mov eax, [esp+8]
19 jne short cpuidOK ; PAS BON ON SORT
20 pop ebx
21 ret 4
22cpuidOK:
23 push ebp
24 push edi
25 mov ebp, [eax] ; EBP = *pszVendorId
26 mov edi, eax ; EDI = pcpuinf
27 test ebp, ebp
28 jz short GO_CpuName
29 xor eax, eax
30 mov [ebp], ebx
31 mov [ebp+4], edx
32 mov [ebp+8], ecx
33 mov dword ptr[ebp+12], eax
34GO_CpuName:
35 mov ebp, [edi+4] ; EBP = pszCpuName
36 mov eax, 80000000h
37 test ebp, ebp
38 jz short GO_EAX1
39 cpuid
40 xor edx, edx
41 cmp eax, 80000004h
42 jae short cpunameOK
43 mov [ebp], edx
44 jmp short GO_EAX1
45cpunameOK:
46 mov eax, 80000002h
47 cpuid ; 1ere PASSE
48 mov [ebp], eax
49 mov [ebp+4], ebx
50 mov [ebp+8], ecx
51 mov [ebp+12], edx
52 mov eax, 80000003h
53 add ebp, 16
54 cpuid ; 2eme PASSE
55 mov [ebp], eax
56 mov [ebp+4], ebx
57 mov [ebp+8], ecx
58 mov [ebp+12], edx
59 mov eax, 80000004h
60 add ebp, 16
61 cpuid ; 3eme PASSE
62 mov [ebp+4], ebx
63 mov [ebp+12], edx
64 lea ebx, [ebp-32]
65 mov [ebp], eax
66 lea edx, [ebx-1]
67 mov [ebp+8], ecx
68trimL:
69 inc edx
70 cmp byte ptr[edx], 32
71 je short trimL
72 cmp edx, ebx
73 je short GO_EAX1 ; PAS DE TRIML A FAIRE
74goName:
75 mov al, [edx]
76 mov [ebx], al
77 inc edx
78 inc ebx
79 test al, al
80 jne short goName
81GO_EAX1:
82 mov eax, 1
83 cpuid
84 mov edx, eax
85 shr ebx, 16
86 mov ecx, eax
87 and edx, 0Fh
88 test bl, bl
89 jne short countOK
90 inc bl
91countOK:
92 shr eax, 4
93 mov [edi+8], bl ; CountOfLogicalProcessors
94 mov [edi+11], dl ; SteppingID
95 and ecx, 0F00h
96 and eax, 0Fh
97 mov [edi+9], ch ; FamilyCode
98 mov [edi+10], al ; ModelNumber
99infoExit:
100 pop edi
101 pop ebp
102 pop ebx
103 ret 4
104 jne short infoExit
105 }
106}
107
108#endif
__declspec(naked) int __stdcall CpuInfo(PCPUINFOS pcpuinf)
Definition Cpuid.cpp:11
Code to retrieve user Processor Datas.
int __stdcall CpuInfo(PCPUINFOS pcpuinf)