> Therefore, from the moment executable image gets loaded into RAM, the
system does not really need the disk file that backs up executable image
I think this is wrong for user-mode sections. Segment object for executable
section is backed by the executable file.
any in-memory modification of executable image will result in modification
of the file on the disk.
The COW( Copy-On-Write ) deals with this. The private copy of a page is
created. This is common for nearly all OSes.
In order to deal with this dilemma, Cache Manager makes a distinction
between executable section and data section - when pages that executable
section is mapped to are swapped to the disk, they get flushed to the
paging file
Only private ( COW pages, see above ) are backed by the page file. Also,
Cache Manager has nothing to do with executable sections, it works with data
sections.
–
Slava Imameyev, xxxxx@hotmail.com
wrote in message news:xxxxx@ntdev…
>I am going to give you a bit more detailed explanation to the concepts
>behind David’s post…
>
> When you create a process, first of all, you open executable file, then
> create an executable section that is backed up by the file, and then call
> ZwCreateProcess() ( or ZwCreateProcessEx()) that, among other things,
> loads executable image into RAM. If memory pages of the target process
> don’t get accessed for a while or if the system is low on memory, they get
> swapped to the disk and are brought back to RAM when they get accessed.
>
> I hope by now you already see the potential problem here - if these pages
> are written to the original file (i.e. everything works the way it does
> with memory-mapped files), any in-memory modification of executable image
> will result in modification of the file on the disk. You don’t really want
> something like that to happen, do you??? At the same time, you don’t want
> the section to be treated as RO either, for understandable reasons -
> otherwise, all in-memory changes that you made to a page will be
> discarded when it gets swapped to the disk, so that the process address
> space will become just incoherent.
>
> In order to deal with this dilemma, Cache Manager makes a distinction
> between executable section and data section - when pages that executable
> section is mapped to are swapped to the disk, they get flushed to the
> paging file, rather than to the one that backs up executable section (when
> it comes to data section, it gets flushed to the file that backs up the
> section).
>
>
> Therefore, from the moment executable image gets loaded into RAM, the
> system does not really need the disk file that backs up executable image
> in order to run the process, so that it maintains file-process
> relationship information only for the statistical purposes. This is why
> file-process relationship information that you get is always the one that
> system had at the time of executable section creation - even if this info
> is already outdated…
>
> Anton Bassov
>