|
Its first time I use of New Message on this forum but I think this article is helpful for you(of course I think you aware of it but for other friends that dont know about it.
Loading a DLL from memory[^].
|
|
|
|
|
Doing advertising?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
No thanks. 
|
|
|
|
|
Hamid. wrote: Its first time I use of New Message on this forum
Want a medal?
Regards,
--Perspx
"I've got my kids brainwashed: You don't use Google, and you don't use an iPod." - Steve Ballmer
"Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen an angry penguin charging at them in excess of 100mph." - Linus Torvalds
|
|
|
|
|
|
I roughly read the article....One basic thing I didnt understand is, how to load a dll into the memory if it is not in the disk?
|
|
|
|
|
A common use for this technique is to load a dll that is stored as a program resource.
This allows single-file distribution of projects that use 3rd party dlls and for whom the source is not avail.
It's also used by some virii.
So, the dll almost always does exist locally on disk - just not in a single stand-alone file.
|
|
|
|
|
Hello everyone,
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.
1.
Since the preferred load address of DLL may conflict, there may be DLL address reloading/address fixing, so if we debug different process to watch the address range for the same DLL, the range are different. My question is, in such address conflicting situation, OS actually use one single copy of physical memory to mapping to different virtual memory block address range in different process? Or using different physical memory blocks to hold multiple copies of the same DLL?
2.
If no address conflicting and the same DLL are all in the same address range of different processes. And OS only use one physical memory block containing the DLL to reflect the virtual memory address in different process?
thanks in advance,
George
|
|
|
|
|
|
|
Hey George, what's up, took another spin on your Wheel Of Questions did you?
led mike
|
|
|
|
|
led mike wrote: Hey George, what's up, took another spin on your Wheel Of Questions did you?

|
|
|
|
|
A dll is broken into 2 parts: code and data.
The first app that loads a dll causes the os to load the code into physical memory and set its reference count to 1. The app also gets its own copy of the dll data block. The os then creates mapping tables for the app that map the app address space to physical address space (or swap file).
Subsequent apps that load the dll cause the os to see it's already loaded and the reference count is just increased. Each of these apps gets its own copy of the dll data block. The os then creates mapping tables ...
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
cmk wrote: causes the os to
All DLL's are not created equal
link[^]
led mike
|
|
|
|
|
Quite right, however a full explanation is beyond the scope of a forum reply - as is evident by the length of the article you linked to (it's a good link, hopefully he will read it).
I figured a simplified version of what would/should happen, in an ideal situation, was sufficient [shrug].
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
cmk wrote: hopefully he will read it
Doesn't matter, even if he reads it he can't understand it. But there it is and the answer to his question none the less.
led mike
|
|
|
|
|
Thanks led mike,
It is really a good document. I read from begin to end and take notes.
My current understanding is, if DLL code is relocation, then it will consume a duplicate copy in memory, or else share a common copy in memory. Correct?
regards,
George
|
|
|
|
|
George_George wrote: Correct?
What? People have written pages and pages of text, and who knows how much code, to account for one simple if condition that you explained in a single sentence. Whatever dude.
led mike
|
|
|
|
|
Hi led mike,
I just summarize. Theory is short.
regards,
George
|
|
|
|
|
|
Also read:
http://support.microsoft.com/kb/100635[^]
http://support.microsoft.com/kb/103858[^]
When thinking about what's in physical memory don't think in terms of the module (dll) as a whole, think in terms of its pages.
Only those pages that have been read will have been loaded from disk into memory.
Only those pages that have been written to (e.g. data page or code page with fix-ups) will have been copied in memory.
At any given point in time a non-copied page could be freed, and loaded again later from the disk when required.
At any given point in time a copied page could be freed from memory and put in the pagefile.
Even after your last app, that uses a given dll, exits pages of the dll may still be using physical memory in the page cache until they expire.
So, the simple answer, the one i originally gave, is usefull for thinking about what happens in general, because thinking about what happens in detail isn't much use.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Thanks cmk,
Let me finally clarify and confirm your points, from simple reply, I think you mean if there is relocation fix in DLL, there is a duplicate copy of page (either in memory or in page file). Correct?
regards,
George
|
|
|
|
|
Hi Experts
I need some Grid Control artical or example.Plz help me
|
|
|
|
|
|