Nasty stuff.
I've got this DLL:
Code:
class GFXBase
{
public:
GFXBase() {}
~GFXBase() {}
void Nothing();
};
void GFXBase::Nothing()
{
MessageBox(NULL, "Nothing doing!", "HMM", MB_OK | MB_ICONEXCLAMATION);
}
extern "C" __declspec(dllexport) GFXBase *pGFXBase = NULL;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
pGFXBase = new GFXBase();
return TRUE;
}
With this trying to use it:
Code:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HMODULE hGFXBaseDLL = NULL;
void *pGFXBase = NULL;
hGFXBaseDLL = LoadLibrary("GFXBase.dll");
if (! hGFXBaseDLL)
{
MessageBox(NULL, "Error loading library", "Error", MB_OK | MB_ICONERROR | MB_TASKMODAL);
return 1;
}
pGFXBase = (void *) GetProcAddress(hGFXBaseDLL, "pGFXBase");
if (! pGFXBase)
{
MessageBox(NULL, "Error calling GetProcAddress()", "Error", MB_OK | MB_ICONERROR | MB_TASKMODAL);
return 1;
}
else
MessageBox(NULL, "Retreived pointer", "Yay", MB_OK | MB_ICONINFORMATION);
FreeLibrary(hGFXBaseDLL);
return 0;
}
Now I want to use the class without "knowing" the class. Hence the void pointer. T'all works fine (the pointer is retreived) but obviously I can't use it. There must be a way to call GFXBase::Nothing(), I just don't know how. Even if it involves insane doings I'd be interested to know.