[ros-diffs] [ekohl] 36985: Service Manager: - Fix declaration of SERVICE_STATUS_HANDLE in the PSDK. - Add a new custom binding handle to svcctl.idl as an alias of SERVICE_STATUS_HANDLE. - Enable all custom binding handles in svcctl.idl and fix services.exe and advapi32.dll accordingly.

ekohl at svn.reactos.org ekohl at svn.reactos.org
Sun Oct 26 13:33:36 CET 2008


Author: ekohl
Date: Sun Oct 26 07:33:36 2008
New Revision: 36985

URL: http://svn.reactos.org/svn/reactos?rev=36985&view=rev
Log:
Service Manager:
- Fix declaration of SERVICE_STATUS_HANDLE in the PSDK.
- Add a new custom binding handle to svcctl.idl as an alias of SERVICE_STATUS_HANDLE.
- Enable all custom binding handles in svcctl.idl and fix services.exe and advapi32.dll accordingly.

Modified:
    trunk/reactos/base/system/services/rpcserver.c
    trunk/reactos/dll/win32/advapi32/service/scm.c
    trunk/reactos/dll/win32/advapi32/service/sctrl.c
    trunk/reactos/include/psdk/winsvc.h
    trunk/reactos/include/reactos/idl/svcctl.idl

Modified: trunk/reactos/base/system/services/rpcserver.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcserver.c?rev=36985&r1=36984&r2=36985&view=diff
==============================================================================
--- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Sun Oct 26 07:33:36 2008
@@ -1004,8 +1004,8 @@
 
 /* Function 7 */
 DWORD RSetServiceStatus(
-    handle_t BindingHandle,
-    SC_RPC_HANDLE hServiceStatus,
+//    handle_t BindingHandle,
+    RPC_SERVICE_STATUS_HANDLE hServiceStatus,
     LPSERVICE_STATUS lpServiceStatus)
 {
     PSERVICE lpService;
@@ -1026,7 +1026,7 @@
         return ERROR_INVALID_HANDLE;
     }
 
-    lpService = ScmGetServiceEntryByClientHandle((ULONG)hServiceStatus);
+    lpService = ScmGetServiceEntryByClientHandle(hServiceStatus);
     if (lpService == NULL)
     {
         DPRINT1("lpService == NULL!\n");
@@ -1091,8 +1091,8 @@
 
 /* Function 10 */
 DWORD RI_ScSetServiceBitsW(
-    handle_t BindingHandle,
-    SC_RPC_HANDLE hServiceStatus,
+//    handle_t BindingHandle,
+    RPC_SERVICE_STATUS_HANDLE hServiceStatus,
     DWORD dwServiceBits,
     int bSetBitsOn,
     int bUpdateImmediately,
@@ -2388,7 +2388,7 @@
 
 /* Function 15 */
 DWORD ROpenSCManagerW(
-    handle_t BindingHandle,
+//    handle_t BindingHandle,
     LPWSTR lpMachineName,
     LPWSTR lpDatabaseName,
     DWORD dwDesiredAccess,
@@ -2893,8 +2893,8 @@
 
 /* Function 22 */
 DWORD RI_ScSetServiceBitsA(
-    handle_t BindingHandle,
-    SC_RPC_HANDLE hServiceStatus,
+//    handle_t BindingHandle,
+    RPC_SERVICE_STATUS_HANDLE hServiceStatus,
     DWORD dwServiceBits,
     int bSetBitsOn,
     int bUpdateImmediately,
@@ -3462,7 +3462,7 @@
 
 /* Function 27 */
 DWORD ROpenSCManagerA(
-    handle_t BindingHandle,
+//    handle_t BindingHandle,
     LPSTR lpMachineName,
     LPSTR lpDatabaseName,
     DWORD dwDesiredAccess,
@@ -3482,7 +3482,7 @@
         RtlCreateUnicodeStringFromAsciiz(&DatabaseName,
                                          lpDatabaseName);
 
-    dwError = ROpenSCManagerW(BindingHandle,
+    dwError = ROpenSCManagerW(//BindingHandle,
                               lpMachineName ? MachineName.Buffer : NULL,
                               lpDatabaseName ? DatabaseName.Buffer : NULL,
                               dwDesiredAccess,

Modified: trunk/reactos/dll/win32/advapi32/service/scm.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service/scm.c?rev=36985&r1=36984&r2=36985&view=diff
==============================================================================
--- trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] Sun Oct 26 07:33:36 2008
@@ -76,6 +76,172 @@
     }
 }
 #endif
+
+handle_t __RPC_USER
+SVCCTL_HANDLEA_bind(SVCCTL_HANDLEA szMachineName)
+{
+    handle_t hBinding = NULL;
+    UCHAR *pszStringBinding;
+    RPC_STATUS status;
+
+    ERR("SVCCTL_HANDLEA_bind() called\n");
+
+    status = RpcStringBindingComposeA((UCHAR *)szMachineName,
+                                      (UCHAR *)"ncacn_np",
+                                      NULL,
+                                      (UCHAR *)"\\pipe\\ntsvcs",
+                                      NULL,
+                                      (UCHAR **)&pszStringBinding);
+    if (status)
+    {
+        ERR("RpcStringBindingCompose returned 0x%x\n", status);
+        return NULL;
+    }
+
+    /* Set the binding handle that will be used to bind to the server. */
+    status = RpcBindingFromStringBindingA(pszStringBinding,
+                                          &hBinding);
+    if (status)
+    {
+        ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
+    }
+
+    status = RpcStringFreeA(&pszStringBinding);
+    if (status)
+    {
+        ERR("RpcStringFree returned 0x%x\n", status);
+    }
+
+    return hBinding;
+}
+
+
+void __RPC_USER
+SVCCTL_HANDLEA_unbind(SVCCTL_HANDLEA szMachineName,
+                      handle_t hBinding)
+{
+    RPC_STATUS status;
+
+    ERR("SVCCTL_HANDLEA_unbind() called\n");
+
+    status = RpcBindingFree(&hBinding);
+    if (status)
+    {
+        ERR("RpcBindingFree returned 0x%x\n", status);
+    }
+}
+
+
+handle_t __RPC_USER
+SVCCTL_HANDLEW_bind(SVCCTL_HANDLEW szMachineName)
+{
+    handle_t hBinding = NULL;
+    LPWSTR pszStringBinding;
+    RPC_STATUS status;
+
+    ERR("SVCCTL_HANDLEW_bind() called\n");
+
+
+    status = RpcStringBindingComposeW(szMachineName,
+                                      L"ncacn_np",
+                                      NULL,
+                                      L"\\pipe\\ntsvcs",
+                                      NULL,
+                                      &pszStringBinding);
+    if (status)
+    {
+        ERR("RpcStringBindingCompose returned 0x%x\n", status);
+        return NULL;
+    }
+
+    /* Set the binding handle that will be used to bind to the server. */
+    status = RpcBindingFromStringBindingW(pszStringBinding,
+                                          &hBinding);
+    if (status)
+    {
+        ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
+    }
+
+    status = RpcStringFreeW(&pszStringBinding);
+    if (status)
+    {
+        ERR("RpcStringFree returned 0x%x\n", status);
+    }
+
+    return hBinding;
+}
+
+
+void __RPC_USER
+SVCCTL_HANDLEW_unbind(SVCCTL_HANDLEW szMachineName,
+                      handle_t hBinding)
+{
+    RPC_STATUS status;
+
+    ERR("SVCCTL_HANDLEW_unbind() called\n");
+
+    status = RpcBindingFree(&hBinding);
+    if (status)
+    {
+        ERR("RpcBindingFree returned 0x%x\n", status);
+    }
+}
+
+
+handle_t __RPC_USER
+RPC_SERVICE_STATUS_HANDLE_bind(RPC_SERVICE_STATUS_HANDLE hServiceStatus)
+{
+    handle_t hBinding = NULL;
+    LPWSTR pszStringBinding;
+    RPC_STATUS status;
+
+    ERR("RPC_SERVICE_STATUS_HANDLE_bind() called\n");
+
+
+    status = RpcStringBindingComposeW(NULL,
+                                      L"ncacn_np",
+                                      NULL,
+                                      L"\\pipe\\ntsvcs",
+                                      NULL,
+                                      &pszStringBinding);
+    if (status)
+    {
+        ERR("RpcStringBindingCompose returned 0x%x\n", status);
+        return NULL;
+    }
+
+    /* Set the binding handle that will be used to bind to the server. */
+    status = RpcBindingFromStringBindingW(pszStringBinding,
+                                          &hBinding);
+    if (status)
+    {
+        ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
+    }
+
+    status = RpcStringFreeW(&pszStringBinding);
+    if (status)
+    {
+        ERR("RpcStringFree returned 0x%x\n", status);
+    }
+
+    return hBinding;
+}
+
+
+void __RPC_USER
+RPC_SERVICE_STATUS_HANDLE_unbind(RPC_SERVICE_STATUS_HANDLE hServiceStatus,
+                                 handle_t hBinding)
+{
+    RPC_STATUS status;
+
+    ERR("RPC_SERVICE_STATUS_HANDLE_unbind() called\n");
+
+    status = RpcBindingFree(&hBinding);
+    if (status)
+    {
+        ERR("RpcBindingFree returned 0x%x\n", status);
+    }
+}
 
 
 DWORD
@@ -1494,12 +1660,12 @@
 
     WaitForSCManager();
 
-    HandleBind();
+//    HandleBind();
 
     _SEH_TRY
     {
         /* Call to services.exe using RPC */
-        dwError = ROpenSCManagerA(BindingHandle,
+        dwError = ROpenSCManagerA(//BindingHandle,
                                   (LPSTR)lpMachineName,
                                   (LPSTR)lpDatabaseName,
                                   dwDesiredAccess,
@@ -1542,12 +1708,12 @@
 
     WaitForSCManager();
 
-    HandleBind();
+//    HandleBind();
 
     _SEH_TRY
     {
         /* Call to services.exe using RPC */
-        dwError = ROpenSCManagerW(BindingHandle,
+        dwError = ROpenSCManagerW(//BindingHandle,
                                   (LPWSTR)lpMachineName,
                                   (LPWSTR)lpDatabaseName,
                                   dwDesiredAccess,

Modified: trunk/reactos/dll/win32/advapi32/service/sctrl.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service/sctrl.c?rev=36985&r1=36984&r2=36985&view=diff
==============================================================================
--- trunk/reactos/dll/win32/advapi32/service/sctrl.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/service/sctrl.c [iso-8859-1] Sun Oct 26 07:33:36 2008
@@ -536,7 +536,7 @@
  * @implemented
  */
 BOOL STDCALL
-I_ScSetServiceBitsA(SC_RPC_HANDLE hServiceStatus,
+I_ScSetServiceBitsA(SERVICE_STATUS_HANDLE hServiceStatus,
                     DWORD dwServiceBits,
                     BOOL bSetBitsOn,
                     BOOL bUpdateImmediately,
@@ -544,13 +544,13 @@
 {
     BOOL bResult;
 
-    HandleBind();
+//    HandleBind();
 
     _SEH_TRY
     {
         /* Call to services.exe using RPC */
-        bResult = RI_ScSetServiceBitsA(BindingHandle,
-                                       (SC_RPC_HANDLE)hServiceStatus,
+        bResult = RI_ScSetServiceBitsA(//BindingHandle,
+                                       (RPC_SERVICE_STATUS_HANDLE)hServiceStatus,
                                        dwServiceBits,
                                        bSetBitsOn,
                                        bUpdateImmediately,
@@ -575,7 +575,7 @@
  * @implemented
  */
 BOOL STDCALL
-I_ScSetServiceBitsW(SC_RPC_HANDLE hServiceStatus,
+I_ScSetServiceBitsW(SERVICE_STATUS_HANDLE hServiceStatus,
                     DWORD dwServiceBits,
                     BOOL bSetBitsOn,
                     BOOL bUpdateImmediately,
@@ -583,13 +583,13 @@
 {
     BOOL bResult;
 
-    HandleBind();
+//    HandleBind();
 
     _SEH_TRY
     {
         /* Call to services.exe using RPC */
-        bResult = RI_ScSetServiceBitsW(BindingHandle,
-                                       (SC_RPC_HANDLE)hServiceStatus,
+        bResult = RI_ScSetServiceBitsW(//BindingHandle,
+                                       (RPC_SERVICE_STATUS_HANDLE)hServiceStatus,
                                        dwServiceBits,
                                        bSetBitsOn,
                                        bUpdateImmediately,
@@ -639,11 +639,11 @@
     TRACE("SetServiceStatus() called\n");
     TRACE("hServiceStatus %lu\n", hServiceStatus);
 
-    HandleBind();
+//    HandleBind();
 
     /* Call to services.exe using RPC */
-    dwError = RSetServiceStatus(BindingHandle,
-                                (SC_RPC_HANDLE)hServiceStatus,
+    dwError = RSetServiceStatus(//BindingHandle,
+                                (RPC_SERVICE_STATUS_HANDLE)hServiceStatus,
                                 lpServiceStatus);
     if (dwError != ERROR_SUCCESS)
     {

Modified: trunk/reactos/include/psdk/winsvc.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winsvc.h?rev=36985&r1=36984&r2=36985&view=diff
==============================================================================
--- trunk/reactos/include/psdk/winsvc.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/winsvc.h [iso-8859-1] Sun Oct 26 07:33:36 2008
@@ -158,7 +158,7 @@
 DECLARE_HANDLE(SC_HANDLE);
 typedef SC_HANDLE *LPSC_HANDLE;
 typedef PVOID SC_LOCK;
-typedef DWORD SERVICE_STATUS_HANDLE;
+DECLARE_HANDLE(SERVICE_STATUS_HANDLE);
 typedef VOID(WINAPI *LPHANDLER_FUNCTION)(DWORD);
 typedef DWORD (WINAPI *LPHANDLER_FUNCTION_EX)(DWORD,DWORD,LPVOID,LPVOID);
 typedef struct _SERVICE_DESCRIPTIONA {

Modified: trunk/reactos/include/reactos/idl/svcctl.idl
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/idl/svcctl.idl?rev=36985&r1=36984&r2=36985&view=diff
==============================================================================
--- trunk/reactos/include/reactos/idl/svcctl.idl [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/idl/svcctl.idl [iso-8859-1] Sun Oct 26 07:33:36 2008
@@ -15,8 +15,9 @@
 const unsigned short SC_MAX_ARGUMENT_LENGTH = 1024;
 const unsigned short SC_MAX_ARGUMENTS = 1024;
 
-typedef /*[handle]*/ LPSTR SVCCTL_HANDLEA;
-typedef /*[handle]*/ LPWSTR SVCCTL_HANDLEW;
+typedef [handle] LPSTR SVCCTL_HANDLEA;
+typedef [handle] LPWSTR SVCCTL_HANDLEW;
+typedef [handle] ULONG_PTR RPC_SERVICE_STATUS_HANDLE;
 typedef /*[context_handle]*/ unsigned long SC_RPC_HANDLE;
 typedef SC_RPC_HANDLE* LPSC_RPC_HANDLE;
 typedef /*[context_handle]*/ unsigned long SC_RPC_LOCK;
@@ -296,9 +297,9 @@
   uuid(367abb81-9844-35f1-ad32-98f038001003),
   version(2.0),
   pointer_default(unique),
-  #ifndef __midl
+//  #ifndef __midl
   ,explicit_handle
-  #endif
+//  #endif
 ]
 interface svcctl
 {
@@ -350,8 +351,8 @@
 
     /* Function 7 */
     DWORD RSetServiceStatus(
-      [in] handle_t BindingHandle,
-      [in] SC_RPC_HANDLE hServiceStatus,
+//      [in] handle_t BindingHandle,
+      [in] RPC_SERVICE_STATUS_HANDLE hServiceStatus,
       [in] LPSERVICE_STATUS lpServiceStatus);
 
     /* Function 8 */
@@ -367,8 +368,8 @@
 
     /* Function 10 */
     DWORD RI_ScSetServiceBitsW(
-        [in] handle_t BindingHandle,
-        [in] SC_RPC_HANDLE hServiceStatus,
+//        [in] handle_t BindingHandle,
+        [in] RPC_SERVICE_STATUS_HANDLE hServiceStatus,
         [in] DWORD dwServiceBits,
         [in] BOOL bSetBitsOn,
         [in] BOOL bUpdateImmediately,
@@ -435,8 +436,8 @@
 
     /* Function 15 */
     DWORD ROpenSCManagerW(
-        [in] handle_t BindingHandle,
-        [in, string, unique, range(0, SC_MAX_COMPUTER_NAME_LENGTH)] LPWSTR lpMachineName,
+//        [in] handle_t BindingHandle,
+        [in, string, unique, range(0, SC_MAX_COMPUTER_NAME_LENGTH)] SVCCTL_HANDLEW lpMachineName,
         [in, string, unique, range(0, SC_MAX_NAME_LENGTH)] LPWSTR lpDatabaseName,
         [in] DWORD dwDesiredAccess,
         [out] LPSC_RPC_HANDLE lpScHandle);
@@ -491,8 +492,8 @@
 
     /* Function 22 */
     DWORD RI_ScSetServiceBitsA(
-        [in] handle_t BindingHandle,
-        [in] SC_RPC_HANDLE hServiceStatus,
+//        [in] handle_t BindingHandle,
+        [in] RPC_SERVICE_STATUS_HANDLE hServiceStatus,
         [in] DWORD dwServiceBits,
         [in] BOOL bSetBitsOn,
         [in] BOOL bUpdateImmediately,
@@ -559,8 +560,8 @@
 
     /* Function 27 */
     DWORD ROpenSCManagerA(
-        [in] handle_t BindingHandle,
-        [in, string, unique, range(0, SC_MAX_COMPUTER_NAME_LENGTH)] LPSTR lpMachineName,
+//        [in] handle_t BindingHandle,
+        [in, string, unique, range(0, SC_MAX_COMPUTER_NAME_LENGTH)] SVCCTL_HANDLEA lpMachineName,
         [in, string, unique, range(0, SC_MAX_NAME_LENGTH)] LPSTR lpDatabaseName,
         [in] DWORD dwDesiredAccess,
         [out] LPSC_RPC_HANDLE lpScHandle);



More information about the Ros-diffs mailing list