Author: ahill
Date: Sun Nov 1 00:40:09 2009
New Revision: 43890
URL:
http://svn.reactos.org/svn/reactos?rev=43890&view=rev
Log:
[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.
Modified:
trunk/reactos/dll/win32/browseui/browseui.cpp
trunk/reactos/lib/atl/atlbase.h
trunk/reactos/lib/atl/atlcore.h
Modified: trunk/reactos/dll/win32/browseui/browseui.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/browseu…
==============================================================================
--- trunk/reactos/dll/win32/browseui/browseui.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/browseui/browseui.cpp [iso-8859-1] Sun Nov 1 00:40:09 2009
@@ -61,12 +61,23 @@
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);
Modified: trunk/reactos/lib/atl/atlbase.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/atl/atlbase.h?rev=4389…
==============================================================================
--- trunk/reactos/lib/atl/atlbase.h [iso-8859-1] (original)
+++ trunk/reactos/lib/atl/atlbase.h [iso-8859-1] Sun Nov 1 00:40:09 2009
@@ -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 @@
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()))
Modified: trunk/reactos/lib/atl/atlcore.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/atl/atlcore.h?rev=4389…
==============================================================================
--- trunk/reactos/lib/atl/atlcore.h [iso-8859-1] (original)
+++ trunk/reactos/lib/atl/atlcore.h [iso-8859-1] Sun Nov 1 00:40:09 2009
@@ -181,6 +181,13 @@
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;