Mel Padden
Mel Padden

Reputation: 1003

DLL loading and system image space

DLL’s are only ever really loaded once. The dynamic loader will link and redirect calls if your app starts using a specific DLL, something from MS-Office for example.

However, WHEN does the repeated referencing of a DLL for various different users and apps, on the system push a DLL image into system space, so that ALL apps can use it?

Otherwise, does the loaded image remain in the user space?

Bearing in mind: All apps actually look at the SAME 2gb system space, and this is virtualized for them by virtual addressing,

OR, Does the linker always load DLLS into the Kernel space, so that all apps can use them.

Upvotes: 0

Views: 78

Answers (1)

jblume
jblume

Reputation: 410

DLL’s are only ever really loaded once.

This is not correct. They are mapped into the virtual address space either when the process starts by the loader of the operating system, or when you ask for it through API functions like LoadLibrary. Each process gets a fresh copy and the DLL is initialized each time this happens.

There is no global "system space" which all processes use at once. Each process has their own private virtual address range (which is 4GB with normally 2GB usable memory on 32 bit Windows). If you overwrite parts of a DLL in your own virtual memory, copies of the DLL in other processes are not affected. One process could easily crash the whole system if it weren't like this.

Upvotes: 2

Related Questions