- fix indentation and remove trailing whitespace

- StartServiceA/W: terminate argument buffer with a double zero.

svn path=/trunk/; revision=23801
This commit is contained in:
Eric Kohl 2006-08-30 10:53:37 +00:00
parent a301256472
commit 99e4b3809f

View file

@ -442,8 +442,7 @@ CreateServiceA(SC_HANDLE hSCManager,
if (!lpServiceNameW) if (!lpServiceNameW)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto cleanup;
goto cleanup;
} }
MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, lpServiceNameW, len); MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, lpServiceNameW, len);
} }
@ -455,8 +454,7 @@ CreateServiceA(SC_HANDLE hSCManager,
if (!lpDisplayNameW) if (!lpDisplayNameW)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto cleanup;
goto cleanup;
} }
MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, lpDisplayNameW, len); MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, lpDisplayNameW, len);
} }
@ -468,8 +466,7 @@ CreateServiceA(SC_HANDLE hSCManager,
if (!lpBinaryPathNameW) if (!lpBinaryPathNameW)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto cleanup;
goto cleanup;
} }
MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, lpBinaryPathNameW, len); MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, lpBinaryPathNameW, len);
} }
@ -481,8 +478,7 @@ CreateServiceA(SC_HANDLE hSCManager,
if (!lpLoadOrderGroupW) if (!lpLoadOrderGroupW)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto cleanup;
goto cleanup;
} }
MultiByteToWideChar(CP_ACP, 0, lpLoadOrderGroup, -1, lpLoadOrderGroupW, len); MultiByteToWideChar(CP_ACP, 0, lpLoadOrderGroup, -1, lpLoadOrderGroupW, len);
} }
@ -502,8 +498,7 @@ CreateServiceA(SC_HANDLE hSCManager,
if (!lpDependenciesW) if (!lpDependenciesW)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto cleanup;
goto cleanup;
} }
MultiByteToWideChar(CP_ACP, 0, lpDependencies, -1, lpDependenciesW, dwDependenciesLength); MultiByteToWideChar(CP_ACP, 0, lpDependencies, -1, lpDependenciesW, dwDependenciesLength);
} }
@ -515,8 +510,7 @@ CreateServiceA(SC_HANDLE hSCManager,
if (!lpServiceStartNameW) if (!lpServiceStartNameW)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto cleanup;
goto cleanup;
} }
MultiByteToWideChar(CP_ACP, 0, lpServiceStartName, -1, lpServiceStartNameW, len); MultiByteToWideChar(CP_ACP, 0, lpServiceStartName, -1, lpServiceStartNameW, len);
} }
@ -528,8 +522,7 @@ CreateServiceA(SC_HANDLE hSCManager,
if (!lpPasswordW) if (!lpPasswordW)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto cleanup;
goto cleanup;
} }
MultiByteToWideChar(CP_ACP, 0, lpPassword, -1, lpPasswordW, len); MultiByteToWideChar(CP_ACP, 0, lpPassword, -1, lpPasswordW, len);
} }
@ -549,34 +542,26 @@ CreateServiceA(SC_HANDLE hSCManager,
lpPasswordW); lpPasswordW);
cleanup: cleanup:
if (lpServiceNameW !=NULL) if (lpServiceNameW !=NULL)
{ HeapFree(GetProcessHeap(), 0, lpServiceNameW);
HeapFree(GetProcessHeap(), 0, lpServiceNameW);
}
if (lpDisplayNameW != NULL) if (lpDisplayNameW != NULL)
{ HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
} if (lpBinaryPathNameW != NULL)
if (lpBinaryPathNameW != NULL) HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
{
HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW); if (lpLoadOrderGroupW != NULL)
} HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
if (lpLoadOrderGroupW != NULL)
{ if (lpDependenciesW != NULL)
HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW); HeapFree(GetProcessHeap(), 0, lpDependenciesW);
}
if (lpDependenciesW != NULL) if (lpServiceStartNameW != NULL)
{ HeapFree(GetProcessHeap(), 0, lpServiceStartNameW);
HeapFree(GetProcessHeap(), 0, lpDependenciesW);
} if (lpPasswordW != NULL)
if (lpServiceStartNameW != NULL) HeapFree(GetProcessHeap(), 0, lpPasswordW);
{
HeapFree(GetProcessHeap(), 0, lpServiceStartNameW);
}
if (lpPasswordW != NULL)
{
HeapFree(GetProcessHeap(), 0, lpPasswordW);
}
return RetVal; return RetVal;
} }
@ -1982,6 +1967,7 @@ StartServiceA(SC_HANDLE hService,
{ {
dwBufSize += (strlen(lpServiceArgVectors[i]) + 1); dwBufSize += (strlen(lpServiceArgVectors[i]) + 1);
} }
dwBufSize++;
DPRINT1("dwBufSize: %lu\n", dwBufSize); DPRINT1("dwBufSize: %lu\n", dwBufSize);
lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufSize); lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufSize);
@ -1997,6 +1983,7 @@ StartServiceA(SC_HANDLE hService,
strcpy(lpStr, lpServiceArgVectors[i]); strcpy(lpStr, lpServiceArgVectors[i]);
lpStr += (strlen(lpServiceArgVectors[i]) + 1); lpStr += (strlen(lpServiceArgVectors[i]) + 1);
} }
*lpStr = 0;
dwError = ScmrStartServiceA(BindingHandle, dwError = ScmrStartServiceA(BindingHandle,
(unsigned int)hService, (unsigned int)hService,
@ -2038,6 +2025,7 @@ StartServiceW(SC_HANDLE hService,
{ {
dwBufSize += ((wcslen(lpServiceArgVectors[i]) + 1) * sizeof(WCHAR)); dwBufSize += ((wcslen(lpServiceArgVectors[i]) + 1) * sizeof(WCHAR));
} }
dwBufSize += sizeof(WCHAR);
DPRINT1("dwBufSize: %lu\n", dwBufSize); DPRINT1("dwBufSize: %lu\n", dwBufSize);
lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufSize); lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufSize);
@ -2053,6 +2041,7 @@ StartServiceW(SC_HANDLE hService,
wcscpy(lpStr, lpServiceArgVectors[i]); wcscpy(lpStr, lpServiceArgVectors[i]);
lpStr += (wcslen(lpServiceArgVectors[i]) + 1); lpStr += (wcslen(lpServiceArgVectors[i]) + 1);
} }
*lpStr = 0;
dwError = ScmrStartServiceW(BindingHandle, dwError = ScmrStartServiceW(BindingHandle,
(unsigned int)hService, (unsigned int)hService,