-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdbgkfuncs_deprectated.txt
367 lines (359 loc) · 12.9 KB
/
dbgkfuncs_deprectated.txt
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
//
// OutputDebugStringW(szPrintBuf);
//#if defined (CONSOLE_APP)
//#if defined(CONSOLE_OUTPUT)
//#error STATUS_NOT_IMPLEMENTED!
//#elif defined(DBGVIEW_OUTPUT)
//
// if (!pFormatString)
// return;
//
// RtlSecureZeroMemory(szPrintBuf, sizeof(szPrintBuf));
//
//#pragma warning(push)
//#pragma warning(disable:4995) ///name was marked as #pragma deprecated
// status = RtlStringValidateDestW(szPrintBuf, sizeof(szPrintBuf)/sizeof(WCHAR), NTSTRSAFE_MAX_CCH);
//#pragma warning(pop)
// if(status){
// OutputDebugStringW(L"RtlStringValidateDestW error!");
// return;
// }
//
// va_start(args, pFormatString);
//#pragma warning(push)
//#pragma warning(disable:4995) ///name was marked as #pragma deprecated
// status = RtlStringVPrintfWorkerW(szPrintBuf, sizeof(szPrintBuf) / sizeof(WCHAR), NULL, pFormatString, args);
//#pragma warning(pop)
// va_end(args);
// if (status){
// OutputDebugStringW(L"RtlStringVPrintfWorkerW error!");
// return;
// }
//
// OutputDebugStringW(szPrintBuf);
//#else
//#error With CONSOLE_APP, either CONSOLE_OUTPUT or DBGVIEW_OUTPUT must be defined!
//#endif
//
//#elif defined (WIN32_APP)
//#if defined(DBGVIEW_OUTPUT)
//
// if (!pFormatString)
// return;
//
// RtlSecureZeroMemory(szPrintBuf, sizeof(szPrintBuf));
//
//#pragma warning(push)
//#pragma warning(disable:4995) ///name was marked as #pragma deprecated
// status = RtlStringValidateDestW(szPrintBuf, sizeof(szPrintBuf)/sizeof(WCHAR), NTSTRSAFE_MAX_CCH);
//#pragma warning(pop)
// if(status){
// OutputDebugStringW(L"RtlStringValidateDestW error!");
// return;
// }
//
// va_start(args, pFormatString);
//#pragma warning(push)
//#pragma warning(disable:4995) ///name was marked as #pragma deprecated
// status = RtlStringVPrintfWorkerW(szPrintBuf, sizeof(szPrintBuf) / sizeof(WCHAR), NULL, pFormatString, args);
//#pragma warning(pop)
// va_end(args);
// if (status){
// OutputDebugStringW(L"RtlStringVPrintfWorkerW error!");
// return;
// }
//
// OutputDebugStringW(szPrintBuf);
//#elif defined (HARDERROR_OUTPUT)
// ULONG harderrorResponse;
// ULONGLONG harderrorParams[4];
// UNICODE_STRING uPrintBuf;
// UNICODE_STRING uTitle;
// WCHAR szTitle[] = L"Bla,undso !!!!!";
//
// if (!pFormatString)
// return;
//
// RtlSecureZeroMemory(szPrintBuf, sizeof(szPrintBuf));
//
//#pragma warning(push)
//#pragma warning(disable:4995) ///name was marked as #pragma deprecated
// status = RtlStringValidateDestW(szPrintBuf, sizeof(szPrintBuf) / sizeof(WCHAR), NTSTRSAFE_MAX_CCH);
//#pragma warning(pop)
// if (status){
// NtRaiseHardError(status, 0, 0, NULL, 0, (PULONG)&status);
// return;
// }
//
// va_start(args, pFormatString);
//#pragma warning(push)
//#pragma warning(disable:4995) ///name was marked as #pragma deprecated
// status = RtlStringVPrintfWorkerW(szPrintBuf, sizeof(szPrintBuf) / sizeof(WCHAR), NULL, pFormatString, args);
//#pragma warning(pop)
// va_end(args);
// if (status){
// NtRaiseHardError(status, 0, 0, NULL, 0, (PULONG)&status);
// return;
// }
//
// RtlInitUnicodeString(&uPrintBuf, szPrintBuf);
// RtlInitUnicodeString(&uTitle, szTitle);
//
// harderrorParams[0] = (ULONGLONG)&uPrintBuf;
// harderrorParams[1] = (ULONGLONG)&uTitle;
// harderrorParams[2] = (ULONGLONG)((ULONG)OptionOk | (ULONG)MB_ICONINFORMATION | (ULONG)0 | (ULONG)MB_DEFBUTTON1);
// harderrorParams[3] = (ULONGLONG)INFINITE;
//
// status = NtRaiseHardError(STATUS_SERVICE_NOTIFICATION, 4, 0x3, harderrorParams, 0, &harderrorResponse);
// if (status)
// NtRaiseHardError(status, 0, 0, NULL, 0, (PULONG)&status);
//#else
//#error With WIN32_APP, either DBGVIEW_OUTPUT or HARDERROR_OUTPUT must be defined!
//#endif
//
//#elif defined (BOOT_APP)
//#if defined (BOOTSCR_OUTPUT)
// UNICODE_STRING uPrintBuf;
//
// if (!pFormatString)
// return;
//
// RtlSecureZeroMemory(szPrintBuf, sizeof(szPrintBuf));
//
//#pragma warning(push)
//#pragma warning(disable:4995) ///name was marked as #pragma deprecated
// status = RtlStringValidateDestW(szPrintBuf, sizeof(szPrintBuf) / sizeof(WCHAR), NTSTRSAFE_MAX_CCH);
//#pragma warning(pop)
// if (status){
// RtlInitUnicodeString(&uPrintBuf, L"RtlStringCbPrintfW error!");
// NtDisplayString(&uPrintBuf);
// return;
// }
//
// va_start(args, pFormatString);
//#pragma warning(push)
//#pragma warning(disable:4995) ///name was marked as #pragma deprecated
// status = RtlStringVPrintfWorkerW(szPrintBuf, sizeof(szPrintBuf) / sizeof(WCHAR), NULL, pFormatString, args);
//#pragma warning(pop)
// va_end(args);
// if (status){
// RtlInitUnicodeString(&uPrintBuf, L"RtlStringVPrintfWorkerW error!");
// NtDisplayString(&uPrintBuf);
// return;
// }
//
// RtlInitUnicodeString(&uPrintBuf, szPrintBuf);
// NtDisplayString(&uPrintBuf);
//#elif defined (HARDERROR_OUTPUT)
// ULONG harderrorResponse;
// ULONGLONG harderrorParams[4];
// UNICODE_STRING uPrintBuf;
// UNICODE_STRING uTitle;
// WCHAR szTitle[] = L"Bla,undso !!!!!";
//
// if (!pFormatString)
// return;
//
// RtlSecureZeroMemory(szPrintBuf, sizeof(szPrintBuf));
//
//#pragma warning(push)
//#pragma warning(disable:4995) ///name was marked as #pragma deprecated
// status = RtlStringValidateDestW(szPrintBuf, sizeof(szPrintBuf) / sizeof(WCHAR), NTSTRSAFE_MAX_CCH);
//#pragma warning(pop)
// if (status){
// NtRaiseHardError(status, 0, 0, NULL, 0, (PULONG)&status);
// return;
// }
//
// va_start(args, pFormatString);
//#pragma warning(push)
//#pragma warning(disable:4995) ///name was marked as #pragma deprecated
// status = RtlStringVPrintfWorkerW(szPrintBuf, sizeof(szPrintBuf) / sizeof(WCHAR), NULL, pFormatString, args);
//#pragma warning(pop)
// va_end(args);
// if (status){
// NtRaiseHardError(status, 0, 0, NULL, 0, (PULONG)&status);
// return;
// }
//
// RtlInitUnicodeString(&uPrintBuf, szPrintBuf);
// RtlInitUnicodeString(&uTitle, szTitle);
//
// harderrorParams[0] = (ULONGLONG)&uPrintBuf;
// harderrorParams[1] = (ULONGLONG)&uTitle;
// harderrorParams[2] = (ULONGLONG)((ULONG)OptionOk | (ULONG)MB_ICONINFORMATION | (ULONG)0 | (ULONG)MB_DEFBUTTON1);
// harderrorParams[3] = (ULONGLONG)INFINITE;
//
// status = NtRaiseHardError(STATUS_SERVICE_NOTIFICATION, 4, 0x3, harderrorParams, 0, &harderrorResponse);
// if(status)
// NtRaiseHardError(status, 0, 0, NULL, 0, (PULONG)&status);
//#else
//#error With BOOT_APP, either BOOTSCR_OUTPUT or HARDERROR_OUTPUT must be defined!
//#endif
//
//#else
//#error Either CONSOLE_APP, WIN32_APP or BOOT_APP must be defined!
//#endif
//WCHAR szDebugEnv[] = L"DebugOutput";
//WCHAR* pBlahh = L"DebugOutput";
//WCHAR szOutputKeyPath[MAX_PATH]; ///This buffer is sufficient since in this special case the key path cannot be much longer than the SID name.
///Longest element is the SID name (e.g. S-1-5-21-1481281698-1014932710-522500205-1002).
///It does NOT depend on the current user's real account name.
//szValueName[0] = 'a'(*(PUCHAR)pLineNum);
//szValueName[1] = *((PUCHAR)pLineNum +1);
//
//ZwOpenKey()
//pBlah[4] = 3;
//pBlahh[2] = 0x50;
//NTSTATUS dumpEatEntriesToDefFile(PVOID pEatEntryList, ULONGLONG listBufferSize, PUCHAR pModuleName){
// OBJECT_ATTRIBUTES defFileAttr;
// UNICODE_STRING uDefFileName;
// IO_STATUS_BLOCK ioSb;
//
// NTSTATUS status, fatalStatus = STATUS_CLUSTER_NETINTERFACE_EXISTS;
//
// PCHAR pDefPreamble = NULL;
// ///Keep it simple. We can't allocate less than 4 kB using NtXxx funcs anyway,
// ///so just allocate 4 kB although we never will need that much.
// ULONGLONG defPreambleSize = PAGE_SIZE;
// HANDLE hDefFile = NULL;
// HANDLE hParentDir = NULL;
// ///Quite some ugly hacking...
// //char szDefPreamblePart[] = { 0x0D, 0x0A, 0x0D, 0x0A, 'E', 'X', 'P', 'O', 'R', 'T', 'S', 0x0D, 0x0A, 0x0 };
//
// //status = NtAllocateVirtualMemory(INVALID_HANDLE_VALUE, &pDefPreamble, 0, &defPreambleSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
// //if (status)
// // return status;
//
// //status = RtlStringCbPrintfA(pDefPreamble, defPreambleSize, "LIBRARY %s%s", pModuleName, szDefPreamblePart);
// //if (status){
// // fatalStatus = NtFreeVirtualMemory(INVALID_HANDLE_VALUE, &pDefPreamble, &defPreambleSize, MEM_RELEASE);
// // if (fatalStatus)
// // mydie(status, fatalStatus);
//
// // return status;
// //}
//
// //status = RtlStringCbLengthA(pDefPreamble, defPreambleSize, &defPreambleSize);
// //if (status){
// // fatalStatus = NtFreeVirtualMemory(INVALID_HANDLE_VALUE, &pDefPreamble, &defPreambleSize, MEM_RELEASE);
// // if (fatalStatus)
// // mydie(status, fatalStatus);
//
// // return status;
// //}
// //status = NtQueryInformationProcess()
// PUNICODE_STRING pFileName = &((PLDR_DATA_TABLE_ENTRY)(NtCurrentPeb()->Ldr->InLoadOrderModuleList.Flink))->FullDllName;
// pFileName->Buffer[pFileName->LengthInBytes / sizeof(WCHAR) - 2] = L'q';
// //hParentDir = NtCurrentPeb()->ProcessParameters->CurrentDirectory.Handle;
// //RTL_USER_PROCESS_PARAMETERS bla;
// //bla.CurrentDirectories[0].
// RtlInitUnicodeString(&uDefFileName, L"\\Users\\exports.def");
// InitializeObjectAttributes(&defFileAttr, &uDefFileName, OBJ_CASE_INSENSITIVE, NULL, NULL);
// status = NtCreateFile(&hDefFile, FILE_ALL_ACCESS | SYNCHRONIZE, &defFileAttr, &ioSb, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_SUPERSEDE, FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE, NULL, 0);
// if (status){
// EXCEPTION_RECORD exRec;
// CONTEXT ctx;
// RtlSecureZeroMemory(&exRec, sizeof(EXCEPTION_RECORD));
// RtlSecureZeroMemory(&ctx, sizeof(CONTEXT));
// exRec.ExceptionCode = (ULONG)status;
// exRec.ExceptionAddress = (PVOID)pFileName->Buffer;
// NtRaiseException(&exRec, &ctx, TRUE);
// }
// pDefPreamble = (PCHAR)pEatEntryList;
// status = NtWriteFile(hDefFile, NULL, NULL, NULL, &ioSb, pDefPreamble, (ULONG)listBufferSize, NULL, NULL);
// if (status){
// EXCEPTION_RECORD exRec;
// CONTEXT ctx;
// RtlSecureZeroMemory(&exRec, sizeof(EXCEPTION_RECORD));
// RtlSecureZeroMemory(&ctx, sizeof(CONTEXT));
// exRec.ExceptionCode = (ULONG)status;
// exRec.ExceptionAddress = (PVOID)209;
// NtRaiseException(&exRec, &ctx, TRUE);
// }
//
// NtClose(hDefFile);
// //if (!status)
// // status = NtWriteFile(hDefFile, NULL, NULL, NULL, &ioSb, pEatEntryList, (ULONG)listBufferSize, NULL, NULL);
//
// //fatalStatus = NtClose(hDefFile);
// //if (fatalStatus)
// // mydie(status, fatalStatus);
//
// //fatalStatus = NtFreeVirtualMemory(INVALID_HANDLE_VALUE, &pDefPreamble, &defPreambleSize, MEM_RELEASE);
// //if (fatalStatus)
// // mydie(status, fatalStatus);
//
// //return status;
// return STATUS_SUCCESS;
//}
//#if !defined(BOOT_APP)
//extern void __cdecl __va_start(va_list *, ...);
//#define my_va_start(ap, x) (__va_start(&ap, x))
//typedef int(*P_VSNPRINTF_S)(char *buffer, unsigned long long sizeOfBuffer, unsigned long long count, const char *format, va_list argptr);
//static P_VSNPRINTF_S sg_fpVsnprintf_s;
//
//static void DebugPrint2A(const char* pFormatstring, ...){ ///LEGACY!!! Use myWPrintf in new designs!
// void* hMod = (void*)0;
// char pBuf[1024];
// if (!pFormatstring)
// return;
//
// pBuf[sizeof(pBuf) - 1] = 0;
// pBuf[sizeof(pBuf) - 2] = 0;
// //RtlZeroMemory(pBuf, sizeof(pBuf));
// //SecureZeroMemory()
//
// if (!sg_fpVsnprintf_s){
// hMod = LoadLibraryA("msvcrt.dll");
// sg_fpVsnprintf_s = (P_VSNPRINTF_S)GetProcAddress(hMod, "_vsnprintf_s");
// if (!sg_fpVsnprintf_s)
// return;
// }
//
// va_list args;
// my_va_start(args, pFormatstring);
//
// sg_fpVsnprintf_s(pBuf, sizeof(pBuf), (unsigned long long)(-1), pFormatstring, args); // C4996
// OutputDebugStringA(pBuf);
//}
//#endif ///!BOOT_APP
//#elif defined(BOOT_APP)
//extern void __cdecl __va_start(va_list *, ...);
//#define my_va_start(ap, x) (__va_start(&ap, x))
//typedef int(*P_VSNPRINTF_S)(char *buffer, unsigned long long sizeOfBuffer, unsigned long long count, const char *format, va_list argptr);
//static P_VSNPRINTF_S sg_fpVsnprintf_s;
// if (!RtlCheckRegistryKey(rootKey, szOutputKeyPath)) {
// szOutputKeyPath[sizeof(szOutputKeyPath) / sizeof(WCHAR) - 2] = L'A' + 1;
// szOutputKeyPath[sizeof(szOutputKeyPath) / sizeof(WCHAR) - 1] = 0x0;
// if (!RtlCheckRegistryKey(rootKey, szOutputKeyPath)) {
// szOutputKeyPath[sizeof(szOutputKeyPath) / sizeof(WCHAR) - 2] = L'A' + 2;
// szOutputKeyPath[sizeof(szOutputKeyPath) / sizeof(WCHAR) - 1] = 0x0;
// }
// }
//}
// szOutputKeyPath[]
// for (USHORT i = 0; i < 26; i++) {
// szValueName[2] = L'A' + (i) % 26;
// szValueName[1] = L'B' + (i) / 26;
// szValueName[0] = L'C' + (i) / (26 * 26);
// szValueName[sizeof(szValueName) / sizeof(WCHAR) - 1] = 0x0;
// status = RtlDeleteRegistryValue(rootKey, L"DebugOutput", szValueName);
// if (status) {
// RtlWriteRegistryValue(rootKey, L"DebugOutput", NULL, REG_BINARY, &status, sizeof(LONG));
// return;
// }
// }
// RtlCheckRegistryKey()
//}
//RtlDeleteK
//RtlWriteRegistryValue(rootKey, L"DebugOutput", L"ab", REG_SZ, szPrintBuf, sizeof(szPrintBuf));
//RtlWriteRegistryValue(rootKey, L"DebugOutput", L"ac", REG_SZ, szPrintBuf, sizeof(szPrintBuf));
//#pragma warning(push)
//#pragma warning(disable:4995) ///name was marked as #pragma deprecated
// status = RtlStringValidateDestW(szPrintBuf, sizeof(szPrintBuf)/sizeof(WCHAR), NTSTRSAFE_MAX_CCH);
//#pragma warning(pop)
// if(status){
// RtlWriteRegistryValue(relativeTo, szOutputKeyPath, NULL, REG_SZ, szValidateErrorString, sizeof(szValidateErrorString));
// return;
// }