mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[atlnew]
- RosBE doesn't support __ImageBase, so use GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS) instead. - Implement CAtlBaseModule constructor. [browseui] - Since RosBE built DLLs don't run global constructors, use placement new to construct them in DllMain. This is a *HACK* and a better solution should be found. - Change DllMain be be extern C so it actually gets used. svn path=/trunk/; revision=43890
This commit is contained in:
parent
3915dba574
commit
5a9218f54f
3 changed files with 20 additions and 4 deletions
|
@ -61,12 +61,23 @@ END_OBJECT_MAP()
|
|||
CBrowseUIModule gModule;
|
||||
CAtlWinModule gWinModule;
|
||||
|
||||
void *operator new (size_t, void *buf)
|
||||
{
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* BROWSEUI DllMain
|
||||
*/
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID fImpLoad)
|
||||
STDAPI_(BOOL) DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID fImpLoad)
|
||||
{
|
||||
TRACE("%p 0x%x %p\n", hInstance, dwReason, fImpLoad);
|
||||
|
||||
/* HACK - the global constructors don't run, so I placement new them here */
|
||||
new (&gModule) CBrowseUIModule;
|
||||
new (&gWinModule) CAtlWinModule;
|
||||
new (&_AtlBaseModule) CAtlBaseModule;
|
||||
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
gModule.Init(ObjectMap, hInstance, NULL);
|
||||
|
|
|
@ -53,8 +53,6 @@
|
|||
|
||||
#define offsetofclass(base, derived) (reinterpret_cast<DWORD_PTR>(static_cast<base *>(reinterpret_cast<derived *>(_ATL_PACKING))) - _ATL_PACKING)
|
||||
|
||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||
|
||||
namespace ATL
|
||||
{
|
||||
|
||||
|
@ -451,7 +449,7 @@ class CAtlComModule : public _ATL_COM_MODULE
|
|||
public:
|
||||
CAtlComModule()
|
||||
{
|
||||
m_hInstTypeLib = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
||||
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)this, &m_hInstTypeLib);
|
||||
m_ppAutoObjMapFirst = NULL;
|
||||
m_ppAutoObjMapLast = NULL;
|
||||
if (FAILED(m_csObjMap.Init()))
|
||||
|
|
|
@ -181,6 +181,13 @@ class CAtlBaseModule : public _ATL_BASE_MODULE
|
|||
public :
|
||||
static bool m_bInitFailed;
|
||||
public:
|
||||
CAtlBaseModule()
|
||||
{
|
||||
cbSize = sizeof(_ATL_BASE_MODULE);
|
||||
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)this, &m_hInst);
|
||||
m_hInstResource = m_hInst;
|
||||
}
|
||||
|
||||
HINSTANCE GetModuleInstance()
|
||||
{
|
||||
return m_hInst;
|
||||
|
|
Loading…
Reference in a new issue