Skip to content

Commit 90831e7

Browse files
committed
[SERVICES] Use pointers to const string (PCWSTR) instead of non-const for argv (reactos#7440)
const PCWSTR* == const (const WCHAR*)* == (const WCHAR*) const *
1 parent 3fd6e34 commit 90831e7

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

base/system/services/database.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ ScmControlServiceEx(
14211421
_In_ SERVICE_STATUS_HANDLE hServiceStatus,
14221422
_In_opt_ DWORD dwServiceTag,
14231423
_In_opt_ DWORD argc,
1424-
_In_reads_opt_(argc) PWSTR* argv)
1424+
_In_reads_opt_(argc) const PCWSTR* argv)
14251425
{
14261426
DWORD dwError = ERROR_SUCCESS;
14271427
BOOL bResult;
@@ -1760,7 +1760,7 @@ ScmWaitForServiceConnect(PSERVICE Service)
17601760
static DWORD
17611761
ScmStartUserModeService(PSERVICE Service,
17621762
DWORD argc,
1763-
LPWSTR* argv)
1763+
const PCWSTR* argv)
17641764
{
17651765
PROCESS_INFORMATION ProcessInformation;
17661766
STARTUPINFOW StartupInfo;
@@ -1910,7 +1910,7 @@ ScmStartUserModeService(PSERVICE Service,
19101910
static DWORD
19111911
ScmLoadService(PSERVICE Service,
19121912
DWORD argc,
1913-
LPWSTR* argv)
1913+
const PCWSTR* argv)
19141914
{
19151915
PSERVICE_GROUP Group = Service->lpGroup;
19161916
DWORD dwError = ERROR_SUCCESS;
@@ -2023,7 +2023,7 @@ ScmLoadService(PSERVICE Service,
20232023
DWORD
20242024
ScmStartService(PSERVICE Service,
20252025
DWORD argc,
2026-
LPWSTR* argv)
2026+
const PCWSTR* argv)
20272027
{
20282028
DWORD dwError = ERROR_SUCCESS;
20292029
SC_RPC_LOCK Lock = NULL;
@@ -2042,7 +2042,8 @@ ScmStartService(PSERVICE Service,
20422042
if (!ScmInitialize)
20432043
{
20442044
dwError = ScmAcquireServiceStartLock(TRUE, &Lock);
2045-
if (dwError != ERROR_SUCCESS) goto done;
2045+
if (dwError != ERROR_SUCCESS)
2046+
goto done;
20462047
}
20472048

20482049
/* Really start the service */

base/system/services/rpcserver.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,7 +3320,7 @@ RStartServiceW(
33203320
return ERROR_SERVICE_MARKED_FOR_DELETE;
33213321

33223322
/* Start the service */
3323-
dwError = ScmStartService(lpService, argc, (LPWSTR*)argv);
3323+
dwError = ScmStartService(lpService, argc, (PCWSTR*)argv);
33243324

33253325
return dwError;
33263326
}
@@ -4378,7 +4378,7 @@ RStartServiceA(
43784378
DWORD dwError = ERROR_SUCCESS;
43794379
PSERVICE_HANDLE hSvc;
43804380
PSERVICE lpService = NULL;
4381-
LPWSTR *lpVector = NULL;
4381+
PWSTR* pVector = NULL;
43824382
DWORD i;
43834383
DWORD dwLength;
43844384

@@ -4417,52 +4417,52 @@ RStartServiceA(
44174417
/* Build a Unicode argument vector */
44184418
if (argc > 0)
44194419
{
4420-
lpVector = HeapAlloc(GetProcessHeap(),
4421-
HEAP_ZERO_MEMORY,
4422-
argc * sizeof(LPWSTR));
4423-
if (lpVector == NULL)
4420+
pVector = HeapAlloc(GetProcessHeap(),
4421+
HEAP_ZERO_MEMORY,
4422+
argc * sizeof(PWSTR));
4423+
if (!pVector)
44244424
return ERROR_NOT_ENOUGH_MEMORY;
44254425

44264426
for (i = 0; i < argc; i++)
44274427
{
44284428
dwLength = MultiByteToWideChar(CP_ACP,
44294429
0,
4430-
((LPSTR*)argv)[i],
4430+
argv[i].StringPtr,
44314431
-1,
44324432
NULL,
44334433
0);
44344434

4435-
lpVector[i] = HeapAlloc(GetProcessHeap(),
4436-
HEAP_ZERO_MEMORY,
4437-
dwLength * sizeof(WCHAR));
4438-
if (lpVector[i] == NULL)
4435+
pVector[i] = HeapAlloc(GetProcessHeap(),
4436+
HEAP_ZERO_MEMORY,
4437+
dwLength * sizeof(WCHAR));
4438+
if (!pVector[i])
44394439
{
44404440
dwError = ERROR_NOT_ENOUGH_MEMORY;
44414441
goto done;
44424442
}
44434443

44444444
MultiByteToWideChar(CP_ACP,
44454445
0,
4446-
((LPSTR*)argv)[i],
4446+
argv[i].StringPtr,
44474447
-1,
4448-
lpVector[i],
4448+
pVector[i],
44494449
dwLength);
44504450
}
44514451
}
44524452

44534453
/* Start the service */
4454-
dwError = ScmStartService(lpService, argc, lpVector);
4454+
dwError = ScmStartService(lpService, argc, (PCWSTR*)pVector);
44554455

44564456
done:
44574457
/* Free the Unicode argument vector */
4458-
if (lpVector != NULL)
4458+
if (pVector)
44594459
{
44604460
for (i = 0; i < argc; i++)
44614461
{
4462-
if (lpVector[i] != NULL)
4463-
HeapFree(GetProcessHeap(), 0, lpVector[i]);
4462+
if (pVector[i])
4463+
HeapFree(GetProcessHeap(), 0, pVector[i]);
44644464
}
4465-
HeapFree(GetProcessHeap(), 0, lpVector);
4465+
HeapFree(GetProcessHeap(), 0, pVector);
44664466
}
44674467

44684468
return dwError;

base/system/services/services.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ VOID ScmAutoStartServices(VOID);
186186
VOID ScmAutoShutdownServices(VOID);
187187
DWORD ScmStartService(PSERVICE Service,
188188
DWORD argc,
189-
LPWSTR *argv);
189+
const PCWSTR* argv);
190190

191191
DWORD ScmReferenceService(PSERVICE lpService);
192192
DWORD ScmDereferenceService(PSERVICE lpService);

0 commit comments

Comments
 (0)