stdcall - Assembly language - Calling convention -
can give me real illustration help me understand callee , caller in assembly language? have been through of sources, still can't how distinguish between callee , caller. give thanks in advance. (i adding explanation - give thanks again! sorry code new here , not know how insert code display properly) trying understand piece of code - learning basics of assembly. trying add together comment each command (i sure else me need too:
sub_401040 proc near .text:00401040 .text:00401040 .text:00401040 000 force ebp ; force content of ebp register onto stack .text:00401041 004 mov ebp, esp ;allocating 8 bytes of storage ; move esp register content ebp register .text:00401043 004 force ecx .text:00401044 008 mov eax, [ebp+8] .text:00401047 008 force eax ; force eax contents onto stack .text:00401048 00c phone call ds:lstrlena .text:0040104e 008 add together eax, [ebp+0ch] .text:00401051 008 mov edx, eax .text:00401053 008 mov ecx, 1 ;set buffer address .text:00401058 008 phone call sub_401000 .text:0040105d 008 mov [ebp-4], eax .text:00401060 008 mov ecx, [ebp-4] .text:00401063 008 shl ecx, 2 .text:00401066 008 mov [ebp-4], ecx .text:00401069 008 mov edx, [ebp-4] .text:0040106c 008 force edx .text:0040106d 00c force offset aresultd ; "result: %d\n" .text:00401072 010 phone call ds:printf .text:00401078 010 add together esp, 8 ; clean stack adding size of argument esp register .text:0040107b 008 mov eax, 539h .text:00401080 008 mov esp, ebp .text:00401082 004 pop ebp ;restore old frame pointer .text:00401083 000 retn ; homecoming near .text:00401083 sub_401040 endp
i read that, in order define calling convention need figure out caller , callee :) spent much time understand logic: phone call ds:lstrlena means callee? , sub_401040 caller? , can have more 1 calling convention in 1 program? cdecl along stdcall? not programmer, , not writing code, want understand how works help analysing viruses.
the caller 1 relevant call
(or rcall/blx/jalr/etc. function calling instruction), , callee function beingness called.
func: do_stuff func2: phone call func
in example, when func2
calls func
, func2
referred caller , func
callee.
any function can either caller or callee (or both in different contexts), unless contains no call
instructions. in latter case, called "leaf function", , optimizations may apply.
assembly stdcall cdecl
No comments:
Post a Comment