[PATCH] implement SetupDiOpenDeviceInterfaceRegKey

Pieter Palmers (none) ppalmers at ox-D820.
Thu Jul 10 12:22:04 CDT 2008


---
 dlls/setupapi/devinst.c     |  122 +++++++++++++++++++++++++++++++++++++++++--
 dlls/setupapi/setupapi.spec |    2 +-
 include/setupapi.h          |    2 +-
 3 files changed, 120 insertions(+), 6 deletions(-)

diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index af4f4d3..ec11148 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -87,6 +87,7 @@ static const WCHAR UpperFilters[] = {'U','p','p','e','r','F','i','l','t','e','r'
 static const WCHAR LowerFilters[] = {'L','o','w','e','r','F','i','l','t','e','r','s',0};
 static const WCHAR Phantom[] = {'P','h','a','n','t','o','m',0};
 static const WCHAR SymbolicLink[] = {'S','y','m','b','o','l','i','c','L','i','n','k',0};
+static const WCHAR DeviceParameters[] = {'D','e','v','i','c','e','P','a','r','a','m','e','t','e','r','s',0};
 
 /* is used to identify if a DeviceInfoSet pointer is
 valid or not */
@@ -539,12 +540,14 @@ static BOOL SETUPDI_AddDeviceToSet(struct DeviceInfoSet *set,
         SP_DEVINFO_DATA **dev)
 {
     BOOL ret = FALSE;
-    struct DeviceInfo *devInfo = SETUPDI_AllocateDeviceInfo(set, set->cDevices,
-            instanceId, phantom);
+    struct DeviceInfo *devInfo;
 
     TRACE("%p, %s, %d, %s, %d\n", set, debugstr_guid(guid), devInst,
             debugstr_w(instanceId), phantom);
 
+    devInfo = SETUPDI_AllocateDeviceInfo(set, set->cDevices,
+            instanceId, phantom);
+
     if (devInfo)
     {
         struct DeviceInstance *devInst =
@@ -1951,6 +1954,10 @@ HDEVINFO WINAPI SetupDiGetClassDevsExA(
     HDEVINFO ret;
     LPWSTR enumstrW = NULL, machineW = NULL;
 
+    TRACE("%s, %s, %p, %08x, %p, %s, %p\n", debugstr_guid(class),
+          debugstr_a(enumstr), parent, flags, deviceset, 
+          debugstr_a(machine), reserved);
+
     if (enumstr)
     {
         int len = MultiByteToWideChar(CP_ACP, 0, enumstr, -1, NULL, 0);
@@ -2104,12 +2111,14 @@ static void SETUPDI_EnumerateMatchingInterfaces(HDEVINFO DeviceInfoSet,
 static void SETUPDI_EnumerateInterfaces(HDEVINFO DeviceInfoSet,
         const GUID *interface, LPCWSTR enumstr, DWORD flags)
 {
-    HKEY interfacesKey = SetupDiOpenClassRegKeyExW(interface, KEY_READ,
-            DIOCR_INTERFACE, NULL, NULL);
+    HKEY interfacesKey;
 
     TRACE("%p, %s, %s, %08x\n", DeviceInfoSet, debugstr_guid(interface),
             debugstr_w(enumstr), flags);
 
+    interfacesKey = SetupDiOpenClassRegKeyExW(interface, KEY_READ,
+            DIOCR_INTERFACE, NULL, NULL);
+
     if (interfacesKey != INVALID_HANDLE_VALUE)
     {
         if (flags & DIGCF_ALLCLASSES)
@@ -3549,6 +3558,10 @@ HKEY WINAPI SetupDiOpenClassRegKeyExW(
     LPCWSTR lpKeyName;
     LONG l;
 
+    TRACE("%s, %08x, %08x, %s, %p\n", debugstr_guid(ClassGuid),
+          samDesired, Flags,
+          debugstr_w(MachineName), Reserved);
+
     if (MachineName != NULL)
     {
         FIXME("Remote access not supported yet!\n");
@@ -3616,6 +3629,107 @@ HKEY WINAPI SetupDiOpenClassRegKeyExW(
 }
 
 /***********************************************************************
+ *		SetupDiOpenDeviceInterfaceRegKey (SETUPAPI.@)
+ */
+HKEY WINAPI SetupDiOpenDeviceInterfaceRegKey(
+       HDEVINFO  DeviceInfoSet,
+       PSP_DEVICE_INTERFACE_DATA  DeviceInterfaceData,
+       DWORD  Reserved,
+       REGSAM  samDesired)
+{
+    struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
+    HKEY key = INVALID_HANDLE_VALUE, interfacesKey;
+    LONG l;
+
+    TRACE("%p %p %d %08x\n", DeviceInfoSet, DeviceInterfaceData, Reserved,
+            samDesired);
+
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
+            set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
+    {
+        SetLastError(ERROR_INVALID_HANDLE);
+        return INVALID_HANDLE_VALUE;
+    }
+    if (!DeviceInterfaceData ||
+            DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA) ||
+            !DeviceInterfaceData->Reserved)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return INVALID_HANDLE_VALUE;
+    }
+    if (!(l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, DeviceClasses, 0, NULL, 0,
+                    samDesired, NULL, &interfacesKey, NULL)))
+    {
+        HKEY parent;
+        WCHAR bracedGuidString[39];
+
+        SETUPDI_GuidToString(&DeviceInterfaceData->InterfaceClassGuid,
+                bracedGuidString);
+        if (!(l = RegCreateKeyExW(interfacesKey, bracedGuidString, 0, NULL, 0,
+                        samDesired, NULL, &parent, NULL)))
+        {
+            struct InterfaceInfo *ifaceInfo =
+                (struct InterfaceInfo *)DeviceInterfaceData->Reserved;
+            PWSTR instancePath = SETUPDI_GetInstancePath(ifaceInfo);
+            PWSTR interfKeyName = HeapAlloc(GetProcessHeap(), 0,
+                    (lstrlenW(ifaceInfo->symbolicLink) + 1) * sizeof(WCHAR));
+            HKEY interfKey;
+            WCHAR *ptr;
+            HKEY devKey;
+
+            lstrcpyW(interfKeyName, ifaceInfo->symbolicLink);
+            if (lstrlenW(ifaceInfo->symbolicLink) > 3)
+            {
+                interfKeyName[0] = '#';
+                interfKeyName[1] = '#';
+                interfKeyName[3] = '#';
+            }
+            ptr = strchrW(interfKeyName, '\\');
+            if (ptr)
+                *ptr = 0;
+            l = RegCreateKeyExW(parent, interfKeyName, 0, NULL, 0,
+                    samDesired, NULL, &interfKey, NULL);
+            if (!l)
+            {
+                struct DeviceInfo *devInfo =
+                        (struct DeviceInfo *)ifaceInfo->device->Reserved;
+				LONG l;
+
+				l = RegCreateKeyExW(interfKey, instancePath, 0, NULL, 0,
+						samDesired, NULL, &devKey, NULL);
+				if (l)
+				{
+					SetLastError(l);
+					key = INVALID_HANDLE_VALUE;
+				} else {
+					LONG l;
+					l = RegCreateKeyExW(devKey, DeviceParameters, 0, NULL, 0,
+							samDesired, NULL, &key, NULL);
+					if (l)
+					{
+						SetLastError(l);
+						key = INVALID_HANDLE_VALUE;
+					}
+					RegCloseKey(devKey);
+				}
+				RegCloseKey(interfKey);
+            }
+            else
+                SetLastError(l);
+            HeapFree(GetProcessHeap(), 0, interfKeyName);
+            HeapFree(GetProcessHeap(), 0, instancePath);
+            RegCloseKey(parent);
+        }
+        else
+            SetLastError(l);
+        RegCloseKey(interfacesKey);
+    }
+    else
+        SetLastError(l);
+    return key;
+}
+
+/***********************************************************************
  *		SetupDiOpenDeviceInterfaceW (SETUPAPI.@)
  */
 BOOL WINAPI SetupDiOpenDeviceInterfaceW(
diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec
index 5f31721..446f267 100644
--- a/dlls/setupapi/setupapi.spec
+++ b/dlls/setupapi/setupapi.spec
@@ -367,8 +367,8 @@
 @ stdcall SetupDiOpenDevRegKey(ptr ptr long long long long)
 @ stub SetupDiOpenDeviceInfoA
 @ stub SetupDiOpenDeviceInfoW
+@ stdcall SetupDiOpenDeviceInterfaceRegKey(ptr ptr long long)
 @ stdcall SetupDiOpenDeviceInterfaceA(ptr str long ptr)
-@ stub SetupDiOpenDeviceInterfaceRegKey
 @ stdcall SetupDiOpenDeviceInterfaceW(ptr wstr long ptr)
 @ stdcall SetupDiRegisterDeviceInfo(ptr ptr long ptr ptr ptr)
 @ stub SetupDiRemoveDevice
diff --git a/include/setupapi.h b/include/setupapi.h
index cb680d2..bcef71a 100644
--- a/include/setupapi.h
+++ b/include/setupapi.h
@@ -1594,7 +1594,7 @@ BOOL     WINAPI SetupDiOpenDeviceInfoW(HDEVINFO, PCWSTR, HWND, DWORD, PSP_DEVINF
 BOOL     WINAPI SetupDiOpenDeviceInterfaceA(HDEVINFO, PCSTR, DWORD, PSP_DEVICE_INTERFACE_DATA);
 BOOL     WINAPI SetupDiOpenDeviceInterfaceW(HDEVINFO, PCWSTR, DWORD, PSP_DEVICE_INTERFACE_DATA);
 #define         SetupDiOpenDeviceInterface WINELIB_NAME_AW(SetupDiOpenDeviceInterface)
-BOOL     WINAPI SetupDiOpenDeviceInterfaceRegKey(HDEVINFO, PSP_DEVINFO_DATA, DWORD, REGSAM);
+HKEY     WINAPI SetupDiOpenDeviceInterfaceRegKey(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, DWORD, REGSAM);
 HKEY     WINAPI SetupDiOpenDevRegKey(HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, DWORD, REGSAM);
 BOOL     WINAPI SetupDiRegisterCoDeviceInstallers(HDEVINFO, PSP_DEVINFO_DATA);
 BOOL     WINAPI SetupDiRegisterDeviceInfo(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PSP_DETSIG_CMPPROC, PVOID, PSP_DEVINFO_DATA);
-- 
1.5.2.5


--------------090006000403090706050301--



More information about the wine-patches mailing list