how to write memory to a a readonly page?

  • Thread starter Thread starter Frankooo
  • Start date Start date
F

Frankooo

Guest
i tried to use ZwProtectVirtualMemory like this


bool WriteToReadOnlyMemory(void* address, void* buffer, size_t size) {

ULONG old_protection = 0;
SIZE_T tmpSize = 0;
NTSTATUS status = STATUS_SUCCESS;

status = ZwProtectVirtualMemory(ZwCurrentProcess(), &address, &tmpSize, PAGE_READWRITE, &old_protection);
if (!NT_SUCCESS(status)) {
DbgPrintEx(0, 0, "couldn't protect memory status : %p \n", status);
return false;
}
else
{
WriteMemory(address, buffer, size);
DbgPrintEx(0, 0, "memory protected !\n");
return true;
}
}
but it returned STATUS_INVALID_PARAMETER_2 idk if i did something wrong but if anyone may explain to me why its doing that it will be very appreciated .

Continue reading...
 
Back
Top