Lets play "Whats Wrong With That DLL?"

This is a discussion on Lets play "Whats Wrong With That DLL?" within the Windows Programming forums, part of the Platform Specific Boards category; Hey evbdy, Iam.TheJinx(who *cares); Okay, heres the deal. I stayed up until 2:30am trying to load-up and include a DLL ...

  1. #1
    Caffienated jinx's Avatar
    Join Date
    Oct 2001
    Posts
    235

    Talking Lets play "Whats Wrong With That DLL?"

    Hey evbdy, Iam.TheJinx(who *cares);

    Okay, heres the deal. I stayed up until 2:30am trying to load-up and include a DLL file in a dialopg project. How in the heck can you load it up and find your function, or whatever, in it? I used the Dependency Viewer that came with MSVC++ and found the address and all, but I can't load it up. Any one wanna help???
    Weeel, itss aboot tieme wee goo back too Canada, eeehy boyss.

  2. #2
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    I'm not too familiar with DLLs, but I think you have to make a .h that contains the prototypes for the functions, I've done that with static libraries and it works.

    Oskilian

  3. #3
    Caffienated jinx's Avatar
    Join Date
    Oct 2001
    Posts
    235

    Exclamation How would you...

    ...How would you make the prototypes in your .h file? I've never seen this done before.
    Weeel, itss aboot tieme wee goo back too Canada, eeehy boyss.

  4. #4
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    for example, if you have a function in the dll like this:

    int AddThreeNumbersEx(int a, int b, int c)
    {
    int d;
    int e;
    d=a+b;
    e=d+c;
    return e;
    }

    you make a .h file which contains the following:

    int AddThreeNumbersEx(int a, int b, int c);


    try it and tell me how it works

    and by the way, that function is OBVIOUSLY not the fastest way to add three numbers, I just made it like that because I wanted to show you a full function

    Oskilian

  5. #5
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    I was browsing the MSDN library and found some functions that might be of your interest:

    LoadLibrary
    FreeLibrary
    GetProcAddress

    they are quite long to explain, so I suggest you go to
    http://msdn.microsoft.com
    and look them up

    Oskilian

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    I don't do the DLL's here but I use them. I use WIN32 API VC (no ++)

    For ActualFunction(BOOL bThing);

    I have a global delaration for the function

    TYPE_DLLFunction ActualFunction;

    this holds the address returned from GetProcAddress()

    Then a prototype define

    typedef int (WINAPI* TYPE_DLLFunction)(BOOL);

    and then call

    hDLLInst=LoadLibrary(szDLLLocationString)

    then

    ActualFunction = (TYPE_DLLFunction)GetProcAddress(hDLLInst, "ActualFunction");

    You may need to create a DEF file as the names of functions get truncated. They are OK in debug but will get mangled in release mode.

  7. #7
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    It works!

    Oskilian

  8. #8
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Check that the exe can get the function names/adresses in both Debug and Release modes. We had trouble with the Release mode not getting the whole function name.

  9. #9
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    why should that happen?

    Oskilian

  10. #10
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Not 100% sure why.
    Seems that name over-runs the storage allowed for it.
    In debug there space is for debug info so no problem. In release the end of the function name is mixed with its paramaters and so lost.
    A def file solved the problem.

    Why do release? About 25% smaller and 25% faster (for my app).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I need to play a pre recorded vox file using C
    By m.sudhakar in forum C Programming
    Replies: 4
    Last Post: 11-17-2006, 06:59 PM
  2. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 08:48 PM
  3. how to play play and stop wav files
    By cnu_sree in forum Linux Programming
    Replies: 4
    Last Post: 08-15-2006, 12:11 AM
  4. PlaySound doesn't play when called!
    By Queatrix in forum Windows Programming
    Replies: 7
    Last Post: 03-03-2006, 08:02 PM
  5. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21