mfc_thread_init.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef BOOST_THREAD_WIN32_MFC_THREAD_INIT_HPP
  2. #define BOOST_THREAD_WIN32_MFC_THREAD_INIT_HPP
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. // (C) Copyright 2008 Anthony Williams
  7. // (C) Copyright 2011-2012 Vicente J. Botet Escriba
  8. // check if we use MFC
  9. #ifdef _AFXDLL
  10. # if defined(_AFXEXT)
  11. // can't use ExtRawDllMain from afxdllx.h as it also defines the symbol _pRawDllMain
  12. extern "C"
  13. inline BOOL WINAPI ExtRawDllMain(HINSTANCE, DWORD dwReason, LPVOID)
  14. {
  15. if (dwReason == DLL_PROCESS_ATTACH)
  16. {
  17. // save critical data pointers before running the constructors
  18. AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
  19. pModuleState->m_pClassInit = pModuleState->m_classList;
  20. pModuleState->m_pFactoryInit = pModuleState->m_factoryList;
  21. pModuleState->m_classList.m_pHead = NULL;
  22. pModuleState->m_factoryList.m_pHead = NULL;
  23. }
  24. return TRUE; // ok
  25. }
  26. extern "C" __declspec(selectany) BOOL (WINAPI * const _pRawDllMainOrig)(HINSTANCE, DWORD, LPVOID) = &ExtRawDllMain;
  27. # elif defined(_USRDLL)
  28. extern "C" BOOL WINAPI RawDllMain(HINSTANCE, DWORD dwReason, LPVOID);
  29. extern "C" __declspec(selectany) BOOL (WINAPI * const _pRawDllMainOrig)(HINSTANCE, DWORD, LPVOID) = &RawDllMain;
  30. # endif
  31. #endif
  32. #endif