There is a console application that was compiled on a Microsoft compiler (using WINAPI functions, of course), C ++. The source code and analogues of this program either. Disassembling shows about 3,500 functions, so full reverse engineering will take a very long time.
I set myself the task - to write a universal loader that supports several operating systems (the code is selected at the compilation stage). While I work only on Windows.
The loading is performed according to the principle “place the original segments in the right places, process the import table, call the entry point”. Gcc (MinGW) was chosen for implementation, since it supports modified linker scripts, C language.
The segments were located correctly, the import table was processed correctly, the entry point is called, the arguments are processed correctly. The problem is that sooner or later an error R6002 occurs (as a side effect), but I am sure that the problem is precisely in the layout of the program (the runtime libraries are incompatible and somewhere was initialized, but not somewhere?) and not in any specific errors. Debugging is done using Qt creator, but it is difficult, as there is only an assembler listing.
The question is: do you have to patch calls of standard functions to make the loader work, or can you think of something?