Re: DLL load issue

Tech-Archive recommends: Fix windows errors by optimizing your registry



"Klueless" <klueless@xxxxxxxxxxxxxxxx> wrote:

"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
My question is about on one single machine, no matter how many different
processes need/load a DLL, the DLL is actually load one copy into physical
memory (not virtual memory) or multiple copies.

DLL's are organized into sections, each which can be readonly,
writeable, executable, ... Windows needs single copies of the static
sections. Multiple copies of the virtual memory pages of the non-static
sections are generated after the first writes to those pages.

Right. Put another way, the pages of a DLL are marked as "copy on write".
As long as there are only reads, the original physical page is shared
amongst all process. Once there is a write, the system makes a copy for
the process doing the write.

The
DLL loader tries to fix a DLL to be relocatable, which implies the image
of the executable sections will look the same to all sharing processes.
Addresses are relative to a base register. The value of the base
register may be different for different processes.

This would be handy if it were true. For Win32, at least, it is not true.
Global and static data and function references are all made with absolute
addresses that need to be relocated. The DLL loader can't know which
registers are still available for this kind of use.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
.



Relevant Pages

  • Re: Why do we need executables in certain formats ?
    ... > Can anybody explain me why do we need executables in certain formats? ... Modern virtual memory processors can locate to ... ..DLL files changed out from under them, ...
    (comp.lang.asm.x86)
  • Re: DLL load issue
    ... processes need/load a DLL, the DLL is actually load one copy into physical ... Multiple copies of the virtual memory pages of the non-static ... Addresses are relative to a base register. ...
    (microsoft.public.vc.language)
  • Re: .Net 2.0 app behavior on 64-bit machine.
    ... their DLL can address the 4GB virtual memory ... I would say it's unlikley their 32 bit dll is addressing 4GB of virtual ...
    (microsoft.public.dotnet.framework)
  • Re: C++ DLL Side Of a VB Call-back function Problem
    ... Nano schrieb im Beitrag ... found that when I implement a call to a C++ DLL which calls back a VB ... When a VB application gets started, the executable image ... will change its virtual memory address for the whole time the image is ...
    (microsoft.public.vb.winapi)
  • Re: DLL Injection from kernel-land
    ... 3- program catches event and asks driver information about process ... 5- DLL walks through PE and patches function addresses ... write in virtual memory some code that loads the DLL of interest ...
    (microsoft.public.win32.programmer.kernel)