Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

assembly code

Options
  • 09-03-2010 1:37pm
    #1
    Closed Accounts Posts: 1


    Hi..

    Can any body help me with this code and tell me what it does and why its get fails when we run?

    00520600 push ebp
    00520601 mov ebp,esp
    00520603 mov dword ptr [pointer],80706050h
    0052060A push ebx
    0052060B push 1
    0052060D call foobar (0x005100F2h)
    00520612 add esp,4
    00520615 mov ebx,dword ptr [pointer]
    00520618 mov dword ptr [ebx],eax

    Thanx


Comments

  • Closed Accounts Posts: 4,564 ✭✭✭Naikon


    Diegog wrote: »
    Hi..

    Can any body help me with this code and tell me what it does and why its get fails when we run?

    00520600 push ebp
    00520601 mov ebp,esp
    00520603 mov dword ptr [pointer],80706050h
    0052060A push ebx
    0052060B push 1
    0052060D call foobar (0x005100F2h)
    00520612 add esp,4
    00520615 mov ebx,dword ptr [pointer]
    00520618 mov dword ptr [ebx],eax
    Thanx

    I am by no means an assembly wizard. I am a little rusty, but I have some knowledge. Breaking it down line by line:

    Line 1: Initialize/push/prepare the base frame pointer for subroutine use(stores local variables, return address of subroutines ect on the stack)
    Line 2: Store contents of stack pointer in base frame pointer.
    Line 3: Store the hex string as a dword (2nd arg) in the specified ptr variable given the variables offset address
    Line 4: Prepare ebx register for use in the assembly program(push it onto the stack)
    Line 5: Push 1 indicates to me that one argument will be passed to foobar(I think!)
    Line 6: Call the foobar function/subroutine provided it's addressable
    Line 7: Clean and reclaim local variable space on the stack(esp,4)
    Line 8: Store the contents of the first dword from the ptr variable in ebx register
    Line 9: Store the contents of the first dword eax into the region of memory referenced by variable offset indirection(ebx's address)
    Local function should end here.


    It will most likely fail because the value 80706050h in hex is probably too large to store in a signed 32-bit dword, thus causing
    arithmetic overflow during execution. It's probably not the only problem, but it seems to be the most obvious. Where did you get
    this code from if you don't mind me asking?


Advertisement