Recently I was trying to add unit tests to an existing binary by creating a extra (DLLMain) entry point to an application that already has a main entry point (it is a console exe). The application seemed to compile correctly although I was unable to use it as a DLL from my python unit test framework, all attempts to use the exe as a dll failed.
Has anyone any ideas or experience in adding extra application entry point with any input as to why this would or wouldn’t work?
There are some problems which you should solve to implement what you want:
I recommend use DUMPBIN.EXE with no some switches (/headers, /exports and without switches) to examine the exe headers. You can compare the structure of your application with Winword.exe or outlook.exe which exports some functions.
If all this will not helps, I’ll try to write a test EXE application which can be loaded as an exe and post the code here.
UPDATED: Just now verified my suggestion. It works. File Loadable.c looks like following
The only important linker switch is
/FIXED:NOwhich one can find in advanced part of linker settings. The program can run and produced the output “2+3=5“.Another EXE loaded the EXE as a DLL and calls
Sumfunction:The program also can run and produced the output “
5+4=9“.