Re: using exe as dll

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Tim Roberts (timr_at_probo.com)
Date: 08/04/04


Date: Tue, 03 Aug 2004 21:10:27 -0700

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: system32.exe
    ... The teal rundll takes as arguments a dll and entry ... point information possibly including agruments, ... runs it as if it had been packaged as an exe. ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Difference between exe and dll??
    ... An EXE is visible to the system as a regular Win32 executable. ... A DLL is visible to the system as a Win32 DLL but most likely without any ... entry points. ... The .NET runtime stores information about the contained ...
    (microsoft.public.dotnet.framework)
  • Re: using exe as dll
    ... Really dllmain is not obligatory because if you have dll without it windows ... >>It is possible to export functions out of exe and then use it as ... the initial entry point goes instead to main or ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Firefox and Sound
    ... number of loads that app performed. ... only references to entry points in the dll. ... specified entry points in it can't be found, ... but the download manager said it was only 78.8 MB. ...
    (comp.os.os2.apps)
  • Re: SAVE-SYSTEM and DLLs
    ... Win32Forth uses a system of pointing all Windows DLL calls on ... and calls the entry point for this time. ... IMP-RESOLVE is called first time through on a Windows call. ... Since my Forth uses EBP as a stack, the stacks are switched for a ...
    (comp.lang.forth)