Function CallFunc(Address: PtrUInt; Arg: Array of PtrUInt; isCDecl: Boolean = True): PtrUInt;
{$ASMMODE INTEL}
begin
if (isCDecl) then
asm
mov ecx, 3 //loop 3 times.
mov edx, Arg
@@start:
dec ecx
push dword ptr[edx + ecx * 4] //push 3 pointers onto the stack.
jnz @@start
call [Address]
//Do cleanup
mov ecx, 3
@@end:
dec ecx
pop dword ptr[edx + ecx * 4] //pop each pointer off the stack.
jnz @@end
mov @Result, eax
end;
end;
但是,清理時出現段錯誤。如果我不彈出堆棧中的參數,它不會出現段錯誤。CDECL中的組件清理堆棧導致崩潰
在這種情況下,我是否需要將參數從堆棧中彈出或者是否安全?
我試圖做「ret 12」,但也失敗了。
但是你失去了我。這個函數是調用者。它「打電話給[地址]」,那麼它必須正確清理它? – Brandon 2015-02-07 20:56:06