Re: Creating DLL Entry Point
FFrozTT <tech@millennium.ab.ca> wrote:
@Igor, After some research into LoadLibrary it turns out LoadLibrary
does call DllMain with DLL_PROCESS_ATTACH, also according to the doc
you sent rundll32 uses LoadLibrary so really it should be calling
DllMain and should work for testing... I think?
Yes - if you pass correct command line to rundll32. If it fails to parse
its command line, it will likely exit with an error before calling
LoadLibrary.
@Joel, Ya, DllMain is holding the OS Loader lock, I left out a bit of
code there where I am recording the handle to that module and force
unloading it to prevent the deadlock you are referring to.
What module? This statement doesn't make any sense to me.
I have
read quite a bit suggesting avoiding doing anything interesting in
DllMain.
A very wise suggestion. I strongly advise you heed it.
So it appears I'm on the right track but I'm not sure if I'm exporting
DllMain properly.
You don't need to export DllMain at all. You need to create a separate
function (call it whatever you want) with a specific signature, as
documented in the article I've referred you to. You then need to export
this function. Finally, you need to call rundll32 as
rundll32 MyDll.dll,MyExportedFunction
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925