ntdll: Avoid accessing builtin views outside of the critical section.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2017-09-11 19:50:30 +02:00
parent a901fa9dc3
commit 8dc8b3e9c0
1 changed files with 16 additions and 16 deletions

View File

@ -1634,13 +1634,12 @@ NTSTATUS virtual_create_builtin_view( void *module )
server_enter_uninterrupted_section( &csVirtual, &sigset ); server_enter_uninterrupted_section( &csVirtual, &sigset );
status = create_view( &view, base, size, SEC_IMAGE | SEC_FILE | VPROT_SYSTEM | status = create_view( &view, base, size, SEC_IMAGE | SEC_FILE | VPROT_SYSTEM |
VPROT_COMMITTED | VPROT_READ | VPROT_WRITECOPY | VPROT_EXEC ); VPROT_COMMITTED | VPROT_READ | VPROT_WRITECOPY | VPROT_EXEC );
if (!status) TRACE( "created %p-%p\n", base, (char *)base + size ); if (!status)
server_leave_uninterrupted_section( &csVirtual, &sigset ); {
TRACE( "created %p-%p\n", base, (char *)base + size );
if (status) return status;
/* The PE header is always read-only, no write, no execute. */ /* The PE header is always read-only, no write, no execute. */
set_page_vprot( view->base, page_size, VPROT_COMMITTED | VPROT_READ ); set_page_vprot( base, page_size, VPROT_COMMITTED | VPROT_READ );
sec = (IMAGE_SECTION_HEADER *)((char *)&nt->OptionalHeader + nt->FileHeader.SizeOfOptionalHeader); sec = (IMAGE_SECTION_HEADER *)((char *)&nt->OptionalHeader + nt->FileHeader.SizeOfOptionalHeader);
for (i = 0; i < nt->FileHeader.NumberOfSections; i++) for (i = 0; i < nt->FileHeader.NumberOfSections; i++)
@ -1650,9 +1649,10 @@ NTSTATUS virtual_create_builtin_view( void *module )
if (sec[i].Characteristics & IMAGE_SCN_MEM_EXECUTE) flags |= VPROT_EXEC; if (sec[i].Characteristics & IMAGE_SCN_MEM_EXECUTE) flags |= VPROT_EXEC;
if (sec[i].Characteristics & IMAGE_SCN_MEM_READ) flags |= VPROT_READ; if (sec[i].Characteristics & IMAGE_SCN_MEM_READ) flags |= VPROT_READ;
if (sec[i].Characteristics & IMAGE_SCN_MEM_WRITE) flags |= VPROT_WRITE; if (sec[i].Characteristics & IMAGE_SCN_MEM_WRITE) flags |= VPROT_WRITE;
set_page_vprot( (char *)view->base + sec[i].VirtualAddress, sec[i].Misc.VirtualSize, flags ); set_page_vprot( (char *)base + sec[i].VirtualAddress, sec[i].Misc.VirtualSize, flags );
} }
}
server_leave_uninterrupted_section( &csVirtual, &sigset );
return status; return status;
} }