[ADVAPI32_APITEST] Open services & SCM handles with correct access rights; improve...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 25 Feb 2018 15:09:21 +0000 (16:09 +0100)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 25 Feb 2018 15:11:00 +0000 (16:11 +0100)
modules/rostests/apitests/advapi32/LockServiceDatabase.c
modules/rostests/apitests/advapi32/ServiceArgs.c

index 850cc4c..d52610a 100644 (file)
@@ -77,8 +77,8 @@ static void Test_LockUnlockServiceDatabase(void)
 
     SetLastError(0xdeadbeef);
     hLock = LockServiceDatabase(hScm);
 
     SetLastError(0xdeadbeef);
     hLock = LockServiceDatabase(hScm);
-    ok(hLock != NULL, "hLock = 0x%p, expected non-zero\n", hLock);
     ok_err(ERROR_SUCCESS);
     ok_err(ERROR_SUCCESS);
+    ok(hLock != NULL, "hLock = 0x%p, expected non-zero\n", hLock);
 
     /* Now unlock it */
     if (hLock)
 
     /* Now unlock it */
     if (hLock)
index 18d9b82..e50ca7b 100644 (file)
@@ -236,7 +236,7 @@ static SC_HANDLE register_service(PCWSTR extra_args)
 
     trace("service_cmd \"%ls\"\n", service_cmd);
 
 
     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)
                              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)
     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)
 
     service_handle = register_service(extra_args);
     if (!service_handle)
-        return;
+        goto Quit;
 
     //trace("starting...\n");
 
 
     //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");
     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);
 
 }
 
 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)
     {
     ok(scm_handle != NULL, "OpenSCManager failed: %lu\n", GetLastError());
     if (!scm_handle)
     {