Skip to content

Commit

Permalink
[WiP] Implement SetupDiGetDeviceInterfacePropertyW for DEVPKEY_Device…
Browse files Browse the repository at this point in the history
…_InstanceId

Fixes a crash in Marvel's Spider-Man
  • Loading branch information
ClearlyClaire committed Mar 17, 2024
1 parent 560abfd commit 1603b22
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
49 changes: 49 additions & 0 deletions dlls/setupapi/devinst.c
Original file line number Diff line number Diff line change
Expand Up @@ -3049,6 +3049,55 @@ BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
return TRUE;
}

/***********************************************************************
* SetupDiGetDeviceInterfacePropertyW (SETUPAPI.@)
*/
BOOL WINAPI SetupDiGetDeviceInterfacePropertyW(HDEVINFO devinfo, SP_DEVICE_INTERFACE_DATA *iface_data,
const DEVPROPKEY *prop_key, DEVPROPTYPE *prop_type, BYTE *prop_buff,
DWORD prop_buff_size, DWORD *required_size, DWORD flags) {

// TODO: should probably use DEVPKEY_Device_InstanceId
static const DEVPROPKEY device_instanceid_key = {
{0x78c34fc8, 0x104a, 0x4aca, {0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57}}, 256
};

TRACE("%p, %p, (%s, %04lx), %p, %p, %ld, %p, %#lx\n", devinfo, iface_data, wine_dbgstr_guid(&prop_key->fmtid), prop_key->pid, prop_type, prop_buff, prop_buff_size,
required_size, flags);

// Special case for InstanceID
if (IsEqualDevPropKey(*prop_key, device_instanceid_key)) {
struct device *device;
struct device_iface *iface;

if (!(iface = get_device_iface(devinfo, iface_data)))
return FALSE;

if (!(device = iface->device))
return FALSE;

TRACE("instance ID: %s\n", debugstr_w(device->instanceId));
if (prop_buff_size < lstrlenW(device->instanceId) + 1)
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
if (required_size)
*required_size = lstrlenW(device->instanceId) + 1;
return FALSE;
}

lstrcpyW((WCHAR *) prop_buff, device->instanceId);
if (required_size)
*required_size = lstrlenW(device->instanceId) + 1;
*prop_type = DEVPROP_TYPE_STRING;

return TRUE;
} else {
// TODO: maybe fall back as SetupDiGetDevicePropertyW?
FIXME("stub\n");
}

return FALSE;
}

/***********************************************************************
* SetupDiGetDeviceInterfaceDetailA (SETUPAPI.@)
*/
Expand Down
1 change: 1 addition & 0 deletions dlls/setupapi/setupapi.spec
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@
@ stub SetupDiGetDeviceInterfaceAlias
@ stdcall SetupDiGetDeviceInterfaceDetailA(long ptr ptr long ptr ptr)
@ stdcall SetupDiGetDeviceInterfaceDetailW(long ptr ptr long ptr ptr)
@ stdcall SetupDiGetDeviceInterfacePropertyW(ptr ptr ptr ptr ptr long ptr long)
@ stdcall SetupDiGetDevicePropertyW(ptr ptr ptr ptr ptr long ptr long)
@ stdcall SetupDiGetDeviceRegistryPropertyA(long ptr long ptr ptr long ptr)
@ stdcall SetupDiGetDeviceRegistryPropertyW(long ptr long ptr ptr long ptr)
Expand Down

0 comments on commit 1603b22

Please sign in to comment.