wine-staging/patches/user32-rawinput-hid/0016-ntoskrnl-Implement-IoSetDevicePropertyData.patch

125 lines
4.7 KiB
Diff

From 2e8dd5065ba659d6f5f5c5bedadbec4e06a98a6a Mon Sep 17 00:00:00 2001
From: Arkadiusz Hiler <ahiler@codeweavers.com>
Date: Tue, 23 Feb 2021 14:41:58 +0200
Subject: [PATCH] ntoskrnl: Implement IoSetDevicePropertyData().
---
dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 1 +
dlls/ntoskrnl.exe/pnp.c | 51 +++++++++++++++++++++++++++++
include/ddk/wdm.h | 4 +++
3 files changed, 56 insertions(+)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
index 2e5e2e6e11b..4eb08faec2e 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
+++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
@@ -465,6 +465,7 @@
@ stdcall IoReuseIrp(ptr long)
@ stub IoSetCompletionRoutineEx
@ stdcall IoSetDeviceInterfaceState(ptr long)
+@ stdcall IoSetDevicePropertyData(ptr ptr long long long long ptr)
@ stub IoSetDeviceToVerify
@ stub IoSetFileOrigin
@ stub IoSetHardErrorOrVerifyDevice
diff --git a/dlls/ntoskrnl.exe/pnp.c b/dlls/ntoskrnl.exe/pnp.c
index 7994a8b85b9..0d5d0d721d4 100644
--- a/dlls/ntoskrnl.exe/pnp.c
+++ b/dlls/ntoskrnl.exe/pnp.c
@@ -38,6 +38,12 @@ DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
+static inline const char *debugstr_propkey( const DEVPROPKEY *id )
+{
+ if (!id) return "(null)";
+ return wine_dbg_sprintf( "{%s,%04x}", wine_dbgstr_guid( &id->fmtid ), id->pid );
+}
+
#define MAX_SERVICE_NAME 260
struct device_interface
@@ -770,6 +776,51 @@ NTSTATUS WINAPI IoSetDeviceInterfaceState( UNICODE_STRING *name, BOOLEAN enable
return ret;
}
+/***********************************************************************
+ * IoSetDevicePropertyData (NTOSKRNL.EXE.@)
+ */
+NTSTATUS WINAPI IoSetDevicePropertyData( DEVICE_OBJECT *device, const DEVPROPKEY *property_key, LCID lcid,
+ ULONG flags, DEVPROPTYPE type, ULONG size, void *data )
+{
+ SP_DEVINFO_DATA sp_device = {sizeof(sp_device)};
+ WCHAR device_instance_id[MAX_DEVICE_ID_LEN];
+ NTSTATUS status;
+ HDEVINFO set;
+
+ TRACE( "device %p, property_key %s, lcid %#x, flags %#x, type %#x, size %u, data %p.\n",
+ device, debugstr_propkey(property_key), lcid, flags, type, size, data );
+
+ /* flags is always treated as PLUGPLAY_PROPERTY_PERSISTENT starting with Win 8 / 2012 */
+
+ if (lcid != LOCALE_NEUTRAL) FIXME( "only LOCALE_NEUTRAL is supported\n" );
+
+ if ((status = get_device_instance_id( device, device_instance_id ))) return status;
+
+ if ((set = SetupDiCreateDeviceInfoList( &GUID_NULL, NULL )) == INVALID_HANDLE_VALUE)
+ {
+ ERR( "Failed to create device list, error %#x.\n", GetLastError() );
+ return GetLastError();
+ }
+
+ if (!SetupDiOpenDeviceInfoW( set, device_instance_id, NULL, 0, &sp_device ))
+ {
+ ERR( "Failed to open device, error %#x.\n", GetLastError() );
+ SetupDiDestroyDeviceInfoList( set );
+ return GetLastError();
+ }
+
+ if (!SetupDiSetDevicePropertyW( set, &sp_device, property_key, type, data, size, 0 ))
+ {
+ ERR( "Failed to set property, error %#x.\n", GetLastError() );
+ SetupDiDestroyDeviceInfoList( set );
+ return GetLastError();
+ }
+
+ SetupDiDestroyDeviceInfoList( set );
+
+ return STATUS_SUCCESS;
+}
+
/***********************************************************************
* IoRegisterDeviceInterface (NTOSKRNL.EXE.@)
*/
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index 3b9af7d52b2..3d0f810c2f0 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -21,6 +21,7 @@
#define _NTDDK_
#include <ntstatus.h>
+#include <devpropdef.h>
#ifdef _WIN64
#define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
@@ -1677,6 +1678,8 @@ void WINAPI ExReleaseResourceForThreadLite(ERESOURCE*,ERESOURCE_THREAD);
ULONG WINAPI ExSetTimerResolution(ULONG,BOOLEAN);
void WINAPI ExUnregisterCallback(void*);
+#define PLUGPLAY_PROPERTY_PERSISTENT 0x0001
+
void WINAPI IoAcquireCancelSpinLock(KIRQL*);
NTSTATUS WINAPI IoAcquireRemoveLockEx(IO_REMOVE_LOCK*,void*,const char*,ULONG, ULONG);
NTSTATUS WINAPI IoAllocateDriverObjectExtension(PDRIVER_OBJECT,PVOID,ULONG,PVOID*);
@@ -1724,6 +1727,7 @@ void WINAPI IoReleaseRemoveLockAndWaitEx(IO_REMOVE_LOCK*,void*,ULONG);
void WINAPI IoReleaseRemoveLockEx(IO_REMOVE_LOCK*,void*,ULONG);
void WINAPI IoReuseIrp(IRP*,NTSTATUS);
NTSTATUS WINAPI IoSetDeviceInterfaceState(UNICODE_STRING*,BOOLEAN);
+NTSTATUS WINAPI IoSetDevicePropertyData(DEVICE_OBJECT*,const DEVPROPKEY*,LCID,ULONG,DEVPROPTYPE,ULONG,void*);
NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT,ULONG);
void FASTCALL KeAcquireInStackQueuedSpinLockAtDpcLevel(KSPIN_LOCK*,KLOCK_QUEUE_HANDLE*);
--
2.30.2