@@ -575,6 +575,41 @@ GetConfigurationData(
575575}
576576
577577
578+ static
579+ PCM_FULL_RESOURCE_DESCRIPTOR
580+ NextResourceDescriptor (
581+ _In_ PCM_FULL_RESOURCE_DESCRIPTOR pDescriptor )
582+ {
583+ PBYTE pNext = NULL ;
584+ ULONG ulLastIndex = 0 ;
585+
586+ if (pDescriptor == NULL )
587+ return NULL ;
588+
589+ /* Skip the full resource descriptor */
590+ pNext = (LPBYTE )pDescriptor + sizeof (CM_FULL_RESOURCE_DESCRIPTOR );
591+
592+ /* Skip the partial resource descriptors */
593+ pNext += (pDescriptor -> PartialResourceList .Count - 1 ) *
594+ sizeof (CM_PARTIAL_RESOURCE_DESCRIPTOR );
595+
596+ /* Skip the device specific data, if present */
597+ if (pDescriptor -> PartialResourceList .Count > 0 )
598+ {
599+ ulLastIndex = pDescriptor -> PartialResourceList .Count - 1 ;
600+
601+ if (pDescriptor -> PartialResourceList .PartialDescriptors [ulLastIndex ].Type ==
602+ CmResourceTypeDeviceSpecific )
603+ {
604+ pNext += pDescriptor -> PartialResourceList .PartialDescriptors [ulLastIndex ].
605+ u .DeviceSpecificData .DataSize ;
606+ }
607+ }
608+
609+ return (PCM_FULL_RESOURCE_DESCRIPTOR )pNext ;
610+ }
611+
612+
578613static
579614BOOL
580615IsCallerInteractive (
@@ -4177,8 +4212,8 @@ PNP_AddEmptyLogConf(
41774212{
41784213 HKEY hConfigKey = NULL ;
41794214 DWORD RegDataType = 0 ;
4180- ULONG ulDataSize = 0 ;
4181- LPBYTE pDataBuffer = NULL ;
4215+ ULONG ulDataSize = 0 , ulNewSize = 0 ;
4216+ PBYTE pDataBuffer = NULL ;
41824217 WCHAR szValueNameBuffer [LOGCONF_NAME_BUFFER_SIZE ];
41834218 CONFIGRET ret = CR_SUCCESS ;
41844219
@@ -4221,7 +4256,9 @@ PNP_AddEmptyLogConf(
42214256 if (RegDataType == REG_RESOURCE_LIST )
42224257 {
42234258 PCM_RESOURCE_LIST pResourceList = NULL ;
4259+ PCM_FULL_RESOURCE_DESCRIPTOR pResource = NULL ;
42244260
4261+ /* Allocate a buffer for the new configuration */
42254262 ulDataSize = sizeof (CM_RESOURCE_LIST ) - sizeof (CM_PARTIAL_RESOURCE_DESCRIPTOR );
42264263 pDataBuffer = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY , ulDataSize );
42274264 if (pDataBuffer == NULL )
@@ -4232,11 +4269,13 @@ PNP_AddEmptyLogConf(
42324269
42334270 pResourceList = (PCM_RESOURCE_LIST )pDataBuffer ;
42344271 pResourceList -> Count = 1 ;
4235- pResourceList -> List [0 ].InterfaceType = InterfaceTypeUndefined ;
4236- pResourceList -> List [0 ].BusNumber = 0 ;
4237- pResourceList -> List [0 ].PartialResourceList .Version = 1 ;
4238- pResourceList -> List [0 ].PartialResourceList .Revision = 1 ;
4239- pResourceList -> List [0 ].PartialResourceList .Count = 0 ;
4272+
4273+ pResource = (PCM_FULL_RESOURCE_DESCRIPTOR )& pResourceList -> List [0 ];
4274+ pResource -> InterfaceType = InterfaceTypeUndefined ;
4275+ pResource -> BusNumber = 0 ;
4276+ pResource -> PartialResourceList .Version = 1 ;
4277+ pResource -> PartialResourceList .Revision = 1 ;
4278+ pResource -> PartialResourceList .Count = 0 ;
42404279 }
42414280 else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST )
42424281 {
@@ -4277,7 +4316,38 @@ PNP_AddEmptyLogConf(
42774316 {
42784317 if (RegDataType == REG_RESOURCE_LIST )
42794318 {
4280- /* FIXME */
4319+ PCM_RESOURCE_LIST pResourceList = NULL ;
4320+ PCM_FULL_RESOURCE_DESCRIPTOR pResource = NULL ;
4321+ ULONG ulIndex ;
4322+
4323+ /* Reallocate a larger buffer in order to add the new configuration */
4324+ ulNewSize = sizeof (CM_FULL_RESOURCE_DESCRIPTOR ) - sizeof (CM_PARTIAL_RESOURCE_DESCRIPTOR );
4325+ pDataBuffer = HeapReAlloc (GetProcessHeap (),
4326+ 0 ,
4327+ pDataBuffer ,
4328+ ulDataSize + ulNewSize );
4329+ if (pDataBuffer == NULL )
4330+ {
4331+ ret = CR_OUT_OF_MEMORY ;
4332+ goto done ;
4333+ }
4334+
4335+ pResourceList = (PCM_RESOURCE_LIST )pDataBuffer ;
4336+
4337+ /* Get a pointer to the new (uninitialized) resource descriptor */
4338+ pResource = (PCM_FULL_RESOURCE_DESCRIPTOR )& pResourceList -> List [0 ];
4339+ for (ulIndex = 0 ; ulIndex < pResourceList -> Count ; ulIndex ++ )
4340+ pResource = NextResourceDescriptor (pResource );
4341+
4342+ /* Initialize the new resource descriptor */
4343+ pResourceList -> Count ++ ;
4344+ pResource -> InterfaceType = InterfaceTypeUndefined ;
4345+ pResource -> BusNumber = 0 ;
4346+ pResource -> PartialResourceList .Version = 1 ;
4347+ pResource -> PartialResourceList .Revision = 1 ;
4348+ pResource -> PartialResourceList .Count = 0 ;
4349+
4350+ * pulLogConfTag = ulIndex ;
42814351 }
42824352 else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST )
42834353 {
@@ -4290,12 +4360,13 @@ PNP_AddEmptyLogConf(
42904360 }
42914361 }
42924362
4363+ /* Store the configuration */
42934364 if (RegSetValueEx (hConfigKey ,
42944365 szValueNameBuffer ,
42954366 0 ,
42964367 RegDataType ,
42974368 pDataBuffer ,
4298- ulDataSize ) != ERROR_SUCCESS )
4369+ ulDataSize + ulNewSize ) != ERROR_SUCCESS )
42994370 {
43004371 ret = CR_REGISTRY_ERROR ;
43014372 goto done ;
0 commit comments