- Implement GetServiceKeyNameW (untested).
- Mark deleted service in the service list.
- Some SCM-Calls fail if the has been marked for delete.
Modified: trunk/reactos/include/idl/svcctl.idl
Modified: trunk/reactos/lib/advapi32/service/scm.c
Modified: trunk/reactos/subsys/system/services/rpcserver.c
Modified: trunk/reactos/subsys/system/services/services.h
_____
Modified: trunk/reactos/include/idl/svcctl.idl
--- trunk/reactos/include/idl/svcctl.idl 2005-10-30 19:37:11 UTC
(rev 18893)
+++ trunk/reactos/include/idl/svcctl.idl 2005-10-30 21:52:23 UTC
(rev 18894)
@@ -136,7 +136,14 @@
[out, size_is(*lpcchBuffer), unique]
LPWSTR lpDisplayName,
[in, out, ref] LPDWORD lpcchBuffer);
+ /* Function 21 */
+ DWORD ScmrGetServiceKeyNameW([in] handle_t BindingHandle,
+ [in] SC_HANDLE hSCManager,
+ [in, string, ref] LPCWSTR lpDisplayName,
+ [out, size_is(*lpcchBuffer), unique]
LPWSTR lpServiceName,
+ [in, out, ref] LPDWORD lpcchBuffer);
+
/* Function 27 */
DWORD ScmrOpenSCManagerA([in] handle_t BindingHandle,
[in, string, unique] LPCSTR lpMachineName,
_____
Modified: trunk/reactos/lib/advapi32/service/scm.c
--- trunk/reactos/lib/advapi32/service/scm.c 2005-10-30 19:37:11 UTC
(rev 18893)
+++ trunk/reactos/lib/advapi32/service/scm.c 2005-10-30 21:52:23 UTC
(rev 18894)
@@ -618,7 +618,7 @@
/**********************************************************************
* GetServiceKeyNameW
*
- * @unimplemented
+ * @implemented
*/
BOOL STDCALL
GetServiceKeyNameW(SC_HANDLE hSCManager,
@@ -626,7 +626,6 @@
LPWSTR lpServiceName,
LPDWORD lpcchBuffer)
{
-#if 0
DWORD dwError;
DPRINT("GetServiceKeyNameW() called\n");
@@ -646,10 +645,6 @@
}
return TRUE;
-#endif
- DPRINT1("GetServiceKeyNameW is unimplemented\n");
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
}
_____
Modified: trunk/reactos/subsys/system/services/rpcserver.c
--- trunk/reactos/subsys/system/services/rpcserver.c 2005-10-30
19:37:11 UTC (rev 18893)
+++ trunk/reactos/subsys/system/services/rpcserver.c 2005-10-30
21:52:23 UTC (rev 18894)
@@ -348,7 +348,15 @@
/* FIXME: Acquire service database lock exclusively */
+ if (lpService->bDeleted)
+ {
+ DPRINT1("The service has already been marked for delete!\n");
+ return ERROR_SERVICE_MARKED_FOR_DELETE;
+ }
+
/* Mark service for delete */
+ lpService->bDeleted = TRUE;
+
dwError = ScmMarkServiceForDelete(lpService);
/* FIXME: Release service database lock */
@@ -533,8 +541,19 @@
return ERROR_INVALID_HANDLE;
}
+ /* FIXME: Lock database exclusively */
+
+ if (lpService->bDeleted)
+ {
+ /* FIXME: Unlock database */
+ DPRINT1("The service has already been marked for delete!\n");
+ return ERROR_SERVICE_MARKED_FOR_DELETE;
+ }
+
/* FIXME: ... */
+ /* FIXME: Unlock database */
+
DPRINT1("ScmrChangeServiceConfigW() done (Error %lu)\n", dwError);
return dwError;
@@ -1007,6 +1026,56 @@
}
+/* Function 21 */
+unsigned long
+ScmrGetServiceKeyNameW(handle_t BindingHandle,
+ unsigned int hSCManager,
+ wchar_t *lpDisplayName,
+ wchar_t *lpServiceName, /* [out, unique] */
+ unsigned long *lpcchBuffer)
+{
+// PMANAGER_HANDLE hManager;
+ PSERVICE lpService;
+ DWORD dwLength;
+ DWORD dwError;
+
+ DPRINT1("ScmrGetServiceKeyNameW() called\n");
+ DPRINT1("hSCManager = %x\n", hSCManager);
+ DPRINT1("lpDisplayName: %S\n", lpDisplayName);
+ DPRINT1("lpServiceName: %p\n", lpServiceName);
+ DPRINT1("*lpcchBuffer: %lu\n", *lpcchBuffer);
+
+// hManager = (PMANAGER_HANDLE)hSCManager;
+// if (hManager->Handle.Tag != MANAGER_TAG)
+// {
+// DPRINT1("Invalid manager handle!\n");
+// return ERROR_INVALID_HANDLE;
+// }
+
+ /* Get service database entry */
+ lpService = ScmGetServiceEntryByDisplayName(lpDisplayName);
+ if (lpService == NULL)
+ {
+ DPRINT1("Could not find a service!\n");
+ return ERROR_SERVICE_DOES_NOT_EXIST;
+ }
+
+ dwLength = wcslen(lpService->lpServiceName);
+
+ if (lpServiceName != NULL &&
+ *lpcchBuffer > dwLength)
+ {
+ wcscpy(lpServiceName, lpService->lpServiceName);
+ }
+
+ dwError = (*lpcchBuffer > dwLength) ? ERROR_SUCCESS :
ERROR_INSUFFICIENT_BUFFER;
+
+ *lpcchBuffer = dwLength;
+
+ return dwError;
+}
+
+
/* Function 27 */
unsigned long
ScmrOpenSCManagerA(handle_t BindingHandle,
_____
Modified: trunk/reactos/subsys/system/services/services.h
--- trunk/reactos/subsys/system/services/services.h 2005-10-30
19:37:11 UTC (rev 18893)
+++ trunk/reactos/subsys/system/services/services.h 2005-10-30
21:52:23 UTC (rev 18894)
@@ -15,6 +15,7 @@
LPWSTR lpServiceName;
LPWSTR lpDisplayName;
UNICODE_STRING ServiceGroup;
+ BOOL bDeleted;
SERVICE_STATUS Status;
DWORD dwStartType;