2
我得到这个错误:内联汇编,误差
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.
我不知道如何解决这个问题,谁能帮助我?
我的代码是:
#include "common.h"
char* file = "c:\\town.las";
char* file_mode = "r";
#pragma pack(1)
struct LASHEADER
{
char LASF[4];
};
void main()
{
LASHEADER lasHeader;
FILE* of;
__asm
{
push ebp
mov eax, file_mode
push eax
push file
call fopen
mov of, eax
mov esi, esp
mov eax, DWORD PTR of
push eax
push 1
push 4 // this should be sizeof LASHEADER
lea ecx, DWORD PTR lasHeader
push ecx
call DWORD PTR fread
add esp, 16
cmp esi, esp
mov eax, of
push eax
call fclose
}
}
我如何能做到什么要求?我试图在没有运气的情况下推动ebp和流行音乐。
你错过了一个'推eax' :) – Jester
@Jester有一个无用的负荷EAX和推动,当推恒定是可能的,所以我取代了它。那是你的意思吗? – Gene
谢谢,它清除了一点,但我现在得到一个新的错误“运行时检查失败#2 - 围绕变量'lasHeader'堆栈已损坏。”但我会尝试你的建议。 – Dean