Hey all. I'm having a problem with a DLL being loaded. In codeblocks, if I don't export Main + ALL the functions in my DLL, they cannot be used by an external program! Yet in visual studio, I exported nothing and external programs are able to load the DLL.
Example:
Main.cpp:
#include <windows.h>
#include "GLHook.hpp"
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
{
MessageBox(NULL, "", "", 0);
DisableThreadLibraryCalls(hinstDLL);
return Initialize();
}
break;
case DLL_PROCESS_DETACH:
{
return DeInitialize();
}
break;
}
return TRUE;
}
GLHook.hpp:
typedef void (WINAPI *ptr_glAccum) (GLenum op, GLfloat value);
GLHook.cpp:
void GLHook_glAccum(GLenum op, GLfloat value)
{
(*optr_glAccum) (op, value);
}
bool Initialize(void)
{
if (!OriginalGL)
{
char Root[MAX_PATH];
GetSystemDirectoryA(Root, MAX_PATH);
strcat(Root, "\\opengl32.dll");
OriginalGL = LoadLibraryA(Root);
if (!OriginalGL) return false;
if ((optr_glAccum = (ptr_glAccum) GetProcAddress(OriginalGL, "glAccum")) == NULL)
{
return false;
}
}
.DEF File:
LIBRARY OpenGL32
;DESCRIPTION "GLHook Definition File"
EXPORTS
glAccum = GLHook_glAccum;
Now the above will compile and work flawlessly in VisualStudio but in codeblocks it'll say "Cannot Export Symbols Undefined"..
When I do export it in codeblocks, it shows 700 symbols in the DLLExport Viewer whereas the Visual Studio one shows 350. The game Loads the Visual studio one but crashes immediately on the Codeblocks one. Visual studio is 80kb in size whereas codeblocks is 744kb.
Why does it do this in codeblocks? I want to use Codeblocks so I can use C++11 ={ Anyway to fix it?
In other words, DLLExport view is showing:
glAccum; //Original functions and..
GLHook_glAccum @8; //The detoured functions.
for codeblocks whereas visual studio one just shows:
glAccum;