-
Notifications
You must be signed in to change notification settings - Fork 1
/
win32_hacks.h
43 lines (32 loc) · 1.09 KB
/
win32_hacks.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
#include "config.h"
#include "debug.h"
#ifdef _WIN32
#if ENABLE_WIN32_MAIN_ALIGNMENT
static void win32_main_alignment(ThreadContext *ctx, FunctionObj *fc)
{
if (fc->functionAddress() == globalSharedContext->spAttrs.__tmainCRTStartup_addr)
ctx->__tmainCRTStartup_stack_size = ctx->shadowStack.size();
if (ctx->__tmainCRTStartup_stack_size == -1)
return;
if (fc->functionAddress() == globalSharedContext->spAttrs.wWinMain_addr ||
fc->functionAddress() == globalSharedContext->spAttrs.main_addr) {
if (ctx->shadowStack.size() > ctx->__tmainCRTStartup_stack_size+1) {
cerr << "WARNING: artifical main() alignment\n";
}
while (ctx->shadowStack.size() > ctx->__tmainCRTStartup_stack_size+1)
ctx->popShadowStack();
}
}
#endif
#if ENABLE_INS_TRACING
inline bool win32_check_nlg_notify(ThreadContext *ctx, ADDRINT currFuncAddr)
{
if (IS_WIN32_NLG_NOTIFY(currFuncAddr)) {
ctx->jumpTargetFuncAddr=currFuncAddr;
ctx->haveToJump=true;
return true;
}
return false;
}
#endif
#endif // #ifdef _WIN32