mirror of
https://github.com/reactos/reactos.git
synced 2025-05-25 12:14:32 +00:00
[SERVICES] Implement ScmGenerateServiceTag and call it on service creation
This allows assigning an unique ServiceTag to each Win32 service
This commit is contained in:
parent
519a2c9f6f
commit
1a9b9800b1
3 changed files with 32 additions and 0 deletions
|
@ -31,6 +31,7 @@ LIST_ENTRY ServiceListHead;
|
||||||
static RTL_RESOURCE DatabaseLock;
|
static RTL_RESOURCE DatabaseLock;
|
||||||
static DWORD ResumeCount = 1;
|
static DWORD ResumeCount = 1;
|
||||||
static DWORD NoInteractiveServices = 0;
|
static DWORD NoInteractiveServices = 0;
|
||||||
|
static DWORD ServiceTag = 0;
|
||||||
|
|
||||||
/* The critical section synchronizes service control requests */
|
/* The critical section synchronizes service control requests */
|
||||||
static CRITICAL_SECTION ControlServiceCriticalSection;
|
static CRITICAL_SECTION ControlServiceCriticalSection;
|
||||||
|
@ -634,6 +635,29 @@ ScmGetServiceEntryByResumeCount(DWORD dwResumeCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
ScmGenerateServiceTag(PSERVICE lpServiceRecord)
|
||||||
|
{
|
||||||
|
/* Check for an overflow */
|
||||||
|
if (ServiceTag == -1)
|
||||||
|
{
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is only valid for Win32 services */
|
||||||
|
if (!(lpServiceRecord->Status.dwServiceType & SERVICE_WIN32))
|
||||||
|
{
|
||||||
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Increment the tag counter and set it */
|
||||||
|
ServiceTag = ServiceTag % 0xFFFFFFFF + 1;
|
||||||
|
lpServiceRecord->dwTag = ServiceTag;
|
||||||
|
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
|
ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
|
||||||
PSERVICE *lpServiceRecord,
|
PSERVICE *lpServiceRecord,
|
||||||
|
@ -847,6 +871,8 @@ CreateServiceListEntry(LPCWSTR lpServiceName,
|
||||||
|
|
||||||
if (ScmIsDeleteFlagSet(hServiceKey))
|
if (ScmIsDeleteFlagSet(hServiceKey))
|
||||||
lpService->bDeleted = TRUE;
|
lpService->bDeleted = TRUE;
|
||||||
|
else
|
||||||
|
ScmGenerateServiceTag(lpService);
|
||||||
|
|
||||||
if (lpService->Status.dwServiceType & SERVICE_WIN32)
|
if (lpService->Status.dwServiceType & SERVICE_WIN32)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2636,6 +2636,10 @@ RCreateServiceW(
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
lpService->dwRefCount = 1;
|
lpService->dwRefCount = 1;
|
||||||
|
|
||||||
|
/* Get the service tag (if Win32) */
|
||||||
|
ScmGenerateServiceTag(lpService);
|
||||||
|
|
||||||
DPRINT("CreateService - lpService->dwRefCount %u\n", lpService->dwRefCount);
|
DPRINT("CreateService - lpService->dwRefCount %u\n", lpService->dwRefCount);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -200,6 +200,8 @@ VOID ScmDeleteNamedPipeCriticalSection(VOID);
|
||||||
DWORD ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams,
|
DWORD ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams,
|
||||||
PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams);
|
PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams);
|
||||||
|
|
||||||
|
DWORD ScmGenerateServiceTag(PSERVICE lpServiceRecord);
|
||||||
|
|
||||||
/* driver.c */
|
/* driver.c */
|
||||||
|
|
||||||
DWORD ScmStartDriver(PSERVICE lpService);
|
DWORD ScmStartDriver(PSERVICE lpService);
|
||||||
|
|
Loading…
Reference in a new issue