25#define MANAGER_TAG 0x72674D68
26#define SERVICE_TAG 0x63765368
27#define INVALID_TAG 0xAABBCCDD
50#define SC_MANAGER_READ \
51 (STANDARD_RIGHTS_READ | \
52 SC_MANAGER_QUERY_LOCK_STATUS | \
53 SC_MANAGER_ENUMERATE_SERVICE)
55#define SC_MANAGER_WRITE \
56 (STANDARD_RIGHTS_WRITE | \
57 SC_MANAGER_MODIFY_BOOT_CONFIG | \
58 SC_MANAGER_CREATE_SERVICE)
60#define SC_MANAGER_EXECUTE \
61 (STANDARD_RIGHTS_EXECUTE | \
63 SC_MANAGER_ENUMERATE_SERVICE | \
64 SC_MANAGER_CONNECT | \
65 SC_MANAGER_CREATE_SERVICE)
69 (STANDARD_RIGHTS_READ | \
70 SERVICE_INTERROGATE | \
71 SERVICE_ENUMERATE_DEPENDENTS | \
72 SERVICE_QUERY_STATUS | \
75#define SERVICE_WRITE \
76 (STANDARD_RIGHTS_WRITE | \
77 SERVICE_CHANGE_CONFIG)
79#define SERVICE_EXECUTE \
80 (STANDARD_RIGHTS_EXECUTE | \
81 SERVICE_USER_DEFINED_CONTROL | \
82 SERVICE_PAUSE_CONTINUE | \
86#define TAG_ARRAY_SIZE 32
111 DPRINT(
"ScmStartRpcServer() called\n");
119 DPRINT1(
"RpcServerUseProtseqEpW() failed (Status %lx)\n",
Status);
128 DPRINT1(
"RpcServerRegisterIf() failed (Status %lx)\n",
Status);
139 DPRINT(
"ScmStartRpcServer() done\n");
149 if (lpDatabaseName ==
NULL)
154 DPRINT(
"Database %S, does not exist\n", lpDatabaseName);
159 DPRINT(
"Invalid Database name %S\n", lpDatabaseName);
171 wcscpy(
Ptr->DatabaseName, lpDatabaseName);
193 Ptr->ServiceEntry = lpServiceEntry;
213 DPRINT1(
"Exception: Invalid Service Manager handle\n");
233 DPRINT1(
"Exception: Invalid Service handle\n");
243 DWORD dwDesiredAccess)
276 DWORD dwGroupTagCount = 0;
279 DWORD dwTagUsedBase = 1;
291 L"System\\CurrentControlSet\\Control\\GroupOrderList",
328 if (cbDataSize <
sizeof(pdwGroupTags[0]))
331 dwGroupTagCount =
min(pdwGroupTags[0], cbDataSize /
sizeof(pdwGroupTags[0]) - 1);
341 for (
i = 1;
i <= dwGroupTagCount;
i++)
343 nTagOffset = pdwGroupTags[
i] - dwTagUsedBase;
345 TagUsed[nTagOffset] =
TRUE;
356 nTagOffset = CurrentService->
dwTag - dwTagUsedBase;
358 TagUsed[nTagOffset] =
TRUE;
361 ServiceEntry = ServiceEntry->
Flink;
369 dwFreeTag = dwTagUsedBase +
i;
375 }
while (!dwFreeTag);
386 lpService->
dwTag = dwFreeTag;
387 DPRINT(
"Assigning new tag %lu to service %S in group %S\n",
393 DPRINT1(
"Failed to assign new tag to service %S, error=%lu\n",
405 SIZE_T ServiceNameLen, ExpandedLen;
412 HANDLE SymbolicLinkHandle;
419 *RelativeName =
NULL;
424 if (ServiceNameLen > 12 &&
429 (ServiceNameLen + 1) *
sizeof(
WCHAR));
430 if (*RelativeName ==
NULL)
432 DPRINT(
"Error allocating memory for boot driver name\n");
439 DPRINT(
"Bootdriver name %S\n", *RelativeName);
444 if (ServiceNameLen > 13 &&
450 ServiceNameLen *
sizeof(
WCHAR));
452 if (*RelativeName ==
NULL)
454 DPRINT(
"Error allocating memory for boot driver name\n");
459 wcscpy(*RelativeName,
L"\\SystemRoot\\");
462 DPRINT(
"Bootdriver name %S\n", *RelativeName);
470 DPRINT(
"Error during a call to ExpandEnvironmentStringsW()\n");
480 DPRINT(
"Error allocating memory for boot driver name\n");
488 DPRINT(
"Error during a call to ExpandEnvironmentStringsW()\n");
496 DPRINT(
"Error during a call to RtlDosPathNameToNtPathName_U()\n");
500 DPRINT(
"Converted to NT-style %wZ\n", &NtPathName);
511 DPRINT(
"Error allocating memory for boot driver name\n");
521 if (ServiceNameLen > ExpandedLen &&
529 (ServiceNameLen - ExpandedLen) *
sizeof(
WCHAR) + 13*
sizeof(
WCHAR));
530 if (*RelativeName ==
NULL)
532 DPRINT(
"Error allocating memory for boot driver name\n");
536 wcscpy(*RelativeName,
L"\\SystemRoot\\");
557 DPRINT(
"Opened symbolic link object\n");
566 DPRINT(
"Too large buffer required\n");
580 DPRINT(
"Unable to alloc buffer\n");
593 if ((ServiceNameLen > ExpandedLen) &&
598 (ServiceNameLen - ExpandedLen) *
sizeof(
WCHAR) + 13*
sizeof(
WCHAR));
600 if (*RelativeName ==
NULL)
602 DPRINT(
"Unable to alloc buffer\n");
608 wcscpy(*RelativeName,
L"\\SystemRoot\\");
643 const wchar_t *lpServiceName,
644 wchar_t **lpCanonName)
653 ServiceNameLen =
wcslen(lpServiceName);
656 if (ServiceNameLen > 12 &&
657 !
_wcsnicmp(
L"\\SystemRoot\\", lpServiceName, 12))
662 (ServiceNameLen + 1) *
sizeof(
WCHAR));
664 if (*lpCanonName ==
NULL)
666 DPRINT(
"Error allocating memory for canonized service name\n");
677 DPRINT(
"Canonicalized name %S\n", *lpCanonName);
682 if (ServiceNameLen > 13 &&
683 !
_wcsnicmp(
L"%SystemRoot%\\", lpServiceName, 13))
688 (ServiceNameLen + 1) *
sizeof(
WCHAR));
690 if (*lpCanonName ==
NULL)
692 DPRINT(
"Error allocating memory for canonized service name\n");
698 wcscpy(*lpCanonName,
L"\\SystemRoot\\");
700 wcscat(*lpCanonName, lpServiceName + 13);
702 DPRINT(
"Canonicalized name %S\n", *lpCanonName);
707 if (lpServiceName[0] !=
L'\\' && lpServiceName[1] !=
L':')
711 (ServiceNameLen + 1) *
sizeof(
WCHAR));
713 if (*lpCanonName ==
NULL)
715 DPRINT(
"Error allocating memory for canonized service name\n");
720 wcscpy(*lpCanonName, lpServiceName);
728 DPRINT(
"RtlDosPathNameToNtPathName_U() failed\n");
736 if (*lpCanonName ==
NULL)
738 DPRINT(
"Error allocating memory for canonized service name\n");
751 DPRINT(
"Canonicalized name %S\n", *lpCanonName);
761 DPRINT(
"Error converting named\n");
768 wcscpy(*lpCanonName, RelativeName + 12);
773 DPRINT(
"Canonicalized name %S\n", *lpCanonName);
784 DWORD dwServiceState,
792 WCHAR *lpszNameBuf = szNameBuf;
793 WCHAR *lpszValueBuf = szValueBuf;
798 HKEY hServiceEnumKey;
800 DWORD dwDependServiceStrPtr = 0;
801 DWORD dwRequiredSize = 0;
818 DPRINT(
"ERROR! Unable to get number of services keys\n");
823 for (dwIteration = 0; dwIteration < dwNumSubKeys; dwIteration++)
861 dwDependServiceStrPtr = 0;
864 while (
wcslen(lpszValueBuf + dwDependServiceStrPtr) > 0)
872 if (!lpCurrentService)
875 DPRINT(
"This should not happen at this point, report to Developer\n");
884 if ((dwCurrentServiceState == dwServiceState) ||
893 dwRequiredSize += (2 *
sizeof(
PVOID));
911 lpServices[*lpServicesReturned] = lpCurrentService;
913 *lpServicesReturned = *lpServicesReturned + 1;
917 dwDependServiceStrPtr += (
DWORD)(
wcslen(lpszValueBuf + dwDependServiceStrPtr) + 1);
942 DPRINT(
"RCloseServiceHandle() called\n");
944 DPRINT(
"hSCObject = %p\n", *hSCObject);
952 if (hManager !=
NULL)
954 DPRINT(
"Found manager handle\n");
964 DPRINT(
"RCloseServiceHandle() done\n");
967 else if (hService !=
NULL)
969 DPRINT(
"Found service handle\n");
992 DPRINT(
"RCloseServiceHandle() done\n");
1015 DWORD dwServicesReturned = 0;
1016 DWORD dwControlsAccepted;
1017 DWORD dwCurrentState;
1020 WCHAR szLogBuffer[80];
1023 DPRINT(
"RControlService() called\n");
1032 DPRINT1(
"Invalid service handle\n");
1038 if (lpService ==
NULL)
1040 DPRINT1(
"lpService == NULL\n");
1066 if (dwControl >= 128 && dwControl <= 255)
1089 L"System\\CurrentControlSet\\Services",
1095 DPRINT(
"Failed to open services key\n");
1105 &dwServicesReturned);
1113 DPRINT(
"Service has running dependencies. Failed to stop service\n");
1135 switch (dwCurrentState)
1224 lpLogStrings[1] = szLogBuffer;
1247 DPRINT(
"RDeleteService() called\n");
1255 DPRINT1(
"Invalid service handle\n");
1264 if (lpService ==
NULL)
1266 DPRINT(
"lpService == NULL\n");
1275 DPRINT(
"Service has already been marked for delete\n");
1289 DPRINT(
"RDeleteService() done\n");
1304 DPRINT(
"RLockServiceDatabase() called\n");
1311 DPRINT1(
"Invalid service manager handle\n");
1329 LPBYTE lpSecurityDescriptor,
1337 DWORD dwBytesNeeded;
1340 DPRINT(
"RQueryServiceObjectSecurity() called\n");
1345 DPRINT1(
"Invalid service handle\n");
1365 if (lpService ==
NULL)
1367 DPRINT(
"lpService == NULL\n");
1376 dwSecurityInformation,
1412 DWORD dwSecurityInformation,
1413 LPBYTE lpSecurityDescriptor,
1414 DWORD dwSecurityDescriptorSize)
1425 DPRINT(
"RSetServiceObjectSecurity() called\n");
1430 DPRINT1(
"Invalid service handle\n");
1434 if (dwSecurityInformation == 0 ||
1473 if (lpService ==
NULL)
1475 DPRINT1(
"lpService == NULL\n");
1509 bDatabaseLocked =
TRUE;
1525 if (hServiceKey !=
NULL)
1529 if (bDatabaseLocked ==
TRUE)
1535 DPRINT(
"RSetServiceObjectSecurity() done (Error %lu)\n", dwError);
1551 DPRINT(
"RQueryServiceStatus() called\n");
1559 DPRINT1(
"Invalid service handle\n");
1571 if (lpService ==
NULL)
1573 DPRINT(
"lpService == NULL\n");
1595 switch (dwCurrentState)
1617 WCHAR szLogBuffer[80];
1657 lpLogStrings[1] = szLogBuffer;
1669 lpLogStrings[1] = szLogBuffer;
1695 DWORD dwPreviousState;
1696 DWORD dwPreviousType;
1698 WCHAR szLogBuffer[80];
1701 DPRINT(
"RSetServiceStatus() called\n");
1713 DPRINT(
"hServiceStatus == NULL\n");
1722 DPRINT(
"Invalid service state\n");
1730 DPRINT(
"Invalid service type\n");
1737 DPRINT(
"Invalid controls accepted\n");
1783 DWORD dwStopThreadId;
1798 if (hStopThread ==
NULL)
1800 DPRINT1(
"Failed to create thread to complete service stop\n");
1804 DPRINT1(
"Service %S has %d references after stop\n", lpService->lpServiceName, lpService->RefCount);
1835 lpLogStrings[1] = szLogBuffer;
1844 DPRINT(
"RSetServiceStatus() done\n");
1856 DPRINT(
"RUnlockServiceDatabase(%p)\n",
Lock);
1866 DWORD BootAcceptable)
1868 DPRINT(
"RNotifyBootConfigStatus(%p %lu)\n",
1869 lpMachineName, BootAcceptable);
1885 int bUpdateImmediately,
1890 DPRINT(
"RI_ScSetServiceBitsW(%p %lx %d %d %S)\n",
1892 bUpdateImmediately, lpString);
1897 if (lpString !=
NULL)
1902 DPRINT(
"hServiceStatus == NULL\n");
1937 DWORD dwServiceType,
1939 DWORD dwErrorControl,
1945 LPWSTR lpServiceStartName,
1958 DPRINT(
"RChangeServiceConfigW() called\n");
1959 DPRINT(
"dwServiceType = 0x%lx\n", dwServiceType);
1960 DPRINT(
"dwStartType = %lu\n", dwStartType);
1961 DPRINT(
"dwErrorControl = %lu\n", dwErrorControl);
1962 DPRINT(
"lpBinaryPathName = %S\n", lpBinaryPathName);
1963 DPRINT(
"lpLoadOrderGroup = %S\n", lpLoadOrderGroup);
1964 DPRINT(
"lpServiceStartName = %S\n", lpServiceStartName);
1965 DPRINT(
"lpPassword = %p\n", lpPassword);
1966 DPRINT(
"dwPwSite = %lu\n", dwPwSize);
1975 DPRINT1(
"Invalid service handle\n");
2026 if (lpdwTagId && (!lpLoadOrderGroup || !*lpLoadOrderGroup))
2032 if (lpService ==
NULL)
2034 DPRINT(
"lpService == NULL\n");
2043 DPRINT(
"Service has already been marked for delete\n");
2071 if (lpDisplayNameW ==
NULL)
2129 if (lpBinaryPathName !=
NULL && *lpBinaryPathName != 0)
2132 lpImagePathW = lpBinaryPathName;
2151 if (lpImagePathW != lpBinaryPathName)
2159 if (lpLoadOrderGroup !=
NULL && *lpLoadOrderGroup != 0)
2165 (
LPBYTE)lpLoadOrderGroup,
2177 if (lpdwTagId !=
NULL)
2192 *lpdwTagId = lpService->
dwTag;
2196 if (lpDependencies !=
NULL && *lpDependencies != 0)
2209 if (lpServiceStartName !=
NULL && *lpServiceStartName != 0)
2215 (
LPBYTE)lpServiceStartName,
2221 if (lpPassword !=
NULL)
2223 if (*(
LPWSTR)lpPassword != 0)
2229 &lpClearTextPassword);
2232 DPRINT1(
"ScmDecryptPassword failed (Error %lu)\n", dwError);
2235 DPRINT(
"Clear text password: %S\n", lpClearTextPassword);
2239 lpClearTextPassword);
2242 DPRINT1(
"ScmSetServicePassword failed (Error %lu)\n", dwError);
2256 DPRINT1(
"ScmSetServicePassword failed (Error %lu)\n", dwError);
2264 if (lpClearTextPassword !=
NULL)
2268 (
wcslen(lpClearTextPassword) + 1) *
sizeof(
WCHAR));
2272 if (hServiceKey !=
NULL)
2278 DPRINT(
"RChangeServiceConfigW() done (Error %lu)\n", dwError);
2291 DWORD dwDesiredAccess,
2292 DWORD dwServiceType,
2294 DWORD dwErrorControl,
2308 SC_HANDLE hServiceHandle =
NULL;
2314 DPRINT(
"RCreateServiceW() called\n");
2315 DPRINT(
"lpServiceName = %S\n", lpServiceName);
2317 DPRINT(
"dwDesiredAccess = %lx\n", dwDesiredAccess);
2318 DPRINT(
"dwServiceType = 0x%lx\n", dwServiceType);
2319 DPRINT(
"dwStartType = %lu\n", dwStartType);
2320 DPRINT(
"dwErrorControl = %lu\n", dwErrorControl);
2321 DPRINT(
"lpBinaryPathName = %S\n", lpBinaryPathName);
2322 DPRINT(
"lpLoadOrderGroup = %S\n", lpLoadOrderGroup);
2323 DPRINT(
"lpdwTagId = %p\n", lpdwTagId);
2329 if (hManager ==
NULL)
2331 DPRINT1(
"Invalid service manager handle\n");
2339 DPRINT(
"Insufficient access rights! 0x%lx\n",
2344 if (*lpServiceName == 0)
2347 if (*lpBinaryPathName == 0)
2390 (lpServiceStartName))
2393 if (
_wcsicmp(lpServiceStartName,
L"LocalSystem"))
2399 if (lpdwTagId && (!lpLoadOrderGroup || !*lpLoadOrderGroup))
2478 if (lpLoadOrderGroup !=
NULL && *lpLoadOrderGroup != 0)
2487 if (lpdwTagId !=
NULL)
2558 (
LPBYTE)lpBinaryPathName,
2576 if (lpLoadOrderGroup !=
NULL && *lpLoadOrderGroup != 0)
2582 (
LPBYTE)lpLoadOrderGroup,
2589 if (lpdwTagId !=
NULL)
2602 if (lpDependencies !=
NULL && *lpDependencies != 0)
2615 lpObjectName = (lpServiceStartName !=
NULL) ? (
LPWSTR)lpServiceStartName :
L"LocalSystem";
2625 if (lpPassword !=
NULL && *(
LPWSTR)lpPassword != 0)
2631 &lpClearTextPassword);
2637 lpClearTextPassword);
2664 DPRINT(
"CreateService - lpService->RefCount %u\n", lpService->
RefCount);
2670 if (hServiceKey !=
NULL)
2673 if (lpClearTextPassword !=
NULL)
2677 (
wcslen(lpClearTextPassword) + 1) *
sizeof(
WCHAR));
2683 DPRINT(
"hService %p\n", hServiceHandle);
2686 if (lpdwTagId !=
NULL)
2687 *lpdwTagId = lpService->
dwTag;
2691 if (lpService !=
NULL &&
2704 if (lpService !=
NULL)
2710 if (lpImagePath !=
NULL)
2713 DPRINT(
"RCreateServiceW() done (Error %lu)\n", dwError);
2724 DWORD dwServiceState,
2731 DWORD dwServicesReturned = 0;
2732 DWORD dwServiceCount;
2741 *lpServicesReturned = 0;
2743 DPRINT(
"REnumDependentServicesW() called\n");
2748 DPRINT1(
"Invalid service handle\n");
2758 DPRINT(
"Insufficient access rights! 0x%lx\n",
2765 L"System\\CurrentControlSet\\Services",
2778 &dwServicesReturned);
2792 (dwServicesReturned + 1) *
sizeof(
PSERVICE));
2793 if (!lpServicesArray)
2795 DPRINT1(
"Could not allocate buffer\n");
2800 dwServicesReturned = 0;
2808 &dwServicesReturned);
2818 for (dwServiceCount = 0; dwServiceCount < dwServicesReturned; dwServiceCount++)
2820 lpService = lpServicesArray[dwServiceCount];
2840 *lpServicesReturned = dwServicesReturned;
2843 if (lpServicesArray !=
NULL)
2848 DPRINT(
"REnumDependentServicesW() done (Error %lu)\n", dwError);
2859 DWORD dwServiceType,
2860 DWORD dwServiceState,
2886 DWORD dwDesiredAccess,
2892 DPRINT(
"ROpenSCManagerW() called\n");
2893 DPRINT(
"lpMachineName = %p\n", lpMachineName);
2894 DPRINT(
"lpMachineName: %S\n", lpMachineName);
2895 DPRINT(
"lpDataBaseName = %p\n", lpDatabaseName);
2896 DPRINT(
"lpDataBaseName: %S\n", lpDatabaseName);
2897 DPRINT(
"dwDesiredAccess = %x\n", dwDesiredAccess);
2909 DPRINT(
"ScmCreateManagerHandle() failed (Error %lu)\n", dwError);
2918 DPRINT(
"ScmCheckAccess() failed (Error %lu)\n", dwError);
2924 DPRINT(
"*hScm = %p\n", *lpScHandle);
2926 DPRINT(
"ROpenSCManagerW() done\n");
2938 DWORD dwDesiredAccess,
2946 DPRINT(
"ROpenServiceW() called\n");
2948 DPRINT(
"lpServiceName = %p\n", lpServiceName);
2949 DPRINT(
"lpServiceName: %S\n", lpServiceName);
2950 DPRINT(
"dwDesiredAccess = %x\n", dwDesiredAccess);
2956 if (hManager ==
NULL)
2958 DPRINT1(
"Invalid service manager handle\n");
2962 if (!lpServiceHandle)
2973 if (lpService ==
NULL)
2975 DPRINT(
"Could not find service\n");
2985 DPRINT(
"ScmCreateServiceHandle() failed (Error %lu)\n", dwError);
2994 DPRINT(
"ScmCheckAccess() failed (Error %lu)\n", dwError);
3003 DPRINT(
"*hService = %p\n", *lpServiceHandle);
3009 DPRINT(
"ROpenServiceW() done\n");
3032 DWORD dwDependenciesLength = 0;
3033 DWORD dwRequiredSize;
3036 DPRINT(
"RQueryServiceConfigW() called\n");
3044 DPRINT1(
"Invalid service handle\n");
3056 if (lpService ==
NULL)
3058 DPRINT(
"lpService == NULL\n");
3081 &lpServiceStartName);
3086 &dwDependenciesLength);
3090 if (lpImagePath !=
NULL)
3093 dwRequiredSize += 2 *
sizeof(
WCHAR);
3098 dwRequiredSize += 2 *
sizeof(
WCHAR);
3100 if (lpDependencies !=
NULL)
3101 dwRequiredSize += dwDependenciesLength *
sizeof(
WCHAR);
3103 dwRequiredSize += 2 *
sizeof(
WCHAR);
3105 if (lpServiceStartName !=
NULL)
3106 dwRequiredSize += (
DWORD)((
wcslen(lpServiceStartName) + 1) *
sizeof(
WCHAR));
3108 dwRequiredSize += 2 *
sizeof(
WCHAR);
3113 dwRequiredSize += 2 *
sizeof(
WCHAR);
3126 lpStr = (
LPWSTR)(lpServiceConfig + 1);
3129 if (lpImagePath !=
NULL)
3131 wcscpy(lpStr, lpImagePath);
3139 lpStr += (
wcslen(lpStr) + 1);
3152 lpStr += (
wcslen(lpStr) + 1);
3155 if (lpDependencies !=
NULL)
3159 dwDependenciesLength *
sizeof(
WCHAR));
3167 if (lpDependencies !=
NULL)
3168 lpStr += dwDependenciesLength;
3170 lpStr += (
wcslen(lpStr) + 1);
3173 if (lpServiceStartName !=
NULL)
3175 wcscpy(lpStr, lpServiceStartName);
3183 lpStr += (
wcslen(lpStr) + 1);
3205 if (lpImagePath !=
NULL)
3208 if (lpServiceStartName !=
NULL)
3211 if (lpDependencies !=
NULL)
3214 if (hServiceKey !=
NULL)
3217 DPRINT(
"RQueryServiceConfigW() done\n");
3234 DWORD dwRequiredSize;
3242 DPRINT1(
"Invalid service manager handle\n");
3281 DPRINT(
"RStartServiceW(%p %lu %p) called\n", hService,
argc,
argv);
3298 DPRINT1(
"Invalid service handle\n");
3310 if (lpService ==
NULL)
3312 DPRINT(
"lpService == NULL\n");
3344 DPRINT(
"RGetServiceDisplayNameW() called\n");
3346 DPRINT(
"lpServiceName: %S\n", lpServiceName);
3348 DPRINT(
"*lpcchBuffer: %lu\n", *lpcchBuffer);
3354 DPRINT(
"Invalid manager handle\n");
3361 if (lpService ==
NULL)
3363 DPRINT(
"Could not find service\n");
3406 DPRINT(
"RGetServiceKeyNameW() called\n");
3409 DPRINT(
"lpServiceName: %p\n", lpServiceName);
3410 DPRINT(
"*lpcchBuffer: %lu\n", *lpcchBuffer);
3416 DPRINT(
"Invalid manager handle\n");
3423 if (lpService ==
NULL)
3425 DPRINT(
"Could not find service\n");
3433 if (lpServiceName !=
NULL)
3456 int bUpdateImmediately,
3462 if (lpString !=
NULL)
3478 DWORD dwServiceType,
3480 DWORD dwErrorControl,
3481 LPSTR lpBinaryPathName,
3482 LPSTR lpLoadOrderGroup,
3486 LPSTR lpServiceStartName,
3497 DWORD dwDependenciesLength = 0;
3502 if (lpBinaryPathName)
3506 if (!lpBinaryPathNameW)
3514 if (lpLoadOrderGroup)
3518 if (!lpLoadOrderGroupW)
3528 lpStr = (
LPCSTR)lpDependencies;
3531 cchLength =
strlen(lpStr) + 1;
3532 dwDependenciesLength += (
DWORD)cchLength;
3533 lpStr = lpStr + cchLength;
3535 dwDependenciesLength++;
3538 if (!lpDependenciesW)
3546 if (lpServiceStartName)
3550 if (!lpServiceStartNameW)
3562 if (!lpDisplayNameW)
3578 dwDependenciesLength,
3579 lpServiceStartNameW,
3585 if (lpBinaryPathNameW !=
NULL)
3588 if (lpLoadOrderGroupW !=
NULL)
3591 if (lpDependenciesW !=
NULL)
3594 if (lpServiceStartNameW !=
NULL)
3597 if (lpDisplayNameW !=
NULL)
3609 LPSTR lpServiceName,
3611 DWORD dwDesiredAccess,
3612 DWORD dwServiceType,
3614 DWORD dwErrorControl,
3615 LPSTR lpBinaryPathName,
3616 LPSTR lpLoadOrderGroup,
3620 LPSTR lpServiceStartName,
3632 DWORD dwDependenciesLength = 0;
3641 if (!lpServiceNameW)
3653 if (!lpDisplayNameW)
3661 if (lpBinaryPathName)
3665 if (!lpBinaryPathNameW)
3673 if (lpLoadOrderGroup)
3677 if (!lpLoadOrderGroupW)
3687 lpStr = (
LPCSTR)lpDependencies;
3690 cchLength =
strlen(lpStr) + 1;
3691 dwDependenciesLength += (
DWORD)cchLength;
3692 lpStr = lpStr + cchLength;
3694 dwDependenciesLength++;
3697 if (!lpDependenciesW)
3705 if (lpServiceStartName)
3709 if (!lpServiceStartNameW)
3728 dwDependenciesLength,
3729 lpServiceStartNameW,
3735 if (lpServiceNameW !=
NULL)
3738 if (lpDisplayNameW !=
NULL)
3741 if (lpBinaryPathNameW !=
NULL)
3744 if (lpLoadOrderGroupW !=
NULL)
3747 if (lpDependenciesW !=
NULL)
3750 if (lpServiceStartNameW !=
NULL)
3762 DWORD dwServiceState,
3769 DWORD dwServicesReturned = 0;
3770 DWORD dwServiceCount;
3779 *lpServicesReturned = 0;
3781 DPRINT(
"REnumDependentServicesA() called\n");
3786 DPRINT1(
"Invalid service handle\n");
3796 DPRINT(
"Insufficient access rights! 0x%lx\n",
3803 L"System\\CurrentControlSet\\Services",
3821 &dwServicesReturned);
3835 (dwServicesReturned + 1) *
sizeof(
PSERVICE));
3836 if (!lpServicesArray)
3838 DPRINT(
"Could not allocate buffer\n");
3843 dwServicesReturned = 0;
3851 &dwServicesReturned);
3861 for (dwServiceCount = 0; dwServiceCount < dwServicesReturned; dwServiceCount++)
3863 lpService = lpServicesArray[dwServiceCount];
3880 lpStr +=
strlen(lpStr) + 1;
3892 lpStr +=
strlen(lpStr) + 1;
3897 *lpServicesReturned = dwServicesReturned;
3900 if (lpServicesArray)
3905 DPRINT(
"REnumDependentServicesA() done (Error %lu)\n", dwError);
3916 DWORD dwServiceType,
3917 DWORD dwServiceState,
3930 DWORD dwServiceCount;
3932 DPRINT(
"REnumServicesStatusA() called\n");
3944 DPRINT(
"Failed to allocate buffer\n");
3959 if (*lpServicesReturned == 0)
3962 lpStatusPtrIncrW = lpStatusPtrW;
3969 for (dwServiceCount = 0; dwServiceCount < *lpServicesReturned; dwServiceCount++)
3977 (
int)
wcslen(lpStringPtrW),
3982 lpStringPtrA +=
wcslen(lpStringPtrW) + 1;
3983 lpStringPtrW +=
wcslen(lpStringPtrW) + 1;
3991 (
int)
wcslen(lpStringPtrW),
3996 lpStringPtrA +=
wcslen(lpStringPtrW) + 1;
3997 lpStringPtrW +=
wcslen(lpStringPtrW) + 1;
4012 DPRINT(
"REnumServicesStatusA() done (Error %lu)\n", dwError);
4022 LPSTR lpMachineName,
4023 LPSTR lpDatabaseName,
4024 DWORD dwDesiredAccess,
4031 DPRINT(
"ROpenSCManagerA() called\n");
4061 LPSTR lpServiceName,
4062 DWORD dwDesiredAccess,
4068 DPRINT(
"ROpenServiceA() called\n");
4103 DWORD dwDependenciesLength = 0;
4104 DWORD dwRequiredSize;
4107 DPRINT(
"RQueryServiceConfigA() called\n");
4115 DPRINT1(
"Invalid service handle\n");
4127 if (lpService ==
NULL)
4129 DPRINT(
"lpService == NULL\n");
4152 &lpServiceStartName);
4157 &dwDependenciesLength);
4161 if (lpImagePath !=
NULL)
4162 dwRequiredSize += (
DWORD)(
wcslen(lpImagePath) + 1);
4164 dwRequiredSize += 2 *
sizeof(
CHAR);
4169 dwRequiredSize += 2 *
sizeof(
CHAR);
4172 if (lpDependencies !=
NULL)
4173 dwRequiredSize += dwDependenciesLength;
4175 dwRequiredSize += 2 *
sizeof(
CHAR);
4177 if (lpServiceStartName !=
NULL)
4178 dwRequiredSize += (
DWORD)(
wcslen(lpServiceStartName) + 1);
4180 dwRequiredSize += 2 *
sizeof(
CHAR);
4185 dwRequiredSize += 2 *
sizeof(
CHAR);
4198 lpStr = (
LPSTR)(lpServiceConfig + 1);
4210 (
int)(
wcslen(lpImagePath) + 1),
4239 lpStr += (
strlen(lpStr) + 1);
4247 dwDependenciesLength,
4249 dwDependenciesLength,
4260 lpStr += dwDependenciesLength;
4262 lpStr += (
strlen(lpStr) + 1);
4264 if (lpServiceStartName)
4271 (
int)(
wcslen(lpServiceStartName) + 1),
4281 lpStr += (
strlen(lpStr) + 1);
4309 if (lpImagePath !=
NULL)
4312 if (lpServiceStartName !=
NULL)
4315 if (lpDependencies !=
NULL)
4318 if (hServiceKey !=
NULL)
4321 DPRINT(
"RQueryServiceConfigA() done\n");
4338 DWORD dwRequiredSize;
4346 DPRINT1(
"Invalid service manager handle\n");
4385 DPRINT(
"RStartServiceA() called\n");
4393 DPRINT1(
"Invalid service handle\n");
4405 if (lpService ==
NULL)
4407 DPRINT(
"lpService == NULL\n");
4487 DPRINT(
"RGetServiceDisplayNameA() called\n");
4489 DPRINT(
"lpServiceName: %s\n", lpServiceName);
4491 DPRINT(
"*lpcchBuffer: %lu\n", *lpcchBuffer);
4497 DPRINT(
"Invalid manager handle\n");
4503 if (lpServiceName !=
NULL)
4509 if (!lpServiceNameW)
4524 if (lpService ==
NULL)
4526 DPRINT(
"Could not find service\n");
4600 LPSTR lpServiceName,
4608 DPRINT(
"RGetServiceKeyNameA() called\n");
4611 DPRINT(
"lpServiceName: %p\n", lpServiceName);
4612 DPRINT(
"*lpcchBuffer: %lu\n", *lpcchBuffer);
4618 DPRINT(
"Invalid manager handle\n");
4629 if (!lpDisplayNameW)
4643 if (lpService ==
NULL)
4645 DPRINT(
"Could not find service\n");
4658 if (lpServiceName !=
NULL &&
4720 DPRINT(
"RI_ScGetCurrentGroupStateW() called\n");
4726 if (hManager ==
NULL)
4728 DPRINT1(
"Invalid service manager handle\n");
4736 DPRINT(
"Insufficient access rights! 0x%lx\n",
4746 if (pServiceGroup ==
NULL)
4759 DPRINT(
"RI_ScGetCurrentGroupStateW() done (Error %lu)\n", dwError);
4770 DWORD dwServiceType,
4771 DWORD dwServiceState,
4785 DWORD dwRequiredSize;
4786 DWORD dwServiceCount;
4788 DWORD dwLastResumeCount = 0;
4792 DPRINT(
"REnumServiceGroupW() called\n");
4798 if (hManager ==
NULL)
4800 DPRINT1(
"Invalid service manager handle\n");
4810 *lpServicesReturned = 0;
4812 if ((dwServiceType == 0) ||
4815 DPRINT(
"Invalid Service Type\n");
4819 if ((dwServiceState == 0) ||
4822 DPRINT(
"Invalid Service State\n");
4830 DPRINT(
"Insufficient access rights! 0x%lx\n",
4836 dwLastResumeCount = *lpResumeIndex;
4842 if (lpService ==
NULL)
4853 ServiceEntry = ServiceEntry->
Flink)
4866 if ((dwState & dwServiceState) == 0)
4871 if (*pszGroupName == 0)
4895 dwRequiredSize +=
dwSize;
4900 DPRINT(
"dwRequiredSize: %lu\n", dwRequiredSize);
4901 DPRINT(
"dwServiceCount: %lu\n", dwServiceCount);
4905 ServiceEntry = ServiceEntry->
Flink)