[SETUPAPI]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 12 Oct 2014 17:13:36 +0000 (17:13 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 12 Oct 2014 17:13:36 +0000 (17:13 +0000)
Store the module handles to loaded property page provider dlls in the DeviceInfoData (for class property pages) or in the DeviceInfo (for device property pages). The dlls are unloaded when the device info set is destroyed. These dlls were unloaded as soon as the property sheet data had been retrieved. These property pages could not be added to a property sheet because unloading the dll invalidated the page reources.

svn path=/trunk/; revision=64700

reactos/dll/win32/setupapi/devclass.c
reactos/dll/win32/setupapi/devinst.c
reactos/dll/win32/setupapi/setupapi_private.h

index 84b5609..2bdd6e9 100644 (file)
@@ -1269,6 +1269,19 @@ SetupDiGetClassDevPropertySheetsW(
             goto cleanup;
         }
 
             goto cleanup;
         }
 
+        if (DeviceInfoData)
+        {
+            struct DeviceInfo *devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
+            devInfo->hmodDevicePropPageProvider = hModule;
+            devInfo->pDevicePropPageProvider = pPropPageProvider;
+        }
+        else
+        {
+            struct DeviceInfoSet *devInfoSet = (struct DeviceInfoSet *)DeviceInfoSet;
+            devInfoSet->hmodClassPropPageProvider = hModule;
+            devInfoSet->pClassPropPageProvider = pPropPageProvider;
+        }
+
         InitialNumberOfPages = PropertySheetHeader->nPages;
 
         Request.cbSize = sizeof(SP_PROPSHEETPAGE_REQUEST);
         InitialNumberOfPages = PropertySheetHeader->nPages;
 
         Request.cbSize = sizeof(SP_PROPSHEETPAGE_REQUEST);
@@ -1299,7 +1312,6 @@ cleanup:
         if (hKey != INVALID_HANDLE_VALUE)
             RegCloseKey(hKey);
         HeapFree(GetProcessHeap(), 0, PropPageProvider);
         if (hKey != INVALID_HANDLE_VALUE)
             RegCloseKey(hKey);
         HeapFree(GetProcessHeap(), 0, PropPageProvider);
-        FreeFunctionPointer(hModule, pPropPageProvider);
     }
 
     TRACE("Returning %d\n", ret);
     }
 
     TRACE("Returning %d\n", ret);
index b7eeeef..26886ba 100644 (file)
@@ -602,6 +602,8 @@ DestroyDeviceInfo(struct DeviceInfo *deviceInfo)
             return FALSE;
     }
     DestroyClassInstallParams(&deviceInfo->ClassInstallParams);
             return FALSE;
     }
     DestroyClassInstallParams(&deviceInfo->ClassInstallParams);
+    if (deviceInfo->hmodDevicePropPageProvider)
+        FreeLibrary(deviceInfo->hmodDevicePropPageProvider);
     return HeapFree(GetProcessHeap(), 0, deviceInfo);
 }
 
     return HeapFree(GetProcessHeap(), 0, deviceInfo);
 }
 
@@ -622,6 +624,8 @@ DestroyDeviceInfoSet(struct DeviceInfoSet* list)
         RegCloseKey(list->HKLM);
     CM_Disconnect_Machine(list->hMachine);
     DestroyClassInstallParams(&list->ClassInstallParams);
         RegCloseKey(list->HKLM);
     CM_Disconnect_Machine(list->hMachine);
     DestroyClassInstallParams(&list->ClassInstallParams);
+    if (list->hmodClassPropPageProvider)
+        FreeLibrary(list->hmodClassPropPageProvider);
     return HeapFree(GetProcessHeap(), 0, list);
 }
 
     return HeapFree(GetProcessHeap(), 0, list);
 }
 
index 21ff8b6..bc3259f 100644 (file)
@@ -172,6 +172,10 @@ struct DeviceInfo /* Element of DeviceInfoSet.ListHead */
     /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */
     struct ClassInstallParams ClassInstallParams;
 
     /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */
     struct ClassInstallParams ClassInstallParams;
 
+    /* Device property page provider data */
+    HMODULE hmodDevicePropPageProvider;
+    PVOID pDevicePropPageProvider;
+
     /* Variable size array (contains data for instanceId, UniqueId, DeviceDescription) */
     WCHAR Data[ANYSIZE_ARRAY];
 };
     /* Variable size array (contains data for instanceId, UniqueId, DeviceDescription) */
     WCHAR Data[ANYSIZE_ARRAY];
 };
@@ -200,6 +204,10 @@ struct DeviceInfoSet /* HDEVINFO */
     /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */
     struct ClassInstallParams ClassInstallParams;
 
     /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */
     struct ClassInstallParams ClassInstallParams;
 
+    /* Class property page provider data */
+    HMODULE hmodClassPropPageProvider;
+    PVOID pClassPropPageProvider;
+
     /* Contains the name of the remote computer ('\\COMPUTERNAME' for example),
      * or NULL if related to local machine. Points into szData field at the
      * end of the structure */
     /* Contains the name of the remote computer ('\\COMPUTERNAME' for example),
      * or NULL if related to local machine. Points into szData field at the
      * end of the structure */