Thread: GetProcAddress Problem

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    80

    GetProcAddress Problem

    I've used the following function to call other DLLs, but for some reason I can't get this one to work correctly. It compiles, but
    errors out when I try to run it. I think it has to do with the function name. The instructions name the function as
    GetSrcBIOWIN. However, when I use Quick View Plus to view the
    dll's properties, its named _GetSrcBIOWIN@52.

    I don't know if the @ symbol in the function name is messing things up. Here's my function, any help is greatly appreciated:

    Code:
    int CallBIOWDLL(void)
    { 
         /* get handle to dll */
         HINSTANCE hGetProcIDDLL = LoadLibrary("C:\\WINDOWS\\system32\\BIOWDLL.dll");
    
         /* get pointer to the function in the dll*/
         FARPROC lpfnGetProcessID = GetProcAddress(HMODULE(hGetProcIDDLL), "GetSrcBIOWIN");
    
         /* Define the Function in the DLL for reuse. This is just prototyping
            the dll's function. A mock of it. Use "stdcall" for maximum compatibility.
     */   
         typedef int (__stdcall * pICFUNC)(char*,char*,char*,char*,char*,char*,char*,char*,char*,char*,char*,char*,char*);
    
         pICFUNC MyFunction;
         MyFunction = pICFUNC(lpfnGetProcessID);
    
    
    	 /* The actual call to the function contained in the dll */ 
         int intMyReturnVal = MyFunction("test","test2",EstLin,EstNon,EstUlt,EstPrim,UltTime,PrimTime,EstMitiLin,EstMitiNon,DetailResults,numLines,ErrorMess);
    
         /* Release the Dll */
         FreeLibrary(hGetProcIDDLL);
    
         /* The return val from the dll */
         return intMyReturnVal;
    }

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Make sure you test the return values from LoadLibrary and GetProcAddress to ensure they are non-NULL. If either is NULL, use GetLastError to get more information.

    >>but errors out<<

    This does not help us to help you. Please state what these errors are and what compiler you are using.

    This question should probably have been directed to the windows board.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    _GetSrcBIOWIN@52
    This just means the method is named GetSrcBIOWIN and takes 52 bytes of parameters ( 13 char pointers in your case I guess ).

    Other than that, you will need to check the return values. If that succeeds, you will need to check your documentation, if it's really 13 char*'s or maybe something else that is 52 bytes combined. If it's really 13 char pointers, you will need to make sure that the values you pass are valid for the function ( most functions crash on NULL or otherwise invalid pointers for example ). If all methods succeed, if all input is valid for this function, you need to consult the manufacturer of said dll. Send him a piece of his documentation and your code and ask for support.

    btw: Google returned zero hits for GetSrcBIOWIN, what kind of function is that ? Seems to be pretty... undocumented
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    80
    Thanks everyone for your help.

    What I mean by errors out is the program freezes and I'm asked if I want to send Microsoft an error report. I run the debugger and that freezes up as well, so I don't get any specific errors.

    I'm using VIsual C++ 4.0. Nvoigt is correct, there is little documentation. I will check the return values. Additionally, here's part of the readme file that came with the dll. Maby it will give insight into what I'm doing wrong:
    Code:
    __declspec ( dllexport )int WINAPI GetSrcBIOWIN (PSTR cSmilePass,
       PSTR cChemical, PSTR EstLin, PSTR EstNon, PSTR EstUlt, PSTR EstPrim,
       PSTR UltTime, PSTR PrimTime, PSTR EstMitiLin, PSTR EstMitiNon,
       PSTR DetailResults, PSTR numLines, PSTR ErrorMess)
    
    
    Arguments with the same names as the KOWDLL.DLL are exactly the same.
    
           This function returns:   0  for no errors
                                   -1  for if a SMILES error occurs
    
    NOTE ... this function receives three variables from the calling
       function:
    
       (1) cSmilePass - the SMILES notation
    
       (2) cChemical - the user chemical name or identifier
    
      Other argument variables:
    
       (3) EstLin - estimated Linear Model biodegradation probability
                     (probability of biodegrading fast or not)
    
     4 etc...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM