util/setupapi.c: Avoid clashes with real devices

We're going to need this for HID emulation, since unlike all the
other device classes regular PCs do actually have a bunch of HIDs
attached to them that we're going to want to access from within
the hooked process.
This commit is contained in:
Tau 2019-02-27 21:54:14 -05:00
parent 243914f23a
commit 65d24c1ada

View File

@ -9,6 +9,7 @@
#include "hook/table.h"
#include "util/dprintf.h"
#include "util/setupapi.h"
struct setupapi_class {
@ -193,8 +194,13 @@ static BOOL WINAPI my_SetupDiEnumDeviceInterfaces(
if ( DeviceInfoSet == INVALID_HANDLE_VALUE ||
DeviceInterfaceData == NULL ||
DeviceInterfaceData->cbSize != sizeof(*DeviceInterfaceData) ||
MemberIndex != 0) {
DeviceInterfaceData->cbSize != sizeof(*DeviceInterfaceData)) {
goto pass;
}
if (MemberIndex > 0) {
MemberIndex--;
goto pass;
}
@ -206,6 +212,10 @@ static BOOL WINAPI my_SetupDiEnumDeviceInterfaces(
if (DeviceInfoSet == setupapi_classes[i].cur_handle) {
class_ = &setupapi_classes[i];
dprintf("SetupAPI: Interface {%08lx-...} -> Device node %S\n",
class_->guid->Data1,
class_->path);
memcpy( &DeviceInterfaceData->InterfaceClassGuid,
class_->guid,
sizeof(GUID));
@ -256,7 +266,8 @@ static BOOL WINAPI my_SetupDiGetDeviceInterfaceDetailW(
for ( i = 0, match = false ;
i < setupapi_nclasses && !match ;
i++) {
if (DeviceInfoSet == setupapi_classes[i].cur_handle) {
if ( DeviceInfoSet == setupapi_classes[i].cur_handle &&
DeviceInterfaceData->Reserved == (ULONG_PTR) setupapi_classes[i].path) {
match = true;
}
}