Paul Vriens : advapi32/service: Check combination of service-type and start-type.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jul 16 16:27:17 CDT 2007


Module: wine
Branch: master
Commit: 6c63fa627e55b3d39c743013021bebb753e89908
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6c63fa627e55b3d39c743013021bebb753e89908

Author: Paul Vriens <paul.vriens.wine at gmail.com>
Date:   Sun Jul 15 12:14:55 2007 +0200

advapi32/service: Check combination of service-type and start-type.

---

 dlls/advapi32/service.c       |    8 ++++++++
 dlls/advapi32/tests/service.c |   12 ++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/dlls/advapi32/service.c b/dlls/advapi32/service.c
index 93f96a8..3fbd242 100644
--- a/dlls/advapi32/service.c
+++ b/dlls/advapi32/service.c
@@ -1377,6 +1377,14 @@ CreateServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName,
         return NULL;
     }
 
+    /* SERVICE_BOOT_START and SERVICE_SYSTEM_START or only allowed for driver services */
+    if (((dwStartType == SERVICE_BOOT_START) || (dwStartType == SERVICE_SYSTEM_START)) &&
+        ((dwServiceType & SERVICE_WIN32_OWN_PROCESS) || (dwServiceType & SERVICE_WIN32_SHARE_PROCESS)))
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return NULL;
+    }
+
     r = RegCreateKeyExW(hscm->hkey, lpServiceName, 0, NULL,
                        REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dp);
     if (r!=ERROR_SUCCESS)
diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c
index dc5087a..9157dea 100644
--- a/dlls/advapi32/tests/service.c
+++ b/dlls/advapi32/tests/service.c
@@ -142,7 +142,7 @@ static void test_create_delete_svc(void)
     static const CHAR servicename         [] = "Winetest";
     static const CHAR pathname            [] = "we_dont_care.exe";
     static const CHAR empty               [] = "";
-    static const CHAR spooler             [] = "Spooler";
+    static const CHAR spooler             [] = "Spooler";           /* Should be available on all platforms */
     static const CHAR password            [] = "secret";
 
     /* Get the username and turn it into an account to be used in some tests */
@@ -267,9 +267,11 @@ static void test_create_delete_svc(void)
     ok(!svc_handle1, "Expected failure\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
 
-    /* TODO: Add check for illegal combination of service-type and start-type */
-
-    /* TODO: Add check for displayname, it must be unique (or NULL/empty) */
+    /* Illegal (SERVICE_BOOT_START and SERVICE_SYSTEM_START or only allowed for driver services) */
+    SetLastError(0xdeadbeef);
+    svc_handle1 = CreateServiceA(scm_handle, servicename, NULL, 0, SERVICE_WIN32_OWN_PROCESS, SERVICE_BOOT_START, 0, pathname, NULL, NULL, NULL, NULL, NULL);
+    ok(!svc_handle1, "Expected failure\n");
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
 
     /* The service already exists (check first, just in case) */
     svc_handle1 = OpenServiceA(scm_handle, spooler, GENERIC_READ);
@@ -284,6 +286,8 @@ static void test_create_delete_svc(void)
     else
         skip("Spooler service doesn't exist\n");
 
+    /* TODO: Add check for displayname, it must be unique (or NULL/empty) */
+
     CloseServiceHandle(scm_handle);
 }
 




More information about the wine-cvs mailing list