mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
- NtAllocateVirtualMemory, NtProtectVirtualMemory: Page Protection cannot be any combination of Memory Protection Constants, see MSDN.
Add checks to handle non compatible combinations are fail. Fixes 6 more kernel32_winetest for virtual memory. svn path=/trunk/; revision=40873
This commit is contained in:
parent
fc81096af5
commit
bf49aa19f7
2 changed files with 26 additions and 5 deletions
|
@ -550,10 +550,7 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
|||
* AllocationType = Indicates the type of virtual memory you like to
|
||||
* allocated, can be a combination of MEM_COMMIT,
|
||||
* MEM_RESERVE, MEM_RESET, MEM_TOP_DOWN.
|
||||
* Protect = Indicates the protection type of the pages allocated, can be
|
||||
* a combination of PAGE_READONLY, PAGE_READWRITE,
|
||||
* PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE, PAGE_GUARD,
|
||||
* PAGE_NOACCESS
|
||||
* Protect = Indicates the protection type of the pages allocated.
|
||||
* RETURNS: Status
|
||||
*/
|
||||
{
|
||||
|
@ -567,6 +564,7 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
|||
ULONG RegionSize;
|
||||
PVOID PBaseAddress;
|
||||
ULONG PRegionSize;
|
||||
ULONG MemProtection;
|
||||
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
||||
KPROCESSOR_MODE PreviousMode;
|
||||
|
||||
|
@ -578,7 +576,15 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
|||
Protect);
|
||||
|
||||
/* Check for valid protection flags */
|
||||
if (!Protect || Protect & ~PAGE_FLAGS_VALID_FROM_USER_MODE)
|
||||
MemProtection = Protect & ~(PAGE_GUARD|PAGE_NOCACHE);
|
||||
if (MemProtection != PAGE_NOACCESS &&
|
||||
MemProtection != PAGE_READONLY &&
|
||||
MemProtection != PAGE_READWRITE &&
|
||||
MemProtection != PAGE_WRITECOPY &&
|
||||
MemProtection != PAGE_EXECUTE &&
|
||||
MemProtection != PAGE_EXECUTE_READ &&
|
||||
MemProtection != PAGE_EXECUTE_READWRITE &&
|
||||
MemProtection != PAGE_EXECUTE_WRITECOPY)
|
||||
{
|
||||
DPRINT1("Invalid page protection\n");
|
||||
return STATUS_INVALID_PAGE_PROTECTION;
|
||||
|
|
|
@ -844,11 +844,26 @@ NtProtectVirtualMemory(IN HANDLE ProcessHandle,
|
|||
{
|
||||
PEPROCESS Process;
|
||||
ULONG OldAccessProtection;
|
||||
ULONG Protection;
|
||||
PVOID BaseAddress = NULL;
|
||||
SIZE_T NumberOfBytesToProtect = 0;
|
||||
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
/* Check for valid protection flags */
|
||||
Protection = NewAccessProtection & ~(PAGE_GUARD|PAGE_NOCACHE);
|
||||
if (Protection != PAGE_NOACCESS &&
|
||||
Protection != PAGE_READONLY &&
|
||||
Protection != PAGE_READWRITE &&
|
||||
Protection != PAGE_WRITECOPY &&
|
||||
Protection != PAGE_EXECUTE &&
|
||||
Protection != PAGE_EXECUTE_READ &&
|
||||
Protection != PAGE_EXECUTE_READWRITE &&
|
||||
Protection != PAGE_EXECUTE_WRITECOPY)
|
||||
{
|
||||
return STATUS_INVALID_PAGE_PROTECTION;
|
||||
}
|
||||
|
||||
/* Check if we came from user mode */
|
||||
if (PreviousMode != KernelMode)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue