Skip to content

Commit

Permalink
kernelbase: Don't use WRITECOPY protection on anonymous mappings.
Browse files Browse the repository at this point in the history
(cherry picked from commit 2ac86fb)

CW-Bug-Id: #23951
  • Loading branch information
julliard authored and Paul Gofman committed Jun 21, 2024
1 parent 9d4635d commit 25891ee
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dlls/kernelbase/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH WriteProcessMemory( HANDLE process, void *addr, co
SIZE_T size, SIZE_T *bytes_written )
{
CROSS_PROCESS_WORK_LIST *list = open_cross_process_connection( process );
DWORD old_prot, prot = PAGE_TARGETS_NO_UPDATE | PAGE_ENCLAVE_NO_CHANGE | PAGE_EXECUTE_WRITECOPY;
DWORD old_prot, prot = PAGE_TARGETS_NO_UPDATE | PAGE_ENCLAVE_NO_CHANGE;
MEMORY_BASIC_INFORMATION info;
void *base_addr;
SIZE_T region_size;
Expand Down Expand Up @@ -634,6 +634,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH WriteProcessMemory( HANDLE process, void *addr, co
base_addr = ROUND_ADDR( addr );
region_size = ROUND_SIZE( addr, size );
region_size = min( region_size, (char *)info.BaseAddress + info.RegionSize - (char *)base_addr );
prot |= (info.Type == MEM_PRIVATE) ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_WRITECOPY;

send_cross_process_notification( list, CrossProcessPreVirtualProtect,
base_addr, region_size, 1, prot );
Expand Down

0 comments on commit 25891ee

Please sign in to comment.