main前干的好事

来源:互联网 发布:北京软件开发设计公司 编辑:程序博客网 时间:2024/04/29 02:25

main函数前工作Release:

全局变量?TLS?……

kernel32.BaseThreadInitThunk

_security_init_cookie

CRT库的__security_cookie 的值就是DEFAULT_SECURITY_COOKIE,在Win32 下被定义为 0xBB40E64E,在 Win64 下被定义为 0x00002B992DDFA232

但是用户进程的 __security_cookie 值,需进行下面的设置:

获得 system time与 GetCurrentProcessId() 异或与 GetCurrentThreadId() 异或与 GetTickCount() 异或与 QueryPerformanceCounter()异或

经过一系列异或用户的 __security_cookie 值就出来,我们大概可以猜到 DEFAULT_SECURITY_COOKIE 这个值就是根据这样算出来的,因此如果算出来结果还是等于 DEFAULT_SECURITY_COOKIE 那么就需要加上1.
security cookie 机制(2)— 初始化___security_cookie

_tmainCRTStartup

__SEH_prolog4

mov esi,offset _native_startup_lock

lock cmpxchg dword ptr ds:[esi],exc

cmp dword ptr ds:__native_startup_state,esi

_amsg_exit

ds:[has_cctor]

cmp dword ptr ds:[__native_startup_state],esi

MSVCR110._initterm_e

or
MSVCR110._initterm

cmp dword ptr ds:[__dyn_tls_init_callback],0x0

IsNonwritableInCurrentImage

ds:[envp]

MSVCR110.___WINITENV

ds:[envp]
ds:[argv]
ds:[argc]
CALL WMAIN

0 0
原创粉丝点击