Commit cd8f0fba authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ntdll: Factor out unmap_view_of_section() function.

parent 03096546
...@@ -5219,11 +5219,13 @@ NTSTATUS WINAPI NtMapViewOfSectionEx( HANDLE handle, HANDLE process, PVOID *addr ...@@ -5219,11 +5219,13 @@ NTSTATUS WINAPI NtMapViewOfSectionEx( HANDLE handle, HANDLE process, PVOID *addr
alloc_type, protect, machine ); alloc_type, protect, machine );
} }
/*********************************************************************** /***********************************************************************
* NtUnmapViewOfSection (NTDLL.@) * unmap_view_of_section
* ZwUnmapViewOfSection (NTDLL.@) *
* NtUnmapViewOfSection[Ex] implementation.
*/ */
NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr ) static NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr )
{ {
struct file_view *view; struct file_view *view;
unsigned int status = STATUS_NOT_MAPPED_VIEW; unsigned int status = STATUS_NOT_MAPPED_VIEW;
...@@ -5244,42 +5246,52 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr ) ...@@ -5244,42 +5246,52 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
} }
server_enter_uninterrupted_section( &virtual_mutex, &sigset ); server_enter_uninterrupted_section( &virtual_mutex, &sigset );
if ((view = find_view( addr, 0 )) && !is_view_valloc( view )) if (!(view = find_view( addr, 0 )) || is_view_valloc( view )) goto done;
if (view->protect & VPROT_SYSTEM)
{ {
if (view->protect & VPROT_SYSTEM) struct builtin_module *builtin;
{
struct builtin_module *builtin;
LIST_FOR_EACH_ENTRY( builtin, &builtin_modules, struct builtin_module, entry ) LIST_FOR_EACH_ENTRY( builtin, &builtin_modules, struct builtin_module, entry )
{
if (builtin->module != view->base) continue;
if (builtin->refcount > 1)
{ {
if (builtin->module != view->base) continue; TRACE( "not freeing in-use builtin %p\n", view->base );
if (builtin->refcount > 1) builtin->refcount--;
{ server_leave_uninterrupted_section( &virtual_mutex, &sigset );
TRACE( "not freeing in-use builtin %p\n", view->base ); return STATUS_SUCCESS;
builtin->refcount--;
server_leave_uninterrupted_section( &virtual_mutex, &sigset );
return STATUS_SUCCESS;
}
} }
} }
}
SERVER_START_REQ( unmap_view ) SERVER_START_REQ( unmap_view )
{ {
req->base = wine_server_client_ptr( view->base ); req->base = wine_server_client_ptr( view->base );
status = wine_server_call( req ); status = wine_server_call( req );
}
SERVER_END_REQ;
if (!status)
{
if (view->protect & SEC_IMAGE) release_builtin_module( view->base );
delete_view( view );
}
else FIXME( "failed to unmap %p %x\n", view->base, status );
} }
SERVER_END_REQ;
if (!status)
{
if (view->protect & SEC_IMAGE) release_builtin_module( view->base );
delete_view( view );
}
else FIXME( "failed to unmap %p %x\n", view->base, status );
done:
server_leave_uninterrupted_section( &virtual_mutex, &sigset ); server_leave_uninterrupted_section( &virtual_mutex, &sigset );
return status; return status;
} }
/***********************************************************************
* NtUnmapViewOfSection (NTDLL.@)
* ZwUnmapViewOfSection (NTDLL.@)
*/
NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
{
return unmap_view_of_section( process, addr );
}
/*********************************************************************** /***********************************************************************
* NtUnmapViewOfSectionEx (NTDLL.@) * NtUnmapViewOfSectionEx (NTDLL.@)
* ZwUnmapViewOfSectionEx (NTDLL.@) * ZwUnmapViewOfSectionEx (NTDLL.@)
...@@ -5287,7 +5299,7 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr ) ...@@ -5287,7 +5299,7 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
NTSTATUS WINAPI NtUnmapViewOfSectionEx( HANDLE process, PVOID addr, ULONG flags ) NTSTATUS WINAPI NtUnmapViewOfSectionEx( HANDLE process, PVOID addr, ULONG flags )
{ {
if (flags) FIXME("Ignoring flags %#x.\n", (int)flags); if (flags) FIXME("Ignoring flags %#x.\n", (int)flags);
return NtUnmapViewOfSection( process, addr ); return unmap_view_of_section( process, addr );
} }
/****************************************************************************** /******************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment