当前位置:   article > 正文

谁调用DllMain__dllmaincrtstartup dwreason

_dllmaincrtstartup dwreason
  1. static
  2. BOOL __cdecl
  3. __DllMainCRTStartup(
  4. HANDLE hDllHandle,
  5. DWORD dwReason,
  6. LPVOID lpreserved
  7. );
  8. BOOL WINAPI
  9. _DllMainCRTStartup(
  10. HANDLE hDllHandle,
  11. DWORD dwReason,
  12. LPVOID lpreserved
  13. )
  14. {
  15. if (dwReason == DLL_PROCESS_ATTACH)
  16. {
  17. /*
  18. * The /GS security cookie must be initialized before any exception
  19. * handling targetting the current image is registered. No function
  20. * using exception handling can be called in the current image until
  21. * after __security_init_cookie has been called.
  22. */
  23. __security_init_cookie();
  24. }
  25. return __DllMainCRTStartup(hDllHandle, dwReason, lpreserved);
  26. }
  27. __declspec(noinline)
  28. BOOL __cdecl
  29. __DllMainCRTStartup(
  30. HANDLE hDllHandle,
  31. DWORD dwReason,
  32. LPVOID lpreserved
  33. )
  34. {
  35. BOOL retcode = TRUE;
  36. __try {
  37. __native_dllmain_reason = dwReason;
  38. __try{
  39. /*
  40. * If this is a process detach notification, check that there has
  41. * been a prior process attach notification.
  42. */
  43. if ( (dwReason == DLL_PROCESS_DETACH) && (__proc_attached == 0) ) {
  44. retcode = FALSE;
  45. __leave;
  46. }
  47. if ( dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH ) {
  48. if ( _pRawDllMain )
  49. retcode = (*_pRawDllMain)(hDllHandle, dwReason, lpreserved);
  50. if ( retcode )
  51. retcode = _CRT_INIT(hDllHandle, dwReason, lpreserved);
  52. if ( !retcode )
  53. __leave;
  54. }
  55. retcode = DllMain(hDllHandle, dwReason, lpreserved);
  56. if ( (dwReason == DLL_PROCESS_ATTACH) && !retcode ) {
  57. /*
  58. * The user's DllMain routine returned failure. Unwind the init.
  59. */
  60. DllMain(hDllHandle, DLL_PROCESS_DETACH, lpreserved);
  61. _CRT_INIT(hDllHandle, DLL_PROCESS_DETACH, lpreserved);
  62. if ( _pRawDllMain )
  63. (*_pRawDllMain)(hDllHandle, DLL_PROCESS_DETACH, lpreserved);
  64. }
  65. if ( (dwReason == DLL_PROCESS_DETACH) ||
  66. (dwReason == DLL_THREAD_DETACH) ) {
  67. if ( _CRT_INIT(hDllHandle, dwReason, lpreserved) == FALSE ) {
  68. retcode = FALSE ;
  69. }
  70. if ( retcode && _pRawDllMain ) {
  71. retcode = (*_pRawDllMain)(hDllHandle, dwReason, lpreserved);
  72. }
  73. }
  74. } __except ( __CppXcptFilter(GetExceptionCode(), GetExceptionInformation()) ) {
  75. retcode = FALSE;
  76. }
  77. } __finally
  78. {
  79. __native_dllmain_reason = __NO_REASON;
  80. }
  81. return retcode ;
  82. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/106356
推荐阅读
相关标签
  

闽ICP备14008679号