|
|
What Is A Dynamically Loaded Library? | ||
Discussion by sparkx with 4 Replies.
Last Update: October 30, 2006, 4:46 pm | |||
![]() |
|
|
Sorry if this is not the right place, You can move this topic anywhere you want.
Thank you very much for the help. When I get older I wanna work with programming.
~Sparkx~
.dll are usually found in Windows systems because those are the libraries found in the operating system. In UNIX, they usually end with the extension .so. On MacOS X, they usually end with .dylib or just .so.
Most .dll files have licenses that restricts you from reverse-engineering by decompiling the library.
xboxrulz
As a DLL is like a normal PE executable, it's usually used as container for executable resources, such as character strings, bitmaps, icons, dialog and window templates, menus.... In fact, many of those DLLs don't have any code at all, just resources that are used by the main program once the DLL is loaded into memory.
A common practice is to put all string tables inside a DLL, then editing that DLL for translating into various languages (and then creating modified DLLs with one language set each), and then the main program will load the required DLL based up on the user settings (language configuration).
Basically, DLLs help in saving memory. There can be 10 applications running, but all they need is one DLL(Assuming their tasks are similar). If we use static libraries, there would be one library for every application that's running there by Loading the memory.
Well, as far I know using VC++ one cal write DLLs. I've never done DLL programming though.
If you are a little specific about which area of system programming you need, I might be able to suggest a good website. As it is, if you give a search on google, one of the first 5 results will serve you well. (Man, I really love Google for their prioratisation algorithm for websites. It's simply marvelous!)
This is really apparent when you actually dip into the c++ code for such a library.
Although this is a very basic overview... this is a snippet of what a .dll may look like.
CODE
// dll// polarysekt, 2006
//
// use requires "pskt.dll"
// link "libpskt.a"
# include "windows.h" // .dll is a windows thing
// i think BUILDING_DLL is MSVC-specific ??
# if BUILDING_DLL
# define PSKTCC __declspec (dllexport)
# else /* not BUILDING_DLL */
# define PSKTCC __declspec (dllimport)
# endif
BOOL APIENTRY DllMain (HINSTANCE hInstance, DWORD reason, LPVOID reserved ) {
switch (reason) {
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;
};
namespace pskt {
void PSKTCC psktSplash ( ) {
// code function here
};
}; // pskt namespace
That's a very basic, and quite incomplete skeleton, however, it shows that a .dll is not much different from your average program in c++.
as it was said above, your entry point is not:
CODE
int main( int argc, char* argv[] ) { };nor:
CODE
INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, INT ) { };Then, after compiling this to a .dll - varies per compiler, although DevC++ and MSVC make it pretty easy - there are a few ways to access the functions - although the easiest is to use a .lib -> hopefully I'm sending you somewhere. If you really want to get advanced, and/or want plugin-style or support for undefined or 3rd party .dll's - then you'll need to use pointers (and of course that requires a little knowledge of function pointers - and goes beyond this small reply.)
But this was not intended to be a .dll tutorial, mainly a snippet to send you in an investigative direction....
If you really want to get started with .dll's there are a few programs that I use occasionally - however, these programs are shipped with Microsoft Visual Studio, and it is beyond me whether you have access to the program.
If not perhaps I waste my time, but here goes if you want a small glance into the code...
The first utility - just to send you in the right direction would be the Dependency Viewer - if you open a .dll with this you will be shown exported functions (assuming you've gotten that far in your basic c++ studies) - which are in fact very similar to standard functions, although the code is compiled in their own library. All of this has been said above or can be found elsewhere.
One thing you may notice however, if you investigate several .dll's - is the dependency upon gdi32.dll, user32.dll, ntdll.dll, kernel32.dll - etc. - these are in essense your windows. Pretty much every call that needs made on your system will address one of these libraries, and you can search them for more specific function. (not to mention this was a brief off the top of my head list)
Another thing you may notice is who has used Visual Basic - as a link to the vbvm is referenced in these programs. For the .NET - it's MSCOREE or something - and DevC++ (ming32w or whatever) compiles with the MSVCRT dependency.
In any case, that's the beginning (as you can quickview a file and get the same information).
Another way is to open the .dll file as Resources in Microsoft Developer Studio - this will allow you to view any icons, bitmaps, dialogs, menus, or any custom or other resources in a .dll. This actually also includes the viewing of resources in "explorer.exe" - as it was said, a .dll is executable.
As a final interesting note, a common introduction to .dll's includes the "cards.dll" on windows systems, which is very handy for a simple deck of cards. Open it as resources and you can view all the bitmaps.
Since I lost track here - the result of .dll's allows programmers to break the large task of programming an application into components. Each of the components can change internally (i.e. faster algorithms, better memory management, etc.) while the basic calling interface remains the same.
In very simplified terms, this is why your windows 95 application using common controls can be quickly ported to windowsXP, using the newest common controls (even those not yet created) - most simply through a .exe.manifest....
P.S. - Explain your intention a little further about the downloadable prog or the system prog... peace.
Similar Topics:
C++ Graphics Or Chart Library
Dynamically Change The Background I...
Problems With Dynamically Loading J...
Nusphere Phped Vs. Zend Technologies Studio (0)
|
(2) Terregan Free Scenery/Landscape Generator
|
HOME 





Flash Tutorial: Dynamically Load External Images SWFs AS3
Dyanmically Loading Library Content to the Stage
Dynamic Flying Birds: Flash Tutorial! Place Movieclips w/ AS 3.0

