https://bugs.winehq.org/show_bug.cgi?id=47503
--- Comment #4 from ghotik ghotik2002@yahoo.com --- I apologize for the delay, but the problem appeared to be more complex than I initially believed and doesn't necessarily involve process control. To cut the discussion short, I made a sample program from DxWnd source code and built a winebug.exe program that accepts (as first argument in the command line) the name of the program to be started. In attach there is the full source code and the executable. The logic is more complex that expected because the following steps are performed: 1) the game process is created in suspended state 2) the program start address is found with the GetThreadStartAddress routine 3) the assembly at start address is patched with an infinite loop 4) the program is resumed until it reaches the start address and loops forever 5) an external dll is injected in the target text segment and will run as a separate thread 6) the program is suspended again 7) the infinite loop patch is removed from the text segment 8) the program is resumed again and let free to run.
Here below also the output of the command wine windebug.exe <gamepath> where for <gamepath> I picked the small game CoccoGame.exe:
----------------------------------------------------------------------------- gho@gho-HP-EliteBook-2570p:~/Games/Cocco Game$ wine winebug.exe CoccoGame.exe exe = CoccoGame.exe InjectSuspended: exe="CoccoGame.exe" dir="(null)" CreateProcess SUSPENDED OK Start address = 0x417ab0 - press any key to continue ...
Start address patched - press any key to continue ...
Process resumed - press any key to continue ...
wait cycle 0 eip=417ab0 Start address reached - press any key to continue ...
WaitForSingleObject returns 258 Process suspended again - press any key to continue ...
Process injected - press any key to continue ...
Process resumed again - press any key to continue ... 008b:err:seh:setup_exception_record stack overflow 1580 bytes in thread 008b eip 7bcad0f3 esp 00230d04 stack 0x230000-0x231000-0x330000
type a key to exit ...