NtProtectVirtualMemory will fail for memory mapped views with valid arguments in these scenarios:
The view is mapped with the undocumented allocation type:SEC_NO_CHANGE(0x00400000).
The desired protection is incompatible with the view's initial protection. Example: trying to set the protection for a view with an initial protection ofPAGE_READONLYtoPAGE_EXECUTE_READWRITE.
The view and/or backing section are created using large pages (unconfirmed / not currently supported).
A process can utilize these cases as an anti-patching mechanism. A demo of this can be foundhere.
This plugin defeats this technique by remapping the view with the desired protection.