本文整理汇总了C++中RTMemAllocZ函数的典型用法代码示例。如果您正苦于以下问题:C++ RTMemAllocZ函数的具体用法?C++ RTMemAllocZ怎么用?C++ RTMemAllocZ使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTMemAllocZ函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addDeviceToList
/**
* Creates a new USB device and adds it to the list.
*
* @returns VBox status code.
* @param pDev Pointer to the USB/IP exported device structure to take
* the information for the new device from.
*/
int USBProxyBackendUsbIp::addDeviceToList(PUsbIpExportedDevice pDev)
{
PUSBDEVICE pNew = (PUSBDEVICE)RTMemAllocZ(sizeof(USBDEVICE));
if (!pNew)
return VERR_NO_MEMORY;
pNew->pszManufacturer = RTStrDup("");
pNew->pszProduct = RTStrDup("");
pNew->pszSerialNumber = NULL;
pNew->pszBackend = RTStrDup("usbip");
/* Make sure the Bus id is 0 terminated. */
pDev->szBusId[31] = '\0';
RTStrAPrintf((char **)&pNew->pszAddress, "usbip://%s:%u:%s", m->pszHost, m->uPort, &pDev->szBusId[0]);
pNew->idVendor = pDev->u16VendorId;
pNew->idProduct = pDev->u16ProductId;
pNew->bcdDevice = pDev->u16BcdDevice;
pNew->bDeviceClass = pDev->bDeviceClass;
pNew->bDeviceSubClass = pDev->bDeviceSubClass;
pNew->bDeviceProtocol = pDev->bDeviceProtocol;
pNew->bNumConfigurations = pDev->bNumConfigurations;
pNew->enmState = USBDEVICESTATE_USED_BY_HOST_CAPTURABLE;
pNew->u64SerialHash = 0;
pNew->bBus = (uint8_t)pDev->u32BusNum;
pNew->bPort = (uint8_t)pDev->u32DevNum;
switch (pDev->u32Speed)
{
case USBIP_SPEED_LOW:
pNew->enmSpeed = USBDEVICESPEED_LOW;
pNew->bcdUSB = 1 << 8;
break;
case USBIP_SPEED_FULL:
pNew->enmSpeed = USBDEVICESPEED_FULL;
pNew->bcdUSB = 1 << 8;
break;
case USBIP_SPEED_HIGH:
pNew->enmSpeed = USBDEVICESPEED_HIGH;
pNew->bcdUSB = 2 << 8;
break;
case USBIP_SPEED_WIRELESS:
pNew->enmSpeed = USBDEVICESPEED_VARIABLE;
pNew->bcdUSB = 1 << 8;
break;
case USBIP_SPEED_SUPER:
pNew->enmSpeed = USBDEVICESPEED_SUPER;
pNew->bcdUSB = 3 << 8;
break;
case USBIP_SPEED_UNKNOWN:
default:
pNew->bcdUSB = 1 << 8;
pNew->enmSpeed = USBDEVICESPEED_UNKNOWN;
}
/* link it */
pNew->pNext = NULL;
pNew->pPrev = *m->ppNext;
*m->ppNext = pNew;
m->ppNext = &pNew->pNext;
m->cDevicesCur++;
return VINF_SUCCESS;
}
示例2: NetIfList
int NetIfList(std::list <ComObjPtr<HostNetworkInterface> > &list)
{
int rc = VINF_SUCCESS;
size_t cbNeeded;
char *pBuf, *pNext;
int aiMib[6];
unsigned short u16DefaultIface = 0; /* shut up gcc. */
bool fDefaultIfaceExistent = true;
/* Get the index of the interface associated with default route. */
rc = getDefaultIfaceIndex(&u16DefaultIface, PF_INET);
if (RT_FAILURE(rc))
{
fDefaultIfaceExistent = false;
rc = VINF_SUCCESS;
}
aiMib[0] = CTL_NET;
aiMib[1] = PF_ROUTE;
aiMib[2] = 0;
aiMib[3] = 0; /* address family */
aiMib[4] = NET_RT_IFLIST;
aiMib[5] = 0;
if (sysctl(aiMib, 6, NULL, &cbNeeded, NULL, 0) < 0)
{
Log(("NetIfList: Failed to get estimate for list size (errno=%d).\n", errno));
return RTErrConvertFromErrno(errno);
}
if ((pBuf = (char*)malloc(cbNeeded)) == NULL)
return VERR_NO_MEMORY;
if (sysctl(aiMib, 6, pBuf, &cbNeeded, NULL, 0) < 0)
{
free(pBuf);
Log(("NetIfList: Failed to retrieve interface table (errno=%d).\n", errno));
return RTErrConvertFromErrno(errno);
}
int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
if (sock < 0)
{
free(pBuf);
Log(("NetIfList: socket() -> %d\n", errno));
return RTErrConvertFromErrno(errno);
}
char *pEnd = pBuf + cbNeeded;
for (pNext = pBuf; pNext < pEnd;)
{
struct if_msghdr *pIfMsg = (struct if_msghdr *)pNext;
if (pIfMsg->ifm_type != RTM_IFINFO)
{
Log(("NetIfList: Got message %u while expecting %u.\n",
pIfMsg->ifm_type, RTM_IFINFO));
rc = VERR_INTERNAL_ERROR;
break;
}
struct sockaddr_dl *pSdl = (struct sockaddr_dl *)(pIfMsg + 1);
size_t cbNameLen = pSdl->sdl_nlen + 1;
PNETIFINFO pNew = (PNETIFINFO)RTMemAllocZ(RT_OFFSETOF(NETIFINFO, szName[cbNameLen]));
if (!pNew)
{
rc = VERR_NO_MEMORY;
break;
}
memcpy(pNew->MACAddress.au8, LLADDR(pSdl), sizeof(pNew->MACAddress.au8));
pNew->enmMediumType = NETIF_T_ETHERNET;
Assert(sizeof(pNew->szShortName) >= cbNameLen);
strlcpy(pNew->szShortName, pSdl->sdl_data, cbNameLen);
strlcpy(pNew->szName, pSdl->sdl_data, cbNameLen);
/* Generate UUID from name and MAC address. */
RTUUID uuid;
RTUuidClear(&uuid);
memcpy(&uuid, pNew->szShortName, RT_MIN(cbNameLen, sizeof(uuid)));
uuid.Gen.u8ClockSeqHiAndReserved = (uuid.Gen.u8ClockSeqHiAndReserved & 0x3f) | 0x80;
uuid.Gen.u16TimeHiAndVersion = (uuid.Gen.u16TimeHiAndVersion & 0x0fff) | 0x4000;
memcpy(uuid.Gen.au8Node, pNew->MACAddress.au8, sizeof(uuid.Gen.au8Node));
pNew->Uuid = uuid;
pNext += pIfMsg->ifm_msglen;
while (pNext < pEnd)
{
struct ifa_msghdr *pIfAddrMsg = (struct ifa_msghdr *)pNext;
if (pIfAddrMsg->ifam_type != RTM_NEWADDR)
break;
extractAddressesToNetInfo(pIfAddrMsg->ifam_addrs,
(char *)(pIfAddrMsg + 1),
pIfAddrMsg->ifam_msglen + (char *)pIfAddrMsg,
pNew);
pNext += pIfAddrMsg->ifam_msglen;
}
if (pSdl->sdl_type == IFT_ETHER || pSdl->sdl_type == IFT_L2VLAN)
{
struct ifreq IfReq;
RTStrCopy(IfReq.ifr_name, sizeof(IfReq.ifr_name), pNew->szShortName);
if (ioctl(sock, SIOCGIFFLAGS, &IfReq) < 0)
//.........这里部分代码省略.........
示例3: RTDECL
/**
* Allocate a new symbol structure.
*
* @returns Pointer to a new structure on success, NULL on failure.
*/
RTDECL(PRTDBGSYMBOL) RTDbgSymbolAlloc(void)
{
return (PRTDBGSYMBOL)RTMemAllocZ(sizeof(RTDBGSYMBOL));
}
示例4: rawCreate
/** @copydoc VBOXHDDBACKEND::pfnCreate */
static int rawCreate(const char *pszFilename, uint64_t cbSize,
unsigned uImageFlags, const char *pszComment,
PCVDGEOMETRY pPCHSGeometry, PCVDGEOMETRY pLCHSGeometry,
PCRTUUID pUuid, unsigned uOpenFlags,
unsigned uPercentStart, unsigned uPercentSpan,
PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
PVDINTERFACE pVDIfsOperation, VDTYPE enmType,
void **ppBackendData)
{
LogFlowFunc(("pszFilename=\"%s\" cbSize=%llu uImageFlags=%#x pszComment=\"%s\" pPCHSGeometry=%#p pLCHSGeometry=%#p Uuid=%RTuuid uOpenFlags=%#x uPercentStart=%u uPercentSpan=%u pVDIfsDisk=%#p pVDIfsImage=%#p pVDIfsOperation=%#p enmType=%u ppBackendData=%#p",
pszFilename, cbSize, uImageFlags, pszComment, pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags, uPercentStart, uPercentSpan, pVDIfsDisk, pVDIfsImage, pVDIfsOperation, enmType, ppBackendData));
int rc;
PRAWIMAGE pImage;
PFNVDPROGRESS pfnProgress = NULL;
void *pvUser = NULL;
PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation);
if (pIfProgress)
{
pfnProgress = pIfProgress->pfnProgress;
pvUser = pIfProgress->Core.pvUser;
}
/* Check the VD container type. Yes, hard disk must be allowed, otherwise
* various tools using this backend for hard disk images will fail. */
if (enmType != VDTYPE_HDD && enmType != VDTYPE_DVD && enmType != VDTYPE_FLOPPY)
{
rc = VERR_VD_INVALID_TYPE;
goto out;
}
/* Check open flags. All valid flags are supported. */
if (uOpenFlags & ~VD_OPEN_FLAGS_MASK)
{
rc = VERR_INVALID_PARAMETER;
goto out;
}
/* Check remaining arguments. */
if ( !VALID_PTR(pszFilename)
|| !*pszFilename
|| !VALID_PTR(pPCHSGeometry)
|| !VALID_PTR(pLCHSGeometry))
{
rc = VERR_INVALID_PARAMETER;
goto out;
}
pImage = (PRAWIMAGE)RTMemAllocZ(sizeof(RAWIMAGE));
if (!pImage)
{
rc = VERR_NO_MEMORY;
goto out;
}
pImage->pszFilename = pszFilename;
pImage->pStorage = NULL;
pImage->pVDIfsDisk = pVDIfsDisk;
pImage->pVDIfsImage = pVDIfsImage;
rc = rawCreateImage(pImage, cbSize, uImageFlags, pszComment,
pPCHSGeometry, pLCHSGeometry, uOpenFlags,
pfnProgress, pvUser, uPercentStart, uPercentSpan);
if (RT_SUCCESS(rc))
{
/* So far the image is opened in read/write mode. Make sure the
* image is opened in read-only mode if the caller requested that. */
if (uOpenFlags & VD_OPEN_FLAGS_READONLY)
{
rawFreeImage(pImage, false);
rc = rawOpenImage(pImage, uOpenFlags);
if (RT_FAILURE(rc))
{
RTMemFree(pImage);
goto out;
}
}
*ppBackendData = pImage;
}
else
RTMemFree(pImage);
out:
LogFlowFunc(("returns %Rrc (pBackendData=%#p)\n", rc, *ppBackendData));
return rc;
}
示例5: solarisWalkDeviceNode
static int solarisWalkDeviceNode(di_node_t Node, void *pvArg)
{
PUSBDEVICELIST pList = (PUSBDEVICELIST)pvArg;
AssertPtrReturn(pList, DI_WALK_TERMINATE);
/*
* Check if it's a USB device in the first place.
*/
bool fUSBDevice = false;
char *pszCompatNames = NULL;
int cCompatNames = di_compatible_names(Node, &pszCompatNames);
for (int i = 0; i < cCompatNames; i++, pszCompatNames += strlen(pszCompatNames) + 1)
if (!strncmp(pszCompatNames, RT_STR_TUPLE("usb")))
{
fUSBDevice = true;
break;
}
if (!fUSBDevice)
return DI_WALK_CONTINUE;
/*
* Check if it's a device node or interface.
*/
int *pInt = NULL;
char *pStr = NULL;
int rc = DI_WALK_CONTINUE;
if (di_prop_lookup_ints(DDI_DEV_T_ANY, Node, "interface", &pInt) < 0)
{
/* It's a device node. */
char *pszDevicePath = di_devfs_path(Node);
PUSBDEVICE pCur = (PUSBDEVICE)RTMemAllocZ(sizeof(*pCur));
if (!pCur)
{
LogRel(("USBService: failed to allocate %d bytes for PUSBDEVICE.\n", sizeof(*pCur)));
return DI_WALK_TERMINATE;
}
bool fValidDevice = false;
do
{
AssertBreak(pszDevicePath);
char *pszDriverName = di_driver_name(Node);
/*
* Skip hubs
*/
if ( pszDriverName
&& !strcmp(pszDriverName, "hubd"))
{
break;
}
/*
* Mandatory.
* snv_85 and above have usb-dev-descriptor node properties, but older one's do not.
* So if we cannot obtain the entire device descriptor, we try falling back to the
* individual properties (those must not fail, if it does we drop the device).
*/
uchar_t *pDevData = NULL;
int cbProp = di_prop_lookup_bytes(DDI_DEV_T_ANY, Node, "usb-dev-descriptor", &pDevData);
if ( cbProp > 0
&& pDevData)
{
usb_dev_descr_t *pDeviceDescriptor = (usb_dev_descr_t *)pDevData;
pCur->bDeviceClass = pDeviceDescriptor->bDeviceClass;
pCur->bDeviceSubClass = pDeviceDescriptor->bDeviceSubClass;
pCur->bDeviceProtocol = pDeviceDescriptor->bDeviceProtocol;
pCur->idVendor = pDeviceDescriptor->idVendor;
pCur->idProduct = pDeviceDescriptor->idProduct;
pCur->bcdDevice = pDeviceDescriptor->bcdDevice;
pCur->bcdUSB = pDeviceDescriptor->bcdUSB;
pCur->bNumConfigurations = pDeviceDescriptor->bNumConfigurations;
pCur->fPartialDescriptor = false;
}
else
{
AssertBreak(di_prop_lookup_ints(DDI_DEV_T_ANY, Node, "usb-vendor-id", &pInt) > 0);
pCur->idVendor = (uint16_t)*pInt;
AssertBreak(di_prop_lookup_ints(DDI_DEV_T_ANY, Node, "usb-product-id", &pInt) > 0);
pCur->idProduct = (uint16_t)*pInt;
AssertBreak(di_prop_lookup_ints(DDI_DEV_T_ANY, Node, "usb-revision-id", &pInt) > 0);
pCur->bcdDevice = (uint16_t)*pInt;
AssertBreak(di_prop_lookup_ints(DDI_DEV_T_ANY, Node, "usb-release", &pInt) > 0);
pCur->bcdUSB = (uint16_t)*pInt;
pCur->fPartialDescriptor = true;
}
char *pszPortAddr = di_bus_addr(Node);
if (pszPortAddr)
pCur->bPort = RTStrToUInt8(pszPortAddr); /* Bus & Port are mixed up (kernel driver/userland) */
else
pCur->bPort = 0;
char szBuf[PATH_MAX + 48];
//.........这里部分代码省略.........
示例6: VBoxDispD3DGlobal2DFormatsInit
HRESULT VBoxDispD3DGlobal2DFormatsInit(PVBOXWDDMDISP_ADAPTER pAdapter)
{
HRESULT hr = S_OK;
memset(&pAdapter->D3D, 0, sizeof (pAdapter->D3D));
memset(&pAdapter->Formats, 0, sizeof (pAdapter->Formats));
/* just calc the max number of formats */
uint32_t cFormats = RT_ELEMENTS(gVBoxFormatOpsBase);
uint32_t cSurfDescs = RT_ELEMENTS(gVBoxSurfDescsBase);
uint32_t cOverlayFormats = 0;
for (uint32_t i = 0; i < pAdapter->cHeads; ++i)
{
VBOXDISPVHWA_INFO *pVhwa = &pAdapter->aHeads[i].Vhwa;
if (pVhwa->Settings.fFlags & VBOXVHWA_F_ENABLED)
{
cOverlayFormats += pVhwa->Settings.cFormats;
}
}
cFormats += cOverlayFormats;
cSurfDescs += cOverlayFormats;
uint32_t cbFormatOps = cFormats * sizeof (FORMATOP);
cbFormatOps = (cbFormatOps + 7) & ~3;
/* ensure the surf descs are 8 byte aligned */
uint32_t offSurfDescs = (cbFormatOps + 7) & ~3;
uint32_t cbSurfDescs = cSurfDescs * sizeof (DDSURFACEDESC);
uint32_t cbBuf = offSurfDescs + cbSurfDescs;
uint8_t* pvBuf = (uint8_t*)RTMemAllocZ(cbBuf);
if (pvBuf)
{
pAdapter->Formats.paFormstOps = (FORMATOP*)pvBuf;
memcpy ((void*)pAdapter->Formats.paFormstOps , gVBoxFormatOpsBase, sizeof (gVBoxFormatOpsBase));
pAdapter->Formats.cFormstOps = RT_ELEMENTS(gVBoxFormatOpsBase);
FORMATOP fo = {D3DDDIFMT_UNKNOWN, 0, 0, 0, 0};
for (uint32_t i = 0; i < pAdapter->cHeads; ++i)
{
VBOXDISPVHWA_INFO *pVhwa = &pAdapter->aHeads[i].Vhwa;
if (pVhwa->Settings.fFlags & VBOXVHWA_F_ENABLED)
{
for (uint32_t j = 0; j < pVhwa->Settings.cFormats; ++j)
{
fo.Format = pVhwa->Settings.aFormats[j];
fo.Operations = FORMATOP_OVERLAY;
hr = vboxFormatOpsMerge((FORMATOP *)pAdapter->Formats.paFormstOps, &pAdapter->Formats.cFormstOps, cFormats, &fo);
if (FAILED(hr))
{
WARN(("vboxFormatOpsMerge failed, hr 0x%x", hr));
}
}
}
}
pAdapter->Formats.paSurfDescs = (DDSURFACEDESC*)(pvBuf + offSurfDescs);
memcpy ((void*)pAdapter->Formats.paSurfDescs , gVBoxSurfDescsBase, sizeof (gVBoxSurfDescsBase));
pAdapter->Formats.cSurfDescs = RT_ELEMENTS(gVBoxSurfDescsBase);
DDSURFACEDESC sd;
for (uint32_t i = 0; i < pAdapter->cHeads; ++i)
{
VBOXDISPVHWA_INFO *pVhwa = &pAdapter->aHeads[i].Vhwa;
if (pVhwa->Settings.fFlags & VBOXVHWA_F_ENABLED)
{
for (uint32_t j = 0; j < pVhwa->Settings.cFormats; ++j)
{
uint32_t fourcc = vboxWddmFormatToFourcc(pVhwa->Settings.aFormats[j]);
if (fourcc)
{
vboxVhwaPopulateOverlayFourccSurfDesc(&sd, fourcc);
hr = vboxSurfDescMerge((DDSURFACEDESC *)pAdapter->Formats.paSurfDescs, &pAdapter->Formats.cSurfDescs, cSurfDescs, &sd);
if (FAILED(hr))
{
WARN(("vboxFormatOpsMerge failed, hr 0x%x", hr));
}
}
}
}
}
}
else
{
WARN(("RTMemAllocZ failed"));
return E_FAIL;
}
return S_OK;
}
示例7: vboxvfs_create_vnode_internal
/**
* Helper function to create XNU VFS vnode object.
*
* @param mp Mount data structure
* @param type vnode type (directory, regular file, etc)
* @param pParent Parent vnode object (NULL for VBoxVFS root vnode)
* @param fIsRoot Flag that indicates if created vnode object is
* VBoxVFS root vnode (TRUE for VBoxVFS root vnode, FALSE
* for all aother vnodes)
* @param Path within Shared Folder
* @param ret Returned newly created vnode
*
* @return 0 on success, error code otherwise
*/
int
vboxvfs_create_vnode_internal(struct mount *mp, enum vtype type, vnode_t pParent, int fIsRoot, PSHFLSTRING Path, vnode_t *ret)
{
int rc;
vnode_t vnode;
vboxvfs_vnode_t *pVnodeData;
vboxvfs_mount_t *pMount;
AssertReturn(mp, EINVAL);
pMount = (vboxvfs_mount_t *)vfs_fsprivate(mp);
AssertReturn(pMount, EINVAL);
AssertReturn(pMount->pLockGroup, EINVAL);
AssertReturn(Path, EINVAL);
pVnodeData = (vboxvfs_vnode_t *)RTMemAllocZ(sizeof(vboxvfs_vnode_t));
AssertReturn(pVnodeData, ENOMEM);
/* Initialize private data */
pVnodeData->pHandle = SHFL_HANDLE_NIL;
pVnodeData->pPath = Path;
pVnodeData->pLockAttr = lck_attr_alloc_init();
if (pVnodeData->pLockAttr)
{
pVnodeData->pLock = lck_rw_alloc_init(pMount->pLockGroup, pVnodeData->pLockAttr);
if (pVnodeData->pLock)
{
struct vnode_fsparam vnode_params;
vnode_params.vnfs_mp = mp;
vnode_params.vnfs_vtype = type;
vnode_params.vnfs_str = NULL;
vnode_params.vnfs_dvp = pParent;
vnode_params.vnfs_fsnode = pVnodeData; /** Private data attached per xnu's vnode object */
vnode_params.vnfs_vops = g_VBoxVFSVnodeDirOpsVector;
vnode_params.vnfs_markroot = fIsRoot;
vnode_params.vnfs_marksystem = FALSE;
vnode_params.vnfs_rdev = 0;
vnode_params.vnfs_filesize = 0;
vnode_params.vnfs_cnp = NULL;
vnode_params.vnfs_flags = VNFS_ADDFSREF | VNFS_NOCACHE;
rc = vnode_create(VNCREATE_FLAVOR, sizeof(vnode_params), &vnode_params, &vnode);
if (rc == 0)
*ret = vnode;
return 0;
}
else
{
PDEBUG("Unable to allocate lock");
rc = ENOMEM;
}
lck_attr_free(pVnodeData->pLockAttr);
}
else
{
PDEBUG("Unable to allocate lock attr");
rc = ENOMEM;
}
return rc;
}
示例8: LogFlowFunc
/**
* Virtio Pci get queue routine. Allocates a PCI queue and DMA resources.
*
* @param pDevice Pointer to the Virtio device instance.
* @param pQueue Where to store the queue.
*
* @return An allocated Virtio Pci queue, or NULL in case of errors.
*/
static void *VirtioPciGetQueue(PVIRTIODEVICE pDevice, PVIRTIOQUEUE pQueue)
{
LogFlowFunc((VIRTIOLOGNAME ":VirtioPciGetQueue pDevice=%p pQueue=%p\n", pDevice, pQueue));
AssertReturn(pDevice, NULL);
virtio_pci_t *pPci = pDevice->pvHyper;
AssertReturn(pPci, NULL);
/*
* Select a Queue.
*/
ddi_put16(pPci->hIO, (uint16_t *)(pPci->addrIOBase + VIRTIO_PCI_QUEUE_SEL), pQueue->QueueIndex);
/*
* Get the currently selected Queue's size.
*/
pQueue->Ring.cDesc = ddi_get16(pPci->hIO, (uint16_t *)(pPci->addrIOBase + VIRTIO_PCI_QUEUE_NUM));
if (RT_UNLIKELY(!pQueue->Ring.cDesc))
{
LogRel((VIRTIOLOGNAME ": VirtioPciGetQueue: Queue[%d] has no descriptors.\n", pQueue->QueueIndex));
return NULL;
}
/*
* Check if it's already active.
*/
uint32_t QueuePFN = ddi_get32(pPci->hIO, (uint32_t *)(pPci->addrIOBase + VIRTIO_PCI_QUEUE_PFN));
if (QueuePFN != 0)
{
LogRel((VIRTIOLOGNAME ":VirtioPciGetQueue: Queue[%d] is already used.\n", pQueue->QueueIndex));
return NULL;
}
LogFlow(("Queue[%d] has %d slots.\n", pQueue->QueueIndex, pQueue->Ring.cDesc));
/*
* Allocate and initialize Pci queue data.
*/
virtio_pci_queue_t *pPciQueue = RTMemAllocZ(sizeof(virtio_pci_queue_t));
if (pPciQueue)
{
/*
* Setup DMA.
*/
size_t cbQueue = VirtioRingSize(pQueue->Ring.cDesc, VIRTIO_PCI_RING_ALIGN);
int rc = ddi_dma_alloc_handle(pDevice->pDip, &g_VirtioPciDmaAttrRing, DDI_DMA_SLEEP, 0 /* addr */, &pPciQueue->hDMA);
if (rc == DDI_SUCCESS)
{
rc = ddi_dma_mem_alloc(pPciQueue->hDMA, cbQueue, &g_VirtioPciAccAttrRing, DDI_DMA_CONSISTENT,
DDI_DMA_SLEEP, 0 /* addr */, &pQueue->pQueue, &pPciQueue->cbBuf,
&pPciQueue->hIO);
if (rc == DDI_SUCCESS)
{
AssertRelease(pPciQueue->cbBuf >= cbQueue);
ddi_dma_cookie_t DmaCookie;
uint_t cCookies;
rc = ddi_dma_addr_bind_handle(pPciQueue->hDMA, NULL /* addrspace */, pQueue->pQueue, pPciQueue->cbBuf,
DDI_DMA_RDWR | DDI_DMA_CONSISTENT, DDI_DMA_SLEEP,
0 /* addr */, &DmaCookie, &cCookies);
if (rc == DDI_SUCCESS)
{
pPciQueue->physBuf = DmaCookie.dmac_laddress;
pPciQueue->pageBuf = pPciQueue->physBuf >> VIRTIO_PCI_QUEUE_ADDR_SHIFT;
LogFlow((VIRTIOLOGNAME ":VirtioPciGetQueue: Queue[%d]%p physBuf=%x pfn of Buf %#x\n", pQueue->QueueIndex,
pQueue->pQueue, pPciQueue->physBuf, pPciQueue->pageBuf));
cmn_err(CE_NOTE, ":VirtioPciGetQueue: Queue[%d]%p physBuf=%x pfn of Buf %x\n", pQueue->QueueIndex,
pQueue->pQueue, pPciQueue->physBuf, pPciQueue->pageBuf);
/*
* Activate the queue and initialize a ring for the queue.
*/
memset(pQueue->pQueue, 0, pPciQueue->cbBuf);
ddi_put32(pPci->hIO, (uint32_t *)(pPci->addrIOBase + VIRTIO_PCI_QUEUE_PFN), pPciQueue->pageBuf);
VirtioRingInit(pQueue, pQueue->Ring.cDesc, pQueue->pQueue, VIRTIO_PCI_RING_ALIGN);
return pPciQueue;
}
else
示例9: parallelsOpenImage
static int parallelsOpenImage(PPARALLELSIMAGE pImage, unsigned uOpenFlags)
{
int rc = VINF_SUCCESS;
ParallelsHeader parallelsHeader;
pImage->pIfError = VDIfErrorGet(pImage->pVDIfsDisk);
pImage->pIfIo = VDIfIoIntGet(pImage->pVDIfsImage);
AssertPtrReturn(pImage->pIfIo, VERR_INVALID_PARAMETER);
rc = vdIfIoIntFileOpen(pImage->pIfIo, pImage->pszFilename,
VDOpenFlagsToFileOpenFlags(uOpenFlags,
false /* fCreate */),
&pImage->pStorage);
if (RT_FAILURE(rc))
goto out;
rc = vdIfIoIntFileGetSize(pImage->pIfIo, pImage->pStorage, &pImage->cbFileCurrent);
if (RT_FAILURE(rc))
goto out;
AssertMsg(pImage->cbFileCurrent % 512 == 0, ("File size is not a multiple of 512\n"));
rc = vdIfIoIntFileReadSync(pImage->pIfIo, pImage->pStorage, 0,
¶llelsHeader, sizeof(parallelsHeader), NULL);
if (RT_FAILURE(rc))
goto out;
if (memcmp(parallelsHeader.HeaderIdentifier, PARALLELS_HEADER_MAGIC, 16))
{
/* Check if the file has hdd as extension. It is a fixed size raw image then. */
char *pszExtension = RTPathExt(pImage->pszFilename);
if (strcmp(pszExtension, ".hdd"))
{
rc = VERR_VD_PARALLELS_INVALID_HEADER;
goto out;
}
/* This is a fixed size image. */
pImage->uImageFlags |= VD_IMAGE_FLAGS_FIXED;
pImage->cbSize = pImage->cbFileCurrent;
pImage->PCHSGeometry.cHeads = 16;
pImage->PCHSGeometry.cSectors = 63;
uint64_t cCylinders = pImage->cbSize / (512 * pImage->PCHSGeometry.cSectors * pImage->PCHSGeometry.cHeads);
pImage->PCHSGeometry.cCylinders = (uint32_t)cCylinders;
}
else
{
if (parallelsHeader.uVersion != PARALLELS_DISK_VERSION)
{
rc = VERR_NOT_SUPPORTED;
goto out;
}
if (parallelsHeader.cEntriesInAllocationBitmap > (1 << 30))
{
rc = VERR_NOT_SUPPORTED;
goto out;
}
Log(("cSectors=%u\n", parallelsHeader.cSectors));
pImage->cbSize = ((uint64_t)parallelsHeader.cSectors) * 512;
pImage->uImageFlags = VD_IMAGE_FLAGS_NONE;
pImage->cAllocationBitmapEntries = parallelsHeader.cEntriesInAllocationBitmap;
pImage->pAllocationBitmap = (uint32_t *)RTMemAllocZ((uint32_t)pImage->cAllocationBitmapEntries * sizeof(uint32_t));
if (!pImage->pAllocationBitmap)
{
rc = VERR_NO_MEMORY;
goto out;
}
rc = vdIfIoIntFileReadSync(pImage->pIfIo, pImage->pStorage,
sizeof(ParallelsHeader), pImage->pAllocationBitmap,
pImage->cAllocationBitmapEntries * sizeof(uint32_t),
NULL);
if (RT_FAILURE(rc))
goto out;
pImage->PCHSGeometry.cCylinders = parallelsHeader.cCylinders;
pImage->PCHSGeometry.cHeads = parallelsHeader.cHeads;
pImage->PCHSGeometry.cSectors = parallelsHeader.cSectorsPerTrack;
}
out:
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
示例10: vboxPciNewInstance
/**
* Creates a new instance.
*
* @returns VBox status code.
* @param pGlobals The globals.
* @param pszName The instance name.
* @param ppDevPort Where to store the pointer to our port interface.
*/
static int vboxPciNewInstance(PVBOXRAWPCIGLOBALS pGlobals,
uint32_t u32HostAddress,
uint32_t fFlags,
PRAWPCIPERVM pVmCtx,
PRAWPCIDEVPORT *ppDevPort,
uint32_t *pfDevFlags)
{
int rc;
PVBOXRAWPCIINS pNew = (PVBOXRAWPCIINS)RTMemAllocZ(sizeof(*pNew));
if (!pNew)
return VERR_NO_MEMORY;
pNew->pGlobals = pGlobals;
pNew->hSpinlock = NIL_RTSPINLOCK;
pNew->cRefs = 1;
pNew->pNext = NULL;
pNew->HostPciAddress = u32HostAddress;
pNew->pVmCtx = pVmCtx;
pNew->DevPort.u32Version = RAWPCIDEVPORT_VERSION;
pNew->DevPort.pfnInit = vboxPciDevInit;
pNew->DevPort.pfnDeinit = vboxPciDevDeinit;
pNew->DevPort.pfnDestroy = vboxPciDevDestroy;
pNew->DevPort.pfnGetRegionInfo = vboxPciDevGetRegionInfo;
pNew->DevPort.pfnMapRegion = vboxPciDevMapRegion;
pNew->DevPort.pfnUnmapRegion = vboxPciDevUnmapRegion;
pNew->DevPort.pfnPciCfgRead = vboxPciDevPciCfgRead;
pNew->DevPort.pfnPciCfgWrite = vboxPciDevPciCfgWrite;
pNew->DevPort.pfnPciCfgRead = vboxPciDevPciCfgRead;
pNew->DevPort.pfnPciCfgWrite = vboxPciDevPciCfgWrite;
pNew->DevPort.pfnRegisterIrqHandler = vboxPciDevRegisterIrqHandler;
pNew->DevPort.pfnUnregisterIrqHandler = vboxPciDevUnregisterIrqHandler;
pNew->DevPort.pfnPowerStateChange = vboxPciDevPowerStateChange;
pNew->DevPort.u32VersionEnd = RAWPCIDEVPORT_VERSION;
rc = RTSpinlockCreate(&pNew->hSpinlock);
if (RT_SUCCESS(rc))
{
rc = RTSemFastMutexCreate(&pNew->hFastMtx);
if (RT_SUCCESS(rc))
{
rc = pNew->DevPort.pfnInit(&pNew->DevPort, fFlags);
if (RT_SUCCESS(rc))
{
*ppDevPort = &pNew->DevPort;
pNew->pNext = pGlobals->pInstanceHead;
pGlobals->pInstanceHead = pNew;
}
else
{
RTSemFastMutexDestroy(pNew->hFastMtx);
RTSpinlockDestroy(pNew->hSpinlock);
RTMemFree(pNew);
}
}
}
return rc;
}
示例11: RTDECL
//.........这里部分代码省略.........
int ch;
bool fNew = true;
while (!feof(pFile) && (ch = fgetc(pFile)) != EOF)
{
if (fNew)
{
RTLogLoggerEx(pLogger, 0, ~0U, "Arg[%u]: ", iArg++);
fNew = false;
}
if (ch)
RTLogLoggerEx(pLogger, 0, ~0U, "%c", ch);
else
{
RTLogLoggerEx(pLogger, 0, ~0U, "\n");
fNew = true;
}
}
if (!fNew)
RTLogLoggerEx(pLogger, 0, ~0U, "\n");
fclose(pFile);
}
# elif defined(RT_OS_FREEBSD)
/* Retrieve the required length first */
int aiName[4];
aiName[0] = CTL_KERN;
aiName[1] = KERN_PROC;
aiName[2] = KERN_PROC_ARGS; /* Introduced in FreeBSD 4.0 */
aiName[3] = getpid();
size_t cchArgs = 0;
int rcBSD = sysctl(aiName, RT_ELEMENTS(aiName), NULL, &cchArgs, NULL, 0);
if (cchArgs > 0)
{
char *pszArgFileBuf = (char *)RTMemAllocZ(cchArgs + 1 /* Safety */);
if (pszArgFileBuf)
{
/* Retrieve the argument list */
rcBSD = sysctl(aiName, RT_ELEMENTS(aiName), pszArgFileBuf, &cchArgs, NULL, 0);
if (!rcBSD)
{
unsigned iArg = 0;
size_t off = 0;
while (off < cchArgs)
{
size_t cchArg = strlen(&pszArgFileBuf[off]);
RTLogLoggerEx(pLogger, 0, ~0U, "Arg[%u]: %s\n", iArg, &pszArgFileBuf[off]);
/* advance */
off += cchArg + 1;
iArg++;
}
}
RTMemFree(pszArgFileBuf);
}
}
# elif defined(RT_OS_L4) || defined(RT_OS_OS2) || defined(RT_OS_DARWIN)
/* commandline? */
# else
# error needs porting.
# endif
}
# else /* IN_GUEST */
/* The user destination is backdoor logging. */
rc = RTLogCreate(&pLogger, 0, NULL, "VBOX_LOG", RT_ELEMENTS(g_apszGroups), &g_apszGroups[0], RTLOGDEST_USER, "VBox.log");
示例12: VBoxServicePageSharingInspectGuest
/**
* Inspect all running processes for executables and dlls that might be worth sharing
* with other VMs.
*
*/
void VBoxServicePageSharingInspectGuest()
{
VBoxServicePageSharingInspectModules(GetCurrentProcessId());
printf("\n\nUSER RESULTS\n");
printf("cNotPresentPages = %d\n", cNotPresentPages);
printf("cWritablePages = %d\n", cWritablePages);
printf("cPrivatePages = %d\n", cPrivatePages);
printf("cSharedPages = %d\n", cSharedPages);
cNotPresentPages = 0;
cWritablePages = 0;
cPrivatePages = 0;
cSharedPages = 0;
/* Check all loaded kernel modules. */
if (ZwQuerySystemInformation)
{
ULONG cbBuffer = 0;
PVOID pBuffer = NULL;
PRTL_PROCESS_MODULES pSystemModules;
NTSTATUS ret = ZwQuerySystemInformation(SystemModuleInformation, (PVOID)&cbBuffer, 0, &cbBuffer);
if (!cbBuffer)
{
printf("ZwQuerySystemInformation returned length 0\n");
goto skipkernelmodules;
}
pBuffer = RTMemAllocZ(cbBuffer);
if (!pBuffer)
goto skipkernelmodules;
ret = ZwQuerySystemInformation(SystemModuleInformation, pBuffer, cbBuffer, &cbBuffer);
if (ret != 0)
{
printf("ZwQuerySystemInformation returned %x (1)\n", ret);
goto skipkernelmodules;
}
pSystemModules = (PRTL_PROCESS_MODULES)pBuffer;
for (unsigned i = 0; i < pSystemModules->NumberOfModules; i++)
{
/* User-mode modules seem to have no flags set; skip them as we detected them above. */
if (pSystemModules->Modules[i].Flags == 0)
continue;
/* New module; register it. */
char szFullFilePath[512];
MODULEENTRY32 ModuleInfo;
strcpy(ModuleInfo.szModule, &pSystemModules->Modules[i].FullPathName[pSystemModules->Modules[i].OffsetToFileName]);
GetSystemDirectoryA(szFullFilePath, sizeof(szFullFilePath));
/* skip \Systemroot\system32 */
char *lpPath = strchr(&pSystemModules->Modules[i].FullPathName[1], '\\');
if (!lpPath)
{
printf("Unexpected kernel module name %s\n", pSystemModules->Modules[i].FullPathName);
break;
}
lpPath = strchr(lpPath+1, '\\');
if (!lpPath)
{
printf("Unexpected kernel module name %s\n", pSystemModules->Modules[i].FullPathName);
break;
}
strcat(szFullFilePath, lpPath);
strcpy(ModuleInfo.szExePath, szFullFilePath);
ModuleInfo.modBaseAddr = (BYTE *)pSystemModules->Modules[i].ImageBase;
ModuleInfo.modBaseSize = pSystemModules->Modules[i].ImageSize;
VBoxServicePageSharingCheckModule(&ModuleInfo);
}
skipkernelmodules:
if (pBuffer)
RTMemFree(pBuffer);
}
printf("\n\nKERNEL RESULTS\n");
printf("cNotPresentPages = %d\n", cNotPresentPages);
printf("cWritablePages = %d\n", cWritablePages);
printf("cPrivatePages = %d\n", cPrivatePages);
printf("cSharedPages = %d\n", cSharedPages);
}
示例13: vboxvfs_mount
static int vboxvfs_mount(struct mount *mp, struct thread *td)
{
int rc;
char *pszShare;
int cbShare, cbOption;
int uid = 0, gid = 0;
struct sf_glob_info *pShFlGlobalInfo;
SHFLSTRING *pShFlShareName = NULL;
int cbShFlShareName;
printf("%s: Enter\n", __FUNCTION__);
if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS))
return EOPNOTSUPP;
if (vfs_filteropt(mp->mnt_optnew, vboxvfs_opts))
{
vfs_mount_error(mp, "%s", "Invalid option");
return EINVAL;
}
rc = vfs_getopt(mp->mnt_optnew, "from", (void **)&pszShare, &cbShare);
if (rc || pszShare[cbShare-1] != '\0' || cbShare > 0xfffe)
return EINVAL;
rc = vfs_getopt(mp->mnt_optnew, "gid", (void **)&gid, &cbOption);
if ((rc != ENOENT) && (rc || cbOption != sizeof(gid)))
return EINVAL;
rc = vfs_getopt(mp->mnt_optnew, "uid", (void **)&uid, &cbOption);
if ((rc != ENOENT) && (rc || cbOption != sizeof(uid)))
return EINVAL;
pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info));
if (!pShFlGlobalInfo)
return ENOMEM;
cbShFlShareName = offsetof (SHFLSTRING, String.utf8) + cbShare + 1;
pShFlShareName = RTMemAllocZ(cbShFlShareName);
if (!pShFlShareName)
return VERR_NO_MEMORY;
pShFlShareName->u16Length = cbShare;
pShFlShareName->u16Size = cbShare + 1;
memcpy (pShFlShareName->String.utf8, pszShare, cbShare + 1);
rc = vboxCallMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map);
RTMemFree(pShFlShareName);
if (RT_FAILURE (rc))
{
RTMemFree(pShFlGlobalInfo);
printf("vboxCallMapFolder failed rc=%d\n", rc);
return EPROTO;
}
pShFlGlobalInfo->uid = uid;
pShFlGlobalInfo->gid = gid;
mp->mnt_data = pShFlGlobalInfo;
/* @todo root vnode. */
vfs_getnewfsid(mp);
vfs_mountedfrom(mp, pszShare);
printf("%s: Leave rc=0\n", __FUNCTION__);
return 0;
}
示例14: parallelsCreateImage
/**
* Internal: Create a parallels image.
*/
static int parallelsCreateImage(PPARALLELSIMAGE pImage, uint64_t cbSize,
unsigned uImageFlags, const char *pszComment,
PCVDGEOMETRY pPCHSGeometry,
PCVDGEOMETRY pLCHSGeometry, unsigned uOpenFlags,
PFNVDPROGRESS pfnProgress, void *pvUser,
unsigned uPercentStart, unsigned uPercentSpan)
{
int rc = VINF_SUCCESS;
int32_t fOpen;
if (uImageFlags & VD_IMAGE_FLAGS_FIXED)
{
rc = vdIfError(pImage->pIfError, VERR_VD_INVALID_TYPE, RT_SRC_POS, N_("Parallels: cannot create fixed image '%s'. Create a raw image"), pImage->pszFilename);
goto out;
}
pImage->uOpenFlags = uOpenFlags & ~VD_OPEN_FLAGS_READONLY;
pImage->uImageFlags = uImageFlags;
pImage->PCHSGeometry = *pPCHSGeometry;
pImage->LCHSGeometry = *pLCHSGeometry;
if (!pImage->PCHSGeometry.cCylinders)
{
/* Set defaults. */
pImage->PCHSGeometry.cSectors = 63;
pImage->PCHSGeometry.cHeads = 16;
pImage->PCHSGeometry.cCylinders = pImage->cbSize / (512 * pImage->PCHSGeometry.cSectors * pImage->PCHSGeometry.cHeads);
}
pImage->pIfError = VDIfErrorGet(pImage->pVDIfsDisk);
pImage->pIfIo = VDIfIoIntGet(pImage->pVDIfsImage);
AssertPtrReturn(pImage->pIfIo, VERR_INVALID_PARAMETER);
/* Create image file. */
fOpen = VDOpenFlagsToFileOpenFlags(pImage->uOpenFlags, true /* fCreate */);
rc = vdIfIoIntFileOpen(pImage->pIfIo, pImage->pszFilename, fOpen, &pImage->pStorage);
if (RT_FAILURE(rc))
{
rc = vdIfError(pImage->pIfError, rc, RT_SRC_POS, N_("Parallels: cannot create image '%s'"), pImage->pszFilename);
goto out;
}
if (RT_SUCCESS(rc) && pfnProgress)
pfnProgress(pvUser, uPercentStart + uPercentSpan * 98 / 100);
/* Setup image state. */
pImage->cbSize = cbSize;
pImage->cAllocationBitmapEntries = cbSize / 512 / pImage->PCHSGeometry.cSectors;
if (pImage->cAllocationBitmapEntries * pImage->PCHSGeometry.cSectors * 512 < cbSize)
pImage->cAllocationBitmapEntries++;
pImage->fAllocationBitmapChanged = true;
pImage->cbFileCurrent = sizeof(ParallelsHeader) + pImage->cAllocationBitmapEntries * sizeof(uint32_t);
/* Round to next sector boundary. */
pImage->cbFileCurrent += 512 - pImage->cbFileCurrent % 512;
Assert(!(pImage->cbFileCurrent % 512));
pImage->pAllocationBitmap = (uint32_t *)RTMemAllocZ(pImage->cAllocationBitmapEntries * sizeof(uint32_t));
if (!pImage->pAllocationBitmap)
rc = VERR_NO_MEMORY;
if (RT_SUCCESS(rc))
{
ParallelsHeader Header;
memcpy(Header.HeaderIdentifier, PARALLELS_HEADER_MAGIC, sizeof(Header.HeaderIdentifier));
Header.uVersion = RT_H2LE_U32(PARALLELS_DISK_VERSION);
Header.cHeads = RT_H2LE_U32(pImage->PCHSGeometry.cHeads);
Header.cCylinders = RT_H2LE_U32(pImage->PCHSGeometry.cCylinders);
Header.cSectorsPerTrack = RT_H2LE_U32(pImage->PCHSGeometry.cSectors);
Header.cEntriesInAllocationBitmap = RT_H2LE_U32(pImage->cAllocationBitmapEntries);
Header.cSectors = RT_H2LE_U32(pImage->cbSize / 512);
memset(Header.Padding, 0, sizeof(Header.Padding));
/* Write header and allocation bitmap. */
rc = vdIfIoIntFileSetSize(pImage->pIfIo, pImage->pStorage, pImage->cbFileCurrent);
if (RT_SUCCESS(rc))
rc = vdIfIoIntFileWriteSync(pImage->pIfIo, pImage->pStorage, 0,
&Header, sizeof(Header), NULL);
if (RT_SUCCESS(rc))
rc = parallelsFlushImage(pImage); /* Writes the allocation bitmap. */
}
out:
if (RT_SUCCESS(rc) && pfnProgress)
pfnProgress(pvUser, uPercentStart + uPercentSpan);
if (RT_FAILURE(rc))
parallelsFreeImage(pImage, rc != VERR_ALREADY_EXISTS);
return rc;
}
示例15: DECLCALLBACK
DECLCALLBACK(int) vboxUhgsmiD3DBufferCreate(PVBOXUHGSMI pHgsmi, uint32_t cbBuf,
VBOXUHGSMI_SYNCHOBJECT_TYPE enmSynchType, HVBOXUHGSMI_SYNCHOBJECT hSynch,
PVBOXUHGSMI_BUFFER* ppBuf)
{
bool bSynchCreated = false;
if (!cbBuf)
return VERR_INVALID_PARAMETER;
int rc = vboxUhgsmiBaseEventChkCreate(enmSynchType, &hSynch, &bSynchCreated);
AssertRC(rc);
if (RT_FAILURE(rc))
return rc;
cbBuf = VBOXWDDM_ROUNDBOUND(cbBuf, 0x1000);
Assert(cbBuf);
uint32_t cPages = cbBuf >> 12;
Assert(cPages);
PVBOXUHGSMI_PRIVATE_D3D pPrivate = VBOXUHGSMID3D_GET(pHgsmi);
PVBOXUHGSMI_BUFFER_PRIVATE_D3D pBuf = (PVBOXUHGSMI_BUFFER_PRIVATE_D3D)RTMemAllocZ(RT_OFFSETOF(VBOXUHGSMI_BUFFER_PRIVATE_D3D, aLockPageIndices[cPages]));
Assert(pBuf);
if (pBuf)
{
struct
{
D3DDDICB_ALLOCATE DdiAlloc;
D3DDDI_ALLOCATIONINFO DdiAllocInfo;
VBOXWDDM_ALLOCINFO AllocInfo;
} Buf;
memset(&Buf, 0, sizeof (Buf));
Buf.DdiAlloc.hResource = NULL;
Buf.DdiAlloc.hKMResource = NULL;
Buf.DdiAlloc.NumAllocations = 1;
Buf.DdiAlloc.pAllocationInfo = &Buf.DdiAllocInfo;
Buf.DdiAllocInfo.pPrivateDriverData = &Buf.AllocInfo;
Buf.DdiAllocInfo.PrivateDriverDataSize = sizeof (Buf.AllocInfo);
Buf.AllocInfo.enmType = VBOXWDDM_ALLOC_TYPE_UMD_HGSMI_BUFFER;
Buf.AllocInfo.cbBuffer = cbBuf;
Buf.AllocInfo.hSynch = hSynch;
Buf.AllocInfo.enmSynchType = enmSynchType;
HRESULT hr = pPrivate->pDevice->RtCallbacks.pfnAllocateCb(pPrivate->pDevice->hDevice, &Buf.DdiAlloc);
Assert(hr == S_OK);
if (hr == S_OK)
{
Assert(Buf.DdiAllocInfo.hAllocation);
pBuf->BasePrivate.Base.pfnLock = vboxUhgsmiD3DBufferLock;
pBuf->BasePrivate.Base.pfnUnlock = vboxUhgsmiD3DBufferUnlock;
// pBuf->Base.pfnAdjustValidDataRange = vboxUhgsmiD3DBufferAdjustValidDataRange;
pBuf->BasePrivate.Base.pfnDestroy = vboxUhgsmiD3DBufferDestroy;
pBuf->BasePrivate.Base.hSynch = hSynch;
pBuf->BasePrivate.Base.enmSynchType = enmSynchType;
pBuf->BasePrivate.Base.cbBuffer = cbBuf;
pBuf->BasePrivate.Base.bSynchCreated = bSynchCreated;
pBuf->pDevice = pPrivate->pDevice;
pBuf->BasePrivate.hAllocation = Buf.DdiAllocInfo.hAllocation;
*ppBuf = &pBuf->BasePrivate.Base;
return VINF_SUCCESS;
}
RTMemFree(pBuf);
}
else
rc = VERR_NO_MEMORY;
if (bSynchCreated)
CloseHandle(hSynch);
return rc;
}