-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathPspProcessDelete.h
294 lines (293 loc) · 8.9 KB
/
PspProcessDelete.h
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
void __fastcall PspProcessDelete(ULONG_PTR BugCheckParameter2)
{
_QWORD *v1; // rsi
struct _KTHREAD *CurrentThread; // rbx
__int64 v4; // rcx
_QWORD *v5; // rax
void *v6; // rcx
void *v7; // rcx
__int64 v8; // rcx
HANDLE ProcessId; // rax
__int64 v10; // rax
bool v11; // zf
void *v12; // rcx
__int64 v13; // rax
__int64 v14; // rcx
__int128 *v15; // r9
__int64 v16; // r8
int v17; // r10d
unsigned int v18; // r11d
__int64 v19; // rdx
__int64 v20; // rax
__int64 v21; // rax
__int64 v22; // rdx
_QWORD *v23; // rbx
const char *v24; // rax
unsigned int v25; // r10d
unsigned __int64 v26; // rcx
__int64 v27; // r9
unsigned __int64 v28; // rax
__int64 v29; // rax
__int128 *v30; // r10
__int64 v31; // rax
int v32; // r9d
__int64 v33; // rcx
__int64 v34; // rax
volatile signed __int32 *v35; // rcx
__int64 v36; // rcx
void *v37; // rcx
__int16 v38; // bx
unsigned int v39; // ebx
_QWORD *v40; // rax
__int64 v41; // rcx
struct _EX_RUNDOWN_REF *v42; // rax
__int128 v43[3]; // [rsp+38h] [rbp-50h] BYREF
*(_DWORD *)(BugCheckParameter2 + 1124) &= ~0x4000000u;
v1 = (_QWORD *)(BugCheckParameter2 + 1096);
memset(v43, 0, sizeof(v43));
CurrentThread = KeGetCurrentThread();
if ( *(_QWORD *)(BugCheckParameter2 + 1096) )
{
--CurrentThread->SpecialApcDisable;
ExAcquirePushLockExclusiveEx((ULONG_PTR)&PspActiveProcessLock, 0i64);
v4 = *v1;
if ( *(_QWORD **)(*v1 + 8i64) != v1 || (v5 = (_QWORD *)v1[1], (_QWORD *)*v5 != v1) )
__fastfail(3u);
*v5 = v4;
*(_QWORD *)(v4 + 8) = v5;
PspUnlockProcessListExclusive(CurrentThread);
}
v6 = *(void **)(BugCheckParameter2 + 1472);
if ( v6 )
{
ExFreePoolWithTag(v6, 0);
*(_QWORD *)(BugCheckParameter2 + 1472) = 0i64;
}
ObClearProcessDeviceMap(BugCheckParameter2);
if ( *(_QWORD *)(BugCheckParameter2 + 2464) )
ZwDeleteWnfStateName();
v7 = *(void **)(BugCheckParameter2 + 1400);
if ( v7 )
{
ObfDereferenceObject(v7);
*(_QWORD *)(BugCheckParameter2 + 1400) = 0i64;
}
v8 = *(_QWORD *)(BugCheckParameter2 + 1200);
if ( v8 )
{
ObfDereferenceObject((PVOID)(v8 & 0xFFFFFFFFFFFFFFF8ui64));
*(_QWORD *)(BugCheckParameter2 + 1200) = 0i64;
}
ProcessId = PsGetProcessId((PEPROCESS)BugCheckParameter2);
WbRemoveWarbirdProcess(ProcessId);
if ( (*(_DWORD *)(BugCheckParameter2 + 1124) & 0x40000) != 0 )
{
KiStackAttachProcess(BugCheckParameter2);
if ( (*(_DWORD *)(BugCheckParameter2 + 1120) & 0x400) != 0 )
(*((void (__fastcall **)(ULONG_PTR))&xmmword_140C1BD30 + 1))(BugCheckParameter2);
PspExitProcess(0i64, BugCheckParameter2);
KiUnstackDetachProcess(v43, 0i64);
MmDeleteProcessAddressSpace(BugCheckParameter2);
}
if ( *(_QWORD *)(BugCheckParameter2 + 1296) )
{
PspRemoveProcessFromJobChain(BugCheckParameter2);
ObDereferenceObjectDeferDeleteWithTag(*(PVOID *)(BugCheckParameter2 + 1296), 0x73507350u);
*(_QWORD *)(BugCheckParameter2 + 1296) = 0i64;
*(_QWORD *)(BugCheckParameter2 + 1256) = 0i64;
*(_QWORD *)(BugCheckParameter2 + 2160) = MmBadPointer;
}
if ( *(_QWORD *)(BugCheckParameter2 + 2520) )
PsDereferencePartition();
if ( *(_QWORD *)(BugCheckParameter2 + 992) )
KeUnsecureProcess(BugCheckParameter2);
if ( *(_QWORD *)(BugCheckParameter2 + 1088) )
{
--CurrentThread->SpecialApcDisable;
v10 = ExMapHandleToPointer(PspCidTable, *(_QWORD *)(BugCheckParameter2 + 1088));
if ( !v10 )
KeBugCheck(0x17u);
ExDestroyHandle(PspCidTable, *(_QWORD *)(BugCheckParameter2 + 1088), v10);
v11 = CurrentThread->SpecialApcDisable++ == -1;
if ( v11 && ($52EAA7366E9607A22D070977C3EFB536 *)CurrentThread->ApcState.ApcListHead[0].Flink != &CurrentThread->152 )
KiCheckForKernelApcDelivery();
}
if ( *(_QWORD *)(BugCheckParameter2 + 1208) )
SeDeassignPrimaryToken(BugCheckParameter2);
v12 = *(void **)(BugCheckParameter2 + 1328);
if ( v12 )
{
ExFreePoolWithTag(v12, 0);
PsReturnProcessNonPagedPoolQuota(BugCheckParameter2, 24616i64);
}
v13 = SmpKeyedStoreEntryGet((ULONG_PTR)&qword_140D321C8);
if ( v13 )
{
v38 = *(_WORD *)(v13 + 16);
CmSiFreeMemory((PPRIVILEGE_SET)v13);
v39 = v38 & 0x3FF;
v40 = (_QWORD *)SmKmStoreRefFromStoreIndex(&SmGlobals, v39);
SmKmStoreDeleteWhenEmpty(v41, *v40, 1i64);
v42 = (struct _EX_RUNDOWN_REF *)SmKmStoreRefFromStoreIndex(&SmGlobals, v39);
ExReleaseRundownProtection(v42 + 1);
}
EtwExitProcess(BugCheckParameter2);
LpcExitProcess(BugCheckParameter2);
ExWnfExitProcess(BugCheckParameter2, 1i64);
IoSetDiskIoAttributionOnProcess(0i64, BugCheckParameter2);
PoEnergyContextCleanup(BugCheckParameter2);
v14 = *(_QWORD *)(BugCheckParameter2 + 2288);
if ( v14 )
{
VmpProcessContextCleanup();
ExFreePoolWithTag(*(PVOID *)(BugCheckParameter2 + 2288), 0);
}
LOBYTE(v14) = 1;
if ( KiQueryUnbiasedInterruptTime(v14) >= (unsigned __int64)qword_140C4ECB0 )
{
v15 = &KeServiceDescriptorTable;
_mm_prefetch((const char *)&KeServiceDescriptorTable, 0);
v16 = qword_140C4ECA0;
v17 = 64;
v18 = qword_140C4ECA8;
v19 = qword_140C4ECA0;
v20 = 8i64;
do
{
v19 = __ROR8__(v19 - *(_QWORD *)v15, qword_140C4ECA8);
v15 = (__int128 *)((char *)v15 + 8);
v17 -= 8;
--v20;
}
while ( v20 );
for ( ; v17; --v17 )
{
v21 = *(unsigned __int8 *)v15;
v15 = (__int128 *)((char *)v15 + 1);
v19 = __ROR8__(v19 - v21, qword_140C4ECA8);
}
v11 = qword_140C4ECB8 == v19;
v22 = qword_140C4EC70;
if ( !v11 && !qword_140C4EC70 )
{
v18 = qword_140C4ECA8;
v16 = qword_140C4ECA0;
v22 = (unsigned int)__ROR4__(2120, 35);
qword_140C4EC70 = (unsigned int)v22;
xmmword_140C4EC78 = 0i64;
qword_140C4EC88 = 267i64;
qword_140C4EC90 = (__int64)&KeServiceDescriptorTable;
}
v23 = (_QWORD *)KeServiceDescriptorTable;
v24 = (const char *)KeServiceDescriptorTable;
v25 = 4 * xmmword_140E018D0;
v26 = KeServiceDescriptorTable + (unsigned int)(4 * xmmword_140E018D0);
if ( (unsigned __int64)KeServiceDescriptorTable < v26 )
{
do
{
_mm_prefetch(v24, 0);
v24 += 64;
}
while ( (unsigned __int64)v24 < v26 );
}
v27 = v16;
if ( v25 >= 8 )
{
v28 = (unsigned __int64)v25 >> 3;
do
{
v27 = __ROR8__(v27 - *v23++, v18);
v25 -= 8;
--v28;
}
while ( v28 );
}
for ( ; v25; --v25 )
{
v29 = *(unsigned __int8 *)v23;
v23 = (_QWORD *)((char *)v23 + 1);
v27 = __ROR8__(v27 - v29, v18);
}
if ( qword_140C4ECC0 != v27 && !v22 )
{
v18 = qword_140C4ECA8;
v16 = qword_140C4ECA0;
v22 = (unsigned int)__ROR4__(1111490560, 150);
qword_140C4EC70 = (unsigned int)v22;
xmmword_140C4EC78 = 0i64;
qword_140C4EC88 = 267i64;
qword_140C4EC90 = KeServiceDescriptorTable;
}
v30 = &KeServiceDescriptorTableShadow;
_mm_prefetch((const char *)&KeServiceDescriptorTableShadow, 0);
v31 = 4i64;
v32 = 32;
do
{
v33 = v18;
v16 = __ROR8__(v16 - *(_QWORD *)v30, v18);
v30 = (__int128 *)((char *)v30 + 8);
v32 -= 8;
--v31;
}
while ( v31 );
for ( ; v32; --v32 )
{
v34 = *(unsigned __int8 *)v30;
v33 = v18;
v30 = (__int128 *)((char *)v30 + 1);
v16 = __ROR8__(v16 - v34, v18);
}
if ( qword_140C4ECC8 != v16 && !v22 )
{
qword_140C4EC88 = 267i64;
v22 = (unsigned int)__ROR4__(603979780, 186);
qword_140C4EC70 = (unsigned int)v22;
xmmword_140C4EC78 = 0i64;
qword_140C4EC90 = (__int64)&KeServiceDescriptorTableShadow;
}
if ( (_QWORD)KeServiceDescriptorTableShadow != (_QWORD)KeServiceDescriptorTable
|| (_DWORD)xmmword_140D07010 != (_DWORD)xmmword_140E018D0 )
{
if ( v22 )
goto LABEL_57;
v22 = (unsigned int)__ROR4__(4240, 68);
qword_140C4EC70 = (unsigned int)v22;
xmmword_140C4EC78 = 0i64;
qword_140C4EC88 = 267i64;
qword_140C4EC90 = KeServiceDescriptorTableShadow;
}
if ( !v22 )
{
LABEL_62:
LOBYTE(v33) = 1;
qword_140C4ECB0 = KiQueryUnbiasedInterruptTime(v33)
+ 41929663 * (__rdtsc() >> 4) % 0x12A05F2000i64
+ 288000000000i64;
goto LABEL_63;
}
LABEL_57:
if ( (KDEFERRED_ROUTINE *)DeferredContext.DeferredRoutine != KiSchedulerDpc )
KeInitializeDpc(&DeferredContext, KiSchedulerDpc, &DeferredContext);
qword_140C4EC98 = 1845792i64;
KeInsertQueueDpc(&DeferredContext, 0i64, 0i64);
goto LABEL_62;
}
LABEL_63:
v35 = *(volatile signed __int32 **)(BugCheckParameter2 + 1384);
if ( v35 )
{
_InterlockedAdd(v35 + 129, 0xFFFFFFFF);
PspDereferenceQuotaBlock((PVOID)v35);
}
v36 = *(_QWORD *)(BugCheckParameter2 + 1024);
if ( v36 )
ExSaFree(v36, 16i64);
v37 = *(void **)(BugCheckParameter2 + 1408);
if ( v37 )
{
ExFreePoolWithTag(v37, 0);
*(_QWORD *)(BugCheckParameter2 + 1408) = 0i64;
}
}