Author: hpoussin
Date: Mon Aug 7 21:04:48 2006
New Revision: 23519
URL:
http://svn.reactos.org/svn/reactos?rev=23519&view=rev
Log:
Call ScmrStartServiceW in StartServiceA to prevent code duplicating between
ScmrStartServiceA/W in services.exe
Modified:
trunk/reactos/base/system/services/rpcserver.c
trunk/reactos/dll/win32/advapi32/service/scm.c
Modified: trunk/reactos/base/system/services/rpcserver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
==============================================================================
--- trunk/reactos/base/system/services/rpcserver.c (original)
+++ trunk/reactos/base/system/services/rpcserver.c Mon Aug 7 21:04:48 2006
@@ -2094,8 +2094,7 @@
unsigned long cbBufSize)
{
DPRINT1("ScmrStartServiceA() called\n");
- return ERROR_SUCCESS;
-// return ERROR_CALL_NOT_IMPLEMENTED;
+ return ERROR_CALL_NOT_IMPLEMENTED;
}
Modified: trunk/reactos/dll/win32/advapi32/service/scm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/service/scm.c (original)
+++ trunk/reactos/dll/win32/advapi32/service/scm.c Mon Aug 7 21:04:48 2006
@@ -1970,16 +1970,16 @@
DWORD dwNumServiceArgs,
LPCSTR *lpServiceArgVectors)
{
- LPSTR lpBuffer;
- LPSTR lpStr;
+ LPWSTR lpBuffer;
+ LPWSTR lpStr;
DWORD dwError;
DWORD dwBufSize;
- DWORD i;
+ DWORD i, step;
dwBufSize = 0;
for (i = 0; i < dwNumServiceArgs; i++)
{
- dwBufSize += (strlen(lpServiceArgVectors[i]) + 1);
+ dwBufSize += MultiByteToWideChar(CP_ACP, 0, lpServiceArgVectors[i], -1, NULL,
0);
}
DPRINT1("dwBufSize: %lu\n", dwBufSize);
@@ -1993,64 +1993,12 @@
lpStr = lpBuffer;
for (i = 0; i < dwNumServiceArgs; i++)
{
- strcpy(lpStr, lpServiceArgVectors[i]);
- lpStr += (strlen(lpServiceArgVectors[i]) + 1);
- }
-
- dwError = ScmrStartServiceA(BindingHandle,
- (unsigned int)hService,
- dwNumServiceArgs,
- (unsigned char *)lpBuffer,
- dwBufSize);
-
- HeapFree(GetProcessHeap(), 0, lpBuffer);
-
- if (dwError != ERROR_SUCCESS)
- {
- DPRINT1("ScmrStartServiceA() failed (Error %lu)\n", dwError);
- SetLastError(dwError);
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/**********************************************************************
- * StartServiceW
- *
- * @implemented
- */
-BOOL STDCALL
-StartServiceW(SC_HANDLE hService,
- DWORD dwNumServiceArgs,
- LPCWSTR *lpServiceArgVectors)
-{
- LPWSTR lpBuffer;
- LPWSTR lpStr;
- DWORD dwError;
- DWORD dwBufSize;
- DWORD i;
-
- dwBufSize = 0;
- for (i = 0; i < dwNumServiceArgs; i++)
- {
- dwBufSize += ((wcslen(lpServiceArgVectors[i]) + 1) * sizeof(WCHAR));
- }
- DPRINT1("dwBufSize: %lu\n", dwBufSize);
-
- lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufSize);
- if (lpBuffer == NULL)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
-
- lpStr = lpBuffer;
- for (i = 0; i < dwNumServiceArgs; i++)
- {
- wcscpy(lpStr, lpServiceArgVectors[i]);
- lpStr += (wcslen(lpServiceArgVectors[i]) + 1);
+ step = MultiByteToWideChar(CP_ACP, 0,
+ lpServiceArgVectors[i], -1,
+ lpStr, lpBuffer + dwBufSize - lpStr);
+ if (step == 0)
+ return FALSE;
+ lpStr += step + 1;
}
dwError = ScmrStartServiceW(BindingHandle,
@@ -2073,6 +2021,62 @@
/**********************************************************************
+ * StartServiceW
+ *
+ * @implemented
+ */
+BOOL STDCALL
+StartServiceW(SC_HANDLE hService,
+ DWORD dwNumServiceArgs,
+ LPCWSTR *lpServiceArgVectors)
+{
+ LPWSTR lpBuffer;
+ LPWSTR lpStr;
+ DWORD dwError;
+ DWORD dwBufSize;
+ DWORD i;
+
+ dwBufSize = 0;
+ for (i = 0; i < dwNumServiceArgs; i++)
+ {
+ dwBufSize += ((wcslen(lpServiceArgVectors[i]) + 1) * sizeof(WCHAR));
+ }
+ DPRINT1("dwBufSize: %lu\n", dwBufSize);
+
+ lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufSize);
+ if (lpBuffer == NULL)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
+ }
+
+ lpStr = lpBuffer;
+ for (i = 0; i < dwNumServiceArgs; i++)
+ {
+ wcscpy(lpStr, lpServiceArgVectors[i]);
+ lpStr += (wcslen(lpServiceArgVectors[i]) + 1);
+ }
+
+ dwError = ScmrStartServiceW(BindingHandle,
+ (unsigned int)hService,
+ dwNumServiceArgs,
+ (unsigned char *)lpBuffer,
+ dwBufSize);
+
+ HeapFree(GetProcessHeap(), 0, lpBuffer);
+
+ if (dwError != ERROR_SUCCESS)
+ {
+ DPRINT1("ScmrStartServiceW() failed (Error %lu)\n", dwError);
+ SetLastError(dwError);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/**********************************************************************
* UnlockServiceDatabase
*
* @implemented