VirtualProtect
VirtualProtect is a Windows API function that changes the protection on a region of virtual memory in the calling process. It is declared in Kernel32.dll. The function takes a pointer to the region's starting address (lpAddress), the size of the region in bytes (dwSize), a flag specifying the requested page protection (flNewProtect), and a pointer to a variable that receives the previous protection attributes (oldProtect). The protection flags can specify read, write, execute permissions, or no access, such as PAGE_READONLY, PAGE_READWRITE, PAGE_EXECUTE, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE, or PAGE_NOACCESS; there are also other attributes for guard pages or caching options depending on the platform.
On success, VirtualProtect changes the protection for all memory pages that intersect the specified region. The
It is also available as VirtualProtectEx to modify memory in another process's address space, requiring appropriate