* PURPOSE: Implementing anonymous memory.
* PROGRAMMER: David Welch
*/
-
+
/* INCLUDE *****************************************************************/
#include <ddk/ntddk.h>
if (PhysicalAddress.QuadPart == 0)
{
- KeBugCheck(0);
+ KEBUGCHECK(0);
}
/*
PageOp->Status = STATUS_UNSUCCESSFUL;
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
MmReleasePageOp(PageOp);
- return(STATUS_UNSUCCESSFUL);
+ return(STATUS_PAGEFILE_QUOTA);
}
}
Region = MmFindRegion(MemoryArea->BaseAddress,
&MemoryArea->Data.VirtualMemoryData.RegionListHead,
Address, NULL);
- if (Region->Type == MEM_RESERVE)
+ if (Region->Type == MEM_RESERVE || Region->Protect == PAGE_NOACCESS)
{
- return(STATUS_UNSUCCESSFUL);
+ return(STATUS_ACCESS_VIOLATION);
}
/*
if (PageOp == NULL)
{
DPRINT1("MmGetPageOp failed");
- KeBugCheck(0);
+ KEBUGCHECK(0);
}
/*
if (Status != STATUS_SUCCESS)
{
DPRINT1("Failed to wait for page op\n");
- KeBugCheck(0);
+ KEBUGCHECK(0);
}
if (PageOp->Status == STATUS_PENDING)
{
DPRINT1("Woke for page op before completion\n");
- KeBugCheck(0);
+ KEBUGCHECK(0);
}
/*
* If this wasn't a pagein then we need to restart the handling
if (!NT_SUCCESS(Status))
{
DPRINT1("MmRequestPageMemoryConsumer failed, status = %x\n", Status);
- KeBugCheck(0);
+ KEBUGCHECK(0);
}
/*
Status = MmReadFromSwapPage(SwapEntry, Mdl);
if (!NT_SUCCESS(Status))
{
- KeBugCheck(0);
+ KEBUGCHECK(0);
}
MmSetSavedSwapEntryPage(Page, SwapEntry);
}
*/
Status = MmCreateVirtualMapping(MemoryArea->Process,
(PVOID)PAGE_ROUND_DOWN(Address),
- MemoryArea->Attributes,
+ Region->Protect,
Page,
FALSE);
while (Status == STATUS_NO_MEMORY)
MmUnlockAddressSpace(AddressSpace);
Status = MmCreateVirtualMapping(MemoryArea->Process,
Address,
- MemoryArea->Attributes,
+ Region->Protect,
Page,
TRUE);
MmLockAddressSpace(AddressSpace);
if (!NT_SUCCESS(Status))
{
DPRINT1("MmCreateVirtualMapping failed, not out of memory\n");
- KeBugCheck(0);
+ KEBUGCHECK(0);
return(Status);
}
}
}
+/*
+ * @implemented
+ */
NTSTATUS STDCALL
NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
IN OUT PVOID* UBaseAddress,
RegionSize,
Protect,
&MemoryArea,
- PBaseAddress != 0);
-
+ PBaseAddress != 0,
+ (AllocationType & MEM_TOP_DOWN));
if (!NT_SUCCESS(Status))
{
MmUnlockAddressSpace(AddressSpace);
if (Status != STATUS_SUCCESS)
{
DPRINT1("Failed to wait for page op\n");
- KeBugCheck(0);
+ KEBUGCHECK(0);
}
MmLockAddressSpace(&Process->AddressSpace);
MmReleasePageOp(PageOp);
(PVOID)Process);
}
+/*
+ * @unimplemented
+ */
NTSTATUS STDCALL
NtFreeVirtualMemory(IN HANDLE ProcessHandle,
IN PVOID* PBaseAddress,