mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-29 19:26:33 +00:00
[ADVAPI32][SERVICES]
- Remove unnecessary casts, fix some const-ness, fix a DPRINT, some spacing svn path=/trunk/; revision=54314
This commit is contained in:
@@ -94,7 +94,7 @@ ScmCreateServiceKey(LPCWSTR lpServiceName,
|
||||
|
||||
DWORD
|
||||
ScmWriteDependencies(HKEY hServiceKey,
|
||||
LPWSTR lpDependencies,
|
||||
LPCWSTR lpDependencies,
|
||||
DWORD dwDependenciesLength)
|
||||
{
|
||||
DWORD dwError = ERROR_SUCCESS;
|
||||
@@ -103,7 +103,7 @@ ScmWriteDependencies(HKEY hServiceKey,
|
||||
DWORD dwLength;
|
||||
LPWSTR lpGroupDeps;
|
||||
LPWSTR lpServiceDeps;
|
||||
LPWSTR lpSrc;
|
||||
LPCWSTR lpSrc;
|
||||
LPWSTR lpDst;
|
||||
|
||||
if (*lpDependencies == 0)
|
||||
|
||||
@@ -191,9 +191,9 @@ ScmCreateOrReferenceServiceImage(PSERVICE pService)
|
||||
if (pServiceImage == NULL)
|
||||
{
|
||||
/* Create a new service image */
|
||||
pServiceImage = (PSERVICE_IMAGE)HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
sizeof(SERVICE_IMAGE) + ((wcslen(ImagePath.Buffer) + 1) * sizeof(WCHAR)));
|
||||
pServiceImage = HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
sizeof(SERVICE_IMAGE) + ((wcslen(ImagePath.Buffer) + 1) * sizeof(WCHAR)));
|
||||
if (pServiceImage == NULL)
|
||||
{
|
||||
dwError = ERROR_NOT_ENOUGH_MEMORY;
|
||||
@@ -366,7 +366,7 @@ ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
|
||||
DPRINT("Service: '%S'\n", lpServiceName);
|
||||
|
||||
/* Allocate service entry */
|
||||
lpService = (SERVICE*)HeapAlloc(GetProcessHeap(),
|
||||
lpService = HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
sizeof(SERVICE) + ((wcslen(lpServiceName) + 1) * sizeof(WCHAR)));
|
||||
if (lpService == NULL)
|
||||
@@ -584,15 +584,17 @@ ScmDeleteRegKey(HKEY hKey, LPCWSTR lpszSubKey)
|
||||
{
|
||||
/* Find the maximum subkey length so that we can allocate a buffer */
|
||||
dwRet = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
|
||||
&dwMaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
&dwMaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
if (!dwRet)
|
||||
{
|
||||
dwMaxSubkeyLen++;
|
||||
if (dwMaxSubkeyLen > sizeof(szNameBuf)/sizeof(WCHAR))
|
||||
if (dwMaxSubkeyLen > sizeof(szNameBuf) / sizeof(WCHAR))
|
||||
{
|
||||
/* Name too big: alloc a buffer for it */
|
||||
lpszName = HeapAlloc(GetProcessHeap(), 0, dwMaxSubkeyLen*sizeof(WCHAR));
|
||||
lpszName = HeapAlloc(GetProcessHeap(), 0, dwMaxSubkeyLen * sizeof(WCHAR));
|
||||
}
|
||||
|
||||
if(!lpszName)
|
||||
if (!lpszName)
|
||||
dwRet = ERROR_NOT_ENOUGH_MEMORY;
|
||||
else
|
||||
{
|
||||
@@ -835,7 +837,7 @@ ScmCheckDriver(PSERVICE Service)
|
||||
|
||||
BufferLength = sizeof(OBJECT_DIRECTORY_INFORMATION) +
|
||||
2 * MAX_PATH * sizeof(WCHAR);
|
||||
DirInfo = (OBJECT_DIRECTORY_INFORMATION*) HeapAlloc(GetProcessHeap(),
|
||||
DirInfo = HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
BufferLength);
|
||||
|
||||
@@ -942,9 +944,9 @@ ScmControlService(PSERVICE Service,
|
||||
PacketSize = sizeof(SCM_CONTROL_PACKET);
|
||||
PacketSize += (wcslen(Service->lpServiceName) + 1) * sizeof(WCHAR);
|
||||
|
||||
ControlPacket = (SCM_CONTROL_PACKET*)HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
PacketSize);
|
||||
ControlPacket = HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
PacketSize);
|
||||
if (ControlPacket == NULL)
|
||||
{
|
||||
LeaveCriticalSection(&ControlServiceCriticalSection);
|
||||
@@ -1171,9 +1173,9 @@ ScmSendStartCommand(PSERVICE Service,
|
||||
}
|
||||
|
||||
/* Allocate a control packet */
|
||||
ControlPacket = (SCM_CONTROL_PACKET*)HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
PacketSize);
|
||||
ControlPacket = HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
PacketSize);
|
||||
if (ControlPacket == NULL)
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
|
||||
|
||||
@@ -144,16 +144,16 @@ ScmCreateManagerHandle(LPWSTR lpDatabaseName,
|
||||
|
||||
if (_wcsicmp(lpDatabaseName, SERVICES_FAILED_DATABASEW) == 0)
|
||||
{
|
||||
DPRINT("Database %S, does not exist\n",lpDatabaseName);
|
||||
DPRINT("Database %S, does not exist\n", lpDatabaseName);
|
||||
return ERROR_DATABASE_DOES_NOT_EXIST;
|
||||
}
|
||||
else if (_wcsicmp(lpDatabaseName, SERVICES_ACTIVE_DATABASEW) != 0)
|
||||
{
|
||||
DPRINT("Invalid Database name %S.\n",lpDatabaseName);
|
||||
DPRINT("Invalid Database name %S.\n", lpDatabaseName);
|
||||
return ERROR_INVALID_NAME;
|
||||
}
|
||||
|
||||
Ptr = (MANAGER_HANDLE*) HeapAlloc(GetProcessHeap(),
|
||||
Ptr = HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
sizeof(MANAGER_HANDLE) + (wcslen(lpDatabaseName) + 1) * sizeof(WCHAR));
|
||||
if (Ptr == NULL)
|
||||
@@ -175,7 +175,7 @@ ScmCreateServiceHandle(PSERVICE lpServiceEntry,
|
||||
{
|
||||
PSERVICE_HANDLE Ptr;
|
||||
|
||||
Ptr = (SERVICE_HANDLE*) HeapAlloc(GetProcessHeap(),
|
||||
Ptr = HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
sizeof(SERVICE_HANDLE));
|
||||
if (Ptr == NULL)
|
||||
@@ -629,7 +629,7 @@ DWORD RCloseServiceHandle(
|
||||
&pcbBytesNeeded,
|
||||
&dwServicesReturned);
|
||||
|
||||
/* if pcbBytesNeeded returned a value then there are services running that are dependent on this service*/
|
||||
/* if pcbBytesNeeded returned a value then there are services running that are dependent on this service */
|
||||
if (pcbBytesNeeded)
|
||||
{
|
||||
DPRINT("Deletion failed due to running dependencies.\n");
|
||||
@@ -1400,9 +1400,9 @@ DWORD RChangeServiceConfigW(
|
||||
(wcslen(lpDisplayName) + 1) * sizeof(WCHAR));
|
||||
|
||||
/* Update the display name */
|
||||
lpDisplayNameW = (LPWSTR)HeapAlloc(GetProcessHeap(),
|
||||
0,
|
||||
(wcslen(lpDisplayName) + 1) * sizeof(WCHAR));
|
||||
lpDisplayNameW = HeapAlloc(GetProcessHeap(),
|
||||
0,
|
||||
(wcslen(lpDisplayName) + 1) * sizeof(WCHAR));
|
||||
if (lpDisplayNameW == NULL)
|
||||
{
|
||||
dwError = ERROR_NOT_ENOUGH_MEMORY;
|
||||
@@ -2083,7 +2083,7 @@ DWORD RCreateServiceW(
|
||||
*lpDisplayName != 0 &&
|
||||
_wcsicmp(lpService->lpDisplayName, lpDisplayName) != 0)
|
||||
{
|
||||
lpService->lpDisplayName = (WCHAR*) HeapAlloc(GetProcessHeap(), 0,
|
||||
lpService->lpDisplayName = HeapAlloc(GetProcessHeap(), 0,
|
||||
(wcslen(lpDisplayName) + 1) * sizeof(WCHAR));
|
||||
if (lpService->lpDisplayName == NULL)
|
||||
{
|
||||
@@ -2212,7 +2212,7 @@ DWORD RCreateServiceW(
|
||||
if (lpDependencies != NULL && *lpDependencies != 0)
|
||||
{
|
||||
dwError = ScmWriteDependencies(hServiceKey,
|
||||
(LPWSTR)lpDependencies,
|
||||
(LPCWSTR)lpDependencies,
|
||||
dwDependSize);
|
||||
if (dwError != ERROR_SUCCESS)
|
||||
goto done;
|
||||
@@ -3519,7 +3519,7 @@ DWORD RCreateServiceA(
|
||||
DWORD dwDependenciesLength = 0;
|
||||
DWORD dwLength;
|
||||
int len;
|
||||
LPSTR lpStr;
|
||||
LPCSTR lpStr;
|
||||
|
||||
if (lpServiceName)
|
||||
{
|
||||
@@ -3571,7 +3571,7 @@ DWORD RCreateServiceA(
|
||||
|
||||
if (lpDependencies)
|
||||
{
|
||||
lpStr = (LPSTR)lpDependencies;
|
||||
lpStr = (LPCSTR)lpDependencies;
|
||||
while (*lpStr)
|
||||
{
|
||||
dwLength = strlen(lpStr) + 1;
|
||||
@@ -3586,7 +3586,7 @@ DWORD RCreateServiceA(
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
goto cleanup;
|
||||
}
|
||||
MultiByteToWideChar(CP_ACP, 0, (LPSTR)lpDependencies, dwDependenciesLength, lpDependenciesW, dwDependenciesLength);
|
||||
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)lpDependencies, dwDependenciesLength, lpDependenciesW, dwDependenciesLength);
|
||||
}
|
||||
|
||||
if (lpServiceStartName)
|
||||
|
||||
@@ -379,7 +379,7 @@ wWinMain(HINSTANCE hInstance,
|
||||
ExitThread(0);
|
||||
}
|
||||
|
||||
DPRINT("SERVICES: created start event with handle %x.\n", hScmStartEvent);
|
||||
DPRINT("SERVICES: created start event with handle %p.\n", hScmStartEvent);
|
||||
|
||||
// ScmInitThreadManager();
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ DWORD ScmCreateServiceKey(LPCWSTR lpServiceName,
|
||||
PHKEY phKey);
|
||||
|
||||
DWORD ScmWriteDependencies(HKEY hServiceKey,
|
||||
LPWSTR lpDependencies,
|
||||
LPCWSTR lpDependencies,
|
||||
DWORD dwDependenciesLength);
|
||||
|
||||
DWORD ScmMarkServiceForDelete(PSERVICE pService);
|
||||
|
||||
@@ -288,14 +288,14 @@ ChangeServiceConfigA(SC_HANDLE hService,
|
||||
DWORD dwError;
|
||||
DWORD dwDependenciesLength = 0;
|
||||
DWORD dwLength;
|
||||
LPSTR lpStr;
|
||||
LPCSTR lpStr;
|
||||
|
||||
TRACE("ChangeServiceConfigA() called\n");
|
||||
|
||||
/* Calculate the Dependencies length*/
|
||||
if (lpDependencies != NULL)
|
||||
{
|
||||
lpStr = (LPSTR)lpDependencies;
|
||||
lpStr = lpDependencies;
|
||||
while (*lpStr)
|
||||
{
|
||||
dwLength = strlen(lpStr) + 1;
|
||||
@@ -362,14 +362,14 @@ ChangeServiceConfigW(SC_HANDLE hService,
|
||||
DWORD dwError;
|
||||
DWORD dwDependenciesLength = 0;
|
||||
DWORD dwLength;
|
||||
LPWSTR lpStr;
|
||||
LPCWSTR lpStr;
|
||||
|
||||
TRACE("ChangeServiceConfigW() called\n");
|
||||
|
||||
/* Calculate the Dependencies length*/
|
||||
if (lpDependencies != NULL)
|
||||
{
|
||||
lpStr = (LPWSTR)lpDependencies;
|
||||
lpStr = lpDependencies;
|
||||
while (*lpStr)
|
||||
{
|
||||
dwLength = wcslen(lpStr) + 1;
|
||||
@@ -540,7 +540,7 @@ CreateServiceA(SC_HANDLE hSCManager,
|
||||
DWORD dwDependenciesLength = 0;
|
||||
DWORD dwError;
|
||||
DWORD dwLength;
|
||||
LPSTR lpStr;
|
||||
LPCSTR lpStr;
|
||||
|
||||
TRACE("CreateServiceA() called\n");
|
||||
TRACE("%p %s %s\n", hSCManager,
|
||||
@@ -552,10 +552,10 @@ CreateServiceA(SC_HANDLE hSCManager,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Calculate the Dependencies length*/
|
||||
/* Calculate the Dependencies length */
|
||||
if (lpDependencies != NULL)
|
||||
{
|
||||
lpStr = (LPSTR)lpDependencies;
|
||||
lpStr = lpDependencies;
|
||||
while (*lpStr)
|
||||
{
|
||||
dwLength = strlen(lpStr) + 1;
|
||||
@@ -628,7 +628,7 @@ CreateServiceW(SC_HANDLE hSCManager,
|
||||
DWORD dwDependenciesLength = 0;
|
||||
DWORD dwError;
|
||||
DWORD dwLength;
|
||||
LPWSTR lpStr;
|
||||
LPCWSTR lpStr;
|
||||
|
||||
TRACE("CreateServiceW() called\n");
|
||||
TRACE("%p %S %S\n", hSCManager,
|
||||
@@ -640,10 +640,10 @@ CreateServiceW(SC_HANDLE hSCManager,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Calculate the Dependencies length*/
|
||||
/* Calculate the Dependencies length */
|
||||
if (lpDependencies != NULL)
|
||||
{
|
||||
lpStr = (LPWSTR)lpDependencies;
|
||||
lpStr = lpDependencies;
|
||||
while (*lpStr)
|
||||
{
|
||||
dwLength = wcslen(lpStr) + 1;
|
||||
|
||||
Reference in New Issue
Block a user