Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows CE .EXE symbol access from DLL
    primarykey
    data
    text
    <p>I have some code which is working on Unix (Linux and Solaris) and Windows (7 to be exact) but doesn't work on Windows CE. This code implements a plug-in framework and requires exporting symbols from the executable into the loaded plug-ins. I am unable to get the loaded plug-ins (DLLs) to resolve symbols from the main executable.</p> <p>I have reduced the interface to a single function in the main executable which is defined as such:</p> <pre><code>extern "C" __declspec( dllexport ) const char * translate_name( const char *key ) { ... } </code></pre> <p>If I run Dumpbin /EXPORTS on the executable I see this as one of the exported symbols:</p> <pre><code>81 50 00001474 translate_name = @ILT+1135(_translate_name) </code></pre> <p>The plug-ins are required to export two functions xxxLoadPlugin and xxxUnloadPlugin which the main executable will call after loading to allow them to interconnect. The xxx is replaced with an agreed upon name prefix (usually the dll or .so name). I have a test project which creates:</p> <pre><code>extern "C" __declspec( dllexport ) int testRegisterLibrary( ) { return 0; } extern "C" __declspec( dllexport ) int testUnregisterLibrary( ) { return 0; } </code></pre> <p>If I compile and run this module everything will work as expected. I can load the dll, and walk through the functions in my debugger.</p> <p>If I add code which references translate_name, such as:</p> <pre><code>extern "C" __declspec( dllimport ) const char * translate_name( const char *key ); extern "C" __declspec( dllexport ) int testRegisterLibrary( ) { translate_name("test"); return 0; } extern "C" __declspec( dllexport ) int testUnregisterLibrary( ) { return 0; } </code></pre> <p>the DLL will now fail to load. Checking the created DLL with dumpbin /IMPORTS I see:</p> <pre><code>50 translate_name </code></pre> <p>translate_name is the only symbol imported from my main executable. If I try using GetProcAddress instead of relying on the linker, like this:</p> <pre><code>extern "C" __declspec( dllexport ) int testRegisterLibrary( ) { HMODULE mainModule = GetModuleHandle(NULL); //handle for main executable void *ptr = (void *)GetProcAddress(L"translate_name"); return 0; } extern "C" __declspec( dllexport ) int testUnregisterLibrary( ) { return 0; } </code></pre> <p>The DLL loads, but the value of 'ptr' is NULL (checked inside a debugger). I've also tried GetProcAddressA("translate_name"), and using "_translate_name" with the same results.</p> <p>Given this it seems that the symbols that were exported by the executable are not retained after the initial loader pass in windows CE. Again, this works in any normal windows environment. Is there some setting I'm missing for windows CE? Why can GetProcAddress not find a symbol in the executable which dumpbin says is exported? Are the symbols being hidden or dropped by the windows CE loader?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload