Load DLL from a XPcom DLL

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Load DLL from a XPcom DLL


I try to make a Firefox extension which can use a dll of another
program of mine. My extension is only for windows platform for the

So I made an extension with a vc++ xpcom dll in the directory
"components". The xpcom dll must bridge my extension with the dll of
my other program (I hope that I'm clear in my explanation coz it's not
easy to explain in my natural language too...).
I based my xpcom on this documentation :
Because I need to load another dll from my xpcom, I create a MFC dll
project in vc++ not a simple dll for to make my xpcom.
My xpcom works well, load the external dll, call the needed function
and unload the dll. But (there's always a @#!& "but"...), after
returning the result, Firefox crash and I don't know why. I put a lot
of message box for detecting where.
There is my code :
 NS_IMETHODIMP CSpecialThing::Add(PRInt32 a, PRInt32 b, PRInt32

        typedef char* (_stdcall *ProcDllPtr)(char* monString);
        HMODULE hinstDLL=LoadLibrary((LPCSTR)"C:\\_project\\Dll\
        if (hinstDLL) {
                AfxMessageBox((LPCTSTR)"XPCOM : DLL load",MB_OK,-2);
                ProcDllPtr ProcExportDll = (ProcDllPtr) GetProcAddress(hinstDLL,
                AfxMessageBox((LPCTSTR)"XPCOM : before function calling",MB_OK,-2);
                char* reponseDLL=ProcExportDll("sanctification personnel");
                AfxMessageBox((LPCTSTR)"XPCOM : after function calling",MB_OK,-2);
                AfxMessageBox((LPCTSTR)"XPCOM : after DLL response",MB_OK,-2);

                AfxMessageBox((LPCTSTR)"XPCOM : DLL free",MB_OK,-2);
        } else {

        AfxMessageBox((LPCTSTR)"before retval",MB_OK,-2);
        *_retval = a + b;
        AfxMessageBox((LPCTSTR)"after retval",MB_OK,-2);
        return NS_OK;
        AfxMessageBox((LPCTSTR)"never show",MB_OK,-2);

The "never show" message doesn't appear, Firefox crash before.

Do you have an idea about this bug? I read that use MFC in xpcom is
not a good idea, do you know how I can load my dll in my xpcom without

Thanks in advance.


dev-tech-xpcom mailing list
[hidden email]