Corinna Vinschen
2011-04-26 09:50:34 UTC
Hi,
I'm wondering if anybody could explain to me how the InheritDisposition
parameter of the NtMapViewOfSection call is supposed to work. At least
it doesn't work as I'm expecting it.
The WDK description seems to be quite clear, that a view created with a
ViewShare dispositon is shared with any child process created in future.
However, assuming I have a view created with ViewShare dispositon in a
Win32 user process. If the user process calls CreateProcess with full
handle inheritance, I expect that the view to the section is immediately
available to the child process. But it isn't. In fact the behaviour is
identical to the behaviour as if I had specified ViewUnmap.
What I have in the child process is the section handle only, which I can
use to recreate the view. That seems ok at first sight, but it's a
problem if I want to have access to a PAGE_WRITECOPY section created by
the parent process. After the child process has been created, I expect
to see all changes to the section made by the parent process. But
actually, none of the changes are visible in the child. The section
looks genuinely as it was before the parent made any changes to it.
I'm not sure if I made myself clear enough. Actually I expected the
ViewShare disposition to allow POSIX-like behaviour of mmaped sections
after a fork. But I don't seem to be able to get that with using
NtCreateSection/NtMapViewOfSection alone.
So, can anybody explain what I'm missing?
Thanks,
Corinna
I'm wondering if anybody could explain to me how the InheritDisposition
parameter of the NtMapViewOfSection call is supposed to work. At least
it doesn't work as I'm expecting it.
The WDK description seems to be quite clear, that a view created with a
ViewShare dispositon is shared with any child process created in future.
However, assuming I have a view created with ViewShare dispositon in a
Win32 user process. If the user process calls CreateProcess with full
handle inheritance, I expect that the view to the section is immediately
available to the child process. But it isn't. In fact the behaviour is
identical to the behaviour as if I had specified ViewUnmap.
What I have in the child process is the section handle only, which I can
use to recreate the view. That seems ok at first sight, but it's a
problem if I want to have access to a PAGE_WRITECOPY section created by
the parent process. After the child process has been created, I expect
to see all changes to the section made by the parent process. But
actually, none of the changes are visible in the child. The section
looks genuinely as it was before the parent made any changes to it.
I'm not sure if I made myself clear enough. Actually I expected the
ViewShare disposition to allow POSIX-like behaviour of mmaped sections
after a fork. But I don't seem to be able to get that with using
NtCreateSection/NtMapViewOfSection alone.
So, can anybody explain what I'm missing?
Thanks,
Corinna