彙編:c語言函式框架及呼叫約定
阿新 • • 發佈:2020-12-10
c語言
呼叫約定(32位)
裸函式
void __declspec(naked) Function()
{
__asm ret
}
無引數無返回值的結構框架
void __declspec(naked) Function()
{
__asm ret
push ebp
mov ebp,esp
sub esp,0x40
push ebx
push esi
push edi
lea edi,dword ptr ds:[ebp-0x40]
mov eax,0xCCCCCCCC
mov ecx, 0x10
rep stosd
pop edi
pop esi
pop edi
mov esp,ebp
pop ebp
ret
}
有引數有返回值的函式框架
void __declspec(naked) Function()
{
__asm ret
push ebp
mov ebp,esp
sub esp,0x40
push ebx
push esi
push edi
lea edi,dword ptr ds:[ebp-0x40]
mov eax,0xCCCCCCCC
mov ecx,0x10
rep stosd
mov eax,dword ptr ds:[ebp+8]
add eax,dword ptr ds:[ebp+0xC]
pop edi
pop esi
pop edi
mov esp,ebp
pop ebp
ret
}
帶區域性變數的函式框架
__asm ret
push ebp
mov ebp,esp
sub esp,0x40
push ebx
push esi
push edi
lea edi, dword ptr ds:[ebp-0x40]
mov eax,0xCCCCCCCC
mov ecx,0x10
rep stosd
mov dword ptr ds:[ebp-4],2
mov dword ptr ds:[ebp-8],3
mov eax,dword ptr ds:[ebp+8]
add eax,dword ptr ds:[ebp+0xC]
pop edi
pop esi
pop edi
mov esp,ebp
pop ebp
ret
}