@@ -3174,182 +3174,6 @@ static HKEY CreateClassKey(HINF hInf)
3174
3174
}
3175
3175
3176
3176
3177
- static BOOL
3178
- InstallServicesSection (
3179
- IN HINF hInf ,
3180
- IN PCWSTR SectionName ,
3181
- IN HDEVINFO DeviceInfoSet OPTIONAL ,
3182
- IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL ,
3183
- OUT PCWSTR * pAssociatedService OPTIONAL ,
3184
- OUT PBOOL pRebootRequired OPTIONAL )
3185
- {
3186
- INFCONTEXT ContextService ;
3187
- INFCONTEXT ContextInclude ;
3188
- DWORD RequiredSize ;
3189
- INT Flags ;
3190
- BOOL ret = FALSE;
3191
-
3192
- /* Parse 'Include' line */
3193
- if (SetupFindFirstLineW (hInf , SectionName , L"Include" , & ContextInclude ))
3194
- {
3195
- DWORD Index = 1 ;
3196
- while (TRUE)
3197
- {
3198
- static WCHAR szBuffer [MAX_PATH ];
3199
- PWSTR pBuffer = NULL ;
3200
- DWORD required ;
3201
-
3202
- ret = SetupGetStringFieldW (& ContextInclude , Index , szBuffer , MAX_PATH , & required );
3203
- if (!ret && GetLastError () == ERROR_INVALID_PARAMETER )
3204
- break ;
3205
- else if (!ret && GetLastError () == ERROR_INSUFFICIENT_BUFFER )
3206
- {
3207
- pBuffer = MyMalloc (required );
3208
- ret = SetupGetStringFieldW (& ContextInclude , Index , pBuffer , required , & required );
3209
- }
3210
- if (ret )
3211
- ret = SetupOpenAppendInfFileW (pBuffer ? pBuffer : szBuffer , hInf , NULL );
3212
-
3213
- MyFree (pBuffer );
3214
- if (!ret )
3215
- goto done ;
3216
- Index ++ ;
3217
- }
3218
- }
3219
-
3220
- /* Parse 'Needs' line */
3221
- if (SetupFindFirstLineW (hInf , SectionName , L"Needs" , & ContextInclude ))
3222
- {
3223
- DWORD Index = 1 ;
3224
- while (TRUE)
3225
- {
3226
- static WCHAR szBuffer [MAX_PATH ];
3227
- PWSTR pBuffer = NULL ;
3228
- DWORD required ;
3229
-
3230
- ret = SetupGetStringFieldW (& ContextInclude , Index , szBuffer , MAX_PATH , & required );
3231
- if (!ret && GetLastError () == ERROR_INVALID_PARAMETER )
3232
- break ;
3233
- else if (!ret && GetLastError () == ERROR_INSUFFICIENT_BUFFER )
3234
- {
3235
- pBuffer = MyMalloc (required );
3236
- ret = SetupGetStringFieldW (& ContextInclude , Index , pBuffer , required , & required );
3237
- }
3238
- if (ret )
3239
- {
3240
- ret = InstallServicesSection (hInf , pBuffer ? pBuffer : szBuffer ,
3241
- DeviceInfoSet , DeviceInfoData , pAssociatedService , pRebootRequired );
3242
- }
3243
-
3244
- MyFree (pBuffer );
3245
- if (!ret )
3246
- goto done ;
3247
- Index ++ ;
3248
- }
3249
- }
3250
-
3251
- ret = SetupFindFirstLineW (hInf , SectionName , NULL , & ContextService );
3252
- while (ret )
3253
- {
3254
- LPWSTR ServiceName = NULL ;
3255
- LPWSTR ServiceSection = NULL ;
3256
-
3257
- ret = SetupGetStringFieldW (
3258
- & ContextService ,
3259
- 1 , /* Field index */
3260
- NULL , 0 ,
3261
- & RequiredSize );
3262
- if (!ret )
3263
- goto nextservice ;
3264
- if (RequiredSize > 0 )
3265
- {
3266
- /* We got the needed size for the buffer */
3267
- ServiceName = HeapAlloc (GetProcessHeap (), 0 , RequiredSize * sizeof (WCHAR ));
3268
- if (!ServiceName )
3269
- {
3270
- SetLastError (ERROR_NOT_ENOUGH_MEMORY );
3271
- goto nextservice ;
3272
- }
3273
- ret = SetupGetStringFieldW (
3274
- & ContextService ,
3275
- 1 , /* Field index */
3276
- ServiceName , RequiredSize ,
3277
- & RequiredSize );
3278
- if (!ret )
3279
- goto nextservice ;
3280
- }
3281
- ret = SetupGetIntField (
3282
- & ContextService ,
3283
- 2 , /* Field index */
3284
- & Flags );
3285
- if (!ret )
3286
- {
3287
- /* The field may be empty. Ignore the error */
3288
- Flags = 0 ;
3289
- }
3290
- ret = SetupGetStringFieldW (
3291
- & ContextService ,
3292
- 3 , /* Field index */
3293
- NULL , 0 ,
3294
- & RequiredSize );
3295
- if (!ret )
3296
- {
3297
- if (GetLastError () == ERROR_INVALID_PARAMETER )
3298
- {
3299
- /* This first is probably missing. It is not
3300
- * required, so ignore the error */
3301
- RequiredSize = 0 ;
3302
- ret = TRUE;
3303
- }
3304
- else
3305
- goto nextservice ;
3306
- }
3307
- if (RequiredSize > 0 )
3308
- {
3309
- /* We got the needed size for the buffer */
3310
- ServiceSection = HeapAlloc (GetProcessHeap (), 0 , RequiredSize * sizeof (WCHAR ));
3311
- if (!ServiceSection )
3312
- {
3313
- SetLastError (ERROR_NOT_ENOUGH_MEMORY );
3314
- goto nextservice ;
3315
- }
3316
- ret = SetupGetStringFieldW (
3317
- & ContextService ,
3318
- 3 , /* Field index */
3319
- ServiceSection , RequiredSize ,
3320
- & RequiredSize );
3321
- if (!ret )
3322
- goto nextservice ;
3323
-
3324
- SetLastError (ERROR_SUCCESS );
3325
- ret = SetupInstallServicesFromInfSectionExW (
3326
- hInf ,
3327
- ServiceSection , Flags , DeviceInfoSet , DeviceInfoData , ServiceName , NULL );
3328
- }
3329
- if (ret && (Flags & SPSVCINST_ASSOCSERVICE ))
3330
- {
3331
- if (pAssociatedService )
3332
- {
3333
- * pAssociatedService = ServiceName ;
3334
- ServiceName = NULL ;
3335
- }
3336
- if (pRebootRequired && GetLastError () == ERROR_SUCCESS_REBOOT_REQUIRED )
3337
- * pRebootRequired = TRUE;
3338
- }
3339
- nextservice :
3340
- HeapFree (GetProcessHeap (), 0 , ServiceName );
3341
- HeapFree (GetProcessHeap (), 0 , ServiceSection );
3342
- if (!ret )
3343
- goto done ;
3344
- ret = SetupFindNextLine (& ContextService , & ContextService );
3345
- }
3346
-
3347
- ret = TRUE;
3348
-
3349
- done :
3350
- return ret ;
3351
- }
3352
-
3353
3177
/***********************************************************************
3354
3178
* SetupDiInstallClassExW (SETUPAPI.@)
3355
3179
*/
@@ -3451,7 +3275,7 @@ BOOL WINAPI SetupDiInstallClassExW(
3451
3275
3452
3276
/* Install .Services section */
3453
3277
lstrcatW (SectionName , DotServices );
3454
- ret = InstallServicesSection (hInf , SectionName , NULL , NULL , NULL , NULL );
3278
+ ret = SetupInstallServicesFromInfSectionW (hInf , SectionName , 0 );
3455
3279
if (!ret )
3456
3280
goto cleanup ;
3457
3281
@@ -5585,8 +5409,6 @@ SetupDiBuildDriverInfoList(
5585
5409
SetLastError (ERROR_INVALID_HANDLE );
5586
5410
else if (DriverType != SPDIT_CLASSDRIVER && DriverType != SPDIT_COMPATDRIVER )
5587
5411
SetLastError (ERROR_INVALID_PARAMETER );
5588
- else if (DriverType == SPDIT_CLASSDRIVER && DeviceInfoData )
5589
- SetLastError (ERROR_INVALID_PARAMETER );
5590
5412
else if (DriverType == SPDIT_COMPATDRIVER && !DeviceInfoData )
5591
5413
SetLastError (ERROR_INVALID_PARAMETER );
5592
5414
else if (DeviceInfoData && DeviceInfoData -> cbSize != sizeof (SP_DEVINFO_DATA ))
@@ -7404,7 +7226,6 @@ SetupDiInstallDevice(
7404
7226
BOOL Result = FALSE;
7405
7227
ULONG DoAction ;
7406
7228
DWORD RequiredSize ;
7407
- LPCWSTR AssociatedService = NULL ;
7408
7229
LPWSTR pSectionName = NULL ;
7409
7230
WCHAR ClassName [MAX_CLASS_NAME_LEN ];
7410
7231
GUID ClassGuid ;
@@ -7569,15 +7390,18 @@ SetupDiInstallDevice(
7569
7390
7570
7391
/* Install .Services section */
7571
7392
wcscpy (pSectionName , DotServices );
7572
- Result = InstallServicesSection (
7393
+ Result = SetupInstallServicesFromInfSectionExW (
7573
7394
SelectedDriver -> InfFileDetails -> hInf ,
7574
7395
SectionName ,
7396
+ 0 ,
7575
7397
DeviceInfoSet ,
7576
7398
DeviceInfoData ,
7577
- & AssociatedService ,
7578
- & RebootRequired );
7399
+ NULL ,
7400
+ NULL );
7579
7401
if (!Result )
7580
7402
goto cleanup ;
7403
+ if (GetLastError () == ERROR_SUCCESS_REBOOT_REQUIRED )
7404
+ RebootRequired = TRUE;
7581
7405
7582
7406
/* Copy .inf file to Inf\ directory (if needed) */
7583
7407
Result = InfIsFromOEMLocation (SelectedDriver -> InfFileDetails -> FullInfFileName , & NeedtoCopyFile );
@@ -7620,16 +7444,13 @@ SetupDiInstallDevice(
7620
7444
TRACE ("ClassGUID : '%S'\n" , lpFullGuidString );
7621
7445
TRACE ("DeviceDesc : '%S'\n" , SelectedDriver -> Info .Description );
7622
7446
TRACE ("Mfg : '%S'\n" , SelectedDriver -> Info .MfgName );
7623
- TRACE ("Service : '%S'\n" , AssociatedService );
7624
7447
rc = RegSetValueEx (hKey , REGSTR_VAL_CLASS , 0 , REG_SZ , (const BYTE * )ClassName , (wcslen (ClassName ) + 1 ) * sizeof (WCHAR ));
7625
7448
if (rc == ERROR_SUCCESS )
7626
7449
rc = RegSetValueEx (hKey , REGSTR_VAL_CLASSGUID , 0 , REG_SZ , (const BYTE * )lpFullGuidString , (wcslen (lpFullGuidString ) + 1 ) * sizeof (WCHAR ));
7627
7450
if (rc == ERROR_SUCCESS )
7628
7451
rc = RegSetValueEx (hKey , REGSTR_VAL_DEVDESC , 0 , REG_SZ , (const BYTE * )SelectedDriver -> Info .Description , (wcslen (SelectedDriver -> Info .Description ) + 1 ) * sizeof (WCHAR ));
7629
7452
if (rc == ERROR_SUCCESS )
7630
7453
rc = RegSetValueEx (hKey , REGSTR_VAL_MFG , 0 , REG_SZ , (const BYTE * )SelectedDriver -> Info .MfgName , (wcslen (SelectedDriver -> Info .MfgName ) + 1 ) * sizeof (WCHAR ));
7631
- if (rc == ERROR_SUCCESS && AssociatedService && * AssociatedService )
7632
- rc = RegSetValueEx (hKey , REGSTR_VAL_SERVICE , 0 , REG_SZ , (const BYTE * )AssociatedService , (wcslen (AssociatedService ) + 1 ) * sizeof (WCHAR ));
7633
7454
if (rc != ERROR_SUCCESS )
7634
7455
{
7635
7456
SetLastError (rc );
@@ -7650,7 +7471,6 @@ SetupDiInstallDevice(
7650
7471
RegCloseKey (hKey );
7651
7472
if (lpGuidString )
7652
7473
RpcStringFreeW (& lpGuidString );
7653
- HeapFree (GetProcessHeap (), 0 , (LPWSTR )AssociatedService );
7654
7474
HeapFree (GetProcessHeap (), 0 , lpFullGuidString );
7655
7475
7656
7476
TRACE ("Returning %d\n" , ret );
0 commit comments