RE: Exporting function from an .exe to be used by loaded .dll

From: Russ Keldorph [MS] (russellk_at_online.microsoft.com)
Date: 03/03/04


Date: Wed, 03 Mar 2004 23:00:40 GMT

Unfortunately, you've discovered a limitation of the CE loader. Unlike XP,
CE will only load and resolve exports from a module with the IMAGE_FILE_DLL
bit set in the PE header, i.e. real DLLs. This design won't work under CE.

-- 
Russ Keldorph
russellk@online.microsoft.com (Remove the 'online.' from my address to 
reach me.)
This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"
--------------------
> From: ledz@argz.com (ledZ)
> Newsgroups: microsoft.public.windowsce.platbuilder
> Subject: Exporting function from an .exe to be used by loaded .dll
> Date: 3 Mar 2004 08:43:22 -0800
> Organization: http://groups.google.com
> Lines: 24
> Message-ID: <ef37a2c8.0403030843.1b721cdb@posting.google.com>
> NNTP-Posting-Host: 63.227.65.233
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: 8bit
> X-Trace: posting.google.com 1078332202 28997 127.0.0.1 (3 Mar 2004 
16:43:22 GMT)
> X-Complaints-To: groups-abuse@google.com
> NNTP-Posting-Date: Wed, 3 Mar 2004 16:43:22 +0000 (UTC)
> Path: 
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!border2.nntp.ash.giganews.com!border1.nntp.ash.giganews.com!nntp.gigane
ws.com!news.glorb.com!postnews1.google.com!not-for-mail
> Xref: cpmsftngxa06.phx.gbl microsoft.public.windowsce.platbuilder:46618
> X-Tomcat-NG: microsoft.public.windowsce.platbuilder
> 
> I have the following design.
> 
> Build host appname.exe that exports some useful functions.  When I
> compile this, appname.lib is created with the exported files.
> 
> Create plugin dlls that link with appname.lib and are loaded at run
> time by the host appname.exe using LoadLibrary(plugin_name).  These
> plugins can use all the functions exported by appname.exe.
> 
> I have this design coded and working flawlessly on Windows XP.  Using
> the same code base I then created my CE.net version in EVC4.  When I
> run appname.exe on CE (in the emulator  - no hardware yet) the plugins
> do not load and GetLastError() returns 193 - Bad EXE Format.
> 
> I can't figure out why this is happening.
> 
> As a test I created a simple .exe and simple .dll in EVC4.  The exe
> exports one function and the dll uses it.
> 
> The dll load failed with the same error but as soon as I remove the
> exported function from the exe and its reference from the dll it loads
> fine.
> 
> This design is critical to my application - any help is appreciated.
> 


Relevant Pages

  • RE: 193 Is not a valid application. ERROR_BAD_EXE_FORMAT
    ... DLL and what the OS can load. ... Another cause is missing exports from other ... > I have no idea why I get this error or what it means since the .exe is ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Convert C-Builder program to Delphi?
    ... > quite separate from the function declaration itself. ... >this DLL ... >way the only place anything needs to be changed is in the #define macro. ... Exports SomeDLL_Open Name 'SomeDLL_Open'; ...
    (comp.lang.pascal.delphi.misc)
  • Re: Convert C-Builder program to Delphi?
    ... > quite separate from the function declaration itself. ... >this DLL ... >way the only place anything needs to be changed is in the #define macro. ... Exports SomeDLL_Open Name 'SomeDLL_Open'; ...
    (comp.lang.cpp)
  • Exporting function from an .exe to be used by loaded .dll
    ... Build host appname.exe that exports some useful functions. ... plugins can use all the functions exported by appname.exe. ... I have this design coded and working flawlessly on Windows XP. ... The dll load failed with the same error but as soon as I remove the ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Export C++ class from a Borland DLL and use it in Microsoft VC
    ... Borland uses a different C runtime than Visual Studio. ... Of course, it is not impossible to use a DLL across compilers, even across different languages. ... You still need to use pure extern "C" exports, but the functions themselves can accept and return C++ classes. ... You must either not use enums in your interface, or modify Borland's compiler settings for your particular cpp file. ...
    (microsoft.public.dotnet.languages.vc)