Commit 1f28e92e authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ntdll: Scan pages only once in get_basic_memory_info().

parent b7fafabc
......@@ -2060,19 +2060,19 @@ done:
/***********************************************************************
* get_committed_size
*
* Get the size of the committed range starting at base.
* Get the size of the committed range with equal masked vprot bytes starting at base.
* Also return the protections for the first page.
*/
static SIZE_T get_committed_size( struct file_view *view, void *base, BYTE *vprot )
static SIZE_T get_committed_size( struct file_view *view, void *base, BYTE *vprot, BYTE vprot_mask )
{
SIZE_T offset;
SIZE_T offset, size;
base = ROUND_ADDR( base, page_mask );
offset = (char *)base - (char *)view->base;
if (view->protect & SEC_RESERVE)
{
SIZE_T ret = 0;
size = 0;
*vprot = get_page_vprot( base );
......@@ -2082,19 +2082,21 @@ static SIZE_T get_committed_size( struct file_view *view, void *base, BYTE *vpro
req->offset = offset;
if (!wine_server_call( req ))
{
ret = reply->size;
size = reply->size;
if (reply->committed)
{
*vprot |= VPROT_COMMITTED;
set_page_vprot_bits( base, ret, VPROT_COMMITTED, 0 );
set_page_vprot_bits( base, size, VPROT_COMMITTED, 0 );
}
}
}
SERVER_END_REQ;
return ret;
if (!size || !(vprot_mask & ~VPROT_COMMITTED)) return size;
}
else size = view->size - offset;
return get_vprot_range_size( base, view->size - offset, VPROT_COMMITTED, vprot );
return get_vprot_range_size( base, size, vprot_mask, vprot );
}
......@@ -4045,7 +4047,7 @@ NTSTATUS WINAPI NtProtectVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T
if ((view = find_view( base, size )))
{
/* Make sure all the pages are committed */
if (get_committed_size( view, base, &vprot ) >= size && (vprot & VPROT_COMMITTED))
if (get_committed_size( view, base, &vprot, VPROT_COMMITTED ) >= size && (vprot & VPROT_COMMITTED))
{
old = get_win32_prot( vprot, view->protect );
status = set_protection( view, base, size, new_prot );
......@@ -4216,16 +4218,14 @@ static NTSTATUS get_basic_memory_info( HANDLE process, LPCVOID addr,
else
{
BYTE vprot;
SIZE_T range_size = get_committed_size( view, base, &vprot );
info->RegionSize = get_committed_size( view, base, &vprot, ~VPROT_WRITEWATCH );
info->State = (vprot & VPROT_COMMITTED) ? MEM_COMMIT : MEM_RESERVE;
info->Protect = (vprot & VPROT_COMMITTED) ? get_win32_prot( vprot, view->protect ) : 0;
info->AllocationProtect = get_win32_prot( view->protect, view->protect );
if (view->protect & SEC_IMAGE) info->Type = MEM_IMAGE;
else if (view->protect & (SEC_FILE | SEC_RESERVE | SEC_COMMIT)) info->Type = MEM_MAPPED;
else info->Type = MEM_PRIVATE;
info->RegionSize = get_vprot_range_size( base, range_size, ~VPROT_WRITEWATCH, &vprot );
}
server_leave_uninterrupted_section( &virtual_mutex, &sigset );
......@@ -4271,8 +4271,8 @@ static NTSTATUS get_working_set_ex( HANDLE process, LPCVOID addr,
}
if ((view = find_view( p->VirtualAddress, 0 )) &&
get_committed_size( view, p->VirtualAddress, &vprot ) &&
(vprot & VPROT_COMMITTED))
get_committed_size( view, p->VirtualAddress, &vprot, VPROT_COMMITTED ) &&
(vprot & VPROT_COMMITTED))
{
p->VirtualAttributes.Valid = !(vprot & VPROT_GUARD) && (vprot & 0x0f) && (pagemap >> 63);
p->VirtualAttributes.Shared = !is_view_valloc( view ) && ((pagemap >> 61) & 1);
......
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