mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 12:53:09 +00:00
[SERVICES] Use safe-string routines in some places, and do not hardcode buffer lengths.
This commit is contained in:
parent
1aa359ec7f
commit
c6d65fec69
2 changed files with 43 additions and 39 deletions
|
@ -13,6 +13,7 @@
|
|||
#include "services.h"
|
||||
|
||||
#include <winnls.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
@ -1241,36 +1242,36 @@ RControlService(
|
|||
|
||||
if (dwError == ERROR_SUCCESS)
|
||||
{
|
||||
if (dwControl == SERVICE_CONTROL_STOP ||
|
||||
dwControl == SERVICE_CONTROL_PAUSE ||
|
||||
dwControl == SERVICE_CONTROL_CONTINUE)
|
||||
if (dwControl == SERVICE_CONTROL_STOP ||
|
||||
dwControl == SERVICE_CONTROL_PAUSE ||
|
||||
dwControl == SERVICE_CONTROL_CONTINUE)
|
||||
{
|
||||
/* Log a successful send control */
|
||||
|
||||
switch (dwControl)
|
||||
{
|
||||
/* Log a successful send control */
|
||||
case SERVICE_CONTROL_STOP:
|
||||
uID = IDS_SERVICE_STOP;
|
||||
break;
|
||||
|
||||
switch (dwControl)
|
||||
{
|
||||
case SERVICE_CONTROL_STOP:
|
||||
uID = IDS_SERVICE_STOP;
|
||||
break;
|
||||
case SERVICE_CONTROL_PAUSE:
|
||||
uID = IDS_SERVICE_PAUSE;
|
||||
break;
|
||||
|
||||
case SERVICE_CONTROL_PAUSE:
|
||||
uID = IDS_SERVICE_PAUSE;
|
||||
break;
|
||||
|
||||
case SERVICE_CONTROL_CONTINUE:
|
||||
uID = IDS_SERVICE_RESUME;
|
||||
break;
|
||||
}
|
||||
LoadStringW(GetModuleHandle(NULL), uID, szLogBuffer, 80);
|
||||
|
||||
lpLogStrings[0] = lpService->lpDisplayName;
|
||||
lpLogStrings[1] = szLogBuffer;
|
||||
|
||||
ScmLogEvent(EVENT_SERVICE_CONTROL_SUCCESS,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
2,
|
||||
lpLogStrings);
|
||||
case SERVICE_CONTROL_CONTINUE:
|
||||
uID = IDS_SERVICE_RESUME;
|
||||
break;
|
||||
}
|
||||
LoadStringW(GetModuleHandle(NULL), uID, szLogBuffer, ARRAYSIZE(szLogBuffer));
|
||||
|
||||
lpLogStrings[0] = lpService->lpDisplayName;
|
||||
lpLogStrings[1] = szLogBuffer;
|
||||
|
||||
ScmLogEvent(EVENT_SERVICE_CONTROL_SUCCESS,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
2,
|
||||
lpLogStrings);
|
||||
}
|
||||
}
|
||||
|
||||
return dwError;
|
||||
|
@ -1757,7 +1758,8 @@ RSetServiceStatus(
|
|||
(lpServiceStatus->dwWin32ExitCode != ERROR_SUCCESS))
|
||||
{
|
||||
/* Log a failed service stop */
|
||||
swprintf(szLogBuffer, L"%lu", lpServiceStatus->dwWin32ExitCode);
|
||||
StringCchPrintfW(szLogBuffer, ARRAYSIZE(szLogBuffer),
|
||||
L"%lu", lpServiceStatus->dwWin32ExitCode);
|
||||
lpLogStrings[0] = lpService->lpDisplayName;
|
||||
lpLogStrings[1] = szLogBuffer;
|
||||
|
||||
|
@ -1787,7 +1789,7 @@ RSetServiceStatus(
|
|||
break;
|
||||
}
|
||||
|
||||
LoadStringW(GetModuleHandle(NULL), uID, szLogBuffer, 80);
|
||||
LoadStringW(GetModuleHandle(NULL), uID, szLogBuffer, ARRAYSIZE(szLogBuffer));
|
||||
lpLogStrings[0] = lpService->lpDisplayName;
|
||||
lpLogStrings[1] = szLogBuffer;
|
||||
|
||||
|
@ -1797,8 +1799,6 @@ RSetServiceStatus(
|
|||
lpLogStrings);
|
||||
}
|
||||
|
||||
|
||||
|
||||
DPRINT("Set %S to %lu\n", lpService->lpDisplayName, lpService->Status.dwCurrentState);
|
||||
DPRINT("RSetServiceStatus() done\n");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue