I am currently working with DLL injection and need to have a single hybrid binary that could act as both an executable and a DLL. I thought of maybe writing a DllMain and WinMain function and then compiling it as an executable but I don't know what would happen if I did that. I know that it is posssible to combine a dll and exe by using something like thinstall or extracting the dll to a temporary location then going from there but I don't want to mess with any of that stuff. So basically, is it possible to define a WinMain and Dll Main and then use the resulting executable as both, and if not, is this even possible? Thanks in advance!
+1
A:
Why don't you put all the common code into a static library (.lib) and have both DLL project and EXE project as a very thin wrapper around the static library?
Igor Zevaka
2010-01-19 02:26:15
There is no common code. I am trying to use dll injection without a dll basically.
2010-01-19 02:28:36
+2
A:
No.
Both a DLL and an EXE have a PE (Portable Executable) header. That header has a field IMAGE_FILE_HEADER::Characteristics
. Bit 14 of that field is either 0 (for an EXE) or 1 (for a DLL).
MSalters
2010-01-19 11:18:31