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 |
__int64 sub_1400075D4()
{
unsigned int v0; // ebx
__int64 (__fastcall *v1)(_QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD); // r15
__int64 (__fastcall *RtlCreateUserThreadFunc)(_QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD); // r13
__int64 result; // rax
int *v4; // rdi
const void *win32kModule; // r14
__int64 win32kfullModule; // rax
__int64 v7; // r8
__int64 v8; // r9
__int64 win32kfullModule1; // rsi
__int64 v10; // r8
__int64 v11; // r9
__int64 v12; // r8
__int64 v13; // r9
__int64 v14; // r8
__int64 v15; // r9
__int64 v16; // r8
__int64 v17; // r9
__int64 v18; // r8
__int64 v19; // r9
PIMAGE_NT_HEADERS winkNts; // rax
PIMAGE_NT_HEADERS winkNts1; // rsi
__int64 win32SizeOfImage; // r12
int v23; // eax
const void *v24; // rbx
const void *W32pServiceTable1; // [rsp+30h] [rbp-48h] BYREF
__int64 v26; // [rsp+38h] [rbp-40h] BYREF
const void *v27; // [rsp+40h] [rbp-38h] BYREF
__int64 v28; // [rsp+48h] [rbp-30h] BYREF
__int64 (__fastcall *v29)(_QWORD, _QWORD); // [rsp+50h] [rbp-28h] BYREF
__int64 W32pServiceTable2; // [rsp+58h] [rbp-20h] BYREF
UNICODE_STRING DestinationString; // [rsp+60h] [rbp-18h] BYREF
const void *win32kMemoryModule; // [rsp+C0h] [rbp+48h] BYREF
__int64 v33; // [rsp+C8h] [rbp+50h] BYREF
__int64 NtUserGetWindowDisplayAffinity; // [rsp+D0h] [rbp+58h] BYREF
__int64 NtUserSetWindowDisplayAffinity; // [rsp+D8h] [rbp+60h] BYREF
v0 = 0;
v1 = 0i64;
v26 = 0i64;
v27 = 0i64;
v29 = 0i64;
v28 = 0i64;
if ( qword_140011700 )
return 0i64;
RtlInitUnicodeString_0(&DestinationString, L"RtlCreateUserThread");
RtlCreateUserThreadFunc = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD))sub_140014948();
if ( !RtlCreateUserThreadFunc )
{
v1 = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD))GetNtCreateThreadEx();
if ( !v1 )
return 0xE01AF211i64;
}
if ( version1 != 1 && version1 != 2 && version1 != 3 )
{
if ( version1 != 4 )
{
switch ( version1 )
{
case 6:
v4 = (int *)&unk_140010480;
break;
case 7:
v4 = (int *)&unk_1400104D0;
break;
case 8:
v4 = (int *)&unk_140010520;
break;
default:
result = sub_140006D7C();
if ( (int)result < 0 )
{
_mm_lfence();
return result;
}
v4 = (int *)&unk_140010570;
LABEL_20:
j_DbgPrint_54("check ntusercalloneparam\n");
if ( v4[9] >= 0 )
{
j_DbgPrint_55("load win32k image\n");
if ( (int)readSysFileToMemory((__int64)&win32kMemoryModule, L"\\systemroot\\system32\\win32k.sys") >= 0 )
{
j_DbgPrint_56("get real win32k address\n");
win32kModule = (const void *)QueryModules("win32k.sys");
if ( !win32kModule )
goto LABEL_23;
j_DbgPrint_57("fetch win32k service table\n");
win32kfullModule = QueryModules("win32kfull.sys");
NtUserGetWindowDisplayAffinity = 0i64;
win32kfullModule1 = win32kfullModule;
NtUserSetWindowDisplayAffinity = 0i64;
if ( win32kfullModule )
{
writeFileLog("win32kfull => %p\n", win32kfullModule, v7, v8);
if ( (int)readSysFileToMemory((__int64)&v33, L"\\systemroot\\system32\\win32kfull.sys") < 0 )
{
GetExportTableFunc(
&NtUserGetWindowDisplayAffinity,
win32kfullModule1,
(__int64)"NtUserGetWindowDisplayAffinity");
GetExportTableFunc(
&NtUserSetWindowDisplayAffinity,
win32kfullModule1,
(__int64)"NtUserSetWindowDisplayAffinity");
writeFileLog("getdisp %p", NtUserGetWindowDisplayAffinity, v16, v17);
writeFileLog("setdisp %p", NtUserSetWindowDisplayAffinity, v18, v19);
}
else
{
writeFileLog("win32kfull safe => %p\n", v33, v10, v11);
if ( (int)GetExportTableFunc(
&NtUserGetWindowDisplayAffinity,
v33,
(__int64)"NtUserGetWindowDisplayAffinity") >= 0 )
{
writeFileLog(
"getdisp %p %08x => %p %p\n",
NtUserGetWindowDisplayAffinity,
NtUserGetWindowDisplayAffinity - v33,
win32kfullModule1);
NtUserGetWindowDisplayAffinity += win32kfullModule1 - v33;
writeFileLog("getdisp %p", NtUserGetWindowDisplayAffinity, v12, v13);
}
if ( (int)GetExportTableFunc(
&NtUserSetWindowDisplayAffinity,
v33,
(__int64)"NtUserSetWindowDisplayAffinity") >= 0 )
{
writeFileLog(
"setdisp %p %08x => %p %p\n",
NtUserSetWindowDisplayAffinity,
NtUserSetWindowDisplayAffinity - v33,
win32kfullModule1);
NtUserSetWindowDisplayAffinity += win32kfullModule1 - v33;
writeFileLog("setdisp %p", NtUserSetWindowDisplayAffinity, v14, v15);
}
tryPrint(v33);
}
}
W32pServiceTable1 = 0i64;
if ( (int)GetExportTableFunc(&W32pServiceTable1, (__int64)win32kMemoryModule, (__int64)"W32pServiceTable") >= 0
&& (W32pServiceTable2 = 0i64,
(int)GetExportTableFunc(&W32pServiceTable2, (__int64)win32kModule, (__int64)"W32pServiceTable") >= 0) )
{
_mm_lfence();
j_DbgPrint_58("get real win32k nt header\n");
winkNts = GetImageNts((__int64)win32kModule);
winkNts1 = winkNts;
if ( !winkNts )
{
LABEL_44:
tryPrint((__int64)win32kMemoryModule);
return v0;
}
_mm_lfence();
win32SizeOfImage = (__int64)win32kModule + winkNts->OptionalHeader.SizeOfImage;
j_DbgPrint_59("resolve pNtUserGetForegroundWindow\n");
v23 = sub_1400070A4(
&v28,
v4[4],
(__int64)win32kMemoryModule,
(__int64)W32pServiceTable1,
(__int64)win32kModule);
_mm_lfence();
if ( v23 < 0 )
{
LABEL_43:
v0 = v23;
goto LABEL_44;
}
j_DbgPrint_60("resolve pNtUserQueryWindow\n");
v23 = sub_1400070A4(
&v29,
v4[6],
(__int64)win32kMemoryModule,
(__int64)W32pServiceTable1,
(__int64)win32kModule);
if ( v23 < 0
|| (j_DbgPrint_61("resolve NtUserSetWindowDisplayAffinity\n"), v4[15] >= 0)
&& (_mm_lfence(),
v23 = sub_1400070A4(
&v27,
v4[15],
(__int64)win32kMemoryModule,
(__int64)W32pServiceTable1,
(__int64)win32kModule),
v23 < 0)
|| v4[16] >= 0
&& (_mm_lfence(),
v23 = sub_1400070A4(
&v26,
v4[16],
(__int64)win32kMemoryModule,
(__int64)W32pServiceTable1,
(__int64)win32kModule),
v23 < 0) )
{
_mm_lfence();
goto LABEL_43;
}
_mm_lfence();
v24 = v27;
W32pServiceTable11 = (__int64)W32pServiceTable1;
qword_1400117C8 = v26;
qword_140011850 = v28;
qword_140011858 = v29;
NtUserGetWindowDisplayAffinity1 = NtUserGetWindowDisplayAffinity;
NtUserSetWindowDisplayAffinity2 = NtUserSetWindowDisplayAffinity;
win32kMemoryModule1 = (__int64)win32kMemoryModule;
win32kModule2 = (__int64)win32kModule;
win32SizeOfImage1 = win32SizeOfImage;
NtCreateThreadEx = v1;
::RtlCreateUserThreadFunc = RtlCreateUserThreadFunc;
qword_1400117C0 = (__int64)v27;
qword_140011708 = (__int64)win32kModule;
qword_140011700 = (__int64)v4;
j_DbgPrint_62("z s_safe_win32k == > %p\n", win32kMemoryModule);
j_DbgPrint_63("z w32_table == > %p\n", W32pServiceTable1);
j_DbgPrint_64("z win32k == > %p\n", win32kModule);
j_DbgPrint_65("z nt == > %p\n", winkNts1);
j_DbgPrint_66("z s_win32k_begin == > %p\n", (const void *)win32kModule2);
j_DbgPrint_67("z s_win32k_end == > %p\n", (const void *)win32SizeOfImage1);
j_DbgPrint_68("z s_win32k_table == > %p\n", (const void *)W32pServiceTable11);
j_DbgPrint_69("z pNtUserSetWindowDisplayAffinity == > %p\n", v24);
}
else
{
LABEL_23:
tryPrint((__int64)win32kMemoryModule);
}
}
return 0i64;
}
return 0xC0000001i64;
}
sub_140006AC8();
goto LABEL_20;
}
v4 = (int *)&unk_140010430;
goto LABEL_20;
}
return 0xC0000001i64;
|