Skip to content

Commit 5824df2

Browse files
committed
[WiP] Implement SetupDiGetDeviceInterfacePropertyW for DEVPKEY_Device_InstanceId
Fixes a crash in Marvel's Spider-Man
1 parent a1915f1 commit 5824df2

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

dlls/setupapi/devinst.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,6 +3049,55 @@ BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
30493049
return TRUE;
30503050
}
30513051

3052+
/***********************************************************************
3053+
* SetupDiGetDeviceInterfacePropertyW (SETUPAPI.@)
3054+
*/
3055+
BOOL WINAPI SetupDiGetDeviceInterfacePropertyW(HDEVINFO devinfo, SP_DEVICE_INTERFACE_DATA *iface_data,
3056+
const DEVPROPKEY *prop_key, DEVPROPTYPE *prop_type, BYTE *prop_buff,
3057+
DWORD prop_buff_size, DWORD *required_size, DWORD flags) {
3058+
3059+
// TODO: should probably use DEVPKEY_Device_InstanceId
3060+
static const DEVPROPKEY device_instanceid_key = {
3061+
{0x78c34fc8, 0x104a, 0x4aca, {0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57}}, 256
3062+
};
3063+
3064+
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,
3065+
required_size, flags);
3066+
3067+
// Special case for InstanceID
3068+
if (IsEqualDevPropKey(*prop_key, device_instanceid_key)) {
3069+
struct device *device;
3070+
struct device_iface *iface;
3071+
3072+
if (!(iface = get_device_iface(devinfo, iface_data)))
3073+
return FALSE;
3074+
3075+
if (!(device = iface->device))
3076+
return FALSE;
3077+
3078+
TRACE("instance ID: %s\n", debugstr_w(device->instanceId));
3079+
if (prop_buff_size < lstrlenW(device->instanceId) + 1)
3080+
{
3081+
SetLastError(ERROR_INSUFFICIENT_BUFFER);
3082+
if (required_size)
3083+
*required_size = lstrlenW(device->instanceId) + 1;
3084+
return FALSE;
3085+
}
3086+
3087+
lstrcpyW((WCHAR *) prop_buff, device->instanceId);
3088+
if (required_size)
3089+
*required_size = lstrlenW(device->instanceId) + 1;
3090+
*prop_type = DEVPROP_TYPE_STRING;
3091+
3092+
return TRUE;
3093+
} else {
3094+
// TODO: maybe fall back as SetupDiGetDevicePropertyW?
3095+
FIXME("stub\n");
3096+
}
3097+
3098+
return FALSE;
3099+
}
3100+
30523101
/***********************************************************************
30533102
* SetupDiGetDeviceInterfaceDetailA (SETUPAPI.@)
30543103
*/

dlls/setupapi/setupapi.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@
349349
@ stub SetupDiGetDeviceInterfaceAlias
350350
@ stdcall SetupDiGetDeviceInterfaceDetailA(long ptr ptr long ptr ptr)
351351
@ stdcall SetupDiGetDeviceInterfaceDetailW(long ptr ptr long ptr ptr)
352+
@ stdcall SetupDiGetDeviceInterfacePropertyW(ptr ptr ptr ptr ptr long ptr long)
352353
@ stdcall SetupDiGetDevicePropertyW(ptr ptr ptr ptr ptr long ptr long)
353354
@ stdcall SetupDiGetDeviceRegistryPropertyA(long ptr long ptr ptr long ptr)
354355
@ stdcall SetupDiGetDeviceRegistryPropertyW(long ptr long ptr ptr long ptr)

0 commit comments

Comments
 (0)