Jungo WinDriver  
Official Documentation

◆ WDS_IpcRegister()

DWORD DLLCALLCONV WDS_IpcRegister ( _In_ const CHAR *  pcProcessName,
_In_ DWORD  dwGroupID,
_In_ DWORD  dwSubGroupID,
_In_ DWORD  dwAction,
_In_ IPC_MSG_RX_HANDLER  pFunc,
_In_ void *  pData 
)

Registers an application with WinDriver IPC.

Parameters
[in]pcProcessNameOptional process name string
[in]dwGroupIDA unique group ID represent the specific application. Must be a positive ID
[in]dwSubGroupIDSub-group ID that should identify your user application type in case you have several types that may work simultaneously. Must be a positive ID
[in]dwActionIPC message type to receive, which can consist one of the enumeration values listed below: WD_IPC_UNICAST_MSG: Receive a message to a specific process with WinDriver IPC unique ID WD_IPC_MULTICAST_MSG: Receive a message from all processes that were registered with the same group ID as this process WD_IPC_ALL_MSG: Receive both types of the messages above
[in]pFuncA user-mode IPC message handler callback function, which will be called when a message was received by WinDriver from a different process (see dwActions) occurs. (See IPC_MSG_RX_HANDLER())
[in]pDataData for the user-mode IPC message handler callback routine (pFunc)
Returns
Returns WD_STATUS_SUCCESS (0) on success, or an appropriate error code otherwise
Remarks
You should choose your user applications a unique group ID parameter. This is done as a precaution to prevent several applications that use WinDriver with its default driver name (windrvrXXXX) to get mixing messages. We strongly recommend that you rename your driver before distributing it to avoid this issue entirely, among other issue (See Section 15.2 on renaming you driver name). The sub-group id parameter should identify your user application type in case you have several types that may work simultaneously.
// WinDriver Callback functions must use DLLCALLCONV macro
static void DLLCALLCONV 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);
switch (pIpcRxMsg->dwMsgID)
{
case A:
{
// ...
}
break;
case B:
{
// ...
}
break;
default:
printf("Unknown IPC type. msgID [0x%lx], msgData [0x%llx] from "
"process [0x%lx]\n\n", pIpcRxMsg->dwMsgID, pIpcRxMsg->qwMsgData,
pIpcRxMsg->dwSenderUID);
}
}
int main(void)
{
DWORD dwSubGroupID = 0; // Or any other ID you want to choose
DWORD dwStatus;
WDS_IPC_SCAN_RESULT ipcScanResult;
// Make sure to fully initialize WinDriver!
if (!WD_DriverName(DEFAULT_DRIVER_NAME))
{
ErrLog("Failed to set the driver name for WDC library.\n");
return;
}
/* Open a handle to the driver and initialize the WDC library */
dwStatus = WDC_DriverOpen(WDC_DRV_OPEN_DEFAULT, DEFAULT_LICENSE_STRING);
if (WD_STATUS_SUCCESS != dwStatus)
{
printf("Failed to initialize the WDC library. Error 0x%lx - %s\n",
dwStatus, Stat2Str(dwStatus));
return dwStatus;
}
dwStatus = WDS_IpcRegister(DEFAULT_PROCESS_NAME, DEFAULT_PROCESS_GROUP_ID,
dwSubGroupID, WD_IPC_ALL_MSG, ipc_msg_event_cb, NULL /* Your cb ctx */);
if (WD_STATUS_SUCCESS != dwStatus)
{
printf("Failed registering process to IPC. Error [0x%lx - %s]\n",
dwStatus, Stat2Str(dwStatus));
goto Exit;
}
printf("Registration completed successfully\n");
printf("Scanning for processes...\n");
dwStatus = WDS_IpcScanProcs(&ipcScanResult);
if (WD_STATUS_SUCCESS != dwStatus)
{
printf("Failed scanning registered processes. Error [0x%lx - %s]\n",
dwStatus, Stat2Str(dwStatus));
goto Exit;
}
if (ipcScanResult.dwNumProcs)
{
printf("Found %ld processes in current group\n",
ipcScanResult.dwNumProcs);
for (i = 0; i < ipcScanResult.dwNumProcs; i++)
{
printf(" %lu) Name: %s, SubGroup ID: 0x%lx, UID: 0x%lx\n", i + 1,
ipcScanResult.procInfo[i].cProcessName,
ipcScanResult.procInfo[i].dwSubGroupID,
ipcScanResult.procInfo[i].hIpc);
}
}
else
{
printf("No processes found in current group\n");
}
// ...
// Rest of your application code
// ...
dwStatus = WDS_IpcUnRegister();
if (dwStatus)
{
printf("Failed unregistering IPC Error [0x%lx - %s]\n",
dwStatus, Stat2Str(dwStatus));
goto Exit;
}
Exit:
}
#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
DWORD dwNumProcs
Number of matching processes.
Definition: wds_lib.h:38
WD_IPC_PROCESS procInfo[WD_IPC_MAX_PROCS]
Array of processes info.
Definition: wds_lib.h:39
IPC scan processes results.
Definition: wds_lib.h:37
DWORD hIpc
Returned from WD_IpcRegister()
Definition: windrvr.h:792
CHAR cProcessName[WD_PROCESS_NAME_LENGTH]
Definition: windrvr.h:786
DWORD dwSubGroupID
Identifier of the processes type.
Definition: windrvr.h:787
#define WDC_DRV_OPEN_DEFAULT
Definition: wdc_lib.h:69
DWORD DLLCALLCONV WDC_DriverClose(void)
Closes the WDC WinDriver handle (acquired and stored by a previous call to WDC_DriverOpen()) and unin...
DWORD DLLCALLCONV WDC_DriverOpen(_In_ WDC_DRV_OPEN_OPTIONS openOptions, _In_ const CHAR *pcLicense)
Opens and stores a handle to WinDriver's kernel module and initializes the WDC library according to t...
DWORD DLLCALLCONV WDS_IpcRegister(_In_ const CHAR *pcProcessName, _In_ DWORD dwGroupID, _In_ DWORD dwSubGroupID, _In_ DWORD dwAction, _In_ IPC_MSG_RX_HANDLER pFunc, _In_ void *pData)
Registers an application with WinDriver IPC.
void DLLCALLCONV WDS_IpcUnRegister(void)
This function enables the user application to unregister with WinDriver IPC.
DWORD DLLCALLCONV WDS_IpcScanProcs(_Outptr_ WDS_IPC_SCAN_RESULT *pIpcScanResult)
Scans and returns information of all registered processes that share the application process groupID ...
#define WD_IPC_ALL_MSG
Definition: windrvr.h:1474
@ WD_STATUS_SUCCESS
[0] Operation completed successfully
Definition: windrvr.h:1061
const char *DLLCALLCONV WD_DriverName(const char *sName)
Sets the name of the WinDriver kernel module, which will be used by the calling application.
#define DLLCALLCONV
Definition: windrvr.h:32