ReactOS 0.4.15-dev-7834-g00c4b3d
lock.c File Reference
#include "services.h"
#include <time.h>
#include <debug.h>
Include dependency graph for lock.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

DWORD ScmAcquireServiceStartLock (IN BOOL IsServiceController, OUT LPSC_RPC_LOCK lpLock)
 
DWORD ScmReleaseServiceStartLock (IN OUT LPSC_RPC_LOCK lpLock)
 
VOID ScmQueryServiceLockStatusW (OUT LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus)
 
VOID ScmQueryServiceLockStatusA (OUT LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus)
 

Variables

static PSTART_LOCK pServiceStartLock = NULL
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file lock.c.

Function Documentation

◆ ScmAcquireServiceStartLock()

DWORD ScmAcquireServiceStartLock ( IN BOOL  IsServiceController,
OUT LPSC_RPC_LOCK  lpLock 
)

Definition at line 31 of file lock.c.

33{
34 DWORD dwRequiredSize;
35 DWORD dwError = ERROR_SUCCESS;
36
37 *lpLock = NULL;
38
39 /* Lock the service database exclusively */
41
43 {
45 goto done;
46 }
47
48 /* Allocate a new lock for the database */
49 dwRequiredSize = sizeof(START_LOCK);
50
51 if (!IsServiceController)
52 {
53 /* FIXME: dwRequiredSize += RtlLengthSid(UserSid <-- to be retrieved); */
54 }
55
58 dwRequiredSize);
60 {
62 goto done;
63 }
64
67
68 /* FIXME: Retrieve the owner SID. Use IsServiceController. */
70
72
73done:
74 /* Unlock the service database */
76
77 return dwError;
78}
VOID ScmUnlockDatabase(VOID)
Definition: database.c:2434
BOOL ScmLockDatabaseExclusive(VOID)
Definition: database.c:2420
static PSTART_LOCK pServiceStartLock
Definition: lock.c:21
#define LOCK_TAG
Definition: services.h:88
struct _START_LOCK START_LOCK
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned long DWORD
Definition: ntddk_ex.h:95
__u16 time
Definition: mkdosfs.c:8
struct _SID * PSID
Definition: eventlog.c:35
#define DWORD
Definition: nt_native.h:44
DWORD TimeWhenLocked
Definition: services.h:93
DWORD Tag
Definition: services.h:92
PSID LockOwnerSid
Definition: services.h:94
SC_RPC_LOCK * LPSC_RPC_LOCK
Definition: svcctl.idl:24
#define ERROR_SERVICE_DATABASE_LOCKED
Definition: winerror.h:606

Referenced by RLockServiceDatabase(), ScmStartService(), and wWinMain().

◆ ScmQueryServiceLockStatusA()

VOID ScmQueryServiceLockStatusA ( OUT LPQUERY_SERVICE_LOCK_STATUSA  lpLockStatus)

Definition at line 159 of file lock.c.

160{
161 /* Lock the service database shared */
163
164 if (pServiceStartLock != NULL)
165 {
166 lpLockStatus->fIsLocked = TRUE;
167
168 /* FIXME: Retrieve the owner name. */
169 lpLockStatus->lpLockOwner = NULL;
170
171 lpLockStatus->dwLockDuration = (DWORD)time(NULL) - pServiceStartLock->TimeWhenLocked;
172 }
173 else
174 {
175 lpLockStatus->fIsLocked = FALSE;
176
177 strcpy((LPSTR)(lpLockStatus + 1), "");
178 lpLockStatus->lpLockOwner = (LPSTR)(ULONG_PTR)sizeof(QUERY_SERVICE_LOCK_STATUSA);
179
180 lpLockStatus->dwLockDuration = 0;
181 }
182
183 /* Unlock the service database */
185
186 return;
187}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
BOOL ScmLockDatabaseShared(VOID)
Definition: database.c:2427
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct _QUERY_SERVICE_LOCK_STATUSA QUERY_SERVICE_LOCK_STATUSA
char * LPSTR
Definition: xmlstorage.h:182

Referenced by RQueryServiceLockStatusA().

◆ ScmQueryServiceLockStatusW()

VOID ScmQueryServiceLockStatusW ( OUT LPQUERY_SERVICE_LOCK_STATUSW  lpLockStatus)

Definition at line 127 of file lock.c.

128{
129 /* Lock the service database shared */
131
132 if (pServiceStartLock != NULL)
133 {
134 lpLockStatus->fIsLocked = TRUE;
135
136 /* FIXME: Retrieve the owner name. */
137 lpLockStatus->lpLockOwner = NULL;
138
139 lpLockStatus->dwLockDuration = (DWORD)time(NULL) - pServiceStartLock->TimeWhenLocked;
140 }
141 else
142 {
143 lpLockStatus->fIsLocked = FALSE;
144
145 wcscpy((LPWSTR)(lpLockStatus + 1), L"");
146 lpLockStatus->lpLockOwner = (LPWSTR)(ULONG_PTR)sizeof(QUERY_SERVICE_LOCK_STATUSW);
147
148 lpLockStatus->dwLockDuration = 0;
149 }
150
151 /* Unlock the service database */
153
154 return;
155}
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
struct _QUERY_SERVICE_LOCK_STATUSW QUERY_SERVICE_LOCK_STATUSW
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by RQueryServiceLockStatusW().

◆ ScmReleaseServiceStartLock()

DWORD ScmReleaseServiceStartLock ( IN OUT LPSC_RPC_LOCK  lpLock)

Definition at line 82 of file lock.c.

83{
84 PSTART_LOCK pStartLock;
85 DWORD dwError = ERROR_SUCCESS;
86
87 if (lpLock == NULL)
89
90 pStartLock = (PSTART_LOCK)*lpLock;
91
92 if (pStartLock->Tag != LOCK_TAG)
94
95 /* Lock the service database exclusively */
97
98 /* Release the lock handle */
99 if ((pStartLock == pServiceStartLock) &&
101 {
104 *lpLock = NULL;
105
106 dwError = ERROR_SUCCESS;
107 }
108 else
109 {
111 }
112
113 /* Unlock the service database */
115
116 return dwError;
117}
struct _START_LOCK * PSTART_LOCK
#define HeapFree(x, y, z)
Definition: compat.h:735
#define ERROR_INVALID_SERVICE_LOCK
Definition: winerror.h:622

Referenced by RUnlockServiceDatabase(), ScmStartService(), and wWinMain().

Variable Documentation

◆ pServiceStartLock