Author: ekohl
Date: Fri May 27 15:07:43 2011
New Revision: 51959
URL:
http://svn.reactos.org/svn/reactos?rev=51959&view=rev
Log:
[SETUPAPI]
- SetupDiGetClassDevPropertySheetsW: Improve the way property sheet pages are added to a
property sheet. This change enables us to retrieve the number of property sheet pages
provided by a property sheet provider without leaking property sheets.
Modified:
trunk/reactos/dll/win32/setupapi/devclass.c
Modified: trunk/reactos/dll/win32/setupapi/devclass.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/devclas…
==============================================================================
--- trunk/reactos/dll/win32/setupapi/devclass.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/setupapi/devclass.c [iso-8859-1] Fri May 27 15:07:43 2011
@@ -1135,9 +1135,10 @@
struct ClassDevPropertySheetsData
{
- HPROPSHEETPAGE *PropertySheetPages;
- DWORD MaximumNumberOfPages;
+ LPPROPSHEETHEADERW PropertySheetHeader;
+ DWORD PropertySheetHeaderPageListSize;
DWORD NumberOfPages;
+ BOOL DontCancel;
};
static BOOL WINAPI
@@ -1149,14 +1150,16 @@
PropPageData = (struct ClassDevPropertySheetsData *)lParam;
- if (PropPageData->NumberOfPages < PropPageData->MaximumNumberOfPages)
- {
- *PropPageData->PropertySheetPages = hPropSheetPage;
- PropPageData->PropertySheetPages++;
- }
-
PropPageData->NumberOfPages++;
- return TRUE;
+
+ if (PropPageData->PropertySheetHeader->nPages <
PropPageData->PropertySheetHeaderPageListSize)
+ {
+
PropPageData->PropertySheetHeader->phpage[PropPageData->PropertySheetHeader->nPages]
= hPropSheetPage;
+ PropPageData->PropertySheetHeader->nPages++;
+ return TRUE;
+ }
+
+ return PropPageData->DontCancel;
}
/***********************************************************************
@@ -1208,6 +1211,7 @@
PROPERTY_PAGE_PROVIDER pPropPageProvider = NULL;
struct ClassDevPropertySheetsData PropPageData;
DWORD dwLength, dwRegType;
+ DWORD InitialNumberOfPages;
DWORD rc;
if (DeviceInfoData)
@@ -1256,27 +1260,29 @@
goto cleanup;
}
+ InitialNumberOfPages = PropertySheetHeader->nPages;
+
Request.cbSize = sizeof(SP_PROPSHEETPAGE_REQUEST);
Request.PageRequested = SPPSR_ENUM_ADV_DEVICE_PROPERTIES;
Request.DeviceInfoSet = DeviceInfoSet;
Request.DeviceInfoData = DeviceInfoData;
- PropPageData.PropertySheetPages =
&PropertySheetHeader->phpage[PropertySheetHeader->nPages];
- PropPageData.MaximumNumberOfPages = PropertySheetHeaderPageListSize -
PropertySheetHeader->nPages;
+
+ PropPageData.PropertySheetHeader = PropertySheetHeader;
+ PropPageData.PropertySheetHeaderPageListSize = PropertySheetHeaderPageListSize;
PropPageData.NumberOfPages = 0;
- ret = pPropPageProvider(&Request, SETUP_GetClassDevPropertySheetsCallback,
(LPARAM)&PropPageData);
- if (!ret)
- goto cleanup;
+ PropPageData.DontCancel = (RequiredSize != NULL) ? TRUE : FALSE;
+
+ pPropPageProvider(&Request, SETUP_GetClassDevPropertySheetsCallback,
(LPARAM)&PropPageData);
if (RequiredSize)
- *RequiredSize = PropPageData.NumberOfPages + PropertySheetHeader->nPages;
- if (PropPageData.NumberOfPages <= PropPageData.MaximumNumberOfPages)
- {
- PropertySheetHeader->nPages += PropPageData.NumberOfPages;
+ *RequiredSize = PropPageData.NumberOfPages;
+
+ if (InitialNumberOfPages + PropPageData.NumberOfPages <=
PropertySheetHeaderPageListSize)
+ {
ret = TRUE;
}
else
{
- PropertySheetHeader->nPages += PropPageData.MaximumNumberOfPages;
SetLastError(ERROR_INSUFFICIENT_BUFFER);
}