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
1 changed files with 14 additions and 3 deletions

View File

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