The MASM Forum

General => The Campus => Topic started by: Magnum on January 28, 2013, 12:13:56 PM

Title: Been reading about dlls
Post by: Magnum on January 28, 2013, 12:13:56 PM
I see lots of dlls in XP and starting wondering about the advantages and disadvantages of dlls.

When should writing a dll be considered ?

If I understand some of the info below, an update can be made for a program by replacing a module like a dll with an updated one.

I am guessing that there are times when you can use a system dll if it contains functions that you can use ?

Andy


A DLL is a library that contains code and data that can be used by more than one program at the same time. For example, in Windows operating systems, the Comdlg32 DLL performs common dialog box related functions. Therefore, each program can use the functionality that is contained in this DLL to implement an Open dialog box. This helps promote code reuse and efficient memory usage.

By using a DLL, a program can be modularized into separate components. For example, an accounting program may be sold by module. Each module can be loaded into the main program at run time if that module is installed. Because the modules are separate, the load time of the program is faster, and a module is only loaded when that functionality is requested.

Additionally, updates are easier to apply to each module without affecting other parts of the program. For example, you may have a payroll program, and the tax rates change each year. When these changes are isolated to a DLL, you can apply an update without needing to build or install the whole program again.
Title: Re: Been reading about dlls
Post by: dedndave on January 28, 2013, 12:19:00 PM
we use them all the time
most of the libraries that you include in your program have associated system DLL's
kernel32, user32, shell32, etc - they all have DLL's in windows\system32
masm32.lib and msvcrt are a little different, however

not all DLL's are referenced the same way, though
some, like ones you may author, must be loaded first
Title: Re: Been reading about dlls
Post by: Tedd on January 29, 2013, 01:30:40 AM
Use a DLL when you have functions/resources that are to be shared by multiple programs.
If you put the shared functionality in the DLL then it doesn't need to be duplicated in each of the separate programs.
It can also save on physical memory usage as the DLL is only loaded once, but can be mapped into the memory space of each process that uses it.
Title: Re: Been reading about dlls
Post by: dedndave on January 29, 2013, 01:36:18 AM
QuoteIt can also save on physical memory usage as the DLL is only loaded once,
but can be mapped into the memory space of each process that uses it.

ahhhh - nice to know   :biggrin:

Tomato3
Title: Re: Been reading about dlls
Post by: jj2007 on January 29, 2013, 01:46:07 AM
Quote from: Tedd on January 29, 2013, 01:30:40 AMIt can also save on physical memory usage as the DLL is only loaded once, but can be mapped into the memory space of each process that uses it.

How does the OS handle DLL-internal data if they share physical memory with other processes?
Title: Re: Been reading about dlls
Post by: qWord on January 29, 2013, 01:55:16 AM
Quote from: jj2007 on January 29, 2013, 01:46:07 AM
How does the OS handle DLL-internal data if they share physical memory with other processes?
only the sections with read-only access are shared. Also, if you request write access to such page (Virtual* functions), window will create a private copy in your process. (they call this copy-on-write protection)
Title: Re: Been reading about dlls
Post by: Magnum on January 29, 2013, 01:55:18 AM
What about this situation.

A company uses a dll called stop_ie_from_irritating_upgrade_messages.DLL

They write a new dll with different name and install it.

Do they delete the old dll ?

If they don't, is it just taking up space ?

Are there unneeded registry entries when it is no longer being used ?

I occasionally look around my registry.

It looks like that belt around the Earth where all the space debris is floating around.

Andy



Title: Re: Been reading about dlls
Post by: jj2007 on January 29, 2013, 02:06:11 AM
Quote from: qWord on January 29, 2013, 01:55:16 AM
only the sections with read-only access are shared. Also, if you request write access to such page (Virtual* functions), window will create a private copy in your process. (they call this copy-on-write protection)

Danke :t
Title: Re: Been reading about dlls
Post by: Magnum on January 29, 2013, 02:15:22 AM
Thanks Tedd.

I will look for a simple example.

Andy