Understand C ++ / Assembly code

0

I am studying a Node, and in this process I decided to help in the study to migrate a system in c / c ++ to node, however I am not familiar with c / c ++ and I have a code snippet that I can not understand very well he does, could you help me?

__declspec(naked) void NKD_AddMessage()
{
    __asm
    {
        PUSH [EBP + 0xC]
        PUSH [EBP + 0x8]
        CALL HKD_AddMessage
        ADD ESP, 0x8

        PUSH EAX

        MOV EAX, 0x41F8C0
        CALL EAX

        POP EAX

        MOV DWORD PTR SS:[EBP + 0x8], EAX
        MOV DWORD PTR SS:[EBP - 0x108], EAX

        RETN
    }
}
    
asked by anonymous 03.09.2016 / 05:13

1 answer

-1

This is not C ++, it's assembly (machine code). It is the calling sequence of an assembly function.

The call string is stacking parameters for the HKD_AddMessage function (PUSH statements [EBP + ...]), and then the function is executed. In the HKD_AddMessage return the previously stacked parameters are unpinning (ADD SP, 8).

Next is indirectly calling (CALL EAX) the address function 0x41F8C0. This function leaves a result on the stack, which is retrieved in the EAX (POP EAX) register and saved to two memory addresses in the stack area (PUSH DWORD PTR SS: [EBP etc].)

There may be some detail that is not entirely right (I'm writing head-on, not consulting anything), but overall that's where I wrote.

    
03.09.2016 / 06:01