47 return (
wcsstr(pServiceImage->pszImagePath,
L"\\system32\\lsass.exe") !=
NULL);
59 DWORD dwServiceCurrent = 1;
60 DWORD dwKeyDisposition;
69 L"SYSTEM\\CurrentControlSet\\Control\\ServiceCurrent",
79 DPRINT1(
"RegCreateKeyEx() failed with error %lu\n", dwError);
85 dwKeySize =
sizeof(
DWORD);
90 (
BYTE*)&dwServiceCurrent,
95 DPRINT1(
"RegQueryValueEx() failed with error %lu\n", dwError);
106 (
BYTE*)&dwServiceCurrent,
107 sizeof(dwServiceCurrent));
113 DPRINT1(
"RegSetValueExW() failed (Error %lu)\n", dwError);
119 dwServiceCurrent = 0;
124 L"\\\\.\\pipe\\net\\NtControlPipe%lu", dwServiceCurrent);
126 DPRINT(
"PipeName: %S\n", szControlPipeName);
128 SecurityAttributes.
nLength =
sizeof(SecurityAttributes);
139 &SecurityAttributes);
140 DPRINT(
"CreateNamedPipeW(%S) done\n", szControlPipeName);
143 DPRINT1(
"Failed to create control pipe\n");
157 DPRINT(
"ScmGetServiceImageByImagePath(%S) called\n", lpImagePath);
171 ImageEntry = ImageEntry->
Flink;
174 DPRINT(
"Couldn't find a matching image\n");
206 CurrentImage = CurrentService->
lpImage;
214 ServiceEntry = ServiceEntry->
Flink;
273 if (pszAccountName1 ==
NULL &&
274 pszAccountName2 ==
NULL)
277 if (pszAccountName1 ==
NULL &&
278 pszAccountName2 !=
NULL &&
279 _wcsicmp(pszAccountName2,
L"LocalSystem") == 0)
282 if (pszAccountName1 !=
NULL &&
283 pszAccountName2 ==
NULL &&
284 _wcsicmp(pszAccountName1,
L"LocalSystem") == 0)
287 if (pszAccountName1 !=
NULL &&
288 pszAccountName2 !=
NULL &&
289 _wcsicmp(pszAccountName1, pszAccountName2) == 0)
301 if (pszAccountName ==
NULL ||
302 _wcsicmp(pszAccountName,
L"LocalSystem") == 0)
319 DPRINT(
"ScmEnableBackupRestorePrivileges(%p %d)\n", hToken,
bEnable);
323 if (pTokenPrivileges ==
NULL)
325 DPRINT1(
"Failed to allocate privilege buffer\n");
344 DPRINT1(
"AdjustTokenPrivileges() succeeded, but with not all privileges assigned\n");
349 if (pTokenPrivileges !=
NULL)
369 DPRINT(
"ScmLogonService(%p %p)\n", pService, pImage);
370 DPRINT(
"Service %S\n", pService->lpServiceName);
380 pszUserName =
ptr + 1;
381 pszDomainName = pImage->pszAccountName;
386 pszUserName = pImage->pszAccountName;
387 pszDomainName =
NULL;
393 (
wcslen(pService->lpServiceName) + 5) *
sizeof(
WCHAR));
394 if (pszPassword ==
NULL)
401 wcscat(pszPassword, pService->lpServiceName);
403 DPRINT(
"Domain: %S User: %S Password: %S\n", pszDomainName, pszUserName, pszPassword);
414 DPRINT1(
"LogonUserW() failed (Error %lu)\n", dwError);
422 ZeroMemory(&ProfileInfo,
sizeof(ProfileInfo));
423 ProfileInfo.
dwSize =
sizeof(ProfileInfo);
439 DPRINT1(
"LoadUserProfileW() failed (Error %lu)\n", dwError);
443 pImage->hProfile = ProfileInfo.
hProfile;
446 if (pszPassword !=
NULL)
467 BOOL bSecurityService;
469 DPRINT(
"ScmCreateOrReferenceServiceImage(%p)\n", pService);
492 DPRINT1(
"RtlQueryRegistryValues() failed (Status %lx)\n",
Status);
496 DPRINT(
"ImagePath: '%wZ'\n", &ImagePath);
500 if (pServiceImage ==
NULL)
510 if (pServiceImage ==
NULL)
541 DPRINT1(
"ScmLogonService() failed (Error %lu)\n", dwError);
556 DPRINT1(
"ScmCreateNewControlPipe() failed (Error %lu)\n", dwError);
576 if (bSecurityService)
608 pService->
lpImage = pServiceImage;
614 DPRINT(
"ScmCreateOrReferenceServiceImage() done (Error: %lu)\n", dwError);
623 DPRINT1(
"ScmRemoveServiceImage() called\n");
661 DPRINT(
"ScmGetServiceEntryByName() called\n");
672 return CurrentService;
675 ServiceEntry = ServiceEntry->
Flink;
678 DPRINT(
"Couldn't find a matching service\n");
690 DPRINT(
"ScmGetServiceEntryByDisplayName() called\n");
701 return CurrentService;
704 ServiceEntry = ServiceEntry->
Flink;
707 DPRINT(
"Couldn't find a matching service\n");
719 DPRINT(
"ScmGetServiceEntryByResumeCount() called\n");
730 return CurrentService;
733 ServiceEntry = ServiceEntry->
Flink;
736 DPRINT(
"Couldn't find a matching service\n");
773 DPRINT(
"Service: '%S'\n", lpServiceName);
779 if (lpService ==
NULL)
782 *lpServiceRecord = lpService;
857 DWORD dwServiceState,
866 DWORD dwServicesReturned = 0;
873 L"System\\CurrentControlSet\\Services",
879 DPRINT1(
"Failed to open services key\n");
889 &dwServicesReturned);
894 DPRINT1(
"Deletion failed due to running dependencies\n");
909 DPRINT1(
"Failed to delete the Service Registry key\n");
965 DWORD dwErrorControl;
968 DPRINT(
"Service: '%S'\n", lpServiceName);
969 if (*lpServiceName ==
L'{')
988 DPRINT(
"Service type: %lx\n", dwServiceType);
1000 DPRINT(
"Start type: %lx\n", dwStartType);
1012 DPRINT(
"Error control: %lx\n", dwErrorControl);
1023 DPRINT(
"Tag: %lx\n", dwTagId);
1031 DPRINT(
"Group: %S\n", lpGroup);
1049 lpService->
dwTag = dwTagId;
1051 if (lpGroup !=
NULL)
1069 DPRINT(
"Start %lx Type %lx Tag %lx ErrorControl %lx\n",
1090 DPRINT(
"No security descriptor found! Assign default security descriptor\n");
1103 if (lpGroup !=
NULL)
1109 if (lpService !=
NULL)
1131 ServiceEntry = ServiceEntry->
Flink;
1136 L"System\\CurrentControlSet\\Services",
1167 L"SYSTEM\\CurrentControlSet\\Control\\Windows",
1175 L"NoInteractiveServices",
1192 DWORD dwSubKeyLength;
1196 DPRINT(
"ScmCreateServiceDatabase() called\n");
1214 L"System\\CurrentControlSet\\Services",
1234 szSubKey[0] !=
L'{')
1236 DPRINT(
"SubKeyName: '%S'\n", szSubKey);
1266 DPRINT(
"ScmCreateServiceDatabase() done\n");
1275 DPRINT(
"ScmShutdownServiceDatabase() called\n");
1280 DPRINT(
"ScmShutdownServiceDatabase() done\n");
1296 DPRINT(
"ScmCheckDriver(%S) called\n",
Service->lpServiceName);
1352 DPRINT(
"Found: '%S' '%wZ'\n",
1359 Service->Status.dwServiceSpecificExitCode = 0;
1360 Service->Status.dwCheckPoint = 0;
1361 Service->Status.dwWaitHint = 0;
1388 DPRINT(
"ScmGetBootAndSystemDriverState() called\n");
1404 ServiceEntry = ServiceEntry->
Flink;
1407 DPRINT(
"ScmGetBootAndSystemDriverState() done\n");
1426 DWORD dwReadCount = 0;
1429 DPRINT(
"ScmSendControlPacket(%p, %lu, %p) called\n",
1430 hControlPipe, dwControlPacketSize, pControlPacket);
1437 dwControlPacketSize,
1439 sizeof(ReplyPacket),
1448 DPRINT1(
"TransactNamedPipe(%S, %d) failed (Error %lu)\n", pServiceName, dwControl, dwError);
1452 DPRINT(
"TransactNamedPipe(%S, %d) returned ERROR_IO_PENDING\n", pServiceName, dwControl);
1455 DPRINT(
"WaitForSingleObject(%S, %d) returned %lu\n", pServiceName, dwControl, dwError);
1459 DPRINT1(
"WaitForSingleObject(%S, %d) timed out\n", pServiceName, dwControl);
1462 DPRINT1(
"CancelIo(%S, %d) failed (Error %lu)\n", pServiceName, dwControl,
GetLastError());
1475 DPRINT1(
"GetOverlappedResult(%S, %d) failed (Error %lu)\n", pServiceName, dwControl, dwError);
1484 if (dwReadCount ==
sizeof(ReplyPacket))
1485 dwError = ReplyPacket.
dwError;
1507 DPRINT(
"ScmControlServiceEx(%S, %d) called\n", pServiceName, dwControl);
1556 PWSTR *pOffPtr, pArgPtr;
1565 DPRINT(
"dwArgumentsCount: %lu\n", ControlPacket->dwArgumentsCount);
1566 DPRINT(
"dwArgumentsOffset: %lu\n", ControlPacket->dwArgumentsOffset);
1572 DPRINT(
"offset[%lu]: %p\n",
i, pOffPtr[
i]);
1586 DPRINT(
"ScmControlServiceEx(%S, %d) done (Error %lu)\n", pServiceName, dwControl, dwError);
1603 DPRINT(
"ScmControlService(%S, %d) called\n", pServiceName, dwControl);
1634 DPRINT(
"ScmControlService(%S, %d) done (Error %lu)\n", pServiceName, dwControl, dwError);
1643 DWORD dwProcessId = 0;
1649 WCHAR szBuffer1[20];
1650 WCHAR szBuffer2[20];
1653 DPRINT(
"ScmWaitForServiceConnect()\n");
1657 if (bResult ==
FALSE)
1659 DPRINT(
"ConnectNamedPipe() returned FALSE\n");
1664 DPRINT(
"dwError: ERROR_IO_PENDING\n");
1668 DPRINT(
"WaitForSingleObject() returned %lu\n", dwError);
1672 DPRINT(
"WaitForSingleObject() returned WAIT_TIMEOUT\n");
1675 if (bResult ==
FALSE)
1682 lpLogStrings[0] =
Service->lpDisplayName;
1683 lpLogStrings[1] = szBuffer1;
1690 DPRINT1(
"Log EVENT_CONNECTION_TIMEOUT by %S\n",
Service->lpDisplayName);
1700 if (bResult ==
FALSE)
1703 DPRINT1(
"GetOverlappedResult failed (Error %lu)\n", dwError);
1711 DPRINT1(
"ConnectNamedPipe failed (Error %lu)\n", dwError);
1716 DPRINT(
"Control pipe connected\n");
1726 if (bResult ==
FALSE)
1728 DPRINT(
"ReadFile() returned FALSE\n");
1733 DPRINT(
"dwError: ERROR_IO_PENDING\n");
1739 DPRINT(
"WaitForSingleObject() returned WAIT_TIMEOUT\n");
1742 if (bResult ==
FALSE)
1749 lpLogStrings[0] = szBuffer1;
1756 DPRINT1(
"Log EVENT_READFILE_TIMEOUT by %S\n",
Service->lpDisplayName);
1762 DPRINT(
"WaitForSingleObject() returned WAIT_OBJECT_0\n");
1764 DPRINT(
"Process Id: %lu\n", dwProcessId);
1770 if (bResult ==
FALSE)
1773 DPRINT1(
"GetOverlappedResult() failed (Error %lu)\n", dwError);
1780 DPRINT1(
"WaitForSingleObject() returned %lu\n", dwError);
1785 DPRINT1(
"ReadFile() failed (Error %lu)\n", dwError);
1791 (dwProcessId !=
Service->lpImage->dwProcessId))
1795 _ultow(dwProcessId, szBuffer2, 10);
1797 lpLogStrings[0] =
Service->lpDisplayName;
1798 lpLogStrings[1] = szBuffer1;
1799 lpLogStrings[2] = szBuffer2;
1807 DPRINT1(
"Log EVENT_SERVICE_DIFFERENT_PID_CONNECTED by %S\n",
Service->lpDisplayName);
1810 DPRINT(
"ScmWaitForServiceConnect() done\n");
1830 if (
Service->lpImage->dwImageRunCount > 1)
1834 ZeroMemory(&StartupInfo,
sizeof(StartupInfo));
1835 StartupInfo.
cb =
sizeof(StartupInfo);
1836 ZeroMemory(&ProcessInformation,
sizeof(ProcessInformation));
1845 DPRINT1(
"CreateEnvironmentBlock() failed with error %d; service '%S' will run with current environment\n",
1847 lpEnvironment =
NULL;
1857 Service->lpImage->pszImagePath,
1865 &ProcessInformation);
1875 DPRINT1(
"ImpersonateLoggedOnUser() failed with error %d\n", dwError);
1885 DPRINT1(
"CreateEnvironmentBlock() failed with error %d; service '%S' will run with current environment\n",
1887 lpEnvironment =
NULL;
1901 Service->lpImage->pszImagePath,
1909 &ProcessInformation);
1925 DPRINT1(
"Starting '%S' failed with error %d\n",
1926 Service->lpServiceName, dwError);
1930 DPRINT(
"Process Id: %lu Handle %p\n",
1933 DPRINT(
"Thread Id: %lu Handle %p\n",
1949 DPRINT1(
"Connecting control pipe failed! (Error %lu)\n", dwError);
1950 Service->lpImage->dwProcessId = 0;
1974 WCHAR szLogBuffer[80];
1976 DPRINT(
"ScmLoadService() called\n");
1981 DPRINT(
"Service %S is already running\n",
Service->lpServiceName);
1985 DPRINT(
"Service->Type: %lu\n",
Service->Status.dwServiceType);
2002 Service->Status.dwControlsAccepted = 0;
2007 Service->lpImage->dwImageRunCount--;
2008 if (
Service->lpImage->dwImageRunCount == 0)
2017 DPRINT(
"ScmLoadService() done (Error %lu)\n", dwError);
2028 lpLogStrings[0] =
Service->lpDisplayName;
2029 lpLogStrings[1] = szLogBuffer;
2043 lpLogStrings[0] =
Service->lpServiceName;
2044 lpLogStrings[1] = szLogBuffer;
2052 switch (
Service->dwErrorControl)
2055 if (IsLastKnownGood ==
FALSE)
2062 if (IsLastKnownGood ==
FALSE)
2087 DPRINT(
"ScmStartService() called\n");
2114 DPRINT(
"ScmStartService() done (Error %lu)\n", dwError);
2129 DWORD SafeBootEnabled;
2142 L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option",
2148 dwKeySize =
sizeof(SafeBootEnabled);
2153 (
LPBYTE)&SafeBootEnabled,
2160 SafeBootEnabled = 0;
2173 L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot");
2175 switch (SafeBootEnabled)
2190 if (SafeBootEnabled != 0)
2194 szSafeBootServicePath,
2208 szSafeBootServicePath,
2226 DPRINT1(
"WARNING: Could not open the associated Safe Boot key\n");
2231 ServiceEntry = ServiceEntry->
Flink;
2250 if ((CurrentService->
lpGroup == CurrentGroup) &&
2259 ServiceEntry = ServiceEntry->
Flink;
2269 if ((CurrentService->
lpGroup == CurrentGroup) &&
2277 ServiceEntry = ServiceEntry->
Flink;
2280 GroupEntry = GroupEntry->
Flink;
2297 ServiceEntry = ServiceEntry->
Flink;
2314 ServiceEntry = ServiceEntry->
Flink;
2323 ServiceEntry = ServiceEntry->
Flink;
2337 DPRINT(
"ScmAutoShutdownServices() called\n");
2359 ServiceEntry = ServiceEntry->
Flink;
2365 DPRINT(
"ScmAutoShutdownServices() done\n");
2400 L"SYSTEM\\CurrentControlSet\\Control",
2408 L"ServicesPipeTimeout",
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
#define InterlockedIncrement
#define InterlockedDecrement
static HANDLE hServicesKey
DWORD ScmReadString(HKEY hServiceKey, LPCWSTR lpValueName, LPWSTR *lpValue)
BOOL ScmIsDeleteFlagSet(HKEY hServiceKey)
DWORD ScmWriteSecurityDescriptor(_In_ HKEY hServiceKey, _In_ PSECURITY_DESCRIPTOR pSecurityDescriptor)
DWORD ScmReadSecurityDescriptor(_In_ HKEY hServiceKey, _Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
DWORD ScmDeleteRegKey(_In_ HKEY hKey, _In_ PCWSTR pszSubKey)
static BOOL ScmEnableBackupRestorePrivileges(_In_ HANDLE hToken, _In_ BOOL bEnable)
DWORD ScmControlService(_In_ HANDLE hControlPipe, _In_ PCWSTR pServiceName, _In_ DWORD dwControl, _In_ SERVICE_STATUS_HANDLE hServiceStatus)
DWORD ScmControlServiceEx(_In_ HANDLE hControlPipe, _In_ PCWSTR pServiceName, _In_ DWORD dwControl, _In_ SERVICE_STATUS_HANDLE hServiceStatus, _In_opt_ DWORD dwServiceTag, _In_opt_ DWORD argc, _In_reads_opt_(argc) const PCWSTR *argv)
VOID ScmAutoStartServices(VOID)
static PSERVICE_IMAGE ScmGetServiceImageByImagePath(LPWSTR lpImagePath)
static DWORD ScmStartUserModeService(PSERVICE Service, DWORD argc, const PCWSTR *argv)
static DWORD CreateServiceListEntry(LPCWSTR lpServiceName, HKEY hServiceKey)
PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount)
VOID ScmRemoveServiceImage(PSERVICE_IMAGE pServiceImage)
VOID ScmUnlockDatabase(VOID)
DWORD ScmGenerateServiceTag(PSERVICE lpServiceRecord)
static DWORD ScmLoadService(PSERVICE Service, DWORD argc, const PCWSTR *argv)
static NTSTATUS ScmCheckDriver(PSERVICE Service)
static BOOL ScmIsSecurityService(_In_ PSERVICE_IMAGE pServiceImage)
DWORD ScmGetServiceNameFromTag(IN PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams, OUT PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams)
static BOOL ScmIsLocalSystemAccount(_In_ PCWSTR pszAccountName)
VOID ScmInitNamedPipeCriticalSection(VOID)
DWORD ScmReferenceService(PSERVICE lpService)
static DWORD NoInteractiveServices
static DWORD ScmCreateOrReferenceServiceImage(PSERVICE pService)
DWORD ScmCreateServiceDatabase(VOID)
DWORD ScmStartService(PSERVICE Service, DWORD argc, const PCWSTR *argv)
static DWORD ScmLogonService(IN PSERVICE pService, IN PSERVICE_IMAGE pImage)
static RTL_RESOURCE DatabaseLock
VOID ScmDeleteServiceRecord(PSERVICE lpService)
VOID ScmAutoShutdownServices(VOID)
BOOL ScmLockDatabaseExclusive(VOID)
static BOOL ScmIsSameServiceAccount(_In_ PCWSTR pszAccountName1, _In_ PCWSTR pszAccountName2)
VOID ScmGetBootAndSystemDriverState(VOID)
DWORD ScmSendControlPacket(_In_ HANDLE hControlPipe, _In_ PCWSTR pServiceName, _In_ DWORD dwControl, _In_ DWORD dwControlPacketSize, _In_ PVOID pControlPacket)
DWORD ScmDereferenceService(PSERVICE lpService)
DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName, PSERVICE *lpServiceRecord, DWORD dwServiceType, DWORD dwStartType)
PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName)
BOOL ScmLockDatabaseShared(VOID)
LIST_ENTRY ServiceListHead
DWORD Int_EnumDependentServicesW(HKEY hServicesKey, PSERVICE lpService, DWORD dwServiceState, PSERVICE *lpServices, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned)
static DWORD ScmCreateNewControlPipe(_In_ PSERVICE_IMAGE pServiceImage, _In_ BOOL bSecurityServiceProcess)
static DWORD ScmWaitForServiceConnect(PSERVICE Service)
VOID ScmDeleteNamedPipeCriticalSection(VOID)
static VOID ScmGetNoInteractiveServicesValue(VOID)
static CRITICAL_SECTION ControlServiceCriticalSection
VOID ScmDeleteMarkedServices(VOID)
DWORD ScmDeleteService(PSERVICE lpService)
VOID ScmShutdownServiceDatabase(VOID)
PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName)
DWORD ScmStartDriver(PSERVICE pService)
DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController, OUT LPSC_RPC_LOCK lpLock)
DWORD ScmReleaseServiceStartLock(IN OUT LPSC_RPC_LOCK lpLock)
#define IDS_SERVICE_START
PSECURITY_DESCRIPTOR pPipeSD
DWORD ScmCreateDefaultServiceSD(PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
DWORD SetSecurityServicesEvent(VOID)
VOID ScmLogEvent(DWORD dwEventId, WORD wType, WORD wStrings, LPCWSTR *lpStrings)
struct _SERVICE_IMAGE SERVICE_IMAGE
#define RegCloseKey(hKey)
_In_ PFCB _In_ PCD_NAME DirName
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define ERROR_NOT_ENOUGH_MEMORY
BOOL WINAPI CancelIo(IN HANDLE hFile)
#define NT_SUCCESS(StatCode)
BOOL WINAPI LogonUserW(_In_ LPWSTR lpszUsername, _In_opt_ LPWSTR lpszDomain, _In_opt_ LPWSTR lpszPassword, _In_ DWORD dwLogonType, _In_ DWORD dwLogonProvider, _Out_opt_ PHANDLE phToken)
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserW(_In_opt_ HANDLE hToken, _In_opt_ LPCWSTR lpApplicationName, _Inout_opt_ LPWSTR lpCommandLine, _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, _In_ BOOL bInheritHandles, _In_ DWORD dwCreationFlags, _In_opt_ LPVOID lpEnvironment, _In_opt_ LPCWSTR lpCurrentDirectory, _In_ LPSTARTUPINFOW lpStartupInfo, _Out_ LPPROCESS_INFORMATION lpProcessInformation)
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
#define ERROR_INVALID_PARAMETER
#define ReadFile(a, b, c, d, e)
#define INVALID_HANDLE_VALUE
#define HeapFree(x, y, z)
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
DWORD WINAPI ResumeThread(IN HANDLE hThread)
BOOL WINAPI RevertToSelf(void)
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
BOOL WINAPI DestroyEnvironmentBlock(IN LPVOID lpEnvironment)
BOOL WINAPI CreateEnvironmentBlock(OUT LPVOID *lpEnvironment, IN HANDLE hToken, IN BOOL bInherit)
BOOL WINAPI LoadUserProfileW(_In_ HANDLE hToken, _Inout_ LPPROFILEINFOW lpProfileInfo)
BOOL WINAPI UnloadUserProfile(_In_ HANDLE hToken, _In_ HANDLE hProfile)
static const WCHAR Cleanup[]
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define InitializeListHead(ListHead)
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
DWORD ScmCreateGroupList(VOID)
DWORD ScmSetServiceGroup(PSERVICE lpService, LPCWSTR lpGroupName)
_CRTIMP wchar_t *__cdecl _ultow(_In_ unsigned long _Value, _Pre_notnull_ _Post_z_ wchar_t *_Dest, _In_ int _Radix)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
void *__RPC_USER MIDL_user_allocate(SIZE_T size)
void __RPC_USER MIDL_user_free(void *p)
#define FILE_FLAG_OVERLAPPED
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
#define SE_BACKUP_PRIVILEGE
#define SE_RESTORE_PRIVILEGE
#define InitializeObjectAttributes(p, n, a, r, s)
struct _OBJECT_DIRECTORY_INFORMATION OBJECT_DIRECTORY_INFORMATION
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceShared(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
NTSYSAPI VOID NTAPI RtlInitializeResource(_In_ PRTL_RESOURCE Resource)
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceExclusive(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
NTSYSAPI VOID NTAPI RtlDeleteResource(_In_ PRTL_RESOURCE Resource)
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
#define EVENT_SERVICE_DIFFERENT_PID_CONNECTED
#define EVENT_CONNECTION_TIMEOUT
#define EVENT_SERVICE_CONTROL_SUCCESS
#define EVENT_SERVICE_START_FAILED
#define EVENT_READFILE_TIMEOUT
#define _In_reads_opt_(s)
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
BOOL WINAPI TransactNamedPipe(IN HANDLE hNamedPipe, IN LPVOID lpInBuffer, IN DWORD nInBufferSize, OUT LPVOID lpOutBuffer, IN DWORD nOutBufferSize, OUT LPDWORD lpBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
HANDLE WINAPI CreateNamedPipeW(LPCWSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
#define DIRECTORY_TRAVERSE
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RTL_QUERY_REGISTRY_REQUIRED
#define RTL_QUERY_REGISTRY_DIRECT
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
#define RTL_REGISTRY_SERVICES
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define REG_OPENED_EXISTING_KEY
#define REG_OPTION_VOLATILE
#define STATUS_NO_MORE_ENTRIES
NTSTATUS NTAPI NtOpenDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
NTSTATUS NTAPI NtQueryDirectoryObject(IN HANDLE DirectoryHandle, OUT PVOID Buffer, IN ULONG BufferLength, IN BOOLEAN ReturnSingleEntry, IN BOOLEAN RestartScan, IN OUT PULONG Context, OUT PULONG ReturnLength OPTIONAL)
static BOOL bSecurityServiceProcess
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
struct _SCM_CONTROL_PACKET SCM_CONTROL_PACKET
#define SERVICE_CONTROL_START_OWN
#define SERVICE_CONTROL_START_SHARE
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
struct _LIST_ENTRY * Flink
DWORD dwServiceNameOffset
SERVICE_STATUS_HANDLE hServiceStatus
LPVOID lpSecurityDescriptor
LIST_ENTRY ImageListEntry
DWORD dwServiceSpecificExitCode
PSECURITY_DESCRIPTOR pSecurityDescriptor
LIST_ENTRY ServiceListEntry
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
#define FIELD_OFFSET(t, f)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define ALIGN_UP(size, type)
#define ALIGN_UP_POINTER(ptr, type)
#define STARTF_INHERITDESKTOP
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
SERVICE_STATUS_HANDLE hServiceStatus
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
DWORD WINAPI GetLastError(void)
#define PIPE_ACCESS_DUPLEX
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define CREATE_UNICODE_ENVIRONMENT
#define PIPE_READMODE_MESSAGE
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define PIPE_TYPE_MESSAGE
#define LOGON32_LOGON_SERVICE
#define LOGON32_PROVIDER_DEFAULT
#define ERROR_SERVICE_LOGON_FAILED
#define ERROR_SERVICE_ALREADY_RUNNING
#define ERROR_SERVICE_NEVER_STARTED
#define ERROR_NOT_ALL_ASSIGNED
#define ERROR_DIFFERENT_SERVICE_ACCOUNT
#define ERROR_DEPENDENT_SERVICES_RUNNING
#define ERROR_SERVICE_DISABLED
#define ERROR_SERVICE_REQUEST_TIMEOUT
#define ERROR_INVALID_DATA
#define ERROR_PIPE_CONNECTED
#define EVENTLOG_ERROR_TYPE
#define EVENTLOG_INFORMATION_TYPE
#define EVENTLOG_WARNING_TYPE
#define HKEY_LOCAL_MACHINE
#define SERVICE_ACCEPT_STOP
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
#define SERVICE_CONTROL_SHUTDOWN
#define SERVICE_START_PENDING
#define SERVICE_ACCEPT_SHUTDOWN
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
#define SERVICE_KERNEL_DRIVER
#define SERVICE_WIN32_SHARE_PROCESS
#define SERVICE_ERROR_SEVERE
#define SERVICE_INTERACTIVE_PROCESS
#define SERVICE_AUTO_START
#define SERVICE_BOOT_START
#define SERVICE_ERROR_CRITICAL
#define SERVICE_WIN32_OWN_PROCESS
#define SERVICE_SYSTEM_START
#define SERVICE_FILE_SYSTEM_DRIVER
#define SERVICE_ERROR_IGNORE
struct _TOKEN_PRIVILEGES TOKEN_PRIVILEGES
#define SE_PRIVILEGE_ENABLED