@hoxsiew
The return value of GetProcAddress is 0x00000000. So for some reason it can't find it...
@Igor Vartanov
You mean that the function name in my dll should also have 'extern' infront of it? Anyway, i tried it but also didn't work.
I'll post everything i have so far. Perhaps you can see where i go wrong.
exe file
DLL fileCode:#include <windows.h> typedef int (* testfunc)(int); int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { MSG msg; HMODULE dllEngine; testfunc bla(0); dllEngine = LoadLibrary ( L"test_engine.dll" ); if ( dllEngine == 0 ) MessageBoxW ( NULL, L"failed loading DLL", L"ERROR", MB_OK ); bla = (testfunc)GetProcAddress ( dllEngine, "testfunc" ); int x = bla(5); while ( GetMessage ( &msg, NULL, 0, 0 ) > 0 ) { TranslateMessage ( &msg ); DispatchMessage ( &msg ); } return msg.wParam; }
Code:#include <windows.h> extern int testfunc ( int x ); BOOL WINAPI DllMain ( HINSTANCE hInstance, DWORD fwdReason, LPVOID lpvReserved ) { switch(fwdReason) { case DLL_PROCESS_ATTACH: break; case DLL_THREAD_ATTACH: break; case DLL_PROCESS_DETACH: break; case DLL_THREAD_DETACH: break; } return(TRUE); } extern int testfunc (int x) { MessageBoxW ( NULL, L"test", L"blaat", MB_OK ); return x; }




Reply With Quote