RustDeskIddDriver icon indicating copy to clipboard operation
RustDeskIddDriver copied to clipboard

SwDeviceCreate returns 0x800700b7 when open an existed device

Open zhangwenjian opened this issue 2 years ago • 5 comments

MSDN: When a client app calls SwDeviceCreate for a software device that was previously marked for SwDeviceLifetimeParentPresent, SwDeviceCreate succeeds if there are no open software device handles for the device (only one handle can be open for a device). A client app can then regain control over a persistent software device for the purposes of updating properties and interfaces or changing the lifetime.

But after I set idd software device to SwDeviceLifetimeParentPresent, and then call SwDeviceCreate again with same createInfo, it returns 0x800700b7, which means object already exist. This result is not what MSDN said.

Even I can't remove the persist software device manually, it's always enumerated again after removed from device manager.

zhangwenjian avatar Jan 30 '23 07:01 zhangwenjian

Sorry, I'm not familiar with Windows drivers.

When a client app calls SwDeviceCreate for a software device that was previously marked for SwDeviceLifetimeParentPresent,

I can't even understand why SwDeviceCreate can be passed a Non-Null software device handle. I see phSwDevice is a pure output for SwDeviceCreate. SwDeviceSetLifetime requires a software device handle to set the lifetime.

fufesou avatar Feb 02 '23 01:02 fufesou

You can use SwDeviceSetLifetime to set the lifetime of the software device to SwDeviceLifetimeParentPresent.

Is it possible for you to call SwDeviceSetLifetime after SwDeviceCreate?

fufesou avatar Feb 02 '23 01:02 fufesou

SwDeviceCreate failed and the out of phSwDevice handle is null, but SwDeviceSetLifetime requires that handle. The software device is abandoned and can not recreated again, even can not be removed completely in windows safemode.

zhangwenjian avatar Feb 07 '23 07:02 zhangwenjian

https://github.com/fufesou/RustDeskIddDriver/releases/tag/v0.4

SwDeviceLifetimeParentPresent works fine for me.

I cannot understand why SwDeviceCreate returns 0x800700b7.

fufesou avatar Nov 07 '23 12:11 fufesou

https://github.com/microsoft/Windows-driver-samples/issues/858#issuecomment-1515080567

The most likely reason is that, as he said, another running process holds the SwDevice handle.

https://github.com/fufesou/RustDeskIddDriver/assets/13586388/960f34f0-f32b-4123-8530-679df42dce89

fufesou avatar Nov 07 '23 14:11 fufesou