DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Assembly (http://www.daniweb.com/forums/forum125.html)
-   -   Asm help .Please (http://www.daniweb.com/forums/thread190580.html)

LangTuHaoHoa May 5th, 2009 1:23 pm
Asm help .Please
 
For Example .I have a function that code in C++ :
void MyFunc(int s) {
        struct itemRec {
                int code;
                int index;
        } bItem;
        bItem.code = 0x0000000B;
        bItem.index = s;
        __asm {
                push        eax
                  push        edx
                  mov        ecx,0x00625388
                  push        00000000h
                  lea        edx,bItem
                  push        edx
                  push        00000016h
                  mov        eax,0x00487273
                  call        eax
                  pop        edx
                  pop        eax
        }
}

and when I compile that function,so I found in asm that code :

                  push        ebp
                  mov        ebp,esp
                  sub        esp,00000008h
                  mov        eax,[ebp+08h]
                  mov        dword ptr [ebp-08h],0000000Bh
                  mov        [ebp-04h],eax
                  push        eax
                  push        edx
                  mov        ecx,00625388h
                  push        00000000h
                  lea        edx,[ebp-08h]
                  push        edx
                  push        00000016h
                  mov        eax,0x00487273h
                  call        eax
                  pop        edx
                  pop        eax
                  mov        esp,ebp
                  pop        ebp
                  retn

It's my example.So when I search in other asm file,I found that asm code :


                  push        ebp
                  mov        ebp,esp
                  sub        esp,00000008h
                  mov        eax,[ebp+08h]
                  add        eax,eax
                  mov        ecx,[eax+eax+L1000D004]
                  add        eax,eax
                  lea        edx,[ebp+08h]
                  mov        [ebp+08h],ecx
                  mov        [ebp-04h],eax
                  mov        [ebp-08h],edx
                  push        eax
                  push        ecx
                  mov        ecx,ds:[00838344h]
                  add        ecx,0000843Ch
                  add        ecx,00007EBCh
                  push        ecx
                  add        ecx,0000054Ch
                  mov        eax,[ebp-08h]
                  push        eax
                  mov        eax,0051F900h
                  call        eax
                  mov        ecx,[eax+0Ch]
                  cmp        ecx,[ebp+08h]
                  pop        ecx
                  jnz        L100010A8
                  add        eax,00000010h
                  add        ecx,[ebp-04h]
                  mov        [ecx],eax
 L100010A8:
                  pop        ecx
                  pop        eax
                  mov        esp,ebp
                  pop        ebp
                  retn

Please help me and tell me know what the real code in C++ (same my example) .And parameter to function that has address 0051F900h .Please help me

sysop_fb May 5th, 2009 2:28 pm
Re: Asm help .Please
 
Either I don't know what you're asking for or this smells like homework.

Anyway the param to the function you were asking about

  
                mov        eax,[ebp-08h]
                  push        eax
                  mov        eax,0051F900h
                  call        eax

The C calling convention is to push arguments on the stack from right to left. So what do you think the argument passed is?

LangTuHaoHoa May 5th, 2009 2:37 pm
Re: Asm help .Please
 
SO,I want to know how many arguments in that function,and How to use that function

for example:

void MyFunc(int s) {
struct itemRec {
int code;
int index;
} bItem;
bItem.code = 0x0000000B;
bItem.index = s;
__asm {
push eax
push edx
mov ecx,0x00625388
push 00000000h
lea edx,bItem
push edx
push 00000016h
mov eax,0x00487273
call eax
pop edx
pop eax
}
}


I really want to know how use that function ( 0x0051F900) .So because I don't know how many arguments that push to that function and code for use that function .Please help me.

In your post.You say :

Quote:

mov eax,[ebp-08h]
push eax
mov eax,0051F900h
call eax
So [ebp-08h] is?I don't know type of that argument.

LangTuHaoHoa May 5th, 2009 3:05 pm
Re: Asm help .Please
 
Quote:

Originally Posted by sysop_fb (Post 862611)
Either I don't know what you're asking for or this smells like homework.

Anyway the param to the function you were asking about

  
                mov        eax,[ebp-08h]
                  push        eax
                  mov        eax,0051F900h
                  call        eax

The C calling convention is to push arguments on the stack from right to left. So what do you think the argument passed is?

If possible,please help me decompile that asm code to real code in C++ .Please see my example to understand what I say .Thanks u

LangTuHaoHoa May 7th, 2009 10:23 am
Re: Asm help .Please
 
No one can help me how to use function 0x51F900 and what is arguments pass to that function ? :( Please help me


All times are GMT -4. The time now is 3:56 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC