CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Location
    Texas, USA
    Posts
    1,206

    DLL's and EXP files

    Hi,

    Currently I'm using LoadLibrary() to load a DLL I compiled. However, I'm finding that GetProcAddress() will not work unless an EXP file is bundled with the DLL.

    Is there a way of getting GetProcAddress() to work with non-mangled names, but without having to have a DEF or EXP file? Could the export information perhaps be embedded in the DLL itself?

    I plan to send these extensions (dlls) to other clients, and I want to avoid sending EXP or DEF files with it since this is a potential security risk, it exposes the addresses of functions. I realize this can be obtained through other facilities, but I don't want to make it THAT easy.

    My goal is to simply send a DLL (by itself) and have the application be able to import functions from it using non-mangled function names.
    --MrDoomMaster
    --C++ Game Programmer


    Don't forget to rate me if I was helpful!

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: DLL's and EXP files

    You functions have to be declared using 'extern "C"' for C++ compilations.
    http://msdn.microsoft.com/en-us/libr...3s(VS.80).aspx

    gg

  3. #3
    Join Date
    Feb 2004
    Location
    Texas, USA
    Posts
    1,206

    Re: DLL's and EXP files

    I'm doing that, however it's still not working unless I provide the EXP file.
    --MrDoomMaster
    --C++ Game Programmer


    Don't forget to rate me if I was helpful!

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: DLL's and EXP files

    Quote Originally Posted by MrDoomMaster
    Is there a way of getting GetProcAddress() to work with non-mangled names,
    That is not the way GetProcAddress() works. It is a very simple function -- whatever function name is exported from the DLL, that is the name that GetProcAddress() recognizes. GetProcAddress() needs no EXP files, as it knows nothing about these files.

    GetProcAddress() doesn't care what compiler, what computer language, or what options were used to create the DLL. The DLL contains exported function names, and whatever those names are, when you call GetProcAddress(), the name you give it must match exactly with the name that shows up in the DLL's export table.

    If you load the DLL into Dependency Walker, look at the names of the exported functions. Those names are the ones that are valid when calling GetProcAddress().

    Regards,

    Paul McKenzie

  5. #5
    Join Date
    Jan 2008
    Location
    India
    Posts
    408

    Re: DLL's and EXP files

    You can accomplish that. Try the attached project.

    Build Library.dsw first and then LibraryUser.dsw
    Attached Files Attached Files
    Rate the posts which you find useful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured