Skip to main content
gamedev.net
🔒 Locked

ESP error

Started by Terren 2 replies 200+ views
Original Post
Terren
Terren
A couple of times when creating new functions and then calling them, the program has crashed with the following debug error: The value of ESP wa not saved across a function call. This is usually the result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. (module: chkesp.c) Now - can anyone tell me what this means, and what I have to do. I''m not creating nor calling these functions any different than usual, and am not using function pointers at all. Please help!!
Evil Bill
Evil Bill
Find out what function its refering to. Its because you create a function using one convention:

  
__stdcall int foo()
{
return 42;
}


But call it using another convention :

  
__cdecl int foo();

int main()
{
int i = foo();
}

This mostly happens when you use GetProcAddress() with stdcall functions in a DLL.

C++ uses cdecl by default, so if you declare a function pointer like this:

  
void (*LPRegisterServiceProcess)(DWORD a, DWORD b);

its effectively sticking a "__cdecl" on the front of it. If its declared using __stdcall, then you''ll duff up the stack when you call it.


Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)
GroZZleR
GroZZleR
Atleast you have ESP, I don''t.. *sobs*
Terren
Terren
Thanks for the help - although I managed to sort it by changing the way it passed the parameters...

Originally I had it so that it passed one of my own classes to the function, but I just changed it so that it passed it as a pointer rather than just a copy of the data.

This is a complete guess, but i''m guessing that the reason ESP wasn''t saved was because the data was being passed, but running out of stack memory??

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.