2023年12月30日发(作者:)

{#ifdef _DEBUG static int fExit = 0;#endif /* _DEBUG */#ifdef _MT _lockexit(); /* assure only 1 thread in exit path */ __TRY#endif /* _MT */ if (_C_Exit_Done == TRUE) /* if doexit() is being called recursively */ TerminateProcess(GetCurrentProcess(),code); /* terminate with extreme prejudice */ _C_Termination_Done = TRUE; /* save callable exit flag (for use by terminators) */ _exitflag = (char) retcaller; /* 0 = term, !0 = callable exit */ if (!quick) { /* * do _onexit/atexit() terminators * (if there are any) * * These terminators MUST be executed in reverse order (LIFO)! * * NOTE: * This code assumes that __onexitbegin points * to the first valid onexit() entry and that * __onexitend points past the last valid entry. * If __onexitbegin == __onexitend, the table * is empty and there are no routines to call. */ if (__onexitbegin) { while ( --__onexitend >= __onexitbegin ) /* * if current table entry is non-NULL, * call thru it. */ if ( *__onexitend != NULL ) (**__onexitend)(); } /* * do pre-terminators */ _initterm(__xp_a, __xp_z); } /* * do terminators */ _initterm(__xt_a, __xt_z);#ifndef CRTDLL#ifdef _DEBUG /* Dump all memory leaks */ if (!fExit && _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & _CRTDBG_LEAK_CHECK_DF) { fExit = 1; _CrtDumpMemoryLeaks(); }#endif /* _DEBUG */#endif /* CRTDLL */

/* return to OS or to caller */#ifdef _MT __FINALLY if (retcaller) _unlockexit(); /* unlock the exit code path */ __END_TRY_FINALLY#endif /* _MT */ if (retcaller) return; _C_Exit_Done = TRUE; __crtExitProcess(code);}其中部分源代码如下:

if (__onexitbegin) {

00406056 cmp dword ptr [___onexitbegin (412DA8h)],0

0040605D je doexit+70h (406090h)

while ( –__onexitend >= __onexitbegin )

0040605F mov edx,dword ptr [___onexitend (412DA4h)]

00406065 sub edx,4

00406068 mov dword ptr [___onexitend (412DA4h)],edx

0040606E mov eax,dword ptr [___onexitend (412DA4h)]

00406073 cmp eax,dword ptr [___onexitbegin (412DA8h)]

00406079 jb doexit+70h (406090h)

/*

* if current table entry is non-NULL,

* call thru it.

*/

if ( *__onexitend != NULL )

0040607B mov ecx,dword ptr [___onexitend (412DA4h)]

00406081 cmp dword ptr [ecx],0

00406084 je doexit+6Eh (40608Eh)

(**__onexitend)();

00406086 mov edx,dword ptr [___onexitend (412DA4h)]

0040608C call dword ptr [edx]

}

0040608E jmp doexit+3Fh (40605Fh)