23 #define MANAGER_TAG 0x72674D68 24 #define SERVICE_TAG 0x63765368 25 #define INVALID_TAG 0xAABBCCDD 48 #define SC_MANAGER_READ \ 49 (STANDARD_RIGHTS_READ | \ 50 SC_MANAGER_QUERY_LOCK_STATUS | \ 51 SC_MANAGER_ENUMERATE_SERVICE) 53 #define SC_MANAGER_WRITE \ 54 (STANDARD_RIGHTS_WRITE | \ 55 SC_MANAGER_MODIFY_BOOT_CONFIG | \ 56 SC_MANAGER_CREATE_SERVICE) 58 #define SC_MANAGER_EXECUTE \ 59 (STANDARD_RIGHTS_EXECUTE | \ 61 SC_MANAGER_ENUMERATE_SERVICE | \ 62 SC_MANAGER_CONNECT | \ 63 SC_MANAGER_CREATE_SERVICE) 66 #define SERVICE_READ \ 67 (STANDARD_RIGHTS_READ | \ 68 SERVICE_INTERROGATE | \ 69 SERVICE_ENUMERATE_DEPENDENTS | \ 70 SERVICE_QUERY_STATUS | \ 73 #define SERVICE_WRITE \ 74 (STANDARD_RIGHTS_WRITE | \ 75 SERVICE_CHANGE_CONFIG) 77 #define SERVICE_EXECUTE \ 78 (STANDARD_RIGHTS_EXECUTE | \ 79 SERVICE_USER_DEFINED_CONTROL | \ 80 SERVICE_PAUSE_CONTINUE | \ 84 #define TAG_ARRAY_SIZE 32 109 DPRINT(
"ScmStartRpcServer() called\n");
117 DPRINT1(
"RpcServerUseProtseqEpW() failed (Status %lx)\n",
Status);
126 DPRINT1(
"RpcServerRegisterIf() failed (Status %lx)\n",
Status);
137 DPRINT(
"ScmStartRpcServer() done\n");
147 if (lpDatabaseName ==
NULL)
152 DPRINT(
"Database %S, does not exist\n", lpDatabaseName);
157 DPRINT(
"Invalid Database name %S.\n", lpDatabaseName);
169 wcscpy(
Ptr->DatabaseName, lpDatabaseName);
191 Ptr->ServiceEntry = lpServiceEntry;
211 DPRINT1(
"Exception: Invalid Service Manager handle!\n");
231 DPRINT1(
"Exception: Invalid Service handle!\n");
241 DWORD dwDesiredAccess)
274 DWORD dwGroupTagCount = 0;
277 DWORD dwTagUsedBase = 1;
289 L"System\\CurrentControlSet\\Control\\GroupOrderList",
326 if (cbDataSize <
sizeof(pdwGroupTags[0]))
329 dwGroupTagCount =
min(pdwGroupTags[0], cbDataSize /
sizeof(pdwGroupTags[0]) - 1);
339 for (
i = 1;
i <= dwGroupTagCount;
i++)
341 nTagOffset = pdwGroupTags[
i] - dwTagUsedBase;
343 TagUsed[nTagOffset] =
TRUE;
354 nTagOffset = CurrentService->
dwTag - dwTagUsedBase;
356 TagUsed[nTagOffset] =
TRUE;
359 ServiceEntry = ServiceEntry->
Flink;
367 dwFreeTag = dwTagUsedBase +
i;
373 }
while (!dwFreeTag);
384 lpService->
dwTag = dwFreeTag;
385 DPRINT(
"Assigning new tag %lu to service %S in group %S\n",
391 DPRINT1(
"Failed to assign new tag to service %S, error=%lu\n",
403 SIZE_T ServiceNameLen, ExpandedLen;
410 HANDLE SymbolicLinkHandle;
417 *RelativeName =
NULL;
422 if (ServiceNameLen > 12 &&
427 (ServiceNameLen + 1) *
sizeof(
WCHAR));
428 if (*RelativeName ==
NULL)
430 DPRINT(
"Error allocating memory for boot driver name!\n");
437 DPRINT(
"Bootdriver name %S\n", *RelativeName);
442 if (ServiceNameLen > 13 &&
448 ServiceNameLen *
sizeof(
WCHAR));
450 if (*RelativeName ==
NULL)
452 DPRINT(
"Error allocating memory for boot driver name!\n");
457 wcscpy(*RelativeName,
L"\\SystemRoot\\");
460 DPRINT(
"Bootdriver name %S\n", *RelativeName);
468 DPRINT(
"Error during a call to ExpandEnvironmentStringsW()\n");
478 DPRINT(
"Error allocating memory for boot driver name!\n");
486 DPRINT(
"Error during a call to ExpandEnvironmentStringsW()\n");
494 DPRINT(
"Error during a call to RtlDosPathNameToNtPathName_U()\n");
498 DPRINT(
"Converted to NT-style %wZ\n", &NtPathName);
509 DPRINT(
"Error allocating memory for boot driver name!\n");
519 if (ServiceNameLen > ExpandedLen &&
527 (ServiceNameLen - ExpandedLen) *
sizeof(
WCHAR) + 13*
sizeof(
WCHAR));
528 if (*RelativeName ==
NULL)
530 DPRINT(
"Error allocating memory for boot driver name!\n");
534 wcscpy(*RelativeName,
L"\\SystemRoot\\");
555 DPRINT(
"Opened symbolic link object\n");
564 DPRINT(
"Too large buffer required\n");
578 DPRINT(
"Unable to alloc buffer\n");
591 if ((ServiceNameLen > ExpandedLen) &&
596 (ServiceNameLen - ExpandedLen) *
sizeof(
WCHAR) + 13*
sizeof(
WCHAR));
598 if (*RelativeName ==
NULL)
600 DPRINT(
"Unable to alloc buffer\n");
606 wcscpy(*RelativeName,
L"\\SystemRoot\\");
641 const wchar_t *lpServiceName,
642 wchar_t **lpCanonName)
651 ServiceNameLen =
wcslen(lpServiceName);
654 if (ServiceNameLen > 12 &&
655 !
_wcsnicmp(
L"\\SystemRoot\\", lpServiceName, 12))
660 (ServiceNameLen + 1) *
sizeof(
WCHAR));
662 if (*lpCanonName ==
NULL)
664 DPRINT(
"Error allocating memory for canonized service name!\n");
675 DPRINT(
"Canonicalized name %S\n", *lpCanonName);
680 if (ServiceNameLen > 13 &&
681 !
_wcsnicmp(
L"%SystemRoot%\\", lpServiceName, 13))
686 (ServiceNameLen + 1) *
sizeof(
WCHAR));
688 if (*lpCanonName ==
NULL)
690 DPRINT(
"Error allocating memory for canonized service name!\n");
696 wcscpy(*lpCanonName,
L"\\SystemRoot\\");
698 wcscat(*lpCanonName, lpServiceName + 13);
700 DPRINT(
"Canonicalized name %S\n", *lpCanonName);
705 if (lpServiceName[0] !=
L'\\' && lpServiceName[1] !=
L':')
709 (ServiceNameLen + 1) *
sizeof(
WCHAR));
711 if (*lpCanonName ==
NULL)
713 DPRINT(
"Error allocating memory for canonized service name!\n");
718 wcscpy(*lpCanonName, lpServiceName);
726 DPRINT(
"RtlDosPathNameToNtPathName_U() failed!\n");
734 if (*lpCanonName ==
NULL)
736 DPRINT(
"Error allocating memory for canonized service name!\n");
749 DPRINT(
"Canonicalized name %S\n", *lpCanonName);
759 DPRINT(
"Error converting named!\n");
766 wcscpy(*lpCanonName, RelativeName + 12);
771 DPRINT(
"Canonicalized name %S\n", *lpCanonName);
783 DWORD dwServiceState,
791 WCHAR *lpszNameBuf = szNameBuf;
792 WCHAR *lpszValueBuf = szValueBuf;
797 HKEY hServiceEnumKey;
799 DWORD dwDependServiceStrPtr = 0;
800 DWORD dwRequiredSize = 0;
817 DPRINT(
"ERROR! Unable to get number of services keys.\n");
822 for (dwIteration = 0; dwIteration < dwNumSubKeys; dwIteration++)
860 dwDependServiceStrPtr = 0;
863 while (
wcslen(lpszValueBuf + dwDependServiceStrPtr) > 0)
871 if (!lpCurrentService)
874 DPRINT(
"This should not happen at this point, report to Developer\n");
883 if ((dwCurrentServiceState == dwServiceState) ||
892 dwRequiredSize += (2 *
sizeof(
PVOID));
910 lpServices[*lpServicesReturned] = lpCurrentService;
912 *lpServicesReturned = *lpServicesReturned + 1;
916 dwDependServiceStrPtr += (
DWORD)(
wcslen(lpszValueBuf + dwDependServiceStrPtr) + 1);
943 DWORD dwServicesReturned = 0;
945 DPRINT(
"RCloseServiceHandle() called\n");
947 DPRINT(
"hSCObject = %p\n", *hSCObject);
955 if (hManager !=
NULL)
957 DPRINT(
"Found manager handle\n");
967 DPRINT(
"RCloseServiceHandle() done\n");
970 else if (hService !=
NULL)
972 DPRINT(
"Found service handle\n");
990 DPRINT(
"CloseServiceHandle - lpService->dwRefCount %u\n",
1001 L"System\\CurrentControlSet\\Services",
1007 DPRINT(
"Failed to open services key\n");
1018 &dwServicesReturned);
1023 DPRINT(
"Deletion failed due to running dependencies.\n");
1040 DPRINT(
"Failed to Delete the Service Registry key\n");
1054 DPRINT(
"RCloseServiceHandle() done\n");
1077 DWORD dwServicesReturned = 0;
1078 DWORD dwControlsAccepted;
1079 DWORD dwCurrentState;
1082 WCHAR szLogBuffer[80];
1085 DPRINT(
"RControlService() called\n");
1094 DPRINT1(
"Invalid service handle!\n");
1100 if (lpService ==
NULL)
1102 DPRINT1(
"lpService == NULL!\n");
1128 if (dwControl >= 128 && dwControl <= 255)
1151 L"System\\CurrentControlSet\\Services",
1157 DPRINT(
"Failed to open services key\n");
1167 &dwServicesReturned);
1175 DPRINT(
"Service has running dependencies. Failed to stop service.\n");
1197 switch (dwCurrentState)
1286 lpLogStrings[1] = szLogBuffer;
1309 DPRINT(
"RDeleteService() called\n");
1317 DPRINT1(
"Invalid service handle!\n");
1326 if (lpService ==
NULL)
1328 DPRINT(
"lpService == NULL!\n");
1337 DPRINT(
"The service has already been marked for delete!\n");
1351 DPRINT(
"RDeleteService() done\n");
1366 DPRINT(
"RLockServiceDatabase() called\n");
1373 DPRINT1(
"Invalid service manager handle!\n");
1391 LPBYTE lpSecurityDescriptor,
1399 DWORD dwBytesNeeded;
1402 DPRINT(
"RQueryServiceObjectSecurity() called\n");
1407 DPRINT1(
"Invalid service handle!\n");
1427 if (lpService ==
NULL)
1429 DPRINT(
"lpService == NULL!\n");
1438 dwSecurityInformation,
1474 DWORD dwSecurityInformation,
1475 LPBYTE lpSecurityDescriptor,
1476 DWORD dwSecurityDescriptorSize)
1487 DPRINT(
"RSetServiceObjectSecurity() called\n");
1492 DPRINT1(
"Invalid service handle!\n");
1496 if (dwSecurityInformation == 0 ||
1535 if (lpService ==
NULL)
1537 DPRINT1(
"lpService == NULL!\n");
1571 bDatabaseLocked =
TRUE;
1587 if (hServiceKey !=
NULL)
1591 if (bDatabaseLocked ==
TRUE)
1597 DPRINT(
"RSetServiceObjectSecurity() done (Error %lu)\n", dwError);
1613 DPRINT(
"RQueryServiceStatus() called\n");
1621 DPRINT1(
"Invalid service handle!\n");
1633 if (lpService ==
NULL)
1635 DPRINT(
"lpService == NULL!\n");
1657 switch (dwCurrentState)
1682 DWORD dwPreviousState;
1683 DWORD dwPreviousType;
1685 WCHAR szLogBuffer[80];
1688 DPRINT(
"RSetServiceStatus() called\n");
1700 DPRINT(
"hServiceStatus == NULL!\n");
1709 DPRINT(
"Invalid service state!\n");
1717 DPRINT(
"Invalid service type!\n");
1724 DPRINT(
"Invalid controls accepted!\n");
1773 lpService->lpImage =
NULL;
1788 lpLogStrings[1] = szLogBuffer;
1818 lpLogStrings[1] = szLogBuffer;
1827 DPRINT(
"RSetServiceStatus() done\n");
1839 DPRINT(
"RUnlockServiceDatabase(%p)\n",
Lock);
1849 DWORD BootAcceptable)
1851 DPRINT(
"RNotifyBootConfigStatus(%p %lu)\n",
1852 lpMachineName, BootAcceptable);
1868 int bUpdateImmediately,
1873 DPRINT(
"RI_ScSetServiceBitsW(%p %lx %d %d %S)\n",
1875 bUpdateImmediately, lpString);
1880 if (lpString !=
NULL)
1885 DPRINT(
"hServiceStatus == NULL!\n");
1920 DWORD dwServiceType,
1922 DWORD dwErrorControl,
1928 LPWSTR lpServiceStartName,
1941 DPRINT(
"RChangeServiceConfigW() called\n");
1942 DPRINT(
"dwServiceType = 0x%lx\n", dwServiceType);
1943 DPRINT(
"dwStartType = %lu\n", dwStartType);
1944 DPRINT(
"dwErrorControl = %lu\n", dwErrorControl);
1945 DPRINT(
"lpBinaryPathName = %S\n", lpBinaryPathName);
1946 DPRINT(
"lpLoadOrderGroup = %S\n", lpLoadOrderGroup);
1947 DPRINT(
"lpServiceStartName = %S\n", lpServiceStartName);
1948 DPRINT(
"lpPassword = %p\n", lpPassword);
1949 DPRINT(
"dwPwSite = %lu\n", dwPwSize);
1958 DPRINT1(
"Invalid service handle!\n");
2009 if (lpdwTagId && (!lpLoadOrderGroup || !*lpLoadOrderGroup))
2015 if (lpService ==
NULL)
2017 DPRINT(
"lpService == NULL!\n");
2026 DPRINT(
"The service has already been marked for delete!\n");
2054 if (lpDisplayNameW ==
NULL)
2112 if (lpBinaryPathName !=
NULL && *lpBinaryPathName != 0)
2115 lpImagePathW = lpBinaryPathName;
2134 if (lpImagePathW != lpBinaryPathName)
2142 if (lpLoadOrderGroup !=
NULL && *lpLoadOrderGroup != 0)
2148 (
LPBYTE)lpLoadOrderGroup,
2160 if (lpdwTagId !=
NULL)
2175 *lpdwTagId = lpService->
dwTag;
2179 if (lpDependencies !=
NULL && *lpDependencies != 0)
2192 if (lpServiceStartName !=
NULL && *lpServiceStartName != 0)
2198 (
LPBYTE)lpServiceStartName,
2204 if (lpPassword !=
NULL)
2206 if (*(
LPWSTR)lpPassword != 0)
2211 &lpClearTextPassword);
2214 DPRINT1(
"ScmDecryptPassword failed (Error %lu)\n", dwError);
2217 DPRINT1(
"Clear text password: %S\n", lpClearTextPassword);
2221 lpClearTextPassword);
2224 DPRINT1(
"ScmSetServicePassword failed (Error %lu)\n", dwError);
2238 DPRINT1(
"ScmSetServicePassword failed (Error %lu)\n", dwError);
2246 if (lpClearTextPassword !=
NULL)
2250 (
wcslen(lpClearTextPassword) + 1) *
sizeof(
WCHAR));
2254 if (hServiceKey !=
NULL)
2260 DPRINT(
"RChangeServiceConfigW() done (Error %lu)\n", dwError);
2273 DWORD dwDesiredAccess,
2274 DWORD dwServiceType,
2276 DWORD dwErrorControl,
2290 SC_HANDLE hServiceHandle =
NULL;
2296 DPRINT(
"RCreateServiceW() called\n");
2297 DPRINT(
"lpServiceName = %S\n", lpServiceName);
2299 DPRINT(
"dwDesiredAccess = %lx\n", dwDesiredAccess);
2300 DPRINT(
"dwServiceType = 0x%lx\n", dwServiceType);
2301 DPRINT(
"dwStartType = %lu\n", dwStartType);
2302 DPRINT(
"dwErrorControl = %lu\n", dwErrorControl);
2303 DPRINT(
"lpBinaryPathName = %S\n", lpBinaryPathName);
2304 DPRINT(
"lpLoadOrderGroup = %S\n", lpLoadOrderGroup);
2305 DPRINT(
"lpdwTagId = %p\n", lpdwTagId);
2311 if (hManager ==
NULL)
2313 DPRINT1(
"Invalid service manager handle!\n");
2321 DPRINT(
"Insufficient access rights! 0x%lx\n",
2326 if (*lpServiceName == 0)
2329 if (*lpBinaryPathName == 0)
2372 (lpServiceStartName))
2375 if (
wcsicmp(lpServiceStartName,
L"LocalSystem"))
2381 if (lpdwTagId && (!lpLoadOrderGroup || !*lpLoadOrderGroup))
2460 if (lpLoadOrderGroup !=
NULL && *lpLoadOrderGroup != 0)
2469 if (lpdwTagId !=
NULL)
2540 (
LPBYTE)lpBinaryPathName,
2558 if (lpLoadOrderGroup !=
NULL && *lpLoadOrderGroup != 0)
2564 (
LPBYTE)lpLoadOrderGroup,
2571 if (lpdwTagId !=
NULL)
2584 if (lpDependencies !=
NULL && *lpDependencies != 0)
2597 lpObjectName = (lpServiceStartName !=
NULL) ? (
LPWSTR)lpServiceStartName :
L"LocalSystem";
2607 if (lpPassword !=
NULL && *(
LPWSTR)lpPassword != 0)
2612 &lpClearTextPassword);
2618 lpClearTextPassword);
2645 DPRINT(
"CreateService - lpService->dwRefCount %u\n", lpService->
dwRefCount);
2651 if (hServiceKey !=
NULL)
2654 if (lpClearTextPassword !=
NULL)
2658 (
wcslen(lpClearTextPassword) + 1) *
sizeof(
WCHAR));
2664 DPRINT(
"hService %p\n", hServiceHandle);
2667 if (lpdwTagId !=
NULL)
2668 *lpdwTagId = lpService->
dwTag;
2672 if (lpService !=
NULL &&
2685 if (lpService !=
NULL)
2691 if (lpImagePath !=
NULL)
2694 DPRINT(
"RCreateServiceW() done (Error %lu)\n", dwError);
2705 DWORD dwServiceState,
2712 DWORD dwServicesReturned = 0;
2713 DWORD dwServiceCount;
2722 *lpServicesReturned = 0;
2724 DPRINT(
"REnumDependentServicesW() called\n");
2729 DPRINT1(
"Invalid service handle!\n");
2739 DPRINT(
"Insufficient access rights! 0x%lx\n",
2746 L"System\\CurrentControlSet\\Services",
2759 &dwServicesReturned);
2773 (dwServicesReturned + 1) *
sizeof(
PSERVICE));
2774 if (!lpServicesArray)
2776 DPRINT1(
"Could not allocate a buffer!!\n");
2781 dwServicesReturned = 0;
2789 &dwServicesReturned);
2799 for (dwServiceCount = 0; dwServiceCount < dwServicesReturned; dwServiceCount++)
2801 lpService = lpServicesArray[dwServiceCount];
2821 *lpServicesReturned = dwServicesReturned;
2824 if (lpServicesArray !=
NULL)
2829 DPRINT(
"REnumDependentServicesW() done (Error %lu)\n", dwError);
2840 DWORD dwServiceType,
2841 DWORD dwServiceState,
2867 DWORD dwDesiredAccess,
2873 DPRINT(
"ROpenSCManagerW() called\n");
2874 DPRINT(
"lpMachineName = %p\n", lpMachineName);
2875 DPRINT(
"lpMachineName: %S\n", lpMachineName);
2876 DPRINT(
"lpDataBaseName = %p\n", lpDatabaseName);
2877 DPRINT(
"lpDataBaseName: %S\n", lpDatabaseName);
2878 DPRINT(
"dwDesiredAccess = %x\n", dwDesiredAccess);
2890 DPRINT(
"ScmCreateManagerHandle() failed (Error %lu)\n", dwError);
2899 DPRINT(
"ScmCheckAccess() failed (Error %lu)\n", dwError);
2905 DPRINT(
"*hScm = %p\n", *lpScHandle);
2907 DPRINT(
"ROpenSCManagerW() done\n");
2919 DWORD dwDesiredAccess,
2927 DPRINT(
"ROpenServiceW() called\n");
2929 DPRINT(
"lpServiceName = %p\n", lpServiceName);
2930 DPRINT(
"lpServiceName: %S\n", lpServiceName);
2931 DPRINT(
"dwDesiredAccess = %x\n", dwDesiredAccess);
2937 if (hManager ==
NULL)
2939 DPRINT1(
"Invalid service manager handle!\n");
2943 if (!lpServiceHandle)
2954 if (lpService ==
NULL)
2956 DPRINT(
"Could not find the service!\n");
2966 DPRINT(
"ScmCreateServiceHandle() failed (Error %lu)\n", dwError);
2975 DPRINT(
"ScmCheckAccess() failed (Error %lu)\n", dwError);
2984 DPRINT(
"*hService = %p\n", *lpServiceHandle);
2990 DPRINT(
"ROpenServiceW() done\n");
3013 DWORD dwDependenciesLength = 0;
3014 DWORD dwRequiredSize;
3017 DPRINT(
"RQueryServiceConfigW() called\n");
3025 DPRINT1(
"Invalid service handle!\n");
3037 if (lpService ==
NULL)
3039 DPRINT(
"lpService == NULL!\n");
3062 &lpServiceStartName);
3067 &dwDependenciesLength);
3071 if (lpImagePath !=
NULL)
3074 dwRequiredSize += 2 *
sizeof(
WCHAR);
3079 dwRequiredSize += 2 *
sizeof(
WCHAR);
3081 if (lpDependencies !=
NULL)
3082 dwRequiredSize += dwDependenciesLength *
sizeof(
WCHAR);
3084 dwRequiredSize += 2 *
sizeof(
WCHAR);
3086 if (lpServiceStartName !=
NULL)
3087 dwRequiredSize += (
DWORD)((
wcslen(lpServiceStartName) + 1) *
sizeof(
WCHAR));
3089 dwRequiredSize += 2 *
sizeof(
WCHAR);
3094 dwRequiredSize += 2 *
sizeof(
WCHAR);
3107 lpStr = (
LPWSTR)(lpServiceConfig + 1);
3110 if (lpImagePath !=
NULL)
3112 wcscpy(lpStr, lpImagePath);
3120 lpStr += (
wcslen(lpStr) + 1);
3133 lpStr += (
wcslen(lpStr) + 1);
3136 if (lpDependencies !=
NULL)
3140 dwDependenciesLength *
sizeof(
WCHAR));
3148 if (lpDependencies !=
NULL)
3149 lpStr += dwDependenciesLength;
3151 lpStr += (
wcslen(lpStr) + 1);
3154 if (lpServiceStartName !=
NULL)
3156 wcscpy(lpStr, lpServiceStartName);
3164 lpStr += (
wcslen(lpStr) + 1);
3186 if (lpImagePath !=
NULL)
3189 if (lpServiceStartName !=
NULL)
3192 if (lpDependencies !=
NULL)
3195 if (hServiceKey !=
NULL)
3198 DPRINT(
"RQueryServiceConfigW() done\n");
3215 DWORD dwRequiredSize;
3223 DPRINT1(
"Invalid service manager handle!\n");
3262 DPRINT(
"RStartServiceW(%p %lu %p) called\n", hService,
argc,
argv);
3279 DPRINT1(
"Invalid service handle!\n");
3291 if (lpService ==
NULL)
3293 DPRINT(
"lpService == NULL!\n");
3325 DPRINT(
"RGetServiceDisplayNameW() called\n");
3327 DPRINT(
"lpServiceName: %S\n", lpServiceName);
3329 DPRINT(
"*lpcchBuffer: %lu\n", *lpcchBuffer);
3335 DPRINT(
"Invalid manager handle!\n");
3342 if (lpService ==
NULL)
3344 DPRINT(
"Could not find the service!\n");
3387 DPRINT(
"RGetServiceKeyNameW() called\n");
3390 DPRINT(
"lpServiceName: %p\n", lpServiceName);
3391 DPRINT(
"*lpcchBuffer: %lu\n", *lpcchBuffer);
3397 DPRINT(
"Invalid manager handle!\n");
3404 if (lpService ==
NULL)
3406 DPRINT(
"Could not find the service!\n");
3414 if (lpServiceName !=
NULL)
3437 int bUpdateImmediately,
3443 if (lpString !=
NULL)
3459 DWORD dwServiceType,
3461 DWORD dwErrorControl,
3462 LPSTR lpBinaryPathName,
3463 LPSTR lpLoadOrderGroup,
3467 LPSTR lpServiceStartName,
3478 DWORD dwDependenciesLength = 0;
3483 if (lpBinaryPathName)
3487 if (!lpBinaryPathNameW)
3495 if (lpLoadOrderGroup)
3499 if (!lpLoadOrderGroupW)
3509 lpStr = (
LPCSTR)lpDependencies;
3512 cchLength =
strlen(lpStr) + 1;
3513 dwDependenciesLength += (
DWORD)cchLength;
3514 lpStr = lpStr + cchLength;
3516 dwDependenciesLength++;
3519 if (!lpDependenciesW)
3527 if (lpServiceStartName)
3531 if (!lpServiceStartNameW)
3543 if (!lpDisplayNameW)
3559 dwDependenciesLength,
3560 lpServiceStartNameW,
3566 if (lpBinaryPathNameW !=
NULL)
3569 if (lpLoadOrderGroupW !=
NULL)
3572 if (lpDependenciesW !=
NULL)
3575 if (lpServiceStartNameW !=
NULL)
3578 if (lpDisplayNameW !=
NULL)
3590 LPSTR lpServiceName,
3592 DWORD dwDesiredAccess,
3593 DWORD dwServiceType,
3595 DWORD dwErrorControl,
3596 LPSTR lpBinaryPathName,
3597 LPSTR lpLoadOrderGroup,
3601 LPSTR lpServiceStartName,
3613 DWORD dwDependenciesLength = 0;
3622 if (!lpServiceNameW)
3634 if (!lpDisplayNameW)
3642 if (lpBinaryPathName)
3646 if (!lpBinaryPathNameW)
3654 if (lpLoadOrderGroup)
3658 if (!lpLoadOrderGroupW)
3668 lpStr = (
LPCSTR)lpDependencies;
3671 cchLength =
strlen(lpStr) + 1;
3672 dwDependenciesLength += (
DWORD)cchLength;
3673 lpStr = lpStr + cchLength;
3675 dwDependenciesLength++;
3678 if (!lpDependenciesW)
3686 if (lpServiceStartName)
3690 if (!lpServiceStartNameW)
3709 dwDependenciesLength,
3710 lpServiceStartNameW,
3716 if (lpServiceNameW !=
NULL)
3719 if (lpDisplayNameW !=
NULL)
3722 if (lpBinaryPathNameW !=
NULL)
3725 if (lpLoadOrderGroupW !=
NULL)
3728 if (lpDependenciesW !=
NULL)
3731 if (lpServiceStartNameW !=
NULL)
3743 DWORD dwServiceState,
3750 DWORD dwServicesReturned = 0;
3751 DWORD dwServiceCount;
3760 *lpServicesReturned = 0;
3762 DPRINT(
"REnumDependentServicesA() called\n");
3767 DPRINT1(
"Invalid service handle!\n");
3777 DPRINT(
"Insufficient access rights! 0x%lx\n",
3784 L"System\\CurrentControlSet\\Services",
3802 &dwServicesReturned);
3816 (dwServicesReturned + 1) *
sizeof(
PSERVICE));
3817 if (!lpServicesArray)
3819 DPRINT(
"Could not allocate a buffer!!\n");
3824 dwServicesReturned = 0;
3832 &dwServicesReturned);
3842 for (dwServiceCount = 0; dwServiceCount < dwServicesReturned; dwServiceCount++)
3844 lpService = lpServicesArray[dwServiceCount];
3861 lpStr +=
strlen(lpStr) + 1;
3873 lpStr +=
strlen(lpStr) + 1;
3878 *lpServicesReturned = dwServicesReturned;
3881 if (lpServicesArray)
3886 DPRINT(
"REnumDependentServicesA() done (Error %lu)\n", dwError);
3897 DWORD dwServiceType,
3898 DWORD dwServiceState,
3911 DWORD dwServiceCount;
3913 DPRINT(
"REnumServicesStatusA() called\n");
3925 DPRINT(
"Failed to allocate buffer!\n");
3940 if (*lpServicesReturned == 0)
3943 lpStatusPtrIncrW = lpStatusPtrW;
3950 for (dwServiceCount = 0; dwServiceCount < *lpServicesReturned; dwServiceCount++)
3958 (
int)
wcslen(lpStringPtrW),
3963 lpStringPtrA +=
wcslen(lpStringPtrW) + 1;
3964 lpStringPtrW +=
wcslen(lpStringPtrW) + 1;
3972 (
int)
wcslen(lpStringPtrW),
3977 lpStringPtrA +=
wcslen(lpStringPtrW) + 1;
3978 lpStringPtrW +=
wcslen(lpStringPtrW) + 1;
3993 DPRINT(
"REnumServicesStatusA() done (Error %lu)\n", dwError);
4003 LPSTR lpMachineName,
4004 LPSTR lpDatabaseName,
4005 DWORD dwDesiredAccess,
4012 DPRINT(
"ROpenSCManagerA() called\n");
4042 LPSTR lpServiceName,
4043 DWORD dwDesiredAccess,
4049 DPRINT(
"ROpenServiceA() called\n");
4084 DWORD dwDependenciesLength = 0;
4085 DWORD dwRequiredSize;
4088 DPRINT(
"RQueryServiceConfigA() called\n");
4096 DPRINT1(
"Invalid service handle!\n");
4108 if (lpService ==
NULL)
4110 DPRINT(
"lpService == NULL!\n");
4133 &lpServiceStartName);
4138 &dwDependenciesLength);
4142 if (lpImagePath !=
NULL)
4143 dwRequiredSize += (
DWORD)(
wcslen(lpImagePath) + 1);
4145 dwRequiredSize += 2 *
sizeof(
CHAR);
4150 dwRequiredSize += 2 *
sizeof(
CHAR);
4153 if (lpDependencies !=
NULL)
4154 dwRequiredSize += dwDependenciesLength;
4156 dwRequiredSize += 2 *
sizeof(
CHAR);
4158 if (lpServiceStartName !=
NULL)
4159 dwRequiredSize += (
DWORD)(
wcslen(lpServiceStartName) + 1);
4161 dwRequiredSize += 2 *
sizeof(
CHAR);
4166 dwRequiredSize += 2 *
sizeof(
CHAR);
4179 lpStr = (
LPSTR)(lpServiceConfig + 1);
4191 (
int)(
wcslen(lpImagePath) + 1),
4220 lpStr += (
strlen(lpStr) + 1);
4228 dwDependenciesLength,
4230 dwDependenciesLength,
4241 lpStr += dwDependenciesLength;
4243 lpStr += (
strlen(lpStr) + 1);
4245 if (lpServiceStartName)
4252 (
int)(
wcslen(lpServiceStartName) + 1),
4262 lpStr += (
strlen(lpStr) + 1);
4290 if (lpImagePath !=
NULL)
4293 if (lpServiceStartName !=
NULL)
4296 if (lpDependencies !=
NULL)
4299 if (hServiceKey !=
NULL)
4302 DPRINT(
"RQueryServiceConfigA() done\n");
4319 DWORD dwRequiredSize;
4327 DPRINT1(
"Invalid service manager handle!\n");
4366 DPRINT(
"RStartServiceA() called\n");
4374 DPRINT1(
"Invalid service handle!\n");
4386 if (lpService ==
NULL)
4388 DPRINT(
"lpService == NULL!\n");
4404 if (lpVector ==
NULL)
4419 if (lpVector[
i] ==
NULL)
4439 if (lpVector !=
NULL)
4443 if (lpVector[
i] !=
NULL)
4468 DPRINT(
"RGetServiceDisplayNameA() called\n");
4470 DPRINT(
"lpServiceName: %s\n", lpServiceName);
4472 DPRINT(
"*lpcchBuffer: %lu\n", *lpcchBuffer);
4478 DPRINT(
"Invalid manager handle!\n");
4484 if (lpServiceName !=
NULL)
4490 if (!lpServiceNameW)
4505 if (lpService ==
NULL)
4507 DPRINT(
"Could not find the service!\n");
4581 LPSTR lpServiceName,
4589 DPRINT(
"RGetServiceKeyNameA() called\n");
4592 DPRINT(
"lpServiceName: %p\n", lpServiceName);
4593 DPRINT(
"*lpcchBuffer: %lu\n", *lpcchBuffer);
4599 DPRINT(
"Invalid manager handle!\n");
4610 if (!lpDisplayNameW)
4624 if (lpService ==
NULL)
4626 DPRINT(
"Could not find the service!\n");
4639 if (lpServiceName !=
NULL &&
4701 DPRINT(
"RI_ScGetCurrentGroupStateW() called\n");
4707 if (hManager ==
NULL)
4709 DPRINT1(
"Invalid service manager handle!\n");
4717 DPRINT(
"Insufficient access rights! 0x%lx\n",
4727 if (pServiceGroup ==
NULL)
4740 DPRINT(
"RI_ScGetCurrentGroupStateW() done (Error %lu)\n", dwError);
4751 DWORD dwServiceType,
4752 DWORD dwServiceState,
4766 DWORD dwRequiredSize;
4767 DWORD dwServiceCount;
4769 DWORD dwLastResumeCount = 0;
4773 DPRINT(
"REnumServiceGroupW() called\n");
4779 if (hManager ==
NULL)
4781 DPRINT1(
"Invalid service manager handle!\n");
4791 *lpServicesReturned = 0;
4793 if ((dwServiceType == 0) ||
4796 DPRINT(
"Not a valid Service Type!\n");
4800 if ((dwServiceState == 0) ||
4803 DPRINT(
"Not a valid Service State!\n");
4811 DPRINT(
"Insufficient access rights! 0x%lx\n",
4817 dwLastResumeCount = *lpResumeIndex;
4823 if (lpService ==
NULL)
4834 ServiceEntry = ServiceEntry->
Flink)
4847 if ((dwState & dwServiceState) == 0)
4852 if (*pszGroupName == 0)
4876 dwRequiredSize +=
dwSize;
4881 DPRINT(
"dwRequiredSize: %lu\n", dwRequiredSize);
4882 DPRINT(
"dwServiceCount: %lu\n", dwServiceCount);
4886 ServiceEntry = ServiceEntry->
Flink)
4899 if ((dwState & dwServiceState) == 0)
4904 if (*pszGroupName == 0)
4924 DPRINT(
"*pcbBytesNeeded: %lu\n", dwRequiredSize);
4927 *lpResumeIndex = dwLastResumeCount;
4929 *lpServicesReturned = dwServiceCount;
4939 ServiceEntry = ServiceEntry->
Flink)
4952 if ((dwState & dwServiceState) == 0)
4957 if (*pszGroupName == 0)
4993 dwRequiredSize +=
dwSize;
4999 if (lpResumeIndex) *lpResumeIndex = 0;
5006 DPRINT(
"REnumServiceGroupW() done (Error %lu)\n", dwError);
5023 DPRINT(
"RChangeServiceConfig2A() called\n");
5024 DPRINT(
"dwInfoLevel = %lu\n",
Info.dwInfoLevel);
5039 lpServiceDescriptionA =
Info.psd;
5041 if (lpServiceDescriptionA &&
5049 if (!lpServiceDescriptionW)
5063 ptr = lpServiceDescriptionW;
5064 InfoW.
psd = lpServiceDescriptionW;
5071 DWORD dwRebootLen = 0;
5072 DWORD dwCommandLen = 0;
5073 DWORD dwActionArrayLen = 0;
5076 lpServiceFailureActionsA =
Info.psfa;
5078 if (lpServiceFailureActionsA)
5091 if (lpServiceFailureActionsA->
lpCommand)
5108 dwActionArrayLen + dwRebootLen + dwCommandLen;
5114 if (!lpServiceFailureActionsW)
5124 if (dwActionArrayLen > 0)
5140 lpStr = (
LPWSTR)((
ULONG_PTR)(lpServiceFailureActionsW + 1) + dwActionArrayLen);
5161 lpStr += dwRebootLen /
sizeof(
WCHAR);
5167 lpServiceFailureActionsW->
lpCommand = lpStr;
5178 ptr = lpServiceFailureActionsW;
5179 InfoW.
psfa = lpServiceFailureActionsW;
5197 DWORD dwRequiredSize = 0;
5202 if (lpFailureActions ==
NULL)
5230 if (lpReadBuffer ==
NULL)