Author: cwittich
Date: Sun Jan 13 17:22:55 2008
New Revision: 31761
URL:
http://svn.reactos.org/svn/reactos?rev=31761&view=rev
Log:
only allocate a buffer in StartServiceA when dwNumServiceArgs > 0
adjust the image path in services/rpcserver
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 Sun Jan 13 17:22:55 2008
@@ -1058,17 +1058,24 @@
if (dwServiceType & SERVICE_DRIVER)
{
- /* FIXME: Adjust the image path */
-
lpImagePath = (WCHAR*) HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
- (wcslen(lpBinaryPathName) + 1) * sizeof(WCHAR));
+ (wcslen(lpBinaryPathName) + 5) * sizeof(WCHAR));
if (lpImagePath == NULL)
{
dwError = ERROR_NOT_ENOUGH_MEMORY;
goto done;
}
- wcscpy(lpImagePath, lpBinaryPathName);
+
+ if (lpBinaryPathName[1] == L':')
+ {
+ wcscpy(lpImagePath, L"\\??\\");
+ wcscat(lpImagePath, lpBinaryPathName);
+ }
+ else
+ {
+ wcscpy(lpImagePath, lpBinaryPathName);
+ }
}
/* Allocate a new service entry */
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 Sun Jan 13 17:22:55 2008
@@ -1998,34 +1998,36 @@
DWORD dwNumServiceArgs,
LPCSTR *lpServiceArgVectors)
{
- LPSTR lpBuffer;
+ LPSTR lpBuffer = NULL;
LPSTR lpStr;
DWORD dwError;
- DWORD dwBufSize;
+ DWORD dwBufSize = 0;
DWORD i;
- dwBufSize = 0;
- for (i = 0; i < dwNumServiceArgs; i++)
- {
- dwBufSize += (strlen(lpServiceArgVectors[i]) + 1);
- }
- dwBufSize++;
- 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++)
- {
- strcpy(lpStr, lpServiceArgVectors[i]);
- lpStr += (strlen(lpServiceArgVectors[i]) + 1);
- }
- *lpStr = 0;
+ if (dwNumServiceArgs > 0)
+ {
+ for (i = 0; i < dwNumServiceArgs; i++)
+ {
+ dwBufSize += (strlen(lpServiceArgVectors[i]) + 1);
+ }
+ dwBufSize++;
+ 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++)
+ {
+ strcpy(lpStr, lpServiceArgVectors[i]);
+ lpStr += (strlen(lpServiceArgVectors[i]) + 1);
+ }
+ *lpStr = 0;
+ }
dwError = ScmrStartServiceA(BindingHandle,
(unsigned int)hService,
@@ -2033,7 +2035,8 @@
(unsigned char *)lpBuffer,
dwBufSize);
- HeapFree(GetProcessHeap(), 0, lpBuffer);
+ if (lpBuffer != NULL)
+ HeapFree(GetProcessHeap(), 0, lpBuffer);
if (dwError != ERROR_SUCCESS)
{