This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

non-persistent DllMain


I'm trying to use the Win32::GuiTest perl module on WinXP SP3.
I installed it under cygwin with something like:

perl -MCPAN -e 'install Win32::GuiTest'

However certain use is failing on the SetWindowHookEx because it is
passing a NULL hModule, which is surprising because dllmain shows that
hModule is saved in g_hDLL - except it's not working like that.

BOOL APIENTRY DllMain(HANDLE hModule, DWORD  ul_reason_for_call,
                      LPVOID lpReserved)
{
        switch (ul_reason_for_call)
        {
        case DLL_PROCESS_ATTACH:
                // Value used by SetWindowsHookEx, etc.
                g_hDLL = (HINSTANCE)hModule;
                break;
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
                break;
        }

        return TRUE;
}

g_hDLL is always 0.

If I put in DllMain
if (! hModule) return FALSE;
then the load does NOT abort like a plain return FALSE, so I know
hModule is passed in as non-zero

Further debugging shows the following:

return FALSE; aborts the program - the only debugging tool that works,
because:

setting global variables in DllMain has no effect, when examined later
in the DLL, they have their default initialized values. Even variables
that don't have a specific initialized don't retain any value set during
DllMain

calling functions like fprintf, fopen have no effect in DllMain, not
even strace shows up their attempted use. Not even setenv does anything
in DllMain.

So, in short, DllMain doesn't save the hModule because it can't save
global variables, in fact it seems so ephemeral that the only thing it
CAN do is: return FALSE or return TRUE.

Anyone recognize this problem or have suggestions on what to do?

Sam

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]