gringogordo
asked on
Getting a dll name (not the name of the exe running the process)
Hi,
I am writing an C++ ISAPI wildcard extension and I want to use the Event Log. I have ripped off some code which is doing this quite nicely. However when I use GetModuleFileName with parameter 1 (hModule) set to NULL I get the IIS worker process address instead of the DLL (i.e. the exe name (as documented!)). I would quite like to install the event source into the registry every time the dll calls GetExtensionVersion even though this is a little pointless - it just seems to keep manual config and possible errors at bay. To do this I want to be able to get the [FILEPATH]\[FILENAME] of the DLL.
Could anyone tell me how to do this ? If the answer is to get a hold of the hModule handle could you give me a fairly clear clue as to how to do this please as I'm not much cop with C++.
Thanks,
Ben.
I am writing an C++ ISAPI wildcard extension and I want to use the Event Log. I have ripped off some code which is doing this quite nicely. However when I use GetModuleFileName with parameter 1 (hModule) set to NULL I get the IIS worker process address instead of the DLL (i.e. the exe name (as documented!)). I would quite like to install the event source into the registry every time the dll calls GetExtensionVersion even though this is a little pointless - it just seems to keep manual config and possible errors at bay. To do this I want to be able to get the [FILEPATH]\[FILENAME] of the DLL.
Could anyone tell me how to do this ? If the answer is to get a hold of the hModule handle could you give me a fairly clear clue as to how to do this please as I'm not much cop with C++.
Thanks,
Ben.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have used this practically verbatum (I added some casting as I had a couple of complie errors)
...
CONTEXT ctx;
LPCVOID TESTVAR; //new line
GetThreadContext( GetCurrentThread(), &ctx);
TESTVAR = (LPCVOID) ctx.Eip; //NEWLINE
VirtualQuery( TESTVAR, &mbi, sizeof ( mbi)); changed param1
...
But I still get the exe name, in this case
c:\windows\system32\inetsr v\w3wp.exe .
Any ideas?
Thanks,
Ben.
...
CONTEXT ctx;
LPCVOID TESTVAR; //new line
GetThreadContext( GetCurrentThread(), &ctx);
TESTVAR = (LPCVOID) ctx.Eip; //NEWLINE
VirtualQuery( TESTVAR, &mbi, sizeof ( mbi)); changed param1
...
But I still get the exe name, in this case
c:\windows\system32\inetsr
Any ideas?
Thanks,
Ben.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry I will get back to this and allocate the points if its successful, I have been sidetracked. I had a quick go but I seemd to get nothing back by passing the reference. I didn't have time to have a proper look though so I will hopefully have another look soon.
Ben.
Ben.
ASKER
I looked for DLLMain but it doesn't have one (although I have based my app on the Wildcardmap ISAPI wildcard extrension SDK sample. If you create a virgin project using the Visual Studio template there is one).
Using the original with the casting I get the IIS process exe address and using the reference I get a blank. I assume that this exe uis running the dll in the thread called but I don't know this for sure. And as even if I hardcode the dll path and name in the registry I can't get it to 'locate' the event message ID's (i.e. I get unkonwn messages in the event log) - although I have a simple console app where I have done this succesfully. I'm beginning to think its an ISAPI issue.
Ben.
Using the original with the casting I get the IIS process exe address and using the reference I get a blank. I assume that this exe uis running the dll in the thread called but I don't know this for sure. And as even if I hardcode the dll path and name in the registry I can't get it to 'locate' the event message ID's (i.e. I get unkonwn messages in the event log) - although I have a simple console app where I have done this succesfully. I'm beginning to think its an ISAPI issue.
Ben.
ASKER
WORD WINAPI HttpExtensionProc( EXTENSION_CONTROL_BLOCK * pecb )
and so I can't pass a parameter in and DLL Main is not the entry point. I think this means that I can't use this solution. Is there another way (or have I misunderstood ...!)
Thanks,
Ben.