谁调用DllMain

来源:互联网 发布:淘宝联盟的优惠券在哪 编辑:程序博客网 时间:2024/06/08 08:00
staticBOOL __cdecl__DllMainCRTStartup(        HANDLE  hDllHandle,        DWORD   dwReason,        LPVOID  lpreserved        );BOOL WINAPI_DllMainCRTStartup(        HANDLE  hDllHandle,        DWORD   dwReason,        LPVOID  lpreserved        ){        if (dwReason == DLL_PROCESS_ATTACH)        {            /*            * The /GS security cookie must be initialized before any exception            * handling targetting the current image is registered.  No function            * using exception handling can be called in the current image until            * after __security_init_cookie has been called.            */            __security_init_cookie();        }        return __DllMainCRTStartup(hDllHandle, dwReason, lpreserved);}__declspec(noinline)BOOL __cdecl__DllMainCRTStartup(        HANDLE  hDllHandle,        DWORD   dwReason,        LPVOID  lpreserved        ){        BOOL retcode = TRUE;    __try {         __native_dllmain_reason = dwReason;        __try{            /*             * If this is a process detach notification, check that there has             * been a prior process attach notification.             */            if ( (dwReason == DLL_PROCESS_DETACH) && (__proc_attached == 0) ) {                retcode = FALSE;                __leave;            }            if ( dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH ) {                if ( _pRawDllMain )                    retcode = (*_pRawDllMain)(hDllHandle, dwReason, lpreserved);                if ( retcode )                    retcode = _CRT_INIT(hDllHandle, dwReason, lpreserved);                if ( !retcode )                    __leave;            }            retcode = DllMain(hDllHandle, dwReason, lpreserved);            if ( (dwReason == DLL_PROCESS_ATTACH) && !retcode ) {                /*                 * The user's DllMain routine returned failure.  Unwind the init.                 */                DllMain(hDllHandle, DLL_PROCESS_DETACH, lpreserved);                _CRT_INIT(hDllHandle, DLL_PROCESS_DETACH, lpreserved);                if ( _pRawDllMain )                    (*_pRawDllMain)(hDllHandle, DLL_PROCESS_DETACH, lpreserved);            }            if ( (dwReason == DLL_PROCESS_DETACH) ||                 (dwReason == DLL_THREAD_DETACH) ) {                if ( _CRT_INIT(hDllHandle, dwReason, lpreserved) == FALSE ) {                    retcode = FALSE ;                }                if ( retcode && _pRawDllMain ) {                    retcode = (*_pRawDllMain)(hDllHandle, dwReason, lpreserved);                }            }        } __except ( __CppXcptFilter(GetExceptionCode(), GetExceptionInformation()) ) {            retcode = FALSE;        }    } __finally    {        __native_dllmain_reason = __NO_REASON;    }        return retcode ;}

0 0
原创粉丝点击