简体   繁体   中英

How to create copy-write protected pages in a module?

I am trying to make different pages protected and not protected, for example there are 10 pages in my module and I just want to make 5 pages protected (copy-on-write), other won't. How can I do that?

Edit: I am using Windows 10 x64.

In your case you'd have to look at the Windows API: VirtualProtect . You can find the function prototype in the provided link.

You want to set the correct protection on your pages using the PAGE_WRITECOPY flag:

auto virtualAddress {reinterpret_cast<PVOID>(desiredAddress)};
SIZE_T size {0x1000}; // not guaranteed to be 0x1000
DWORD oldProtection {};
const auto newProtection {PAGE_WRITECOPY};
const auto successful = VirtualProtect(virtualAddress, size, newProtection, &oldProtection) != 0;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM