Jump to content
xisto Community
Sign in to follow this  
sparkx

What Is A Dynamically Loaded Library?

Recommended Posts

I was just going threw some programs and I found a .dll file. I have no idea what that is except that it stores data of some sort on your computer. I was kinda interested in making a down loadable program but I had no idea how. I figure a .dll is useful for something but I'm not sure what. I tried to open it up and see what kind of code was in it but all i got was binary script. Is there a way to convert this script to English so that I can edit it? Also what would be a good website to learn how to make system related programs. Sorry if I make no sense I am kinda new to this system scripting. I have already learned basic programming (a little C++).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~

Share this post


Link to post
Share on other sites

a .dll is a library that a software requires to run. A dynamic library means that it is a universal library which many software would require it to run. However, a static library is only used by one software and bloats the software package. Usually, most Windows application use .dll files as static libraries. True dynamic libraries are commonly found on UNIX machines..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

Edited by xboxrulz (see edit history)

Share this post


Link to post
Share on other sites

As long as you know about C++ programming, i'll tell you that, for Windows, a Dinamic DLL is just a compiled executable PE program, but it is compiled with a special entry point. You know, the entry point of a regular C program is the main() function. At windows programs, the entry point is WinMain(). At DLLs, the entry point is (not in every case) DllMain, and contains a startup routine to initialize some variables and allocate some memory for other functions. When a C program loads a DLL into memory, then it can use the functions that are stored in that dll. When some functions are no longer needed, the program might unload the DLL so can free some memory.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).

Share this post


Link to post
Share on other sites

Well, DLL (Dynamic Link Library) is a collection of routines (Procedures which perform a job/multiple jobs) which are commonly accessible for "linking" by any application/program.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!)

Share this post


Link to post
Share on other sites

Yeah, as it was said above, a .dll is nearly identical to your standard PE, including both code and resources.


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.

// 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)#  endifBOOL 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:

int main( int argc, char* argv[] ) { };

nor:

INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, INT ) { };
- which browsing the MSVCRT source will explain a little better.

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.
Edited by polarysekt (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.