-
Notifications
You must be signed in to change notification settings - Fork 47
/
struct.asm
178 lines (160 loc) · 2.16 KB
/
struct.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
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
; --------------------------------------- Macro and Structure Definitions ---------------------------------------
macro linear reg,trg,seg = DATA16
{
; xor reg,reg
mov reg,seg
shl reg,4
add reg,trg
}
macro dh_virtualization
{
local .nuvmx
local .nvmx
; dh -> 0 no virtualization
; dh -> 1 virtualization plain
; dh -> 2 virtualization unrestricted guest
mov eax,1
cpuid
xor dx,dx
bt ecx,5
jnc .nvmx
mov dh,1
xor eax,eax
xor edx,edx
mov ecx,0x48B ; IA32_VMX_PROCBASED_CTLS2
rdmsr
bt edx,7
jnc .nuvmx
mov dh,2
jmp .nvmx
.nuvmx:
mov dh,1
.nvmx:
}
macro pushadxeax
{
push ebx
push ecx
push edx
push esi
push edi
push ebp
}
macro popadxeax
{
pop ebp
pop edi
pop esi
pop edx
pop ecx
pop ebx
}
macro push64
{
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
push rbp
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
}
macro pop64
{
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rbp
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
}
struc A_CPU a,b,c,d
{
.acpi dd a
.apic dd b
.flags dd c
.handle dd d
}
struc GDT_STR s0_15,b0_15,b16_23,flags,access,b24_31
{
.s0_15 dw s0_15
.b0_15 dw b0_15
.b16_23 db b16_23
.flags db flags
.access db access
.b24_31 db b24_31
}
struc IDT_STR o0_15,se0_15,zb,flags,o16_31
{
.o0_15 dw o0_15
.se0_15 dw se0_15
.zb db zb
.flags db flags
.o16_31 dw o16_31
}
struc IDT_STR64 o0_15,se0_15,zb,flags,o16_31,o32_63,zr
{
.o0_15 dw o0_15
.se0_15 dw se0_15
.zb db zb
.flags db flags
.o16_31 dw o16_31
.o32_63 dd o32_63
.zr dd zr
}
macro vmw16 code,value
{
mov ebx,code
xor eax,eax
mov ax,value
vmwrite ebx,eax
}
macro vmw32 code,value
{
mov ebx,code
mov eax,value
vmwrite ebx,eax
}
macro vmw64 code,value
{
mov rbx,code
mov rax,value
vmwrite rbx,rax
}
macro vmr r,code
{
mov rbx,code
vmread r,rbx
}
macro break
{
xchg bx,bx
}
struc LoadX a,b,c,d,e,f,g
{
.f1 dw a
.f2 dd b
.f3 dd c
.f4 dd d
.sp dw g
.ss dw f
.cs dw e
.ip dw e
}