Re: using exe as dll

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Arkady Frenkel (arkadyf_at_hotmailxdotx.com)
Date: 08/04/04


Date: Wed, 4 Aug 2004 10:46:13 +0300

Really dllmain is not obligatory because if you have dll without it windows
will supply it's own one instead , so if you don't need any init/deinit ,
you don't need it at all.
OTOH you can LoadLibrary of your exe , GetProcAddress of export function in
it and go...
Arkady

"Tim Roberts" <timr@probo.com> wrote in message
news:v3o0h01uptrlnlik536fk6diq5roqlhj2s@4ax.com...
> dbabits@hotmail.com (dima) wrote:
> >
> >It is possible to export functions out of exe and then use it as
> >dll.What are the potential problems? I am aware of possible C-runtime
> >initialization issues, and also of course there's no DllMain etc.
>
> Actually, your last phrase pinpoints the root of the problem. DllMain is
> not magic, it's just the standard name used for the initial entry point of
> a DLL. For an EXE, the initial entry point goes instead to main or
> WinMain.
>
> When a PE file is loaded, the operating system always calls the initial
> entry point. Thus, although you CAN load an executable as a DLL, as soon
> as you do so, the executable's main() entry point will be called and the
> program will run.
>
> >But still, any comments appreciated. BTW, the goal is to have 1 file
> >that could be used as an executable or as a library and not have to
> >compile 2 binaries.
>
> I think you'll need to make a DLL with a very small main program to call
> it.
> --
> - Tim Roberts, timr@probo.com
> Providenza & Boekelheide, Inc



Relevant Pages

  • Re: MFC DLL - ExitInstance hang on WaitForSingleObject
    ... Why MSDN do not talk about that? ... For more on DllMain ... So the EXE could load the DLL, call InitLib, create a new Pooler using the ...
    (microsoft.public.vc.mfc)
  • Re: System-wide hooking, VB+ASM
    ... >returned by the SetWindowsHookEx function used to set the hook. ... The reason is that only the /first/ instance of the DLL ... >Look up DllMain in the SDK documentation. ... standard entry point. ...
    (microsoft.public.vb.winapi)
  • Re: C coding guidelines
    ... They can do what they like regarding the entry points they need ... send all startup code related to C library initialization to la la ... It's either in a DLL (if you only linked with ... What do you think calls DLLMain? ...
    (comp.lang.c)
  • Re: C coding guidelines
    ... ALL dlls will be called BY THE LOADER before the program starts. ... This call will be done to a special entry point called DllMain ... For instance, in the dll you sent me, the header ...
    (comp.lang.c)
  • Re: C coding guidelines
    ... A DLL can contain many functions. ... This is NOT a call y your user code, it is a call by the ... This call will be done to a special entry point called DllMain ...
    (comp.lang.c)