1

I'm using Code::Blocks to code, but one of the code I referenced is from Visual C++,so I have difficulties on the difference...:(

the full code are here

NAKED void ijlWrite()
{
__asm {
    PUSH    EBP
    MOV     EBP, ESP
    MOV     EAX, DWORD PTR SS:[EBP+8h]
    MOV     ECX, ssQuality
    MOV     DWORD PTR DS:[EAX+50h], ECX
    MOV     EDX, DWORD PTR SS:[EBP+0Ch]
    PUSH    EDX
    MOV     EAX, DWORD PTR SS:[EBP+08h]
    PUSH    EAX
    CALL    lpfnIJLWrite //a global variable
    POP     EBP
    RETN
}
}

I'll be very grateful if you translate them all.

P.S. I also don't know how to translate RETN. how to do it? The cheatsheet doesn't have such things:(

Elderry
  • 1,902
  • 5
  • 31
  • 45
xxbidiao
  • 834
  • 5
  • 14
  • 27
  • You have a synthetic cheat sheet [there](http://www.imada.sdu.dk/Courses/DM516/Litteratur/IntelnATT.htm) – Alexandre C. May 28 '11 at 10:29
  • Also see [there](http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html), since GCC inline asm requires you to declare a lot of things MSVC's inline asm doesn't. – Alexandre C. May 28 '11 at 10:30
  • And you are sure that the calling conventions make a straight translation possible? – Bo Persson May 28 '11 at 10:53

3 Answers3

4

Can't you just write the function in C++? A little more type information would help, but how about this?

void ijlWrite(int* p, int i)
{
    p[80] = ssQuality;
    lpfnIJLWrite(p, i);
}
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
  • actually the `ijlWrite` is from a dll and the code tried to hook the dll and change a parameter and then run the original function. – xxbidiao May 28 '11 at 11:21
3
MOV     EAX, DWORD PTR SS:[EBP+8h]

is equivalent to

movl %ss:8(%ebp), %eax

You just swap the order of the source and destination, the DWORD translates to an l suffix. The %ss: prefix is strictly unnecessary, it's the default when using EBP based memory access.

CB Bailey
  • 755,051
  • 104
  • 632
  • 656
1

I think it's

movl %ss:8(%ebp), %eax

See this for a quick reference.

detunized
  • 15,059
  • 3
  • 48
  • 64