/*
The DxgkDdiCreateAllocation function creates allocations of system or video memory.
DX调用DxgkDdiGetStandardAllocationDriverData后,接着调用DxgkDdiCreateAllocation实际分配内存
*/
NTSTATUS APIENTRY DxgkDdiCreateAllocation(
CONST HANDLE hAdapter,
DXGKARG_CREATEALLOCATION* pCreateAllocation)
{
/* DxgkDdiCreateAllocation should be made pageable. */
PAGED_CODE();
dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
NTSTATUS Status = STATUS_SUCCESS;
for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i)
{
Status = vboxWddmCreateAllocation((PDEVICE_EXTENSION)hAdapter, &pCreateAllocation->pAllocationInfo[i]);
Assert(Status == STATUS_SUCCESS);
if (Status != STATUS_SUCCESS)
{
drprintf((__FUNCTION__ ": ERROR: vboxWddmCreateAllocation error (0x%x)\n", Status));
/* note: i-th allocation is expected to be cleared in a fail handling code above */
for (UINT j = 0; j < i; ++j)
{
vboxWddmDestroyAllocation((PDEVICE_EXTENSION)hAdapter, (PVBOXWDDM_ALLOCATION)pCreateAllocation->pAllocationInfo[j].hAllocation);
}
}
}
dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
return Status;
}