Jungo WinDriver  
Official Documentation

◆ WDC_DMABufGet()

DWORD DLLCALLCONV WDC_DMABufGet ( _In_ DWORD  hDma,
_Outptr_ WD_DMA **  ppDma 
)

Retrieves a contiguous DMA buffer which was allocated by another process.

Parameters
[in]hDmaDMA buffer handle.
[out]ppDmaPointer to a pointer to a DMA buffer information structure, which is associated with hDma.
Returns
Returns WD_STATUS_SUCCESS (0) on success, or an appropriate error code otherwise

For more detailed usage of the WDC_DMA functions, please refer to 11.2. Performing Direct Memory Access (DMA)

static void ipc_msg_event_cb(WDS_IPC_MSG_RX *pIpcRxMsg, void *pData)
{
printf("\n\nReceived an IPC message:\n"
"msgID [0x%lx], msgData [0x%llx] from process [0x%lx]\n",
pIpcRxMsg->dwMsgID, pIpcRxMsg->qwMsgData, pIpcRxMsg->dwSenderUID);
/* In this example, the hDma was sent by the other process and saved it
in pIpcRxMsg->qwMsgData. The current process gets the buffer by the IPC
message event callback */
switch (pIpcRxMsg->dwMsgID)
{
case IPC_MSG_CONTIG_DMA_BUFFER_READY:
{
DWORD dwStatus;
WD_DMA *pDma = NULL;
printf("\nThis is a DMA buffer, getting it...\n");
dwStatus = WDC_DMABufGet((DWORD)pIpcRxMsg->qwMsgData, &pDma);
if (WD_STATUS_SUCCESS != dwStatus)
{
printf("ipc_msg_event_cb: Failed getting DMA buffer. "
"Error [0x%lx - %s]\n", dwStatus, Stat2Str(dwStatus));
return;
}
printf("Got a DMA buffer. UserAddr [%p], "
"pPhysicalAddr [0x%"PRI64"x], size [%ld(0x%lx)]\n",
pDma->pUserAddr, pDma->Page[0].pPhysicalAddr,
pDma->Page[0].dwBytes, pDma->Page[0].dwBytes);
/* For sample purpose we immediately release the buffer */
}
break;
default:
printf("Unknown IPC type. msgID [0x%lx], msgData [0x%llx] from "
"process [0x%lx]\n\n", pIpcRxMsg->dwMsgID, pIpcRxMsg->qwMsgData,
pIpcRxMsg->dwSenderUID);
}
}
#define NULL
Definition: kpstdlib.h:268
const char *DLLCALLCONV Stat2Str(_In_ DWORD dwStatus)
Retrieves the status string that corresponds to a status code.
DWORD dwSenderUID
WinDriver IPC unique ID of the sending process.
Definition: wds_lib.h:44
DWORD dwMsgID
A 32 bit unique number defined by the user application.
Definition: wds_lib.h:45
UINT64 qwMsgData
Optional - 64 bit additional data from the sending user-application process.
Definition: wds_lib.h:50
IPC message received.
Definition: wds_lib.h:43
DMA_ADDR pPhysicalAddr
Physical address of page.
Definition: windrvr.h:525
DWORD dwBytes
Size of page.
Definition: windrvr.h:526
PVOID pUserAddr
User address.
Definition: windrvr.h:537
WD_DMA_PAGE Page[WD_DMA_PAGES]
Definition: windrvr.h:562
DWORD DLLCALLCONV WDC_DMABufUnlock(_In_ WD_DMA *pDma)
Unlocks and frees the memory allocated for a DMA buffer by a previous call to WDC_DMAContigBufLock(),...
DWORD DLLCALLCONV WDC_DMABufGet(_In_ DWORD hDma, _Outptr_ WD_DMA **ppDma)
Retrieves a contiguous DMA buffer which was allocated by another process.
#define PRI64
formatting for printing a 64bit variable
Definition: windrvr.h:345
@ WD_STATUS_SUCCESS
[0] Operation completed successfully
Definition: windrvr.h:1066