Skip to content

Commit 12e2988

Browse files
committed
[WiP] Implement SetupDiGetDeviceInterfacePropertyW for DEVPKEY_Device_InstanceId
Fixes a crash in Marvel's Spider-Man
1 parent 505bac7 commit 12e2988

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
@@ -3050,6 +3050,55 @@ BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
30503050
return TRUE;
30513051
}
30523052

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

dlls/setupapi/setupapi.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@
347347
@ stub SetupDiGetDeviceInterfaceAlias
348348
@ stdcall SetupDiGetDeviceInterfaceDetailA(long ptr ptr long ptr ptr)
349349
@ stdcall SetupDiGetDeviceInterfaceDetailW(long ptr ptr long ptr ptr)
350+
@ stdcall SetupDiGetDeviceInterfacePropertyW(ptr ptr ptr ptr ptr long ptr long)
350351
@ stdcall SetupDiGetDevicePropertyW(ptr ptr ptr ptr ptr long ptr long)
351352
@ stdcall SetupDiGetDeviceRegistryPropertyA(long ptr long ptr ptr long ptr)
352353
@ stdcall SetupDiGetDeviceRegistryPropertyW(long ptr long ptr ptr long ptr)

0 commit comments

Comments
 (0)