Module: wine
Branch: master
Commit: f21096ad01c1ac75410916a4eee4626ce1bc2201
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f21096ad01c1ac75410916a4e…
Author: Alexandre Julliard <julliard(a)winehq.org>
Date: Wed Nov 5 12:31:49 2008 +0100
ntdll: Don't force anonymous file mappings to always be fully committed.
---
dlls/kernel32/tests/virtual.c | 5 -----
dlls/ntdll/virtual.c | 27 +++++++--------------------
2 files changed, 7 insertions(+), 25 deletions(-)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index 925f753..032af2b 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -531,9 +531,7 @@ static void test_MapViewOfFile(void)
ok(info.AllocationBase == ptr, "AllocationBase should have been %p but was %p instead\n", ptr, info.AllocationBase);
ok(info.AllocationProtect == PAGE_READWRITE, "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n", info.AllocationProtect);
ok(info.RegionSize == MAPPING_SIZE, "RegionSize should have been 0x%x but was 0x%x\n", MAPPING_SIZE, (unsigned int)info.RegionSize);
-todo_wine
ok(info.State == MEM_RESERVE, "State should have been MEM_RESERVE instead of 0x%x\n", info.State);
-todo_wine
ok(info.Protect == 0, "Protect should have been 0 instead of 0x%x\n", info.Protect);
ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of 0x%x\n", info.Type);
@@ -543,9 +541,7 @@ todo_wine
ok(info.AllocationBase == ptr2, "AllocationBase should have been %p but was %p instead\n", ptr2, info.AllocationBase);
ok(info.AllocationProtect == PAGE_READWRITE, "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n", info.AllocationProtect);
ok(info.RegionSize == MAPPING_SIZE, "RegionSize should have been 0x%x but was 0x%x\n", MAPPING_SIZE, (unsigned int)info.RegionSize);
-todo_wine
ok(info.State == MEM_RESERVE, "State should have been MEM_RESERVE instead of 0x%x\n", info.State);
-todo_wine
ok(info.Protect == 0, "Protect should have been 0 instead of 0x%x\n", info.Protect);
ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of 0x%x\n", info.Type);
@@ -570,7 +566,6 @@ todo_wine
ok(info.BaseAddress == ptr2, "BaseAddress should have been %p but was %p instead\n", ptr2, info.BaseAddress);
ok(info.AllocationBase == ptr2, "AllocationBase should have been %p but was %p instead\n", ptr2, info.AllocationBase);
ok(info.AllocationProtect == PAGE_READWRITE, "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n", info.AllocationProtect);
-todo_wine
ok(info.RegionSize == 0x10000, "RegionSize should have been 0x10000 but was 0x%x\n", (unsigned int)info.RegionSize);
ok(info.State == MEM_COMMIT, "State should have been MEM_RESERVE instead of 0x%x\n", info.State);
ok(info.Protect == PAGE_READWRITE, "Protect should have been 0 instead of 0x%x\n", info.Protect);
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 17fe711..a7ea2b3 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -824,7 +824,7 @@ static NTSTATUS map_file_into_view( struct file_view *view, int fd, size_t start
off_t offset, unsigned int vprot, BOOL removable )
{
void *ptr;
- int prot = VIRTUAL_GetUnixProt( vprot );
+ int prot = VIRTUAL_GetUnixProt( vprot | VPROT_COMMITTED /* make sure it is accessible */ );
BOOL shared_write = (vprot & VPROT_WRITE) != 0;
assert( start < view->size );
@@ -1422,15 +1422,15 @@ void VIRTUAL_SetForceExec( BOOL enable )
LIST_FOR_EACH_ENTRY( view, &views_list, struct file_view, entry )
{
UINT i, count;
- int unix_prot;
char *addr = view->base;
- BYTE prot = view->prot[0];
+ BYTE commit = view->mapping ? VPROT_COMMITTED : 0; /* file mappings are always accessible */
+ int unix_prot = VIRTUAL_GetUnixProt( view->prot[0] | commit );
if (view->protect & VPROT_NOEXEC) continue;
for (count = i = 1; i < view->size >> page_shift; i++, count++)
{
- if (view->prot[i] == prot) continue;
- unix_prot = VIRTUAL_GetUnixProt( prot );
+ int prot = VIRTUAL_GetUnixProt( view->prot[i] | commit );
+ if (prot == unix_prot) continue;
if ((unix_prot & PROT_READ) && !(unix_prot & PROT_EXEC))
{
TRACE( "%s exec prot for %p-%p\n",
@@ -1440,12 +1440,11 @@ void VIRTUAL_SetForceExec( BOOL enable )
unix_prot | (force_exec_prot ? PROT_EXEC : 0) );
}
addr += (count << page_shift);
- prot = view->prot[i];
+ unix_prot = prot;
count = 0;
}
if (count)
{
- unix_prot = VIRTUAL_GetUnixProt( prot );
if ((unix_prot & PROT_READ) && !(unix_prot & PROT_EXEC))
{
TRACE( "%s exec prot for %p-%p\n",
@@ -2012,11 +2011,7 @@ NTSTATUS WINAPI NtCreateSection( HANDLE *handle, ACCESS_MASK access, const OBJEC
}
vprot = VIRTUAL_GetProt( protect );
- if (sec_flags & SEC_RESERVE)
- {
- if (file) return STATUS_INVALID_PARAMETER;
- }
- else vprot |= VPROT_COMMITTED;
+ if (!(sec_flags & SEC_RESERVE)) vprot |= VPROT_COMMITTED;
if (sec_flags & SEC_NOCACHE) vprot |= VPROT_NOCACHE;
if (sec_flags & SEC_IMAGE) vprot |= VPROT_IMAGE;
@@ -2200,14 +2195,6 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
goto done;
}
- /* FIXME: If a mapping is created with SEC_RESERVE and a process,
- * which has a view of this mapping commits some pages, they will
- * appear committed in all other processes, which have the same
- * view created. Since we don't support this yet, we create the
- * whole mapping committed.
- */
- prot |= VPROT_COMMITTED;
-
/* Reserve a properly aligned area */
server_enter_uninterrupted_section( &csVirtual, &sigset );