[ros-diffs] [hpoussin] 32265: Simplify SetupDiSetDeviceRegistryPropertyW/SetupDiGetDeviceRegistryPropertyW Misc cleanup

hpoussin at svn.reactos.org hpoussin at svn.reactos.org
Sun Feb 10 15:37:20 CET 2008


Author: hpoussin
Date: Sun Feb 10 17:37:19 2008
New Revision: 32265

URL: http://svn.reactos.org/svn/reactos?rev=32265&view=rev
Log:
Simplify SetupDiSetDeviceRegistryPropertyW/SetupDiGetDeviceRegistryPropertyW
Misc cleanup

Modified:
    trunk/reactos/dll/win32/setupapi/devinst.c
    trunk/reactos/dll/win32/setupapi/misc.c
    trunk/reactos/dll/win32/setupapi/parser.c
    trunk/reactos/dll/win32/setupapi/queue.c
    trunk/reactos/dll/win32/setupapi/setupapi_private.h

Modified: trunk/reactos/dll/win32/setupapi/devinst.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/devinst.c?rev=32265&r1=32264&r2=32265&view=diff
==============================================================================
--- trunk/reactos/dll/win32/setupapi/devinst.c (original)
+++ trunk/reactos/dll/win32/setupapi/devinst.c Sun Feb 10 17:37:19 2008
@@ -1235,7 +1235,7 @@
     {
         MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
         if (MachineNameW == NULL)
-            return (HDEVINFO)INVALID_HANDLE_VALUE;
+            return INVALID_HANDLE_VALUE;
     }
 
     hDevInfo = SetupDiCreateDeviceInfoListExW(ClassGuid, hwndParent,
@@ -1273,7 +1273,7 @@
     DWORD size = FIELD_OFFSET(struct DeviceInfoSet, szData);
     DWORD rc;
     CONFIGRET cr;
-    HDEVINFO ret = (HDEVINFO)INVALID_HANDLE_VALUE;
+    HDEVINFO ret = INVALID_HANDLE_VALUE;
 
     TRACE("%s %p %s %p\n", debugstr_guid(ClassGuid), hwndParent,
       debugstr_w(MachineName), Reserved);
@@ -1292,14 +1292,14 @@
     if (Reserved != NULL)
     {
         SetLastError(ERROR_INVALID_PARAMETER);
-        return (HDEVINFO)INVALID_HANDLE_VALUE;
+        return INVALID_HANDLE_VALUE;
     }
 
     list = MyMalloc(size);
     if (!list)
     {
         SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-        return (HDEVINFO)INVALID_HANDLE_VALUE;
+        return INVALID_HANDLE_VALUE;
     }
     ZeroMemory(list, FIELD_OFFSET(struct DeviceInfoSet, szData));
 
@@ -1413,7 +1413,7 @@
     TRACE("%p %p %lu %lu %lu %p %s\n", DeviceInfoSet, DeviceInfoData, Scope,
             HwProfile, KeyType, InfHandle, debugstr_w(InfSectionName));
 
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
     {
         SetLastError(ERROR_INVALID_HANDLE);
         return INVALID_HANDLE_VALUE;
@@ -1680,7 +1680,7 @@
         SetLastError(ERROR_INVALID_DEVINST_NAME);
         return FALSE;
     }
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
     {
         SetLastError(ERROR_INVALID_HANDLE);
         return FALSE;
@@ -1784,7 +1784,7 @@
     TRACE("%p %p %08x %p %p %p\n", DeviceInfoSet, DeviceInfoData, Flags,
             CompareProc, CompareContext, DupDeviceInfoData);
 
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
     {
         SetLastError(ERROR_INVALID_HANDLE);
         return FALSE;
@@ -1823,7 +1823,7 @@
         SetLastError(ERROR_INVALID_PARAMETER);
         return FALSE;
     }
-    if (devinfo && devinfo != (HDEVINFO)INVALID_HANDLE_VALUE)
+    if (devinfo && devinfo != INVALID_HANDLE_VALUE)
     {
         struct DeviceInfoSet *list = (struct DeviceInfoSet *)devinfo;
         if (list->magic == SETUP_DEVICE_INFO_SET_MAGIC)
@@ -1887,7 +1887,7 @@
                                 &size);
     if (!ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
         return FALSE;
-    instanceId = MyMalloc(DeviceInstanceIdSize * sizeof(WCHAR));
+    instanceId = MyMalloc(size * sizeof(WCHAR));
     if (instanceId)
     {
         ret = SetupDiGetDeviceInstanceIdW(DeviceInfoSet,
@@ -2275,7 +2275,7 @@
         enumstrW = MultiByteToUnicode(enumstr, CP_ACP);
         if (!enumstrW)
         {
-            ret = (HDEVINFO)INVALID_HANDLE_VALUE;
+            ret = INVALID_HANDLE_VALUE;
             goto end;
         }
     }
@@ -2285,7 +2285,7 @@
         if (!machineW)
         {
             MyFree(enumstrW);
-            ret = (HDEVINFO)INVALID_HANDLE_VALUE;
+            ret = INVALID_HANDLE_VALUE;
             goto end;
         }
     }
@@ -2446,7 +2446,7 @@
 
     TRACE("%p %p\n", DeviceInfoSet, DevInfoData);
 
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
     {
         SetLastError(ERROR_INVALID_HANDLE);
         return FALSE;
@@ -2487,7 +2487,7 @@
 
     TRACE("%p %p\n", DeviceInfoSet, DevInfoData);
 
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
     {
         SetLastError(ERROR_INVALID_HANDLE);
         return FALSE;
@@ -2562,7 +2562,7 @@
             debugstr_guid(InterfaceClassGuid), debugstr_w(ReferenceString),
             CreationFlags, DeviceInterfaceData);
 
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
     {
         SetLastError(ERROR_INVALID_HANDLE);
         return FALSE;
@@ -2640,7 +2640,7 @@
     TRACE("%p %p %d %08x %p %p\n", DeviceInfoSet, DeviceInterfaceData, Reserved,
             samDesired, InfHandle, InfSectionName);
 
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE ||
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
             set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
     {
         SetLastError(ERROR_INVALID_HANDLE);
@@ -2678,7 +2678,7 @@
 
     TRACE("%p %p %d\n", DeviceInfoSet, DeviceInterfaceData, Reserved);
 
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE ||
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
             set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
     {
         SetLastError(ERROR_INVALID_HANDLE);
@@ -2733,7 +2733,7 @@
     TRACE("%p, %p, %s, %d, %p\n", DeviceInfoSet, DeviceInfoData,
      debugstr_guid(InterfaceClassGuid), MemberIndex, DeviceInterfaceData);
 
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE ||
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
             set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
     {
         SetLastError(ERROR_INVALID_HANDLE);
@@ -2838,7 +2838,7 @@
     BOOL ret = FALSE;
 
     TRACE("%p\n", devinfo);
-    if (devinfo && devinfo != (HDEVINFO)INVALID_HANDLE_VALUE)
+    if (devinfo && devinfo != INVALID_HANDLE_VALUE)
     {
         struct DeviceInfoSet *list = (struct DeviceInfoSet *)devinfo;
 
@@ -2874,7 +2874,7 @@
      DeviceInterfaceData, DeviceInterfaceDetailData,
      DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData);
 
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE ||
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
             set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
     {
         SetLastError(ERROR_INVALID_HANDLE);
@@ -2960,7 +2960,7 @@
      DeviceInterfaceData, DeviceInterfaceDetailData,
      DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData);
 
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE ||
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
             set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
     {
         SetLastError(ERROR_INVALID_HANDLE);
@@ -3024,6 +3024,51 @@
     return ret;
 }
 
+struct PropertyMapEntry
+{
+    DWORD   regType;
+    LPCSTR  nameA;
+    LPCWSTR nameW;
+};
+
+static struct PropertyMapEntry PropertyMap[] = {
+    { REG_SZ, "DeviceDesc", REGSTR_VAL_DEVDESC },
+    { REG_MULTI_SZ, "HardwareId", REGSTR_VAL_HARDWAREID },
+    { REG_MULTI_SZ, "CompatibleIDs", REGSTR_VAL_COMPATIBLEIDS },
+    { 0, NULL, NULL }, /* SPDRP_UNUSED0 */
+    { REG_SZ, "Service", REGSTR_VAL_SERVICE },
+    { 0, NULL, NULL }, /* SPDRP_UNUSED1 */
+    { 0, NULL, NULL }, /* SPDRP_UNUSED2 */
+    { REG_SZ, "Class", REGSTR_VAL_CLASS },
+    { REG_SZ, "ClassGUID", REGSTR_VAL_CLASSGUID },
+    { REG_SZ, "Driver", REGSTR_VAL_DRIVER },
+    { REG_DWORD, "ConfigFlags", REGSTR_VAL_CONFIGFLAGS },
+    { REG_SZ, "Mfg", REGSTR_VAL_MFG },
+    { REG_SZ, "FriendlyName", REGSTR_VAL_FRIENDLYNAME },
+    { REG_SZ, "LocationInformation", REGSTR_VAL_LOCATION_INFORMATION },
+    { 0, NULL, NULL }, /* SPDRP_PHYSICAL_DEVICE_OBJECT_NAME */
+    { REG_DWORD, "Capabilities", REGSTR_VAL_CAPABILITIES },
+    { REG_DWORD, "UINumber", REGSTR_VAL_UI_NUMBER },
+    { REG_MULTI_SZ, "UpperFilters", REGSTR_VAL_UPPERFILTERS },
+    { REG_MULTI_SZ, "LowerFilters", REGSTR_VAL_LOWERFILTERS },
+    { 0, NULL, NULL }, /* SPDRP_BUSTYPEGUID */
+    { 0, NULL, NULL }, /* SPDRP_LEGACYBUSTYPE */
+    { 0, NULL, NULL }, /* SPDRP_BUSNUMBER */
+    { 0, NULL, NULL }, /* SPDRP_ENUMERATOR_NAME */
+    { REG_BINARY, "Security", REGSTR_SECURITY },
+    { 0, NULL, NULL }, /* SPDRP_SECURITY_SDS */
+    { 0, NULL, NULL }, /* SPDRP_DEVTYPE */
+    { 0, NULL, NULL }, /* SPDRP_EXCLUSIVE */
+    { 0, NULL, NULL }, /* SPDRP_CHARACTERISTICS */
+    { 0, NULL, NULL }, /* SPDRP_ADDRESS */
+    { REG_SZ, "UINumberDescFormat", REGSTR_UI_NUMBER_DESC_FORMAT },
+    { 0, NULL, NULL }, /* SPDRP_DEVICE_POWER_DATA */
+    { 0, NULL, NULL }, /* SPDRP_REMOVAL_POLICY */
+    { 0, NULL, NULL }, /* SPDRP_REMOVAL_POLICY_HW_DEFAULT */
+    { 0, NULL, NULL }, /* SPDRP_REMOVAL_POLICY_OVERRIDE */
+    { 0, NULL, NULL }, /* SPDRP_INSTALL_STATE */
+};
+
 /***********************************************************************
  *		SetupDiGetDeviceRegistryPropertyA (SETUPAPI.@)
  */
@@ -3122,8 +3167,6 @@
         DWORD   PropertyBufferSize,
         PDWORD  RequiredSize)
 {
-    HKEY hEnumKey, hKey;
-    DWORD rc;
     BOOL ret = FALSE;
     struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
     struct DeviceInfo *devInfo;
@@ -3148,171 +3191,56 @@
         SetLastError(ERROR_INVALID_PARAMETER);
         return FALSE;
     }
-    if (Property >= SPDRP_MAXIMUM_PROPERTY)
-    {
-        SetLastError(ERROR_INVALID_PARAMETER);
-        return FALSE;
-    }
-    
     devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
-    {
-        switch (Property)
-        {
-            case SPDRP_CAPABILITIES:
-            case SPDRP_CLASS:
-            case SPDRP_CLASSGUID:
-            case SPDRP_COMPATIBLEIDS:
-            case SPDRP_CONFIGFLAGS:
-            case SPDRP_DEVICEDESC:
-            case SPDRP_DRIVER:
-            case SPDRP_FRIENDLYNAME:
-            case SPDRP_HARDWAREID:
-            case SPDRP_LOCATION_INFORMATION:
-            case SPDRP_LOWERFILTERS:
-            case SPDRP_MFG:
-            case SPDRP_SECURITY:
-            case SPDRP_SERVICE:
-            case SPDRP_UI_NUMBER:
-            case SPDRP_UI_NUMBER_DESC_FORMAT:
-            case SPDRP_UPPERFILTERS:
-            {
-                LPCWSTR RegistryPropertyName;
-                DWORD BufferSize;
-
-                switch (Property)
-                {
-                    case SPDRP_CAPABILITIES:
-                        RegistryPropertyName = REGSTR_VAL_CAPABILITIES; break;
-                    case SPDRP_CLASS:
-                        RegistryPropertyName = REGSTR_VAL_CLASS; break;
-                    case SPDRP_CLASSGUID:
-                        RegistryPropertyName = REGSTR_VAL_CLASSGUID; break;
-                    case SPDRP_COMPATIBLEIDS:
-                        RegistryPropertyName = REGSTR_VAL_COMPATIBLEIDS; break;
-                    case SPDRP_CONFIGFLAGS:
-                        RegistryPropertyName = REGSTR_VAL_CONFIGFLAGS; break;
-                    case SPDRP_DEVICEDESC:
-                        RegistryPropertyName = REGSTR_VAL_DEVDESC; break;
-                    case SPDRP_DRIVER:
-                        RegistryPropertyName = REGSTR_VAL_DRIVER; break;
-                    case SPDRP_FRIENDLYNAME:
-                        RegistryPropertyName = REGSTR_VAL_FRIENDLYNAME; break;
-                    case SPDRP_HARDWAREID:
-                        RegistryPropertyName = REGSTR_VAL_HARDWAREID; break;
-                    case SPDRP_LOCATION_INFORMATION:
-                        RegistryPropertyName = REGSTR_VAL_LOCATION_INFORMATION; break;
-                    case SPDRP_LOWERFILTERS:
-                        RegistryPropertyName = REGSTR_VAL_LOWERFILTERS; break;
-                    case SPDRP_MFG:
-                        RegistryPropertyName = REGSTR_VAL_MFG; break;
-                    case SPDRP_SECURITY:
-                        RegistryPropertyName = REGSTR_SECURITY; break;
-                    case SPDRP_SERVICE:
-                        RegistryPropertyName = REGSTR_VAL_SERVICE; break;
-                    case SPDRP_UI_NUMBER:
-                        RegistryPropertyName = REGSTR_VAL_UI_NUMBER; break;
-                    case SPDRP_UI_NUMBER_DESC_FORMAT:
-                        RegistryPropertyName = REGSTR_UI_NUMBER_DESC_FORMAT; break;
-                    case SPDRP_UPPERFILTERS:
-                        RegistryPropertyName = REGSTR_VAL_UPPERFILTERS; break;
-                    default:
-                        /* Should not happen */
-                        RegistryPropertyName = NULL; break;
-                }
-
-                /* Open registry key name */
-                rc = RegOpenKeyExW(
-                    set->HKLM,
-                    REGSTR_PATH_SYSTEMENUM,
-                    0, /* Options */
-                    0,
-                    &hEnumKey);
-                if (rc != ERROR_SUCCESS)
-                {
-                    SetLastError(rc);
-                    break;
-                }
-                rc = RegOpenKeyExW(
-                    hEnumKey,
-                    devInfo->Data,
-                    0, /* Options */
-                    KEY_QUERY_VALUE,
-                    &hKey);
-                RegCloseKey(hEnumKey);
-                if (rc != ERROR_SUCCESS)
-                {
-                    SetLastError(rc);
-                    break;
-                }
-                /* Read registry entry */
-                BufferSize = PropertyBufferSize;
-                rc = RegQueryValueExW(
-                    hKey,
-                    RegistryPropertyName,
-                    NULL, /* Reserved */
-                    PropertyRegDataType,
-                    PropertyBuffer,
-                    &BufferSize);
-                if (RequiredSize)
-                    *RequiredSize = BufferSize;
-                switch(rc) {
-                    case ERROR_SUCCESS:
-                        if (PropertyBuffer != NULL || BufferSize == 0)
-                            ret = TRUE;
-                        else
-                            SetLastError(ERROR_INSUFFICIENT_BUFFER);
-                        break;
-                    case ERROR_MORE_DATA:
-                        SetLastError(ERROR_INSUFFICIENT_BUFFER);
-                        break;
-                    default:
-                        SetLastError(rc);
-                }
-                RegCloseKey(hKey);
-                break;
-            }
-
-            case SPDRP_PHYSICAL_DEVICE_OBJECT_NAME:
-            {
-                DWORD required = (strlenW(devInfo->Data) + 1) * sizeof(WCHAR);
-
-                if (PropertyRegDataType)
-                    *PropertyRegDataType = REG_SZ;
-                if (RequiredSize)
-                    *RequiredSize = required;
-                if (PropertyBufferSize >= required)
-                {
-                    strcpyW((LPWSTR)PropertyBuffer, devInfo->Data);
+    if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
+        && PropertyMap[Property].nameW)
+    {
+        DWORD size = PropertyBufferSize;
+        HKEY hKey;
+        LONG l;
+        hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_QUERY_VALUE);
+        if (hKey == INVALID_HANDLE_VALUE)
+            return FALSE;
+        l = RegQueryValueExW(hKey, PropertyMap[Property].nameW,
+                NULL, PropertyRegDataType, PropertyBuffer, &size);
+        RegCloseKey(hKey);
+
+        if (RequiredSize)
+            *RequiredSize = size;
+        switch(l) {
+            case ERROR_SUCCESS:
+                if (PropertyBuffer != NULL || size == 0)
                     ret = TRUE;
-                }
                 else
                     SetLastError(ERROR_INSUFFICIENT_BUFFER);
                 break;
-            }
-
-            /*case SPDRP_BUSTYPEGUID:
-            case SPDRP_LEGACYBUSTYPE:
-            case SPDRP_BUSNUMBER:
-            case SPDRP_ENUMERATOR_NAME:
-            case SPDRP_SECURITY_SDS:
-            case SPDRP_DEVTYPE:
-            case SPDRP_EXCLUSIVE:
-            case SPDRP_CHARACTERISTICS:
-            case SPDRP_ADDRESS:
-            case SPDRP_DEVICE_POWER_DATA:*/
-#if (WINVER >= 0x501)
-            /*case SPDRP_REMOVAL_POLICY:
-            case SPDRP_REMOVAL_POLICY_HW_DEFAULT:
-            case SPDRP_REMOVAL_POLICY_OVERRIDE:
-            case SPDRP_INSTALL_STATE:*/
-#endif
-
+            case ERROR_MORE_DATA:
+                SetLastError(ERROR_INSUFFICIENT_BUFFER);
+                break;
             default:
-            {
-                ERR("Property 0x%lx not implemented\n", Property);
-                SetLastError(ERROR_NOT_SUPPORTED);
-            }
-        }
+                SetLastError(l);
+        }
+    }
+    else if (Property == SPDRP_PHYSICAL_DEVICE_OBJECT_NAME)
+    {
+        DWORD required = (strlenW(devInfo->Data) + 1) * sizeof(WCHAR);
+
+        if (PropertyRegDataType)
+            *PropertyRegDataType = REG_SZ;
+        if (RequiredSize)
+            *RequiredSize = required;
+        if (PropertyBufferSize >= required)
+        {
+            strcpyW((LPWSTR)PropertyBuffer, devInfo->Data);
+            ret = TRUE;
+        }
+        else
+            SetLastError(ERROR_INSUFFICIENT_BUFFER);
+    }
+    else
+    {
+        ERR("Property 0x%lx not implemented\n", Property);
+        SetLastError(ERROR_NOT_SUPPORTED);
     }
     return ret;
 }
@@ -3388,107 +3316,29 @@
         SetLastError(ERROR_INVALID_PARAMETER);
         return FALSE;
     }
-
-    switch (Property)
-    {
-        case SPDRP_COMPATIBLEIDS:
-        case SPDRP_CONFIGFLAGS:
-        case SPDRP_FRIENDLYNAME:
-        case SPDRP_HARDWAREID:
-        case SPDRP_LOCATION_INFORMATION:
-        case SPDRP_LOWERFILTERS:
-        case SPDRP_SECURITY:
-        case SPDRP_SERVICE:
-        case SPDRP_UI_NUMBER_DESC_FORMAT:
-        case SPDRP_UPPERFILTERS:
-        {
-            LPCWSTR RegistryPropertyName;
-            DWORD RegistryDataType;
-            HKEY hKey;
-            LONG rc;
-
-            switch (Property)
-            {
-                case SPDRP_COMPATIBLEIDS:
-                    RegistryPropertyName = REGSTR_VAL_COMPATIBLEIDS;
-                    RegistryDataType = REG_MULTI_SZ;
-                    break;
-                case SPDRP_CONFIGFLAGS:
-                    RegistryPropertyName = REGSTR_VAL_CONFIGFLAGS;
-                    RegistryDataType = REG_DWORD;
-                    break;
-                case SPDRP_FRIENDLYNAME:
-                    RegistryPropertyName = REGSTR_VAL_FRIENDLYNAME;
-                    RegistryDataType = REG_SZ;
-                    break;
-                case SPDRP_HARDWAREID:
-                    RegistryPropertyName = REGSTR_VAL_HARDWAREID;
-                    RegistryDataType = REG_MULTI_SZ;
-                    break;
-                case SPDRP_LOCATION_INFORMATION:
-                    RegistryPropertyName = REGSTR_VAL_LOCATION_INFORMATION;
-                    RegistryDataType = REG_SZ;
-                    break;
-                case SPDRP_LOWERFILTERS:
-                    RegistryPropertyName = REGSTR_VAL_LOWERFILTERS;
-                    RegistryDataType = REG_MULTI_SZ;
-                    break;
-                case SPDRP_SECURITY:
-                    RegistryPropertyName = REGSTR_SECURITY;
-                    RegistryDataType = REG_BINARY;
-                    break;
-                case SPDRP_SERVICE:
-                    RegistryPropertyName = REGSTR_VAL_SERVICE;
-                    RegistryDataType = REG_SZ;
-                    break;
-                case SPDRP_UI_NUMBER_DESC_FORMAT:
-                    RegistryPropertyName = REGSTR_UI_NUMBER_DESC_FORMAT;
-                    RegistryDataType = REG_SZ;
-                    break;
-                case SPDRP_UPPERFILTERS:
-                    RegistryPropertyName = REGSTR_VAL_UPPERFILTERS;
-                    RegistryDataType = REG_MULTI_SZ;
-                    break;
-                default:
-                    /* Should not happen */
-                    RegistryPropertyName = NULL;
-                    RegistryDataType = REG_BINARY;
-                    break;
-            }
-            /* Open device registry key */
-            hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_SET_VALUE);
-            if (hKey != INVALID_HANDLE_VALUE)
-            {
-                /* Write new data */
-                rc = RegSetValueExW(
-                    hKey,
-                    RegistryPropertyName,
-                    0, /* Reserved */
-                    RegistryDataType,
-                    PropertyBuffer,
-                    PropertyBufferSize);
-                if (rc == ERROR_SUCCESS)
-                    ret = TRUE;
-                else
-                    SetLastError(rc);
-                RegCloseKey(hKey);
-            }
-            break;
-        }
-
-        /*case SPDRP_CHARACTERISTICS:
-        case SPDRP_DEVTYPE:
-        case SPDRP_EXCLUSIVE:*/
-#if (WINVER >= 0x501)
-        //case SPDRP_REMOVAL_POLICY_OVERRIDE:
-#endif
-        //case SPDRP_SECURITY_SDS:
-
-        default:
-        {
-            ERR("Property 0x%lx not implemented\n", Property);
-            SetLastError(ERROR_NOT_SUPPORTED);
-        }
+    if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
+        && PropertyMap[Property].nameW)
+    {
+    	HKEY hKey;
+    	LONG l;
+        hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_SET_VALUE);
+        if (hKey == INVALID_HANDLE_VALUE)
+            return FALSE;
+        /* Write new data */
+        l = RegSetValueExW(
+            hKey, PropertyMap[Property].nameW, 0,
+                PropertyMap[Property].regType, PropertyBuffer,
+                PropertyBufferSize);
+        if (!l)
+            ret = TRUE;
+        else
+            SetLastError(l);
+        RegCloseKey(hKey);
+    }
+    else
+    {
+        ERR("Property 0x%lx not implemented\n", Property);
+        SetLastError(ERROR_NOT_SUPPORTED);
     }
 
     TRACE("Returning %d\n", ret);
@@ -5457,7 +5307,7 @@
     TRACE("%p %p %d %d %d %x\n", DeviceInfoSet, DeviceInfoData,
           Scope, HwProfile, KeyType, samDesired);
 
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
     {
         SetLastError(ERROR_INVALID_HANDLE);
         return INVALID_HANDLE_VALUE;
@@ -5543,7 +5393,7 @@
     TRACE("%p %p %d %d %d\n", DeviceInfoSet, DeviceInfoData, Scope, HwProfile,
             KeyType);
 
-    if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+    if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
     {
         SetLastError(ERROR_INVALID_HANDLE);
         return FALSE;

Modified: trunk/reactos/dll/win32/setupapi/misc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/misc.c?rev=32265&r1=32264&r2=32265&view=diff
==============================================================================
--- trunk/reactos/dll/win32/setupapi/misc.c (original)
+++ trunk/reactos/dll/win32/setupapi/misc.c Sun Feb 10 17:37:19 2008
@@ -787,7 +787,7 @@
 
     TRACE("%s %p\n", debugstr_w(lpFileName), pSecurityDescriptor);
 
-    SecDesc = (PSECURITY_DESCRIPTOR)MyMalloc(dwSize);
+    SecDesc = MyMalloc(dwSize);
     if (SecDesc == NULL)
         return ERROR_NOT_ENOUGH_MEMORY;
 
@@ -806,7 +806,7 @@
         return dwError;
     }
 
-    SecDesc = (PSECURITY_DESCRIPTOR)MyRealloc(SecDesc, dwSize);
+    SecDesc = MyRealloc(SecDesc, dwSize);
     if (SecDesc == NULL)
         return ERROR_NOT_ENOUGH_MEMORY;
 

Modified: trunk/reactos/dll/win32/setupapi/parser.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/parser.c?rev=32265&r1=32264&r2=32265&view=diff
==============================================================================
--- trunk/reactos/dll/win32/setupapi/parser.c (original)
+++ trunk/reactos/dll/win32/setupapi/parser.c Sun Feb 10 17:37:19 2008
@@ -243,7 +243,7 @@
 
 
 /* retrieve a given line from section/line index */
-inline static struct line *get_line( struct inf_file *file, unsigned int section_index,
+static inline struct line *get_line( struct inf_file *file, unsigned int section_index,
                                      unsigned int line_index )
 {
     struct section *section;
@@ -433,7 +433,7 @@
 
 
 /* push the current state on the parser stack */
-inline static void push_state( struct parser *parser, enum parser_state state )
+static inline void push_state( struct parser *parser, enum parser_state state )
 {
     ASSERT( parser->stack_pos < sizeof(parser->stack)/sizeof(parser->stack[0]) );
     parser->stack[parser->stack_pos++] = state;
@@ -441,7 +441,7 @@
 
 
 /* pop the current state */
-inline static void pop_state( struct parser *parser )
+static inline void pop_state( struct parser *parser )
 {
     ASSERT( parser->stack_pos );
     parser->state = parser->stack[--parser->stack_pos];
@@ -449,7 +449,7 @@
 
 
 /* set the parser state and return the previous one */
-inline static enum parser_state set_state( struct parser *parser, enum parser_state state )
+static inline enum parser_state set_state( struct parser *parser, enum parser_state state )
 {
     enum parser_state ret = parser->state;
     parser->state = state;
@@ -458,14 +458,14 @@
 
 
 /* check if the pointer points to an end of file */
-inline static int is_eof( const struct parser *parser, const WCHAR *ptr )
+static inline int is_eof( const struct parser *parser, const WCHAR *ptr )
 {
     return (ptr >= parser->end || *ptr == CONTROL_Z);
 }
 
 
 /* check if the pointer points to an end of line */
-inline static int is_eol( const struct parser *parser, const WCHAR *ptr )
+static inline int is_eol( const struct parser *parser, const WCHAR *ptr )
 {
     return (ptr >= parser->end || *ptr == CONTROL_Z || *ptr == '\n');
 }
@@ -1067,7 +1067,7 @@
 HINF WINAPI SetupOpenInfFileA( PCSTR name, PCSTR class, DWORD style, UINT *error )
 {
     UNICODE_STRING nameW, classW;
-    HINF ret = (HINF)INVALID_HANDLE_VALUE;
+    HINF ret = INVALID_HANDLE_VALUE;
 
     classW.Buffer = NULL;
     if (class && !RtlCreateUnicodeStringFromAsciiz( &classW, class ))
@@ -1171,11 +1171,11 @@
 
     if (strchrW( name, '\\' ) || strchrW( name, '/' ))
     {
-        if (!(len = GetFullPathNameW( name, 0, NULL, NULL ))) return (HINF)INVALID_HANDLE_VALUE;
+        if (!(len = GetFullPathNameW( name, 0, NULL, NULL ))) return INVALID_HANDLE_VALUE;
         if (!(path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
         {
             SetLastError( ERROR_NOT_ENOUGH_MEMORY );
-            return (HINF)INVALID_HANDLE_VALUE;
+            return INVALID_HANDLE_VALUE;
         }
         GetFullPathNameW( name, len, path, NULL );
         handle = CreateFileW( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
@@ -1189,7 +1189,7 @@
         if (!(path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
         {
             SetLastError( ERROR_NOT_ENOUGH_MEMORY );
-            return (HINF)INVALID_HANDLE_VALUE;
+            return INVALID_HANDLE_VALUE;
         }
         GetWindowsDirectoryW( path, len );
         p = path + strlenW(path);
@@ -1212,7 +1212,7 @@
     if (!file)
     {
         HeapFree( GetProcessHeap(), 0, path );
-        return (HINF)INVALID_HANDLE_VALUE;
+        return INVALID_HANDLE_VALUE;
     }
     TRACE( "%s -> %p\n", debugstr_w(path), file );
     file->filename = path;
@@ -1226,7 +1226,7 @@
             /* Not enough memory */
             SetLastError(ERROR_NOT_ENOUGH_MEMORY);
             SetupCloseInfFile((HINF)file);
-            return (HINF)INVALID_HANDLE_VALUE;
+            return INVALID_HANDLE_VALUE;
         }
         else if (!PARSER_GetInfClassW((HINF)file, &ClassGuid, ClassName, strlenW(class) + 1, NULL))
         {
@@ -1234,7 +1234,7 @@
             HeapFree(GetProcessHeap(), 0, ClassName);
             SetLastError(ERROR_CLASS_MISMATCH);
             SetupCloseInfFile((HINF)file);
-            return (HINF)INVALID_HANDLE_VALUE;
+            return INVALID_HANDLE_VALUE;
         }
         else if (strcmpW(class, ClassName) != 0)
         {
@@ -1242,7 +1242,7 @@
             HeapFree(GetProcessHeap(), 0, ClassName);
             SetLastError(ERROR_CLASS_MISMATCH);
             SetupCloseInfFile((HINF)file);
-            return (HINF)INVALID_HANDLE_VALUE;
+            return INVALID_HANDLE_VALUE;
         }
         HeapFree(GetProcessHeap(), 0, ClassName);
     }
@@ -1261,7 +1261,7 @@
 
     if (!name) return SetupOpenAppendInfFileW( NULL, parent_hinf, error );
     child_hinf = SetupOpenInfFileA( name, NULL, INF_STYLE_WIN4, error );
-    if (child_hinf == (HINF)INVALID_HANDLE_VALUE) return FALSE;
+    if (child_hinf == INVALID_HANDLE_VALUE) return FALSE;
     append_inf_file( parent_hinf, child_hinf );
     TRACE( "%p: appended %s (%p)\n", parent_hinf, debugstr_a(name), child_hinf );
     return TRUE;
@@ -1286,14 +1286,14 @@
                                      sizeof(filename)/sizeof(WCHAR), NULL ))
         {
             child_hinf = SetupOpenInfFileW( filename, NULL, INF_STYLE_WIN4, error );
-            if (child_hinf == (HINF)INVALID_HANDLE_VALUE) return FALSE;
+            if (child_hinf == INVALID_HANDLE_VALUE) return FALSE;
             append_inf_file( parent_hinf, child_hinf );
             TRACE( "%p: appended %s (%p)\n", parent_hinf, debugstr_w(filename), child_hinf );
         }
         return TRUE;
     }
     child_hinf = SetupOpenInfFileW( name, NULL, INF_STYLE_WIN4, error );
-    if (child_hinf == (HINF)INVALID_HANDLE_VALUE) return FALSE;
+    if (child_hinf == INVALID_HANDLE_VALUE) return FALSE;
     append_inf_file( parent_hinf, child_hinf );
     TRACE( "%p: appended %s (%p)\n", parent_hinf, debugstr_w(name), child_hinf );
     return TRUE;

Modified: trunk/reactos/dll/win32/setupapi/queue.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/queue.c?rev=32265&r1=32264&r2=32265&view=diff
==============================================================================
--- trunk/reactos/dll/win32/setupapi/queue.c (original)
+++ trunk/reactos/dll/win32/setupapi/queue.c Sun Feb 10 17:37:19 2008
@@ -63,7 +63,7 @@
 };
 
 
-inline static WCHAR *strdupW( const WCHAR *str )
+static inline WCHAR *strdupW( const WCHAR *str )
 {
     WCHAR *ret = NULL;
     if (str)
@@ -74,7 +74,7 @@
     return ret;
 }
 
-inline static char *strdupWtoA( const WCHAR *str )
+static inline char *strdupWtoA( const WCHAR *str )
 {
     char *ret = NULL;
     if (str)
@@ -87,7 +87,7 @@
 }
 
 /* append a file operation to a queue */
-inline static void queue_file_op( struct file_op_queue *queue, struct file_op *op )
+static inline void queue_file_op( struct file_op_queue *queue, struct file_op *op )
 {
     op->next = NULL;
     if (queue->tail) queue->tail->next = op;
@@ -417,7 +417,7 @@
     struct file_queue *queue;
 
     if (!(queue = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*queue))))
-        return (HSPFILEQ)INVALID_HANDLE_VALUE;
+        return INVALID_HANDLE_VALUE;
     return queue;
 }
 

Modified: trunk/reactos/dll/win32/setupapi/setupapi_private.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/setupapi_private.h?rev=32265&r1=32264&r2=32265&view=diff
==============================================================================
--- trunk/reactos/dll/win32/setupapi/setupapi_private.h (original)
+++ trunk/reactos/dll/win32/setupapi/setupapi_private.h Sun Feb 10 17:37:19 2008
@@ -241,11 +241,11 @@
 
 struct inf_file;
 extern const WCHAR *DIRID_get_string( int dirid );
+extern unsigned int PARSER_string_substA( const struct inf_file *file, const WCHAR *text,
+                                          char *buffer, unsigned int size );
+extern unsigned int PARSER_string_substW( const struct inf_file *file, const WCHAR *text,
+                                          WCHAR *buffer, unsigned int size );
 extern const WCHAR *PARSER_get_inf_filename( HINF hinf );
-extern unsigned int PARSER_string_substA( const struct inf_file *file, const WCHAR *text, char *buffer,
-                                          unsigned int size );
-extern unsigned int PARSER_string_substW( const struct inf_file *file, const WCHAR *text, WCHAR *buffer,
-                                          unsigned int size );
 extern WCHAR *PARSER_get_src_root( HINF hinf );
 extern WCHAR *PARSER_get_dest_dir( INFCONTEXT *context );
 




More information about the Ros-diffs mailing list