* mmap.cc (gen_create_protect): Always generate WRITECOPY protection

for private maps.
	(fixup_mmaps_after_fork): Fix calculation of WRITECOPY protection for
	VirtualProtect.  Add some words to the comment.
This commit is contained in:
Corinna Vinschen 2005-12-12 10:00:32 +00:00
parent 4e8e54543e
commit 2193d02b4d
2 changed files with 19 additions and 10 deletions

View file

@ -1,3 +1,10 @@
2005-12-12 Corinna Vinschen <corinna@vinschen.de>
* mmap.cc (gen_create_protect): Always generate WRITECOPY protection
for private maps.
(fixup_mmaps_after_fork): Fix calculation of WRITECOPY protection for
VirtualProtect. Add some words to the comment.
2005-12-10 Christopher Faylor <cgf@timesys.com> 2005-12-10 Christopher Faylor <cgf@timesys.com>
* dirent.h: Change the rest of the d_ino's to __deprecated_d_ino. * dirent.h: Change the rest of the d_ino's to __deprecated_d_ino.

View file

@ -98,8 +98,10 @@ gen_create_protect (DWORD openflags, int flags)
{ {
DWORD ret = PAGE_READONLY; DWORD ret = PAGE_READONLY;
if (openflags & GENERIC_WRITE) if (priv (flags))
ret = priv (flags) ? PAGE_WRITECOPY : PAGE_READWRITE; ret = PAGE_WRITECOPY;
else if (openflags & GENERIC_WRITE)
ret = PAGE_READWRITE;
/* Ignore EXECUTE permission on 9x. */ /* Ignore EXECUTE permission on 9x. */
if ((openflags & GENERIC_EXECUTE) if ((openflags & GENERIC_EXECUTE)
@ -1963,16 +1965,16 @@ fixup_mmaps_after_fork (HANDLE parent)
"address %p, %E", address); "address %p, %E", address);
return -1; return -1;
} }
else if ((mbi.AllocationProtect & PAGE_WRITECOPY) else if ((mbi.AllocationProtect == PAGE_WRITECOPY
|| mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY)
&& (mbi.Protect == PAGE_READWRITE && (mbi.Protect == PAGE_READWRITE
|| mbi.Protect == PAGE_EXECUTE_READWRITE)) || mbi.Protect == PAGE_EXECUTE_READWRITE))
{ /* A WRITECOPY page which has been written to is set to
/* A PAGE_WRITECOPY page which has been written to is READWRITE, but that's an incompatible protection to
set to PAGE_READWRITE, but that's an incompatible set the page to. Convert the protection to WRITECOPY
protection to set the page to. */ so that the below VirtualProtect doesn't fail. */
mbi.Protect &= ~PAGE_READWRITE; mbi.Protect <<= 1;
mbi.Protect |= PAGE_WRITECOPY;
}
if (!ReadProcessMemory (parent, address, address, if (!ReadProcessMemory (parent, address, address,
mbi.RegionSize, NULL)) mbi.RegionSize, NULL))
{ {