Loading a resource DLL will later cause an access violation
Hi,
I'm writing a Microsoft Outlook plugin and I'm now localizing it. I have the
main COM component loaded at Outlook startup time. Then I have another COM
component that is hotplugged when the Options tab is opened (intercepting the
OnOptionsAddPages event).
To localize the strings I'm using the resource DLL tecnique, loading it like
this:
CAddInModule _AtlModule;
// DLL Entry Point
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID
lpReserved)
{
// if I comment this line evreything works fine, I think there is an
issue with
// the released handle to the DLL.
if (dwReason == DLL_PROCESS_ATTACH) {
_AtlModule.SetResourceInstance(UIResources::GetUIResourceHandle(hInstance));
}
return _AtlModule.DllMain(dwReason, lpReserved);;
}
where _AtlModule is an extern variable of type CAtlDllModuleT.
The function UIResources::GetUIResourceHandle(HMODULE) returns the handle to
the resource DLL, loaded according to the system's locale and a registry
option. Basically it performs a LoadLibrary(char*) internally.
The same code is used both in the plugin dll and in the option panel
composite control dll (loaded by the plugin DLL). The problem is that it only
works in the plugin and not for the composite control for which I have this
error:
Unhandled exception at 0x03961fa5 (OutlookOptionsAddin.dll) in OUTLOOK.EXE:
0xC0000005: Access violation reading location 0x00000001.
This is the error stack trace:
OutlookOptionsAddin.dll!ATL::CAxWindowT<ATL::CWindow>::QueryHost(const _GUID
& iid={...}, void * * ppUnk=0x00000001) Line 2117 + 0x3 bytes C++
OutlookOptionsAddin.dll!ATL::CComCompositeControl<CSametimeMeetingOptions>::BackgroundColorEnumProc(HWND__
* hwnd=0x00000000, long l=13160660) Line 1605 C++
user32.dll!7e41ccb5()
user32.dll!7e41da3f()
OutlookOptionsAddin.dll!ATL::CComCompositeControl<CSametimeMeetingOptions>:Tongue TiedetBackgroundColorFromAmbient() Line 1598 C++
OutlookOptionsAddin.dll!ATL::CComCompositeControl<CSametimeMeetingOptions>::Create(HWND__
* hWndParent=0x00101222, tagRECT & __formal={...}, long dwInitParam=0) Line
1630 C++
OutlookOptionsAddin.dll!ATL::CComCompositeControl<CSametimeMeetingOptions>::CreateControlWindow(HWND__
* hWndParent=0x00101222, tagRECT & rcPos={...}) Line 1833 + 0x19 bytes C++
OutlookOptionsAddin.dll!ATL::CComControlBase::InPlaceActivate(long iVerb=-5,
const tagRECT * __formal=0x0013e328) Line 999 C++
OutlookOptionsAddin.dll!ATL::IOleObjectImpl<CSametimeMeetingOptions>:Big
SmileoVerbInPlaceActivate(const tagRECT * prcPosRect=0x0013e328, HWND__ *
__formal=0x00101222) Line 2136 + 0x14 bytes C++
OutlookOptionsAddin.dll!ATL::IOleObjectImpl<CSametimeMeetingOptions>:Big
SmileoVerb(long iVerb=-5, tagMSG * __formal=0x00000000, IOleClientSite *
pActiveSite=0x03ac5e28, tagMSG * __formal=0x00000000, HWND__ *
hwndParent=0x00101222, const tagRECT * lprcPosRect=0x0013e328) Line 2224
C++
.... and than many OUTLIB.DLL internal calls
The most interesting thing is that if I don't load the resource DLL
(commenting out the lines in the first code snipped posted above) this error
doesn't occur and the application runs smoothly.
Do you have any feelings about the possible cause? To me it looks like a
memory overrun problem, but I can't find where the error happens.
Thank you guys!