mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 02:15:47 +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
|
* AllocationType = Indicates the type of virtual memory you like to
|
||||||
* allocated, can be a combination of MEM_COMMIT,
|
* allocated, can be a combination of MEM_COMMIT,
|
||||||
* MEM_RESERVE, MEM_RESET, MEM_TOP_DOWN.
|
* MEM_RESERVE, MEM_RESET, MEM_TOP_DOWN.
|
||||||
* Protect = Indicates the protection type of the pages allocated, can be
|
* Protect = Indicates the protection type of the pages allocated.
|
||||||
* a combination of PAGE_READONLY, PAGE_READWRITE,
|
|
||||||
* PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE, PAGE_GUARD,
|
|
||||||
* PAGE_NOACCESS
|
|
||||||
* RETURNS: Status
|
* RETURNS: Status
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
@ -567,6 +564,7 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
ULONG RegionSize;
|
ULONG RegionSize;
|
||||||
PVOID PBaseAddress;
|
PVOID PBaseAddress;
|
||||||
ULONG PRegionSize;
|
ULONG PRegionSize;
|
||||||
|
ULONG MemProtection;
|
||||||
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
||||||
KPROCESSOR_MODE PreviousMode;
|
KPROCESSOR_MODE PreviousMode;
|
||||||
|
|
||||||
|
@ -578,7 +576,15 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
Protect);
|
Protect);
|
||||||
|
|
||||||
/* Check for valid protection flags */
|
/* 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");
|
DPRINT1("Invalid page protection\n");
|
||||||
return STATUS_INVALID_PAGE_PROTECTION;
|
return STATUS_INVALID_PAGE_PROTECTION;
|
||||||
|
|
|
@ -844,11 +844,26 @@ NtProtectVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
{
|
{
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
ULONG OldAccessProtection;
|
ULONG OldAccessProtection;
|
||||||
|
ULONG Protection;
|
||||||
PVOID BaseAddress = NULL;
|
PVOID BaseAddress = NULL;
|
||||||
SIZE_T NumberOfBytesToProtect = 0;
|
SIZE_T NumberOfBytesToProtect = 0;
|
||||||
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
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 */
|
/* Check if we came from user mode */
|
||||||
if (PreviousMode != KernelMode)
|
if (PreviousMode != KernelMode)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue