forked from killeven/ObjToShellCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.cpp
More file actions
37 lines (30 loc) · 1.18 KB
/
common.cpp
File metadata and controls
37 lines (30 loc) · 1.18 KB
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
#include "common.h"
#include <Shlwapi.h>
#pragma comment(lib, "Shlwapi.lib")
void _cdecl debug(char* fmt, ...) {
va_list va;
va_start(va, fmt);
char o[1024];
wvnsprintfA(o, sizeof(o) / sizeof(o[0]), fmt, va);
OutputDebugStringA(o);
va_end(va);
}
void assert(char* code, char* file, int line) {
char msg[4096];
char msgerr[1024];
uint32_t errcode = GetLastError();
if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errcode, 0, msgerr, sizeof(msgerr), NULL))
msgerr[0] = 0;
int cb = 0;
cb += wsprintfA(msg + cb, "应用程序错误自检...\r\n\r\n");
cb += wsprintfA(msg + cb, "===================================================================================\r\n\r\n");
cb += wsprintfA(msg + cb, " 代码 : %s\r\n", code);
cb += wsprintfA(msg + cb, " 文件 : %s\r\n", file);
cb += wsprintfA(msg + cb, " 行号 : %d\r\n", line);
cb += wsprintfA(msg + cb, " 错误 : [%d]%s\r\n", errcode, msgerr);
cb += wsprintfA(msg + cb, "===================================================================================\r\n\r\n");
cb += wsprintfA(msg + cb, "\r\n");
MessageBoxA(NULL, msg, "DBG_ASSERT", MB_SERVICE_NOTIFICATION + MB_OK);
SetLastError(errcode);
abort();
}