Jungo WinDriver  
Official Documentation

◆ WD_DriverName()

const char* DLLCALLCONV WD_DriverName ( const char *  sName)

Sets the name of the WinDriver kernel module, which will be used by the calling application.

The default driver name, which is used if the function is not called, is windrvr1620.

This function must be called once, and only once, from the beginning of your application, before calling any other WinDriver function (including WD_Open() / WDC_DriverOpen() / WDC_PciDeviceOpen() / WDC_IsaDeviceOpen()), as demonstrated in the sample and generated DriverWizard WinDriver applications, which include a call to this function with the default driver name - windrvr1620

On Windows and Linux, if you select to modify the name of the WinDriver kernel module (windrvr1620.sys/.dll/.o/.ko), as explained in 17.2. Renaming the WinDriver Kernel Driver, you must ensure that your application calls WD_DriverName() with your new driver name.

In order to use the WD_DriverName() function, your user-mode driver project must be built with WD_DRIVER_NAME_CHANGE preprocessor flag (e.g.: -DWD_DRIVER_NAME_CHANGE — for MS Visual Studio, Windows GCC, and GCC). The sample and generated DriverWizard Windows and Linux WinDriver projects/makefiles already set this preprocessor flag.

Parameters
[in]sNameThe name of the WinDriver kernel module to be used by the application. NOTE: The driver name should be indicated without the driver file's extension. For example, use windrvr1620, not windrvr1620.sys or windrvr1620.o.
Returns
Returns the selected driver name on success; returns NULL on failure (e.g., if the function is called twice from the same application).
int main(void)
{
DWORD dwStatus;
WD_PCI_SLOT slot = {0, 0, 0, 0}; /* Replace domain/bus/slot/function with your own */
WD_PCI_CARD_INFO deviceInfo;
BYTE bData = 0x1;
WORD wData = 0x2;
UINT32 u32Data = 0x3;
UINT64 u64Data = 0x4;
/* Make sure to fully initialize WinDriver! */
if (!WD_DriverName(DEFAULT_DRIVER_NAME))
{
printf("Failed to set the driver name for WDC library.\n");
return WD_INTERNAL_ERROR;
}
if (WD_STATUS_SUCCESS != dwStatus)
{
printf("Failed to initialize debug options for WDC library.\n"
"Error 0x%lx - %s\n", dwStatus, Stat2Str(dwStatus));
return dwStatus;
}
/* 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;
}
BZERO(deviceInfo);
deviceInfo.pciSlot = slot;
dwStatus = WDC_PciGetDeviceInfo(&deviceInfo);
if (WD_STATUS_SUCCESS != dwStatus)
{
printf("Failed retrieving the device's resources "
"information. Error [0x%lx - %s]\n", dwStatus, Stat2Str(dwStatus));
goto Exit;
}
/* Open a device handle */
dwStatus = WDC_PciDeviceOpen(&hDev, &deviceInfo, NULL);
if (WD_STATUS_SUCCESS != dwStatus)
{
printf("Failed opening a WDC device handle. Error 0x%lx - %s\n",
dwStatus, Stat2Str(dwStatus));
goto Exit;
}
/* Read/Write memory examples: */
/* Check BYTE */
dwResult = WDC_WriteAddrBlock8(hDev, MEM_SPACE, REG, 1,
if (dwResult)
goto Exit;
dwResult = WDC_ReadAddrBlock8(hDev, MEM_SPACE, REG, 1,
if (dwResult)
goto Exit;
/* Check WORD */
dwResult = WDC_WriteAddrBlock16(hDev, MEM_SPACE, REG, 2,
if (dwResult)
goto Exit;
dwResult = WDC_ReadAddrBlock16(hDev, MEM_SPACE, REG, 2,
if (dwResult)
goto Exit;
/* Check UINT32 */
dwResult = WDC_WriteAddrBlock32(hDev, MEM_SPACE, REG, 4,
&u32Data, WDC_ADDR_RW_DEFAULT);
if (dwResult)
goto Exit;
dwResult = WDC_ReadAddrBlock32(hDev, MEM_SPACE, REG, 4,
&u32Data, WDC_ADDR_RW_DEFAULT);
if (dwResult)
goto Exit;
/* Check UINT64 */
dwResult = WDC_WriteAddrBlock64(hDev, MEM_SPACE, REG, 8,
&u64Data, WDC_ADDR_RW_DEFAULT);
if (dwResult)
goto Exit;
dwResult = WDC_ReadAddrBlock64(hDev, MEM_SPACE, REG, 8,
&u64Data, WDC_ADDR_RW_DEFAULT);
if (dwResult)
goto Exit;
Exit:
if (hDev)
{
dwStatus = WDC_PciDeviceClose(hDev);
if (WD_STATUS_SUCCESS != dwStatus)
{
printf("Failed closing a WDC device handle (0x%p). Error 0x%lx "
"- %s\n", hDev, dwStatus, Stat2Str(dwStatus));
}
}
}
#define NULL
Definition: kpstdlib.h:268
const char *DLLCALLCONV Stat2Str(_In_ DWORD dwStatus)
Retrieves the status string that corresponds to a status code.
WD_PCI_SLOT pciSlot
PCI slot information.
Definition: windrvr.h:921
#define WDC_ReadAddrBlock8(hDev, dwAddrSpace, dwOffset, dwBytes, pData, options)
WDC_ReadAddrBlock with 1 byte mode.
Definition: wdc_lib.h:959
#define WDC_WriteAddrBlock8(hDev, dwAddrSpace, dwOffset, dwBytes, pData, options)
WDC_WriteAddrBlock with 1 byte mode.
Definition: wdc_lib.h:983
DWORD DLLCALLCONV WDC_SetDebugOptions(_In_ WDC_DBG_OPTIONS dbgOptions, _In_ const CHAR *pcDbgFile)
Sets debug options for the WDC library - see the description of WDC_DBG_OPTIONS for details regarding...
DWORD DLLCALLCONV WDC_PciDeviceOpen(_Outptr_ WDC_DEVICE_HANDLE *phDev, _In_ const WD_PCI_CARD_INFO *pDeviceInfo, _In_ const PVOID pDevCtx)
Allocates and initializes a WDC PCI device structure, registers the device with WinDriver,...
#define WDC_WriteAddrBlock32(hDev, dwAddrSpace, dwOffset, dwBytes, pData, options)
WDC_WriteAddrBlock with 4 bytes mode.
Definition: wdc_lib.h:995
#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_PciDeviceClose(_In_ WDC_DEVICE_HANDLE hDev)
Uninitializes a WDC PCI device structure and frees the memory allocated for it.
#define WDC_ReadAddrBlock32(hDev, dwAddrSpace, dwOffset, dwBytes, pData, options)
WDC_ReadAddrBlock with 4 bytes mode.
Definition: wdc_lib.h:971
#define WDC_DBG_DEFAULT
Convenient debug options combinations/defintions.
Definition: wdc_lib.h:86
DWORD DLLCALLCONV WDC_PciGetDeviceInfo(_Inout_ WD_PCI_CARD_INFO *pDeviceInfo)
Retrieves a PCI device's resources information (memory and I/O ranges and interrupt information).
@ WDC_ADDR_RW_DEFAULT
Default: memory resource - direct access; autoincrement on block transfers.
Definition: wdc_lib.h:124
#define WDC_WriteAddrBlock64(hDev, dwAddrSpace, dwOffset, dwBytes, pData, options)
WDC_WriteAddrBlock with 8 bytes mode.
Definition: wdc_lib.h:1001
#define WDC_ReadAddrBlock16(hDev, dwAddrSpace, dwOffset, dwBytes, pData, options)
WDC_ReadAddrBlock with 2 bytes mode.
Definition: wdc_lib.h:965
#define WDC_ReadAddrBlock64(hDev, dwAddrSpace, dwOffset, dwBytes, pData, options)
WDC_ReadAddrBlock with 8 bytes mode.
Definition: wdc_lib.h:977
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...
void * WDC_DEVICE_HANDLE
Handle to device information struct.
Definition: wdc_lib.h:33
#define WDC_WriteAddrBlock16(hDev, dwAddrSpace, dwOffset, dwBytes, pData, options)
WDC_WriteAddrBlock with 2 bytes mode.
Definition: wdc_lib.h:989
unsigned short int WORD
Definition: windrvr.h:333
unsigned char BYTE
Definition: windrvr.h:332
@ WD_STATUS_SUCCESS
[0] Operation completed successfully
Definition: windrvr.h:1061
#define BZERO(buf)
Definition: windrvr.h:1548
unsigned __int64 UINT64
Definition: windrvr.h:314
const char *DLLCALLCONV WD_DriverName(const char *sName)
Sets the name of the WinDriver kernel module, which will be used by the calling application.
unsigned int UINT32
Definition: windrvr.h:337