View Full Version : How to run a .dll
CyberCat
May 31, 2006, 04:10 PM
OK,
Does anybody know how (if its possible) to open a programs .dll file (in VB) and have it run as if it was running within its parent program?
I have a few .dll's and I want to see what they do.
leoandru
May 31, 2006, 04:30 PM
You can't run dll's like you do an executable program. If you want to load them and see the symbols defined in one you can. If you wrote a program in VB and its producing a dll chances are you have the configuration wrong if that wasn't your intentions. You need to change the project to generate an executable (.exe) file instead.
Blunty Killer
May 31, 2006, 04:49 PM
You can use RunDLL32 if you have an entry point.
Using rundll32.exe in Windows XP (http://vlaurie.com/computers2/Articles/rundll32.htm)
crosswire
May 31, 2006, 10:54 PM
I am not sure if rundll will run all the functions in a dll, only those with a winmain like signiture. Possibly I am quoting out of context but the rundll does seem to be what you want to do
The Run DLL utility (Rundll32.exe) included in Windows enables you to call functions exported from a 32-bit DLL. These functions must have the following syntax:
void CALLBACK EntryPoint(
HWND hwnd, // handle to owner window
HINSTANCE hinst, // instance handle for the DLL
LPTSTR lpCmdLine, // string the DLL will parse
int nCmdShow // show state
);
Typically, you would not run a dll by itself, but an application would make calls on functions in the dll. Running the dll by itself usually does not produce the same effect as the application. The application has an overall purpose defined in its main entry point. What Leo says is true. If you want to see the overall purpose of a dll then you should compile your source to an exe, where the main entry point has the word "main" in it, usually.
In you are working with a .net dll, then you can get a list of all the functions in the dll using VS or "C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin\Ildasm.exe"
For non .net dlls, I think you can use a Windows exe tool to extract a list of functions within a dll. Google the windows exe tools.
After you get the function name, if it is in .net then you can rebuild the .net dll to an exe with "C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\AL.ex e" and specify one of the functions as the entry point (what about parameter list :eusa_thin) You do not need source code. Note that you might not get any purpose from just the one function call unless it was written with an overall purpose, eg, something that would be typically hosted in a process.
If the function is not in a .Net dll but you are using VB.net then, use VS to compile a new exe aplication and import the dll and rewrite the function entry point. Then call it from within main and build a new exe application.
VB.Net
<DllImport("KERNEL32.DLL", EntryPoint := "MoveFileW", _
SetLastError := True, CharSet := CharSet.Unicode, _
ExactSpelling := True, _
CallingConvention := CallingConvention.StdCall)> _
Public Shared Function MoveFile(src As String, dst As String) As Boolean
' Leave function empty - DLLImport attribute forwards calls to MoveFile to
' MoveFileW in KERNEL32.DLL.
End Function
Public Main ...
If you want to see the functions that are listed in dlls in the Windows directory, then check msdn documentation. I will try to look up the tool that list them, but do a google. You can also get documentation on their functionality.
Please forgive me of any errors and correct me.
Blunty Killer
May 31, 2006, 11:13 PM
It would be best he get a list from the original developers (exported dll functions). If it is part of an SDK it shouldn't be a problem. If not, maybe a name of the app would be a good starting point, as some app developers have released in public domain a list of functions exported from their libraries.
Here was one program i came across too that could help you peek into the libraries
DLL Export Viewer (http://www.nirsoft.net/utils/dll_export_viewer.html)
Such utilities will be very useful if you wish to use existing libraries in your project.
Exported functions usually use a nomenclature that reflects the result of the function.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.