-
June 5th, 2009, 05:27 AM
#1
Error 127 on a getProcAddress call
Hello,
I´m developing an application to hook mouse click using Visual Studio 2005. I´ve created a DLL called bloq_mouse.dll. To create this DLL I wrote an bloq_mouse.h defining the functions to be exportable:
#define DLLEXPORT __declspec(dllexport)
std::vector< std:air< POINT , POINT > > coords;
DLLEXPORT int loadBloqCoords(const char config[_MAX_PATH]);
DLLEXPORT LRESULT CALLBACK mouseHookProc(int nCode, WPARAM wParam, LPARAM lParam);
I also created an .def file :
LIBRARY bloq_mouse
EXPORTS
loadBloqCoords
mouseHookProc
And then, in a separate project, I´ve created an executable with this code:
hinstDLL = LoadLibraryA("bloq_mouse.dll");
if( hinstDLL == NULL )
{
//send error message
}
FARPROC lpfnGetProcess = GetProcAddress(hinstDLL, "loadBloqCoords");
if(lpfnGetProcess == NULL )
{
//send error message
}
The DLL seems to load succesfully (I copied it in the executable´s project dir) but when I try to access loadBloqCoords function I get an 127 error (cannot find the proccess).
I´m new with DLL making and accessing, Can Anyone Help Me?
Thanks.
-
June 5th, 2009, 08:28 AM
#2
Re: Error 127 on a getProcAddress call
Originally Posted by Unull
The DLL seems to load succesfully (I copied it in the executable´s project dir) but when I try to access loadBloqCoords function I get an 127 error (cannot find the proccess).
Always check using a utility such as Dependency Walker (depends.exe) or dumpbin to ensure that the actual function name you're trying to get the address of is actually exported using that very same name.
More than likely, the function wasn't exported, or it was exported with a decorated name (not the name you're calling GetProcAddress() with).
Regards,
Paul McKenzie
-
June 5th, 2009, 08:41 AM
#3
Re: Error 127 on a getProcAddress call
Paul is correct. You need to modify your #define as so:
#define DLLEXPORT extern "C" __declspec( dllexport )
if you want to prevent C++ compiler from mangling the names.
-
June 5th, 2009, 10:09 AM
#4
Re: Error 127 on a getProcAddress call
I used Dependency walker to see functions names and you were right, the names were decorated. I solved the problem using the decorated name in my GetProcAddress. Tried to put extern "C" in my .h file but the names were still decorated.
Thanks a lot for your quick and aimed answers!
-
June 5th, 2009, 10:22 AM
#5
Re: Error 127 on a getProcAddress call
Originally Posted by Unull
I used Dependency walker to see functions names and you were right, the names were decorated. I solved the problem using the decorated name in my GetProcAddress. Tried to put extern "C" in my .h file but the names were still decorated.
See the FAQ, as creating clean, unmangled exported names requires you to do the steps detailed here:
http://www.codeguru.com/forum/showthread.php?t=231254
Regards,
Paul McKenzie
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|