Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > API > extracting functions


Reply
 
Thread Tools Display Modes
  #1  
Old 08-18-2003, 09:52 AM
Benzakhar Benzakhar is offline
Junior Contributor
 
Join Date: Mar 2003
Posts: 274
Default extracting functions


Lets say I have a dll that I didn't make and I don't know what functions it has. Is it possible to extract the names of the functions. Eg. just the part like myfunc(parameters..) as datatype. Im not looking for the code of the functions just names.

Is it possible to use a costume dll made in C or C++ in VB. If so How?
Also is it possible to add my own functions to a dll made in C or C++ from vb?

If I make a dll with functions it then use the applypatchtofile api function to a dll in c or c++ would the functions be added from my dll to the new dll containing both functions from the dll's?

Thanx in advance.

Last edited by Benzakhar; 08-18-2003 at 10:03 AM.
Reply With Quote
  #2  
Old 09-15-2003, 08:12 AM
Mathimagics's Avatar
Mathimagics Mathimagics is offline
Algorithms 'R' Us

Forum Leader
* Guru *
 
Join Date: Jun 2002
Location: Canberra
Posts: 4,123
Default

I can answer some of your questions:

1. A WIn32 dll is a "Portable Executable" file, and so are "exe"'s. The list of function names exported by the dll are in an "Export Table". This is easily located and read - there are various freeware "PE file info" utilities around that will do the job for you. Note that you'll see the function names, but you will not know what (or how many) parameters are required.

2. Not sure what you mean by a "costume dll", but from VB you should be able to call any DLL function, just as long as the DLL uses the same calling convention as VB. There are 2 different calling conventions, "cdecl" and "stdcall". VB only supports "stdcall", and all Windows API dll's use it, but some 3rd-party DLL's may have been built using "cdecl" (which is the default mode in Unix) in which case you can't call them from VB (but you can from many other languages, e.g. C, PowerBasic)

3. You can't "add" functions to an existing dll


Hope this helps
__________________
Sept, 2006: 2 ^ 232,582,657 - 1 is prime!

At first, I was iridescent. Then, I became transparent. Finally, I was absent.
Reply With Quote
  #3  
Old 09-15-2003, 06:30 PM
Benzakhar Benzakhar is offline
Junior Contributor
 
Join Date: Mar 2003
Posts: 274
Default

Quote:
1. A WIn32 dll is a "Portable Executable" file, and so are "exe"'s. The list of function names exported by the dll are in an "Export Table". This is easily located and read - there are various freeware "PE file info" utilities around that will do the job for you. Note that you'll see the function names, but you will not know what (or how many) parameters are required.
There Is stated that you can find the function names on the "Export Table" How can I read the export table? And I need to know the parameters. I know its posible becuase VB does this. How can I get the parameters for the functions. I have VB and Visual C++ both 6.0.

Thanx in advance!
Reply With Quote
  #4  
Old 09-15-2003, 09:28 PM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default

Quote:
...I know its posible becuase VB does this.
VB doesn't do this. Where did you get an idea like that???
__________________
Posting Guidelines
Reply With Quote
  #5  
Old 09-16-2003, 03:29 AM
Mathimagics's Avatar
Mathimagics Mathimagics is offline
Algorithms 'R' Us

Forum Leader
* Guru *
 
Join Date: Jun 2002
Location: Canberra
Posts: 4,123
Default

Sorry, VB does NOT do that - to call a function in a DLL you have to declare it, telling VB the function and DLL name, and what the parameters are - if you get this wrong the program will crash.

If you are unfamiliar with API programming, you'll have trouble writing code to look at Export Tables - search the web for something like "PE File Viewer", there are free and/or share programs available.

Assuming your aim is legitimate, and not an attempt to "hack" something, tell us more about what you're trying to do, what the DLL is you want to use, etc....


(Whoops - just saw Thinker had already replied! Just like old times!)
__________________
Sept, 2006: 2 ^ 232,582,657 - 1 is prime!

At first, I was iridescent. Then, I became transparent. Finally, I was absent.
Reply With Quote
  #6  
Old 09-16-2003, 05:48 AM
00100b's Avatar
00100b 00100b is offline
Martian In Disguise

Retired Moderator
* Guru *
 
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
Default

I believe that what Benzakhar is referring to is that the Object Browser is capable of displaying the members, methods, and a method's arguments.

You could use the OLEView utility to view the Type Library of a library file. You will need to do some C type translations.

If you are looking to do this programmatically, this requires the use of the TypeLib Information library (TLBINF32.DLL) which if not already in the References dialog, can be browsed to. Depending on your OS, it either resides in the System or System32 directory.

This however, is not an easy library to use. You need to have an understanding of Type Libraries and how they are structured.

NOTE:
These will not work for libraries that don't expose a Type Library (like in the DLL's used in Win32 API calls).
__________________
The only stupid question is the one that goes un-asked.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
dayCounter with functions Help fupa Miscellaneous Languages 1 07-31-2003 09:49 PM
Array and String Functions rhawke General 5 07-10-2003 02:33 AM
Vba Functions in Excel category rino Word, PowerPoint, Outlook, and Other Office Products 1 10-28-2002 06:39 AM
string functions Ad1 General 4 03-09-2001 09:12 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->