-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpuinfo.asm
76 lines (59 loc) · 1.01 KB
/
cpuinfo.asm
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
format ELF executable 3
entry _
segment readable writeable executable
_:
mov eax, 80000000h
cpuid
cmp eax, 80000004h
jb exit
mov edi, cpuname
mov eax, 80000002h
call get_cpu_name_part
mov eax, 80000003h
call get_cpu_name_part
mov eax, 80000004h
call get_cpu_name_part
mov ecx, cpuname
mov edx, cpuname_size
call print
mov eax, 1
cpuid
shl ecx, 1
jnc exit
vm:
mov eax, 40000000h
cpuid
mov edi, hypervisor
call save_cpuid_string2
mov ecx, hypervisor
mov edx, hypervisor_size
call print
jmp exit
get_cpu_name_part:
cpuid
call save_cpuid_string
ret
print:
mov ebx, 1
mov eax, 4
int 80h
ret
exit:
mov eax, 1
int 80h
save_cpuid_string:
stosd
save_cpuid_string2:
mov eax, ebx
stosd
mov eax, ecx
stosd
mov eax, edx
stosd
ret
cpuname rb 48
db 0x0A
cpuname_size = $ - cpuname
hypervisor rb 12
db 0x0A
hypervisor_size = $ - hypervisor