&Size,
MEM_RESERVE,
PAGE_NOACCESS);
- ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
ok(BaseAddress == UlongToPtr(0x50000000), "Got back wrong base address: %p", BaseAddress);
ok(Size == 0x3000, "Got back wrong size: 0x%Ix", Size);
&Size,
MEM_RESERVE,
PAGE_NOACCESS);
- ok(!NT_SUCCESS(Status), "NtAllocateVirtualMemory should fail!\n");
+ ok_ntstatus(Status, STATUS_CONFLICTING_ADDRESSES);
/* Commit memory */
BaseAddress = UlongToPtr(0x50002000);
&Size,
MEM_COMMIT,
PAGE_NOACCESS);
- ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
ok(BaseAddress == UlongToPtr(0x50002000), "Got back wrong base address: %p", BaseAddress);
ok(Size == 0x1000, "Got back wrong size: 0x%Ix", Size);
- /* Commit memory */
+ /* Commit the same address again with a different protection */
+ BaseAddress = UlongToPtr(0x50002000);
+ Size = 0x1000;
+ Status = NtAllocateVirtualMemory(NtCurrentProcess(),
+ &BaseAddress,
+ 0,
+ &Size,
+ MEM_COMMIT,
+ PAGE_READWRITE);
+ ok_ntstatus(Status, STATUS_SUCCESS);
+ ok(BaseAddress == UlongToPtr(0x50002000), "Got back wrong base address: %p", BaseAddress);
+ ok(Size == 0x1000, "Got back wrong size: 0x%Ix", Size);
+
+ /* Commit memory at a too high address */
BaseAddress = UlongToPtr(0x50003000);
Size = 0x1000;
Status = NtAllocateVirtualMemory(NtCurrentProcess(),
&Size,
MEM_COMMIT,
PAGE_NOACCESS);
- ok(!NT_SUCCESS(Status), "NtAllocateVirtualMemory should fail!\n");
+ ok_ntstatus(Status, STATUS_CONFLICTING_ADDRESSES);
+
+ /* Decommit the memory, even those pages that were not committed */
+ BaseAddress = UlongToPtr(0x50000000);
+ Size = 0x3000;
+ Status = NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &Size, MEM_DECOMMIT);
+ ok_ntstatus(Status, STATUS_SUCCESS);
/* Try to release memory in a different 64k region */
BaseAddress = UlongToPtr(0x50010000);
Size = 0x1000;
Status = NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &Size, MEM_RELEASE);
- ok(!NT_SUCCESS(Status), "NtFreeVirtualMemory should fail!\n");
+ ok_ntstatus(Status, STATUS_MEMORY_NOT_ALLOCATED);
/* Release the memory in the same 64k region at a different address */
BaseAddress = UlongToPtr(0x50008000);
Size = 0x1000;
Status = NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &Size, MEM_RELEASE);
- ok(!NT_SUCCESS(Status), "NtFreeVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_MEMORY_NOT_ALLOCATED);
/* Release the memory at the correct address but with wrong size */
BaseAddress = UlongToPtr(0x50000000);
Size = 0x4000;
Status = NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &Size, MEM_RELEASE);
- ok(!NT_SUCCESS(Status), "NtFreeVirtualMemory should fail!\n");
+ ok_ntstatus(Status, STATUS_UNABLE_TO_FREE_VM);
/* Release the memory */
BaseAddress = UlongToPtr(0x50000000);
Size = 0x3000;
Status = NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &Size, MEM_RELEASE);
- ok(NT_SUCCESS(Status), "NtFreeVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
/* Reserve and commit at once */
BaseAddress = UlongToPtr(0x50004080);
&Size,
MEM_RESERVE | MEM_COMMIT,
PAGE_READWRITE);
- ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
ok(BaseAddress == UlongToPtr(0x50000000), "Got back wrong base address: %p", BaseAddress);
ok(Size == 0x6000, "Got back wrong size: 0x%Ix", Size);
/* Release the memory */
Status = NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &Size, MEM_RELEASE);
- ok(NT_SUCCESS(Status), "NtFreeVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
}
&Size,
MEM_RESERVE,
PAGE_NOACCESS);
- ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
if (!NT_SUCCESS(Status))
return;
&Size,
MEM_RESERVE,
PAGE_NOACCESS);
- ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
if (!NT_SUCCESS(Status))
return;
BaseAddress = UlongToPtr(0x50000000);
Size = 0x30000;
Status = NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &Size, MEM_RELEASE);
- ok(!NT_SUCCESS(Status), "NtFreeVirtualMemory should fail!\n");
+ ok_ntstatus(Status, STATUS_UNABLE_TO_FREE_VM);
/* Reserve the part in the middle */
BaseAddress = UlongToPtr(0x50010000);
&Size,
MEM_RESERVE,
PAGE_NOACCESS);
- ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
/* Try to commit memory covering 2 allocations */
BaseAddress = UlongToPtr(0x50004000);
&Size,
MEM_COMMIT,
PAGE_NOACCESS);
- ok(!NT_SUCCESS(Status), "NtAllocateVirtualMemory should fail!\n");
+ ok_ntstatus(Status, STATUS_CONFLICTING_ADDRESSES);
/* Commit a page */
BaseAddress = UlongToPtr(0x50000000);
&Size,
MEM_COMMIT,
PAGE_READWRITE);
- ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
/* Commit another page */
BaseAddress = UlongToPtr(0x50002000);
&Size,
MEM_COMMIT,
PAGE_NOACCESS);
- ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
_SEH2_TRY
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
- ok(Status = STATUS_ACCESS_VIOLATION, "Should get an exception!\n");
+ ok_ntstatus(Status, STATUS_ACCESS_VIOLATION);
/* Allocate 3 pages, on top of the previous 2 */
BaseAddress = UlongToPtr(0x50000000);
&Size,
MEM_COMMIT,
PAGE_READONLY);
- ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
_SEH2_TRY
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
- ok(Status = STATUS_ACCESS_VIOLATION, "Should get an exception!\n");
+ ok_ntstatus(Status, STATUS_ACCESS_VIOLATION);
/* Try to free the whole region at once */
BaseAddress = UlongToPtr(0x50000000);
Size = 0x30000;
Status = NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &Size, MEM_RELEASE);
- ok(!NT_SUCCESS(Status), "NtFreeVirtualMemory should fail!\n");
+ ok_ntstatus(Status, STATUS_UNABLE_TO_FREE_VM);
BaseAddress = UlongToPtr(0x50000000);
Size = 0x10000;
Status = NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &Size, MEM_RELEASE);
- ok(NT_SUCCESS(Status), "NtFreeVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
BaseAddress = UlongToPtr(0x50010000);
Size = 0x10000;
Status = NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &Size, MEM_RELEASE);
- ok(NT_SUCCESS(Status), "NtFreeVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
BaseAddress = UlongToPtr(0x50020000);
Size = 0x10000;
Status = NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &Size, MEM_RELEASE);
- ok(NT_SUCCESS(Status), "NtFreeVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
/* Reserve 3 full 64k region */
BaseAddress = UlongToPtr(0x50000000);
&Size,
MEM_RESERVE,
PAGE_NOACCESS);
- ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
if (!NT_SUCCESS(Status))
return;
BaseAddress = UlongToPtr(0x50010000);
Size = 0x10000;
Status = NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &Size, MEM_RELEASE);
- ok(NT_SUCCESS(Status), "NtFreeVirtualMemory failed!\n");
+ ok_ntstatus(Status, STATUS_SUCCESS);
}
PVOID Mem1, Mem2;
SIZE_T Size1, Size2;
ULONG i;
+ NTSTATUS Status;
CheckAlignment();
CheckAdjacentVADs();
+ /* Reserve memory below 0x10000 */
+ Mem1 = UlongToPtr(0xf000);
+ Size1 = 0x1000;
+ Status = NtAllocateVirtualMemory(NtCurrentProcess(),
+ &Mem1,
+ 0,
+ &Size1,
+ MEM_RESERVE,
+ PAGE_READWRITE);
+ ok_ntstatus(Status, STATUS_INVALID_PARAMETER_2);
+
+ /* Reserve memory at 0x10000 */
+ Mem1 = UlongToPtr(0x10000);
+ Size1 = 0x1000;
+ Status = NtAllocateVirtualMemory(NtCurrentProcess(),
+ &Mem1,
+ 0,
+ &Size1,
+ MEM_RESERVE,
+ PAGE_READWRITE);
+ ok_ntstatus(Status, STATUS_CONFLICTING_ADDRESSES);
+
Size1 = 32;
Mem1 = Allocate(Size1);
AccessMemory1(Mem1, Size1);