Coder's Guild Mailing List

Re: Calling DLL functions

Posted by Kspansel@xxx.xxx on 2000-03-07

Yeah,
    I figured out how to load the DLLs, but like you said the hard part is 
getting the prototypes.  I tried using quickview but that didn't show me what 
I wanted to know.  I might just have to load up softice, or do you think I 
could windasm it?  You think it'd list the arguments or maybe just look at 
the registers.  Well, Thanks.  

Kory Spansel

> Dunno if this helps, but you can call the exported functions just like
>  calling any other functions, provided you link the import library for the
>  .dll with your .exe. The library basically takes care about loading
>  the apropriate dll and providing your .exe with its export table. This
>  is load-time linking.
>  
>  Another way is run-time linking. You should not link your .exe with
>  the import library. Instead, you load the dll at run time using
>  LoadLibrary() or LoadLibraryEx() API, then you get the address of the
>  function you want to invoke by GetProcAddress() API. Invoke the
>  function by means of pointer to function then free the .dll if you
>  don't need it anymore.
>  
>  The hard part is determining the function prototypes. I can't help you
>  with that, but one suggestion, try 'quick-view'-ing the .dll file in
>  explorer. The export table can be read there. Usually, the functions
>  in a .dll uses pascal calling convention. To verify this, usually the
>  function names in the export table are appended with '@some-number'.
>  This shows that the function is using pascal conventions. The
>  'some-number' part shows how many bytes the function are expecting as
>  argument. At least you know how many bytes to pass to the function.
>  
>  If you are desperate, you can always debug the exported functions by
>  means of a window debugger (softice comes in mind). But it sure ain't
>  pretty trying to figure out those asm opcodes cause source-level
>  debugging is definitely out of question.
>  
Sponsored by Wrox Press - www.wrox.com. Programmer to Programmer (TM)
To signoff send a mail to listserver@xxxx.xx.xx with 
  "signoff tcg" in the body of your message.