Hello everyone!
For the last week I've been trying to convert an EXE file into a DLL. I read about 1000 Google pages on the way and now know much more than in the beginning :) I have nearly succeeded in getting the "DLL" to run but there is one last problem I cannot figure out. Because the DLL was an EXE before the program entry point function (before main) calls WinMain which I want to prevent. Now I only have the disassembled code of this function and couldn't find a way to change the assembly code to not call WinMain without getting a crash. I uploaded a picture of the code so you can see what it does:


In the "middle" of the code there is this section:

call    __setargv
call    __setenvp
call    __cinit
mov     esi, lpCmdLine
mov     al, [esi]
cmp     al, 22h
jz      short loc_4F1FBB

I figured I want no code to be executed after the call to __cinit. I tried that by writing

mov eax, 1
retn 0Ch

after it but this (and other things I tried) produced a crash in my program. From the little ASM I know I thought the stack might not be properly cleaned up that way. Now I'm kindly asking someone to change the code as I stated above and maybe teaches me what I did wrong. Some additional info: The function is given three DWORDs as parameters on start (the standard parameters when DLLMain is called). In the end the function has to return TRUE (1) in order to show everything went right.

I know some people will say something like "learn ASM!" and I guess that wouldn't be wrong but after I get this function to work the way I want I can return to coding in C/C++. As I already spent a week coming to this point I'm not in the mood of learning ASM for the next few weeks if I won't be needing it after this.

Anyway thanks in advance for any help!

Although yesterday I had nearly lost motivation to go on and I thought I wouldn't be able to figure out the problem I did today with some extra effort. I took my time to read about some important things regarding assembly in Narue's assembly tutorial which gave me enough insight (in addition to other sources) to finally find and understand the problem.
Sorry for the trouble :)

Maybe I'll post again if there's another project with similar ASM code.

This question has already been answered. Start a new discussion instead.