Thanks a lot Doron for clarifying my doubts on driver instance.
and i have done some change in code
I have created a device interface with WdfDeviceCreateDeviceInterface with the reference string being an encoded with Func Number in driver.
In the user app how can i connect to the specific hardware (with the reference string ) encoded
hardwareDeviceInfo = SetupDiGetClassDevs(
(LPGUID)&GUID_MYDEVICE,
NULL, // Define no enumerator (global)
NULL, // Define no
(DIGCF_PRESENT | // Only Devices present
DIGCF_DEVICEINTERFACE)); // Function class devices.
deviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
printf(“Calling SetupDiEnumDeviceInterfaces()…\n”);
bResult = SetupDiEnumDeviceInterfaces(hardwareDeviceInfo,
0,
(LPGUID)&GUID_MYDEVICE,
0,
&deviceInterfaceData);
printf(“Calling SetupDiGetDeviceInterfaceDetail()…\n”);
SetupDiGetDeviceInterfaceDetail(
hardwareDeviceInfo,
&deviceInterfaceData,
NULL,
0,
&RequiredLength,
NULL
);
deviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)
LocalAlloc(LMEM_FIXED, RequiredLength);
deviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
predictedLength = RequiredLength;
bResult = SetupDiGetDeviceInterfaceDetail(
hardwareDeviceInfo,
&deviceInterfaceData,
deviceInterfaceDetailData,
predictedLength,
&RequiredLength,
NULL);
printf(" SetupDiGetDeviceInterfaceDetail() bResult=0x%x…\n", bResult);
*handle= CreateFile(deviceInterfaceDetailData->DevicePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, // no SECURITY_ATTRIBUTES structure
OPEN_EXISTING, // No special create flags
0, // No special attributes
NULL); // No template file
if (DeviceIoControl(handle,
MYDEVICE_FW_IOCTL_BDF,
&pci_addr,
sizeof(test_pci_addr_t),
NULL,
NULL,
&bytes,
NULL))
Through this, I can hit the driver, but even though if I give the wrong function number its hitting the driver ioctl, where I am missing to add the reference string in user code.
Thanks for your help