Heres my code so far:
Code:
#include <iostream>
#include <windows.h>
#include <httpext.h>
#include <string>
using namespace std;
HINSTANCE gMyDLL = NULL;
typedef DWORD (*HTTPEXTENSIONPROC)( EXTENSION_CONTROL_BLOCK *pECB );
HTTPEXTENSIONPROC pHttpExtensionProc;
BOOL WINAPI pReadClient(HCONN ConnID, LPVOID lpvBuffer, LPDWORD lpdwSize)
{
cout << "ReadClient() called" << endl;
return true;
}
BOOL WINAPI pWriteClient(HCONN ConnID, LPVOID Buffer, LPDWORD lpdwBytes, DWORD dwReserved )
{
cout << "WriteClient() called" << endl;
return true;
}
BOOL WINAPI pServerSupportFunction(HCONN hConn, DWORD dwHSERequest, LPVOID lpvBuffer, LPDWORD lpdwSize, LPDWORD lpdwDataType)
{
cout << "ServerSupportFunction() called" << endl;
return true;
}
BOOL WINAPI pGetServerVariable(HCONN hConn, LPSTR lpszVariableName, LPVOID lpvBuffer, LPDWORD lpdwSize)
{
cout << "GetServerVariable() called" << endl;
return true;
}
int main()
{
// Create an Extension Control Block
EXTENSION_CONTROL_BLOCK ECB;
HSE_VERSION_INFO hse;
// Load the DLL
gMyDLL = LoadLibrary("C:\\PHP\\sapi\\php4isapi.dll");
if (gMyDLL == NULL)
{
cout << "ERROR LOADING DLL\n\n";
return 0;
}
pHttpExtensionProc = (HTTPEXTENSIONPROC) GetProcAddress(gMyDLL, "HttpExtensionProc");
ECB.ReadClient = &pReadClient;
ECB.WriteClient = &pWriteClient;
ECB.ServerSupportFunction = &pServerSupportFunction;
ECB.GetServerVariable = &pGetServerVariable;
pHttpExtensionProc(&ECB);
return 0;
}
As far as I understand so far, I have to create an EXTENSION_CONTROL_BLOCK, and inside it I have to put those pReadClient(), pWriteClient etc... functions. I've done that, and then I call pHttpExtensionProc.
The program runs... and WOOHOO it prints:
ServerSupportFunction() called
WriteClient() called
But then theres an error, telling me that:
The value of ESP was not properly saved across a function call. This is usually the result of blah blah calling convention stuff.
So, I'm getting there. I guess maybe theres something wrong with the stuff I'm returning in my functions. Does anyone know what that error means and what I'm supposed to do?
PS: Now theres some C++ in it, could you move it back to the C++ board please?