-handle RPC_X_ENUM_VALUE_OUT_OF_RANGE and RPC_X_BYTE_COUNT_TOO_SMALL in ScmRpcStatusToWinError
-add some traces
-don't write to NULL pointers, don't do strlen on a NULL pointer
svn path=/trunk/; revision=38603
DWORD
-ScmCreateServiceKey(LPWSTR lpServiceName,
+ScmCreateServiceKey(LPCWSTR lpServiceName,
REGSAM samDesired,
PHKEY phKey)
{
PSERVICE
-ScmGetServiceEntryByName(LPWSTR lpServiceName)
+ScmGetServiceEntryByName(LPCWSTR lpServiceName)
{
PLIST_ENTRY ServiceEntry;
PSERVICE CurrentService;
PSERVICE
-ScmGetServiceEntryByDisplayName(LPWSTR lpDisplayName)
+ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName)
{
PLIST_ENTRY ServiceEntry;
PSERVICE CurrentService;
DWORD
-ScmCreateNewServiceRecord(LPWSTR lpServiceName,
+ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
PSERVICE *lpServiceRecord)
{
PSERVICE lpService = NULL;
static DWORD
-CreateServiceListEntry(LPWSTR lpServiceName,
+CreateServiceListEntry(LPCWSTR lpServiceName,
HKEY hServiceKey)
{
PSERVICE lpService = NULL;
DWORD
ScmSetServiceGroup(PSERVICE lpService,
- LPWSTR lpGroupName)
+ LPCWSTR lpGroupName)
{
PLIST_ENTRY GroupEntry;
PSERVICE_GROUP lpGroup;
DWORD
ScmCanonDriverImagePath(DWORD dwStartType,
- wchar_t *lpServiceName,
+ const wchar_t *lpServiceName,
wchar_t **lpCanonName)
{
DWORD ServiceNameLen, Result;
UNICODE_STRING NtServiceName;
WCHAR *RelativeName;
- WCHAR *SourceName = lpServiceName;
+ const WCHAR *SourceName = lpServiceName;
/* Calculate the length of the service's name */
ServiceNameLen = wcslen(lpServiceName);
/* Function 12 */
DWORD RCreateServiceW(
SC_RPC_HANDLE hSCManager,
- LPWSTR lpServiceName,
- LPWSTR lpDisplayName,
+ LPCWSTR lpServiceName,
+ LPCWSTR lpDisplayName,
DWORD dwDesiredAccess,
DWORD dwServiceType,
DWORD dwStartType,
DWORD dwErrorControl,
- LPWSTR lpBinaryPathName,
- LPWSTR lpLoadOrderGroup,
+ LPCWSTR lpBinaryPathName,
+ LPCWSTR lpLoadOrderGroup,
LPDWORD lpdwTagId,
LPBYTE lpDependencies,
DWORD dwDependSize,
- LPWSTR lpServiceStartName,
+ LPCWSTR lpServiceStartName,
LPBYTE lpPassword,
DWORD dwPwSize,
LPSC_RPC_HANDLE lpServiceHandle)
/* Function 20 */
DWORD RGetServiceDisplayNameW(
SC_RPC_HANDLE hSCManager,
- LPWSTR lpServiceName,
+ LPCWSTR lpServiceName,
LPWSTR lpDisplayName,
DWORD *lpcchBuffer)
{
if (*lpcchBuffer == 0)
{
*lpcchBuffer = 1;
- *lpDisplayName = '\0';
+ if (lpDisplayName != NULL)
+ {
+ *lpDisplayName = '\0';
+ }
}
return ERROR_SERVICE_DOES_NOT_EXIST;
{
dwLength = wcslen(lpService->lpServiceName);
- if (lpServiceName != NULL &&
+ if (lpDisplayName != NULL &&
*lpcchBuffer > dwLength)
{
wcscpy(lpDisplayName, lpService->lpServiceName);
/* Function 21 */
DWORD RGetServiceKeyNameW(
SC_RPC_HANDLE hSCManager,
- LPWSTR lpDisplayName,
+ LPCWSTR lpDisplayName,
LPWSTR lpServiceName,
DWORD *lpcchBuffer)
{
if (*lpcchBuffer == 0)
{
*lpcchBuffer = 2;
- *lpServiceName = '\0';
+ if (lpServiceName != NULL)
+ {
+ *lpServiceName = '\0';
+ }
}
return ERROR_SERVICE_DOES_NOT_EXIST;
/* Function 32 */
DWORD RGetServiceDisplayNameA(
SC_RPC_HANDLE hSCManager,
- LPSTR lpServiceName,
+ LPCSTR lpServiceName,
LPSTR lpDisplayName,
LPBOUNDED_DWORD_4K lpcchBuffer)
{
// PMANAGER_HANDLE hManager;
- PSERVICE lpService;
+ PSERVICE lpService = NULL;
DWORD dwLength;
DWORD dwError;
LPWSTR lpServiceNameW;
// return ERROR_INVALID_HANDLE;
// }
- dwLength = strlen(lpServiceName) + 1;
- lpServiceNameW = HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- dwLength * sizeof(WCHAR));
- if (!lpServiceNameW)
- return ERROR_NOT_ENOUGH_MEMORY;
+ if (lpServiceName != NULL)
+ {
+ dwLength = strlen(lpServiceName) + 1;
+ lpServiceNameW = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ dwLength * sizeof(WCHAR));
+ if (!lpServiceNameW)
+ return ERROR_NOT_ENOUGH_MEMORY;
- MultiByteToWideChar(CP_ACP,
- 0,
- lpServiceName,
- strlen(lpServiceName),
- lpServiceNameW,
- dwLength);
+ MultiByteToWideChar(CP_ACP,
+ 0,
+ lpServiceName,
+ -1,
+ lpServiceNameW,
+ dwLength);
- lpService = ScmGetServiceEntryByName(lpServiceNameW);
+ lpService = ScmGetServiceEntryByName(lpServiceNameW);
- HeapFree(GetProcessHeap(), 0, lpServiceNameW);
+ HeapFree(GetProcessHeap(), 0, lpServiceNameW);
+ }
if (lpService == NULL)
{
if (*lpcchBuffer == 0)
{
*lpcchBuffer = 1;
- *lpDisplayName = '\0';
+ if (lpDisplayName != NULL)
+ {
+ *lpDisplayName = '\0';
+ }
}
return ERROR_SERVICE_DOES_NOT_EXIST;
}
if (!lpService->lpDisplayName)
{
dwLength = wcslen(lpService->lpServiceName);
- if (lpServiceName != NULL &&
+ if (lpDisplayName != NULL &&
*lpcchBuffer > dwLength)
{
WideCharToMultiByte(CP_ACP,
lpService->lpServiceName,
wcslen(lpService->lpServiceName),
lpDisplayName,
- *lpcchBuffer,
+ dwLength + 1,
NULL,
NULL);
return ERROR_SUCCESS;
lpService->lpDisplayName,
wcslen(lpService->lpDisplayName),
lpDisplayName,
- *lpcchBuffer,
+ dwLength + 1,
NULL,
NULL);
return ERROR_SUCCESS;
/* Function 33 */
DWORD RGetServiceKeyNameA(
SC_RPC_HANDLE hSCManager,
- LPSTR lpDisplayName,
+ LPCSTR lpDisplayName,
LPSTR lpServiceName,
LPBOUNDED_DWORD_4K lpcchBuffer)
{
MultiByteToWideChar(CP_ACP,
0,
lpDisplayName,
- strlen(lpDisplayName),
+ -1,
lpDisplayNameW,
dwLength);
if (*lpcchBuffer == 0)
{
*lpcchBuffer = 1;
- *lpServiceName = '\0';
+ if (lpServiceName != NULL)
+ {
+ *lpServiceName = '\0';
+ }
}
return ERROR_SERVICE_DOES_NOT_EXIST;
}
dwLength = wcslen(lpService->lpServiceName);
- if (lpService != NULL &&
+ if (lpServiceName != NULL &&
*lpcchBuffer > dwLength)
{
WideCharToMultiByte(CP_ACP,
0,
lpService->lpServiceName,
wcslen(lpService->lpServiceName),
- lpServiceName,
+ lpServiceName + 1,
dwLength,
NULL,
NULL);
REGSAM samDesired,
PHKEY phKey);
-DWORD ScmCreateServiceKey(LPWSTR lpServiceName,
+DWORD ScmCreateServiceKey(LPCWSTR lpServiceName,
REGSAM samDesired,
PHKEY phKey);
DWORD argc,
LPWSTR *argv);
-PSERVICE ScmGetServiceEntryByName(LPWSTR lpServiceName);
-PSERVICE ScmGetServiceEntryByDisplayName(LPWSTR lpDisplayName);
+PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName);
+PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName);
PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount);
PSERVICE ScmGetServiceEntryByClientHandle(HANDLE Handle);
-DWORD ScmCreateNewServiceRecord(LPWSTR lpServiceName,
+DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
PSERVICE *lpServiceRecord);
VOID ScmDeleteServiceRecord(PSERVICE lpService);
DWORD ScmMarkServiceForDelete(PSERVICE pService);
DWORD ScmCreateGroupList(VOID);
DWORD ScmSetServiceGroup(PSERVICE lpService,
- LPWSTR lpGroupName);
+ LPCWSTR lpGroupName);
/* rpcserver.c */
(UCHAR *)"\\pipe\\ntsvcs",
NULL,
(UCHAR **)&pszStringBinding);
- if (status)
+ if (status != RPC_S_OK)
{
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)
+ if (status != RPC_S_OK)
{
ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
}
status = RpcStringFreeA(&pszStringBinding);
- if (status)
+ if (status != RPC_S_OK)
{
ERR("RpcStringFree returned 0x%x\n", status);
}
TRACE("SVCCTL_HANDLEA_unbind() called\n");
status = RpcBindingFree(&hBinding);
- if (status)
+ if (status != RPC_S_OK)
{
ERR("RpcBindingFree returned 0x%x\n", status);
}
L"\\pipe\\ntsvcs",
NULL,
&pszStringBinding);
- if (status)
+ if (status != RPC_S_OK)
{
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)
+ if (status != RPC_S_OK)
{
ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
}
status = RpcStringFreeW(&pszStringBinding);
- if (status)
+ if (status != RPC_S_OK)
{
ERR("RpcStringFree returned 0x%x\n", status);
}
TRACE("SVCCTL_HANDLEW_unbind() called\n");
status = RpcBindingFree(&hBinding);
- if (status)
+ if (status != RPC_S_OK)
{
ERR("RpcBindingFree returned 0x%x\n", status);
}
L"\\pipe\\ntsvcs",
NULL,
&pszStringBinding);
- if (status)
+ if (status != RPC_S_OK)
{
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)
+ if (status != RPC_S_OK)
{
ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
}
status = RpcStringFreeW(&pszStringBinding);
- if (status)
+ if (status != RPC_S_OK)
{
ERR("RpcStringFree returned 0x%x\n", status);
}
TRACE("RPC_SERVICE_STATUS_HANDLE_unbind() called\n");
status = RpcBindingFree(&hBinding);
- if (status)
+ if (status != RPC_S_OK)
{
ERR("RpcBindingFree returned 0x%x\n", status);
}
return ERROR_INVALID_HANDLE;
case RPC_X_NULL_REF_POINTER:
+ case RPC_X_ENUM_VALUE_OUT_OF_RANGE:
+ case RPC_X_BYTE_COUNT_TOO_SMALL:
return ERROR_INVALID_PARAMETER;
case STATUS_ACCESS_VIOLATION:
LPWSTR lpStr;
TRACE("CreateServiceW() called\n");
+ TRACE("%p %S %S\n", hSCManager,
+ lpServiceName, lpDisplayName);
/* Calculate the Dependencies length*/
if (lpDependencies != NULL)
{
/* Call to services.exe using RPC */
dwError = RCreateServiceW((SC_RPC_HANDLE)hSCManager,
- (LPWSTR)lpServiceName,
- (LPWSTR)lpDisplayName,
+ lpServiceName,
+ lpDisplayName,
dwDesiredAccess,
dwServiceType,
dwStartType,
dwErrorControl,
- (LPWSTR)lpBinaryPathName,
- (LPWSTR)lpLoadOrderGroup,
+ lpBinaryPathName,
+ lpLoadOrderGroup,
lpdwTagId,
(LPBYTE)lpDependencies,
dwDependenciesLength,
- (LPWSTR)lpServiceStartName,
+ lpServiceStartName,
NULL, /* FIXME: lpPassword */
0, /* FIXME: dwPasswordLength */
(SC_RPC_HANDLE *)&hService);
DWORD dwError;
TRACE("GetServiceDisplayNameA() called\n");
+ TRACE("%p %s %p %p\n", hSCManager,
+ debugstr_a(lpServiceName), lpDisplayName, lpcchBuffer);
if (!lpDisplayName)
*lpcchBuffer = 0;
_SEH2_TRY
{
dwError = RGetServiceDisplayNameA((SC_RPC_HANDLE)hSCManager,
- (LPSTR)lpServiceName,
+ lpServiceName,
lpDisplayName,
lpcchBuffer);
}
_SEH2_TRY
{
dwError = RGetServiceDisplayNameW((SC_RPC_HANDLE)hSCManager,
- (LPWSTR)lpServiceName,
+ lpServiceName,
lpDisplayName,
lpcchBuffer);
}
_SEH2_TRY
{
dwError = RGetServiceKeyNameA((SC_RPC_HANDLE)hSCManager,
- (LPSTR)lpDisplayName,
+ lpDisplayName,
lpServiceName,
lpcchBuffer);
}
_SEH2_TRY
{
dwError = RGetServiceKeyNameW((SC_RPC_HANDLE)hSCManager,
- (LPWSTR)lpDisplayName,
+ lpDisplayName,
lpServiceName,
lpcchBuffer);
}
/* Function 12 */
DWORD RCreateServiceW(
[in] SC_RPC_HANDLE hSCManager,
- [in, string, range(0, SC_MAX_NAME_LENGTH)] LPWSTR lpServiceName,
- [in, string, unique, range(0, SC_MAX_NAME_LENGTH)] LPWSTR lpDisplayName,
+ [in, string, range(0, SC_MAX_NAME_LENGTH)] LPCWSTR lpServiceName,
+ [in, string, unique, range(0, SC_MAX_NAME_LENGTH)] LPCWSTR lpDisplayName,
[in] DWORD dwDesiredAccess,
[in] DWORD dwServiceType,
[in] DWORD dwStartType,
[in] DWORD dwErrorControl,
- [in, string, range(0, SC_MAX_PATH_LENGTH)] LPWSTR lpBinaryPathName,
- [in, string, unique, range(0, SC_MAX_NAME_LENGTH)] LPWSTR lpLoadOrderGroup,
+ [in, string, range(0, SC_MAX_PATH_LENGTH)] LPCWSTR lpBinaryPathName,
+ [in, string, unique, range(0, SC_MAX_NAME_LENGTH)] LPCWSTR lpLoadOrderGroup,
[in, out, unique] LPDWORD lpdwTagId,
[in, unique, size_is(dwDependSize)] LPBYTE lpDependencies,
[in, range(0, SC_MAX_DEPEND_SIZE)] DWORD dwDependSize,
- [in, string, unique, range(0, SC_MAX_ACCOUNT_NAME_LENGTH)] LPWSTR lpServiceStartName,
+ [in, string, unique, range(0, SC_MAX_ACCOUNT_NAME_LENGTH)] LPCWSTR lpServiceStartName,
[in, unique, size_is(dwPwSize)] LPBYTE lpPassword,
[in, range(0, SC_MAX_PWD_SIZE)] DWORD dwPwSize,
[out] LPSC_RPC_HANDLE lpServiceHandle);
/* Function 20 */
DWORD RGetServiceDisplayNameW(
[in] SC_RPC_HANDLE hSCManager,
- [in, string, range(0, SC_MAX_NAME_LENGTH)] LPWSTR lpServiceName,
+ [in, string, range(0, SC_MAX_NAME_LENGTH)] LPCWSTR lpServiceName,
[out, string, range(1, 4*1024+1), size_is(*lpcchBuffer + 1)] LPWSTR lpDisplayName,
[in, out] DWORD* lpcchBuffer);
/* Function 21 */
DWORD RGetServiceKeyNameW(
[in] SC_RPC_HANDLE hSCManager,
- [in, string, range(0, SC_MAX_NAME_LENGTH)] LPWSTR lpDisplayName,
+ [in, string, range(0, SC_MAX_NAME_LENGTH)] LPCWSTR lpDisplayName,
[out, string, range(1, 4*1024+1), size_is(*lpcchBuffer + 1)] LPWSTR lpServiceName,
[in, out] DWORD* lpcchBuffer);
/* Function 32 */
DWORD RGetServiceDisplayNameA(
[in] SC_RPC_HANDLE hSCManager,
- [in, string, range(0, SC_MAX_NAME_LENGTH)] LPSTR lpServiceName,
+ [in, string, range(0, SC_MAX_NAME_LENGTH)] LPCSTR lpServiceName,
[out, string, size_is(*lpcchBuffer)] LPSTR lpDisplayName,
[in, out] LPBOUNDED_DWORD_4K lpcchBuffer);
/* Function 33 */
DWORD RGetServiceKeyNameA(
[in] SC_RPC_HANDLE hSCManager,
- [in, string, range(0, SC_MAX_NAME_LENGTH)] LPSTR lpDisplayName,
+ [in, string, range(0, SC_MAX_NAME_LENGTH)] LPCSTR lpDisplayName,
[out, string, size_is(*lpcchBuffer)] LPSTR lpKeyName,
[in, out] LPBOUNDED_DWORD_4K lpcchBuffer);