Henne / Bright-Eyes

"Bright Eyes" is a variation of DOSBox with customized support for the CRPG "Das schwarze Auge 1 - Schicksalsklinge"
GNU General Public License v2.0
19 stars 7 forks source link

How Ida to dosbox pseudo code is done? #49

Open xor2003 opened 5 years ago

xor2003 commented 5 years ago

I'm doing similar thing with my masm2c. How did you converted ida/asm to dosbox pseudo instructions?

Henne commented 5 years ago

Hi xOr,

this process has been done manually by me, since I know C and x86 assembly very well. The code, I have translated, was not optimized by the compiler, so it was a straight forward process. I also have the compiler, Borland C++ 3.1, which has been used to compile that binary. So I did the following for each function separately of the original binary:

  1. analyze the code of the function
  2. write that code in C
  3. compile the C code again with Borland C++ 3.1
  4. compare the binary code of the rewritten function with the binary code of the original
  5. When they differ goto 1. When they are the same DONE.

There are no DOSBox pseudo instructions, a rewritten function is executed natively on the host processor.

I've hooked into the two call instructions of the software DOSBox-CPU. If a function I have rewritten is called:

  1. I get the parameters from the stack
  2. call my rewritten function with the parameters
  3. place the return value of the function into register AX
  4. skip the emulation of that function call

Otherwise DOSBox emulates that function call.

But I think, that will not help you for masm2c, since you are doing something general with that. I had only a special case.

I hope to find time next month to reactivate Bright-Eyes, and I'll try out masm2c on one function which I did not managed to translate correctly.

Feel free to ask, if you want more details.

xor2003 commented 5 years ago

Thanks mostly clear and interesting. I will try to prepare Borland C++ Dos as target of my translator.

xor2003 commented 5 years ago

Testing resulting code on Dos might be easier before porting sound, graphics, etc to SDL. The problem is reversed code is a code modification and no tests available. Good solution for it is binary equality as in your case.