setupapi: Fix error handling in SetupInstallServicesFromInfSection().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
56aab6aaf8
commit
6b2b6cde8b
|
@ -1458,36 +1458,38 @@ 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 = TRUE;
|
BOOL ret = TRUE;
|
||||||
|
|
||||||
if (!(ok = SetupFindFirstLineW( hinf, section, NULL, &context )))
|
if (!SetupFindFirstLineW( hinf, section, NULL, &context ))
|
||||||
{
|
{
|
||||||
SetLastError( ERROR_SECTION_NOT_FOUND );
|
SetLastError( ERROR_SECTION_NOT_FOUND );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!(scm = OpenSCManagerW( NULL, NULL, SC_MANAGER_ALL_ACCESS ))) return FALSE;
|
if (!(scm = OpenSCManagerW( NULL, NULL, SC_MANAGER_ALL_ACCESS ))) return FALSE;
|
||||||
|
|
||||||
ok = SetupFindFirstLineW( hinf, section, AddService, &context );
|
if (SetupFindFirstLineW( hinf, section, AddService, &context ))
|
||||||
while (ok)
|
|
||||||
{
|
{
|
||||||
if (!SetupGetStringFieldW( &context, 1, service_name, MAX_INF_STRING_LENGTH, NULL ))
|
do
|
||||||
continue;
|
{
|
||||||
if (!SetupGetIntField( &context, 2, §ion_flags )) section_flags = 0;
|
if (!SetupGetStringFieldW( &context, 1, service_name, MAX_INF_STRING_LENGTH, NULL ))
|
||||||
if (!SetupGetStringFieldW( &context, 3, service_section, MAX_INF_STRING_LENGTH, NULL ))
|
continue;
|
||||||
continue;
|
if (!SetupGetIntField( &context, 2, §ion_flags )) section_flags = 0;
|
||||||
if (!(ret = add_service( scm, hinf, service_name, service_section, section_flags | flags )))
|
if (!SetupGetStringFieldW( &context, 3, service_section, MAX_INF_STRING_LENGTH, NULL ))
|
||||||
goto done;
|
continue;
|
||||||
ok = SetupFindNextMatchLineW( &context, AddService, &context );
|
if (!(ret = add_service( scm, hinf, service_name, service_section, section_flags | flags )))
|
||||||
|
goto done;
|
||||||
|
} while (SetupFindNextMatchLineW( &context, AddService, &context ));
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = SetupFindFirstLineW( hinf, section, DelService, &context );
|
if (SetupFindFirstLineW( hinf, section, DelService, &context ))
|
||||||
while (ok)
|
|
||||||
{
|
{
|
||||||
if (!SetupGetStringFieldW( &context, 1, service_name, MAX_INF_STRING_LENGTH, NULL ))
|
do
|
||||||
continue;
|
{
|
||||||
if (!SetupGetIntField( &context, 2, §ion_flags )) section_flags = 0;
|
if (!SetupGetStringFieldW( &context, 1, service_name, MAX_INF_STRING_LENGTH, NULL ))
|
||||||
if (!(ret = del_service( scm, hinf, service_name, section_flags | flags ))) goto done;
|
continue;
|
||||||
ok = SetupFindNextMatchLineW( &context, AddService, &context );
|
if (!SetupGetIntField( &context, 2, §ion_flags )) section_flags = 0;
|
||||||
|
if (!(ret = del_service( scm, hinf, service_name, section_flags | flags ))) goto done;
|
||||||
|
} while (SetupFindNextMatchLineW( &context, AddService, &context ));
|
||||||
}
|
}
|
||||||
if (ret) SetLastError( ERROR_SUCCESS );
|
if (ret) SetLastError( ERROR_SUCCESS );
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -574,6 +574,20 @@ static void test_install_svc_from(void)
|
||||||
SetupCloseInfFile(infhandle);
|
SetupCloseInfFile(infhandle);
|
||||||
DeleteFileA(inffile);
|
DeleteFileA(inffile);
|
||||||
|
|
||||||
|
strcpy(inf, "[Version]\nSignature=\"$Chicago$\"\n");
|
||||||
|
strcat(inf, "[Winetest.Services]\n");
|
||||||
|
strcat(inf, "AddService=,2\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, "Winetest.Services", 0);
|
||||||
|
ok(ret, "Expected success\n");
|
||||||
|
ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
|
||||||
|
SetupCloseInfFile(infhandle);
|
||||||
|
DeleteFileA(inffile);
|
||||||
|
|
||||||
/* TODO: Test the Flags */
|
/* TODO: Test the Flags */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue