Hi @hulirou ,
Sorry for the late response.
Thank you for sharing your code and details. I do not know much about this program, but I will help you the best I can. From my research:
The error 0xC0000010
means STATUS_INVALID_DEVICE_REQUEST, which usually happens when the device stack is not ready for the request. For VhfCreate
, this almost always means Vhf.sys (Virtual HID Framework) is not loaded as a lower filter in your device stack.
The reasons why this happens:
-
VhfCreate
needs Vhf.sys in the device stack. If your INF file does not addvhf
as a LowerFilters entry, the call will fail withSTATUS_INVALID_DEVICE_REQUEST
. - Your code placement (inside
EvtDriverDeviceAdd
) and report descriptor look correct, so the problem is likely configuration, not code.
You can try:
1. Update your INF file to include VHF as a lower filter.
Add this snippet in the .NT.HW
section of your INF file:
[HIDVHF_Inst.NT.HW]
AddReg = HIDVHF_Inst.NT.AddReg
[HIDVHF_Inst.NT.AddReg]
HKR,, "LowerFilters", 0x00010000, "vhf"
Where to place it: Here’s an example of the correct structure:
[Version]
Signature="$WINDOWS NT$"
Class=HIDClass
ClassGuid={745A17A0-74D3-11D0-B6FE-00A0C90F57DA}
Provider=%ManufacturerName%
DriverVer=09/16/2025,1.0.0.0
[Manufacturer]
%ManufacturerName%=Standard,NT$ARCH$
[Standard.NT$ARCH$]
%DeviceName%=HIDVHF_Inst, HID\MyVirtualDevice
[HIDVHF_Inst.NT]
CopyFiles=...
[HIDVHF_Inst.NT.HW]
AddReg=HIDVHF_Inst.NT.AddReg
[HIDVHF_Inst.NT.AddReg]
HKR,, "LowerFilters", 0x00010000, "vhf"
[Strings]
ManufacturerName="Your Company"
DeviceName="Virtual HID Device"
After updating, reinstall the driver and check the device stack (Device Manager → View → Devices by driver or use devcon stack
) to confirm vhf is present.
2. Link against vhfkm.lib
Make sure your project links to vhfkm.lib
(uncomment #pragma comment(lib, "vhfkm.lib")
or set it in project properties).
3. Keep VhfCreate
at PASSIVE_LEVEL (your current placement is correct).
4. Add cleanup logic:
VOID VhfSourceDeviceCleanup(_In_ WDFOBJECT DeviceObject)
{
PDEVICE_CONTEXT ctx = DeviceGetContext(DeviceObject);
if (ctx->VhfHandle != WDF_NO_HANDLE) {
VhfDelete(ctx->VhfHandle, TRUE);
}
}
I also managed to find some documents relating to this post, please take a look when you have the chance:
- Write a HID source driver using Virtual HID Framework (VHF)
- VhfCreate function
- VHF_CONFIG_INIT macro
- VHF_CONFIG structure
- NTSTATUS values (STATUS_INVALID_DEVICE_REQUEST)
You can change the language from English to Chinese by simply changing the "/en-us/" to "/zh-cn/" in the URL if you want. This is as many documents as I can find regarding this program.
If you find my suggestions helpful, please kindly accept this answer so others with the same issue can find help in your post. Thank you!