Solved

DLL's GetProcAddress() cont'd to nietod

Posted on 1998-04-22
6
227 Views
Last Modified: 2010-04-10
OK Thanks for your help but I'm still having problems..
GetProcAddress() is returning NULL, despite my checking
The DLL being put where it should, the DLL having the function, checking spelling etc etc etc
Could it be to do with Name Mangling ?
Or is it because of being 32 bit DLL? (app is 32 bit)
0
Comment
Question by:Matlock
  • 4
  • 2
6 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1163099
Can you fill me in on the details?  
0
 
LVL 22

Expert Comment

by:nietod
ID: 1163100
Never mind I found it.  (No need to point out that was yesterday)

Here is your original question for others reference.

! want to Dynamically Load a DLL in C++ Builder   Ex:
     HINSTANCE hndl;
     FARPROC Func;
     hndl = LoadLibrary("c:\\wwwroot\\cgi-bin\\control.dll");
     Func = (FARPROC) GetProcAddress(hndl,"Passed");
     if(Func(Name.c_str(),Password.c_str())){ FreeLibrary(hndl); return 1;}//Passed
     else {FreeLibrary(hndl); return 0;}

    I'm getting an error message saying "Too Many Arguments" to the DLL function even though the number
    of arguments is correct
    Regards Matlock.

Yes, the problem is very likely to be name mangeling.
0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 1163101
To dissable name mangeling, you must declare a function as extern "C".    Like

extern "C" bool Passed(char *Param1,char *Param2)
{
   . . .
};

Does that help?  If not let me know.
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 

Author Comment

by:Matlock
ID: 1163102
I guess I must be clucthing at straws afraid I have already declared it as
extern "C" __declspec(dllexport) bool Passed(char *,char *);
and even tried
extern "C" __declspec(dllexport) bool PASSED(char *,char *);
and tried to fine PASSED insted , all to no avail

Matlock
0
 
LVL 22

Expert Comment

by:nietod
ID: 1163103
Opps.  I forgot something.  Builder prefixes the name with an underscore.  Look for "_Passed".  (MSVC does not do that by the way.)  

Now something from the its better to teach a man to cook than to feed him a meal department.

There are a variety of tools available for listing the exported or imported procedures in an EXE or DLL.  I use DUMPBIN.EXE which came with MSVC (Also part of MSDN? or SDK?)  Borland probably has a similar tool if you don't have it.  Use it to list the exports in the DLL. (That's how I found out about the underscore.)
0
 

Author Comment

by:Matlock
ID: 1163104
Thankyou It now works brilliantly!
Yes it was the underscore.
OK I appreciate the advice on looking at the contents first
Haven't got the tools yet but looking through notepad I found
that the DLL had been created without the function, re-compiled and there it was. Don't know why, not worried.
Thanks for all your Help
Matlock
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question