Error 127 on a getProcAddress call
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Error 127 on a getProcAddress call

  1. #1
    Join Date
    Jun 2009
    Posts
    6

    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.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,426

    Re: Error 127 on a getProcAddress call

    Quote Originally Posted by Unull View Post
    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

  3. #3
    Join Date
    Feb 2005
    Posts
    2,160

    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.

  4. #4
    Join Date
    Jun 2009
    Posts
    6

    Thumbs up 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!

  5. #5
    Join Date
    Apr 1999
    Posts
    27,426

    Re: Error 127 on a getProcAddress call

    Quote Originally Posted by Unull View Post
    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center