I have tired a couple of things now, and i noticed that when i turn off optimizing it works 100%, when i turn on the lower optimalisation, it freezes, and @ high optimalisation it crashes :(.
Has this something to do with importing functions from dll's
.....
GETMODULEFILENAMEEX GetModuleFileNameExDLL = (GETMODULEFILENAMEEX) GetProcAddress(psapiLib, "GetModuleFileNameExA");
....
GetModuleFileNameExDLL(hMainProc,mod,fileName,sizeFileName); // <--- this is where somethings goes wrong.
I dont even know if this is a problem of c::b (not likely IMO), mingw, or my own code :cry:. Any help on this is really appreciated.
Sorry for not posting for a while, but often i cant reach the site. Anyway i found the solution to my problem. It was related to the calling conventions of the dll. The correct code is :
typedef DWORD (WINAPI *GETMODULEFILENAMEEX)(HANDLE, HMODULE, LPTSTR, DWORD);
i forgot the WINAPI so the stack was totaly screwed up after calling the function.
So there was no bug whatsoever. It was just me being stupid :). Am i the only one who has never ever heard of calling conventions ?!