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