setupapi: SetupInstallServicesFromInfSection doesn't fail if there are no AddService or DelService directives in the section.

This commit is contained in:
Hans Leidekker 2012-07-09 11:07:37 +02:00 committed by Alexandre Julliard
parent 700eec9687
commit da922769c5
2 changed files with 22 additions and 5 deletions

View File

@ -1447,12 +1447,16 @@ BOOL WINAPI SetupInstallServicesFromInfSectionW( HINF hinf, PCWSTR section, DWOR
SC_HANDLE scm; SC_HANDLE scm;
INFCONTEXT context; INFCONTEXT context;
INT section_flags; INT section_flags;
BOOL ok, ret = FALSE; BOOL ok, ret = TRUE;
if (!(ok = SetupFindFirstLineW( hinf, section, NULL, &context )))
{
SetLastError( ERROR_SECTION_NOT_FOUND );
return FALSE;
}
if (!(scm = OpenSCManagerW( NULL, NULL, SC_MANAGER_ALL_ACCESS ))) return FALSE; if (!(scm = OpenSCManagerW( NULL, NULL, SC_MANAGER_ALL_ACCESS ))) return FALSE;
if (!(ok = SetupFindFirstLineW( hinf, section, AddService, &context ))) ok = SetupFindFirstLineW( hinf, section, AddService, &context );
SetLastError( ERROR_SECTION_NOT_FOUND );
while (ok) while (ok)
{ {
if (!SetupGetStringFieldW( &context, 1, service_name, MAX_INF_STRING_LENGTH, NULL )) if (!SetupGetStringFieldW( &context, 1, service_name, MAX_INF_STRING_LENGTH, NULL ))
@ -1465,8 +1469,7 @@ BOOL WINAPI SetupInstallServicesFromInfSectionW( HINF hinf, PCWSTR section, DWOR
ok = SetupFindNextMatchLineW( &context, AddService, &context ); ok = SetupFindNextMatchLineW( &context, AddService, &context );
} }
if (!(ok = SetupFindFirstLineW( hinf, section, DelService, &context ))) ok = SetupFindFirstLineW( hinf, section, DelService, &context );
SetLastError( ERROR_SECTION_NOT_FOUND );
while (ok) while (ok)
{ {
if (!SetupGetStringFieldW( &context, 1, service_name, MAX_INF_STRING_LENGTH, NULL )) if (!SetupGetStringFieldW( &context, 1, service_name, MAX_INF_STRING_LENGTH, NULL ))

View File

@ -322,6 +322,20 @@ static void test_install_svc_from(void)
CloseServiceHandle(svc_handle); CloseServiceHandle(svc_handle);
CloseServiceHandle(scm_handle); CloseServiceHandle(scm_handle);
strcpy(inf, "[Version]\nSignature=\"$Chicago$\"\n");
strcat(inf, "[XSP.InstallPerVer]\n");
strcat(inf, "AddReg=AspEventlogMsg.Reg,Perf.Reg,AspVersions.Reg,FreeADO.Reg,IndexServer.Reg\n");
create_inf_file(inffile, inf);
sprintf(path, "%s\\%s", CURR_DIR, inffile);
infhandle = SetupOpenInfFileA(path, NULL, INF_STYLE_WIN4, NULL);
SetLastError(0xdeadbeef);
ret = SetupInstallServicesFromInfSectionA(infhandle, "XSP.InstallPerVer", 0);
ok(ret, "Expected success\n");
ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
SetupCloseInfFile(infhandle);
DeleteFile(inffile);
/* TODO: Test the Flags */ /* TODO: Test the Flags */
} }