ESP not saved accross function call?
I doubt anyone here will be able to solve this, but I'm open to any suggestions. I have a function that looks like so:
HttpExtensionProc is a function in a DLL that is loaded in (no problems there). Now, pReadClient, pWriteClient etc etc are all functions I've made myself that I've put into the ECB structure.
// Create an Extension Control Block
ECB.cbSize = sizeof(ECB);
ECB.ConnID = (HCONN) 10;
ECB.dwHttpStatusCode = 200;
ECB.lpbData = (unsigned char *)&ECB.cbAvailable;
ECB.lpszMethod = "GET";
ECB.lpszPathInfo = "/index.php";
ECB.lpszPathTranslated = "C:\\SWS\\Webroot\\test.php";
ECB.lpszQueryString = "user=john";
ECB.lpszContentType = "text/html";
// Load the DLL
gMyDLL = LoadLibrary("C:\\PHP\\sapi\\php4isapi.dll");
if (gMyDLL == NULL)
cout << "ERROR LOADING DLL\n\n";
pHttpExtensionProc = (HTTPEXTENSIONPROC) GetProcAddress(gMyDLL, "HttpExtensionProc");
ECB.ReadClient = &pReadClient;
ECB.WriteClient = &pWriteClient;
ECB.ServerSupportFunction = &pServerSupportFunction;
ECB.GetServerVariable = &pGetServerVariable;
Then I call the HttpExtensionProc function. It runs fine, and gives me all the output I expected. But then I get this error:
(Note: Its in a message box titled Microsoft Visual C++ Debug Library)
Now, to me this suggests perhaps I didn't send enough arguments to HttpExtensionProc. So, I head over to MSDN and it has this:
The Value of ESP was not properly saved accross a function call. This is usually the result of a function declared with one calling convention with a function pointer declared with another convention
DWORD WINAPI HttpExtensionProc(
So obviously I'm sending enough arguments. So then I say to myself... what if the pReadClient, pWriteClients have the wrong number of arguments? Nope. That can't be because I got them straigh from the header file from microsoft, and I know they're right.
So I wonder, maybe I declared HttpExtensionProc wrongly when I created the function pointer. This is what I have:
typedef DWORD (*HTTPEXTENSIONPROC)( EXTENSION_CONTROL_BLOCK *pECB );
Which, minus the WINAPI return thing, is exactly what it wants. So I don't think thats the problem either (it was to do with a function argument, not a return type).
So basically I'm stumped. Does anyone have any idea what the cause of the problem could be? Its not in the DLL I'm sure, because its the PHP ISAPI Dll, and it runs on apache/IIS just fine, so I know its me whos done something wrong. Any ideas?
PS: If your interested, I'm trying to write a web server that uses ISAPI with PHP. Thats what this code is, its almost impossible to find anything about writing the server side of things, so I've had to make most of it up. So far though everythings going great, I call the DLL, hand it a file to interpret, any query strings etc etc and it gives me the correct output. It just stuffs up at that point.