[ADVAPI32_APITEST] Open services & SCM handles with correct access rights; improve a check order.

This commit is contained in:
Hermès Bélusca-Maïto 2018-02-25 16:09:21 +01:00
parent 509dd4e645
commit 5f4a4b35e6
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 12 additions and 7 deletions

View file

@ -77,8 +77,8 @@ static void Test_LockUnlockServiceDatabase(void)
SetLastError(0xdeadbeef);
hLock = LockServiceDatabase(hScm);
ok(hLock != NULL, "hLock = 0x%p, expected non-zero\n", hLock);
ok_err(ERROR_SUCCESS);
ok(hLock != NULL, "hLock = 0x%p, expected non-zero\n", hLock);
/* Now unlock it */
if (hLock)

View file

@ -236,7 +236,7 @@ static SC_HANDLE register_service(PCWSTR extra_args)
trace("service_cmd \"%ls\"\n", service_cmd);
service = CreateServiceW(scm_handle, service_nameW, service_nameW, GENERIC_ALL,
service = CreateServiceW(scm_handle, service_nameW, service_nameW, SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START, SERVICE_ERROR_IGNORE,
service_cmd, NULL, NULL, NULL, NULL, NULL);
if (!service && GetLastError() == ERROR_ACCESS_DENIED)
@ -351,11 +351,11 @@ static void test_runner(BOOLEAN unicode, PCWSTR extra_args, int service_argc, vo
thread = CreateThread(NULL, 0, pipe_thread, NULL, 0, NULL);
ok(thread != NULL, "CreateThread failed: %lu\n", GetLastError());
if (!thread)
return;
goto Quit;
service_handle = register_service(extra_args);
if (!service_handle)
return;
goto Quit;
//trace("starting...\n");
@ -370,15 +370,20 @@ static void test_runner(BOOLEAN unicode, PCWSTR extra_args, int service_argc, vo
CloseServiceHandle(service_handle);
ok(WaitForSingleObject(thread, 10000) == WAIT_OBJECT_0, "Timeout waiting for thread\n");
CloseHandle(thread);
CloseHandle(pipe_handle);
Quit:
if (thread)
CloseHandle(thread);
if (pipe_handle != INVALID_HANDLE_VALUE)
CloseHandle(pipe_handle);
}
START_TEST(ServiceArgs)
{
argc = winetest_get_mainargs(&argv);
scm_handle = OpenSCManagerW(NULL, NULL, GENERIC_ALL);
scm_handle = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
ok(scm_handle != NULL, "OpenSCManager failed: %lu\n", GetLastError());
if (!scm_handle)
{