#include "services.h"
#include <userenv.h>
+#include <strsafe.h>
#define NDEBUG
#include <debug.h>
}
/* Create '\\.\pipe\net\NtControlPipeXXX' instance */
- swprintf(szControlPipeName, L"\\\\.\\pipe\\net\\NtControlPipe%lu", ServiceCurrent);
+ StringCchPrintfW(szControlPipeName, ARRAYSIZE(szControlPipeName),
+ L"\\\\.\\pipe\\net\\NtControlPipe%lu", ServiceCurrent);
DPRINT("PipeName: %S\n", szControlPipeName);
if (Service->dwErrorControl != SERVICE_ERROR_IGNORE)
{
/* Log a failed service start */
- swprintf(szLogBuffer, L"%lu", dwError);
+ StringCchPrintfW(szLogBuffer, ARRAYSIZE(szLogBuffer),
+ L"%lu", dwError);
lpLogStrings[0] = Service->lpServiceName;
lpLogStrings[1] = szLogBuffer;
ScmLogEvent(EVENT_SERVICE_START_FAILED,
CurrentService = CONTAINING_RECORD(ServiceEntry, SERVICE, ServiceListEntry);
/* Build the safe boot path */
- wcscpy(szSafeBootServicePath,
- L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot");
+ StringCchCopyW(szSafeBootServicePath, ARRAYSIZE(szSafeBootServicePath),
+ L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot");
switch (SafeBootEnabled)
{
/* NOTE: Assumes MINIMAL (1) and DSREPAIR (3) load same items */
case 1:
case 3:
- wcscat(szSafeBootServicePath, L"\\Minimal\\");
+ StringCchCatW(szSafeBootServicePath, ARRAYSIZE(szSafeBootServicePath),
+ L"\\Minimal\\");
break;
case 2:
- wcscat(szSafeBootServicePath, L"\\Network\\");
+ StringCchCatW(szSafeBootServicePath, ARRAYSIZE(szSafeBootServicePath),
+ L"\\Network\\");
break;
}
RegCloseKey(hKey);
/* Finish Safe Boot path off */
- wcsncat(szSafeBootServicePath,
- CurrentService->lpServiceName,
- MAX_PATH - wcslen(szSafeBootServicePath));
+ StringCchCatW(szSafeBootServicePath, ARRAYSIZE(szSafeBootServicePath),
+ CurrentService->lpServiceName);
/* Check that the key is in the Safe Boot path */
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
#include "services.h"
#include <winnls.h>
+#include <strsafe.h>
#define NDEBUG
#include <debug.h>
if (dwError == ERROR_SUCCESS)
{
- if (dwControl == SERVICE_CONTROL_STOP ||
- dwControl == SERVICE_CONTROL_PAUSE ||
- dwControl == SERVICE_CONTROL_CONTINUE)
- {
- /* Log a successful send control */
+ if (dwControl == SERVICE_CONTROL_STOP ||
+ dwControl == SERVICE_CONTROL_PAUSE ||
+ dwControl == SERVICE_CONTROL_CONTINUE)
+ {
+ /* Log a successful send control */
- switch (dwControl)
- {
- 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);
+ case SERVICE_CONTROL_CONTINUE:
+ uID = IDS_SERVICE_RESUME;
+ break;
+ }
+ LoadStringW(GetModuleHandle(NULL), uID, szLogBuffer, ARRAYSIZE(szLogBuffer));
- lpLogStrings[0] = lpService->lpDisplayName;
- lpLogStrings[1] = szLogBuffer;
+ lpLogStrings[0] = lpService->lpDisplayName;
+ lpLogStrings[1] = szLogBuffer;
- ScmLogEvent(EVENT_SERVICE_CONTROL_SUCCESS,
- EVENTLOG_INFORMATION_TYPE,
- 2,
- lpLogStrings);
- }
+ ScmLogEvent(EVENT_SERVICE_CONTROL_SUCCESS,
+ EVENTLOG_INFORMATION_TYPE,
+ 2,
+ lpLogStrings);
+ }
}
return dwError;
(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;
break;
}
- LoadStringW(GetModuleHandle(NULL), uID, szLogBuffer, 80);
+ LoadStringW(GetModuleHandle(NULL), uID, szLogBuffer, ARRAYSIZE(szLogBuffer));
lpLogStrings[0] = lpService->lpDisplayName;
lpLogStrings[1] = szLogBuffer;
lpLogStrings);
}
-
-
DPRINT("Set %S to %lu\n", lpService->lpDisplayName, lpService->Status.dwCurrentState);
DPRINT("RSetServiceStatus() done\n");