From da922769c5536932185d7bfce604ee1b7885b75d Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Mon, 9 Jul 2012 11:07:37 +0200 Subject: [PATCH] setupapi: SetupInstallServicesFromInfSection doesn't fail if there are no AddService or DelService directives in the section. --- dlls/setupapi/install.c | 13 ++++++++----- dlls/setupapi/tests/install.c | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/dlls/setupapi/install.c b/dlls/setupapi/install.c index 874b4a95ea9..1c8236a7d47 100644 --- a/dlls/setupapi/install.c +++ b/dlls/setupapi/install.c @@ -1447,12 +1447,16 @@ BOOL WINAPI SetupInstallServicesFromInfSectionW( HINF hinf, PCWSTR section, DWOR SC_HANDLE scm; INFCONTEXT context; 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 (!(ok = SetupFindFirstLineW( hinf, section, AddService, &context ))) - SetLastError( ERROR_SECTION_NOT_FOUND ); + ok = SetupFindFirstLineW( hinf, section, AddService, &context ); while (ok) { 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 ); } - if (!(ok = SetupFindFirstLineW( hinf, section, DelService, &context ))) - SetLastError( ERROR_SECTION_NOT_FOUND ); + ok = SetupFindFirstLineW( hinf, section, DelService, &context ); while (ok) { if (!SetupGetStringFieldW( &context, 1, service_name, MAX_INF_STRING_LENGTH, NULL )) diff --git a/dlls/setupapi/tests/install.c b/dlls/setupapi/tests/install.c index 1c204b53867..a2fa00bc7a6 100644 --- a/dlls/setupapi/tests/install.c +++ b/dlls/setupapi/tests/install.c @@ -322,6 +322,20 @@ static void test_install_svc_from(void) CloseServiceHandle(svc_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 */ }