Cannot get target file handle to local I/O target in UMDF v2

I cannot find any sample code for UM VHF online so I am trying to port the HIDInjector example to UMDF v2. I am stuck at trying to call VhfCreate.

VHF_CONFIG_INIT expects a "FileHandle" which the docs specify as:

Required for user-mode drivers. A file handle obtained by calling WdfIoTargetWdmGetTargetFileHandle. To open a WDFIOTARGET, a user-mode (UMDF) VHF source driver should call WdfIoTargetOpen with OpenParams.Type set to WdfIoTargetOpenLocalTargetByFile .

So I set up my code as follows:

    status = WdfIoTargetCreate(WdfDevice, WDF_NO_OBJECT_ATTRIBUTES, &ioTarget);
    if (!NT_SUCCESS(status))
    {
        TraceEvents(TRACE_LEVEL_ERROR, TRACE_DRIVER, "WdfIoTargetCreate failed %!STATUS!", status);
        goto _exit;
    }

    WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_FILE(&openParams, NULL);
    status = WdfIoTargetOpen(ioTarget, &openParams);
    if (!NT_SUCCESS(status)) {
        TraceEvents(TRACE_LEVEL_ERROR, TRACE_DRIVER, "WdfIoTargetOpen failed %!STATUS!", status);
        WdfObjectDelete(ioTarget);
        goto _exit;
    }

    deviceContext = GetHidDeviceContext(WdfDevice);

    VHF_CONFIG_INIT(&vhfConfig,
        WdfIoTargetWdmGetTargetFileHandle(ioTarget),
        deviceContext->HidDescriptor.DescriptorList[0].wReportLength,
        deviceContext->ReportDescriptor);

    vhfConfig.VhfClientContext = deviceContext;
    vhfConfig.OperationContextSize = 11;
    vhfConfig.EvtVhfAsyncOperationGetFeature = Driver_VhfAsyncOperationGetFeature;
    vhfConfig.EvtVhfAsyncOperationSetFeature = Driver_VhfAsyncOperationSetFeature;

    status = VhfCreate(&vhfConfig, &deviceContext->VhfHandle);

The problem is that WdfIoTargetWdmGetTargetFileHandle(ioTarget) returns NULL and that causes VhfCreate to fail. However, I am not sure why it is failing because I am following the example at the bottom of the docs for WdfIoTargetWdmGetTargetFileHandle .

What is your device? How did you install this driver? What's the device you're handling?

I am trying to use Virtual HID Framework to create a virtual HID device which can be used to interface with a 3rd party HID client. Currently, I am using devgen to create the device node. The driver is installed using pnputil. My INI is as follows:

;
; XGMDriver.inf
;

[Version]
Signature   = "$Windows NT$"
Class       = HIDClass
ClassGuid   = {745a17a0-74d3-11d0-b6fe-00a0c90f57da}
Provider    = %ManufacturerName%
CatalogFile = XGMDriver.cat
DriverVer   = 1
PnpLockdown = 1

[Manufacturer]
; This driver package is only installable on Win11+
%ManufacturerName% = Standard,NT$ARCH$.10.0...22000 ; wudfrd.inf introduced in build 22000

[Standard.NT$ARCH$.10.0...22000]
%DeviceName% = XGMDevice_Install, Root\FakeXGMDevice

[SourceDisksFiles]
XGMDriver.dll = 1

[SourceDisksNames]
1 = %DiskName%

; =================== UMDF Device ==================================

[XGMDevice_Install.NT]
CopyFiles = UMDriverCopy
AddReg = XGMDevice_AddRegSW
Include = hidvhf.inf
Needs = vhfservice.NT
Include = wudfrd.inf
Needs = WUDFRD.NT

[XGMDevice_Install.NT.hw]
AddReg = XGMDevice_AddRegHW
Include = wudfrd.inf
Needs = WUDFRD.NT.HW

[XGMDevice_Install.NT.Services]
Include = wudfrd.inf
Needs = WUDFRD.NT.Services
Include = hidvhf.inf
Needs = vhfservice.NT.Services

[XGMDevice_Install.NT.Wdf]
UmdfDispatcher = FileHandle
UmdfService = XGMDriver,XGMDriver_Install
UmdfServiceOrder = XGMDriver

;[XGMDevice_Install.NT.Filters]
;AddFilter = Vhf,,Vhf_LowerFilterPosition

[XGMDriver_Install]
UmdfLibraryVersion = $UMDFVERSION$ 
ServiceBinary = %13%\XGMDriver.dll

[DestinationDirs]
UMDriverCopy = 13

[UMDriverCopy]
XGMDriver.dll

[XGMDevice_AddRegSW]
HKR, "Parameters", "Model", 0x00001000, "GC32L"
HKR, "Parameters", "Serial", 0x00001000, ""

[XGMDevice_AddRegHW]
HKR, , "LowerFilters", 0x00010000, "vhf"

;[Vhf_LowerFilterPosition]
;FilterPosition = Lower

; =================== Generic ==================================

[Strings]
ManufacturerName = "osy"
DiskName = "Fake XGM Device Installation Disk"
DeviceName ="Fake XGM Device"
VhfService = "Virtual HID Framework (VHF) Driver"
VhfDesc    = "Kernel mode driver that implements the Virtual HID Framework (VHF)"

; non-localizable strings
SPSVCINST_ASSOCSERVICE = 0x00000000
SERVICE_KERNEL_DRIVER  = 1
SERVICE_DEMAND_START   = 3
SERVICE_ERROR_IGNORE   = 0
SERVICE_ERROR_NORMAL   = 1