mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:52:57 +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;
|
CBrowseUIModule gModule;
|
||||||
CAtlWinModule gWinModule;
|
CAtlWinModule gWinModule;
|
||||||
|
|
||||||
|
void *operator new (size_t, void *buf)
|
||||||
|
{
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* BROWSEUI DllMain
|
* 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);
|
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)
|
if (dwReason == DLL_PROCESS_ATTACH)
|
||||||
{
|
{
|
||||||
gModule.Init(ObjectMap, hInstance, NULL);
|
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)
|
#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
|
namespace ATL
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -451,7 +449,7 @@ class CAtlComModule : public _ATL_COM_MODULE
|
||||||
public:
|
public:
|
||||||
CAtlComModule()
|
CAtlComModule()
|
||||||
{
|
{
|
||||||
m_hInstTypeLib = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)this, &m_hInstTypeLib);
|
||||||
m_ppAutoObjMapFirst = NULL;
|
m_ppAutoObjMapFirst = NULL;
|
||||||
m_ppAutoObjMapLast = NULL;
|
m_ppAutoObjMapLast = NULL;
|
||||||
if (FAILED(m_csObjMap.Init()))
|
if (FAILED(m_csObjMap.Init()))
|
||||||
|
|
|
@ -181,6 +181,13 @@ class CAtlBaseModule : public _ATL_BASE_MODULE
|
||||||
public :
|
public :
|
||||||
static bool m_bInitFailed;
|
static bool m_bInitFailed;
|
||||||
public:
|
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()
|
HINSTANCE GetModuleInstance()
|
||||||
{
|
{
|
||||||
return m_hInst;
|
return m_hInst;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue