Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call

来源:互联网 发布:mac如何恢复苹果系统 编辑:程序博客网 时间:2024/05/21 23:17

动态加载dll后,执行导出的C API发生运行时错误:

Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.






这可能是函数调用约定不一致或者参数传递出错。

函数调用约定主要约束了两件事:

1.参数传递顺序

2.调用堆栈由谁(调用函数或被调用函数)清理

常见的函数调用约定:stdcall cdecl fastcall thiscall naked call

__stdcall表示

1.参数从右向左压入堆栈

2.函数被调用者修改堆栈

3.函数名自动加前导的下划线,后面紧跟一个@符号,其后紧跟着参数的尺寸

用depends就可以看到函数的导出名。

设定导入C API的调用约定:

typedef int (__stdcall *ImpAPI)(int,int);

0 0
原创粉丝点击