Go to the source code of this file.
|
| LPSERVICE_STATUS_PROCESS | QueryService (LPCTSTR ServiceName) |
| |
| static DWORD | EnumServices (ENUM_SERVICE_STATUS_PROCESS **pServiceStatus, DWORD dwServiceType, DWORD dwServiceState, DWORD dwBufferSize, DWORD dwResumeIndex, LPCTSTR pszGroupName) |
| |
| static BOOL | ParseQueryArguments (IN LPCTSTR *ServiceArgs, IN INT ArgCount, OUT PDWORD pdwServiceType, OUT PDWORD pdwServiceState, OUT PDWORD pdwBufferSize, OUT PDWORD pdwResumeIndex, OUT LPCTSTR *ppszGroupName, OUT LPCTSTR *ppszServiceName) |
| |
| BOOL | Query (LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended) |
| |
◆ EnumServices()
Definition at line 75 of file query.c.
81{
83 DWORD BytesNeeded = 0;
84 DWORD ResumeHandle = dwResumeIndex;
85 DWORD NumServices = 0;
87
92 {
94 return 0;
95 }
96
97 if (dwBufferSize == 0)
98 {
101 dwServiceType,
102 dwServiceState,
104 dwBufferSize,
105 &BytesNeeded,
106 &NumServices,
107 &ResumeHandle,
108 pszGroupName);
110 {
112 return 0;
113 }
114
115 dwBufferSize = BytesNeeded;
116 }
117
120 0,
121 dwBufferSize);
122 if (*pServiceStatus !=
NULL)
123 {
126 dwServiceType,
127 dwServiceState,
129 dwBufferSize,
130 &BytesNeeded,
131 &NumServices,
132 &ResumeHandle,
133 pszGroupName))
134 {
136 return NumServices;
137 }
138 }
139
141 if (*pServiceStatus)
143
145
146 return NumServices;
147}
#define HeapFree(x, y, z)
DWORD ReportLastError(void)
#define SC_MANAGER_ENUMERATE_SERVICE
#define EnumServicesStatusEx
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
DWORD WINAPI GetLastError(void)
Referenced by Query().
◆ ParseQueryArguments()
Definition at line 152 of file query.c.
161{
162 INT TmpCount, TmpIndex;
164
165 TmpCount = ArgCount;
166 TmpIndex = 0;
167 while (TmpCount > 0)
168 {
169 if (!
lstrcmpi(ServiceArgs[TmpIndex],
_T(
"type=")))
170 {
171 TmpIndex++;
172 TmpCount--;
173
174 if (TmpCount > 0)
175 {
176 if (!
lstrcmpi(ServiceArgs[TmpIndex],
_T(
"service")))
177 {
179 }
180 else if (!
lstrcmpi(ServiceArgs[TmpIndex],
_T(
"driver")))
181 {
183 }
184 else if (!
lstrcmpi(ServiceArgs[TmpIndex],
_T(
"all")))
185 {
187 }
188 else if (!
lstrcmpi(ServiceArgs[TmpIndex],
_T(
"interact")))
189 {
191 }
192 else
193 {
194 _tprintf(
_T(
"ERROR following \"type=\"!\nMust be one of: all, driver, interact, service.\n"));
196 }
197
198 TmpIndex++;
199 TmpCount--;
200 }
201 }
202 else if (!
lstrcmpi(ServiceArgs[TmpIndex],
_T(
"state=")))
203 {
204 TmpIndex++;
205 TmpCount--;
206
207 if (TmpCount > 0)
208 {
209 if (!
lstrcmpi(ServiceArgs[TmpIndex],
_T(
"active")))
210 {
212 }
213 else if (!
lstrcmpi(ServiceArgs[TmpIndex],
_T(
"inactive")))
214 {
216 }
217 else if (!
lstrcmpi(ServiceArgs[TmpIndex],
_T(
"all")))
218 {
220 }
221 else
222 {
223 _tprintf(
_T(
"ERROR following \"state=\"!\nMust be one of: active, all, inactive.\n"));
225 }
226
227 TmpIndex++;
228 TmpCount--;
229 }
230 }
231 else if (!
lstrcmpi(ServiceArgs[TmpIndex],
_T(
"bufsize=")))
232 {
233 TmpIndex++;
234 TmpCount--;
235
236 if (TmpCount > 0)
237 {
239 if (dwValue > 0)
240 {
241 *pdwBufferSize = dwValue;
242 }
243
244 TmpIndex++;
245 TmpCount--;
246 }
247 }
248 else if (!
lstrcmpi(ServiceArgs[TmpIndex],
_T(
"ri=")))
249 {
250 TmpIndex++;
251 TmpCount--;
252
253 if (TmpCount >= 0)
254 {
256 if (dwValue > 0)
257 {
258 *pdwResumeIndex = dwValue;
259 }
260
261 TmpIndex++;
262 TmpCount--;
263 }
264 }
265 else if (!
lstrcmpi(ServiceArgs[TmpIndex],
_T(
"group=")))
266 {
267 TmpIndex++;
268 TmpCount--;
269
270 if (TmpCount > 0)
271 {
272 *ppszGroupName = ServiceArgs[TmpIndex];
273
274 TmpIndex++;
275 TmpCount--;
276 }
277 }
278 else
279 {
280 *ppszServiceName = ServiceArgs[TmpIndex];
281
282 TmpIndex++;
283 TmpCount--;
284 }
285 }
286
288}
#define SERVICE_STATE_ALL
#define SERVICE_INTERACTIVE_PROCESS
Referenced by Query().
◆ Query()
Definition at line 292 of file query.c.
295{
297 DWORD NumServices = 0;
300 DWORD dwBufferSize = 0;
301 DWORD dwResumeIndex = 0;
305
306#ifdef SCDBG
307 LPCTSTR *TmpArgs = ServiceArgs;
308 INT TmpCnt = ArgCount;
309
311 while (TmpCnt)
312 {
314 TmpArgs++;
315 TmpCnt--;
316 }
318#endif
319
320
322 ArgCount,
323 &dwServiceType,
324 &dwServiceState,
325 &dwBufferSize,
326 &dwResumeIndex,
327 &pszGroupName,
328 &pszServiceName))
330
331#ifdef SCDBG
332 _tprintf(
_T(
"Service type: %lx\n"), dwServiceType);
333 _tprintf(
_T(
"Service state: %lx\n"), dwServiceState);
334 _tprintf(
_T(
"Buffer size: %lu\n"), dwBufferSize);
335 _tprintf(
_T(
"Resume index: %lu\n"), dwResumeIndex);
336 _tprintf(
_T(
"Group name: %s\n"), pszGroupName);
337 _tprintf(
_T(
"Service name: %s\n"), pszServiceName);
338#endif
339
340 if (pszServiceName)
341 {
342
343
345
348 {
352 bExtended);
353
355 }
356 }
357 else
358 {
359
360
362 dwServiceType,
363 dwServiceState,
364 dwBufferSize,
365 dwResumeIndex,
366 pszGroupName);
367 if (NumServices == 0)
369
370 for (
i = 0;
i < NumServices;
i++)
371 {
374 &pServiceStatus[
i].ServiceStatusProcess,
375 bExtended);
376 }
377
378#ifdef SCDBG
380#endif
381
382 if (pServiceStatus)
384 }
385
387}
VOID PrintService(LPCTSTR lpServiceName, LPCTSTR lpDisplayName, LPSERVICE_STATUS_PROCESS pStatus, BOOL bExtended)
LPSERVICE_STATUS_PROCESS QueryService(LPCTSTR ServiceName)
static BOOL ParseQueryArguments(IN LPCTSTR *ServiceArgs, IN INT ArgCount, OUT PDWORD pdwServiceType, OUT PDWORD pdwServiceState, OUT PDWORD pdwBufferSize, OUT PDWORD pdwResumeIndex, OUT LPCTSTR *ppszGroupName, OUT LPCTSTR *ppszServiceName)
static DWORD EnumServices(ENUM_SERVICE_STATUS_PROCESS **pServiceStatus, DWORD dwServiceType, DWORD dwServiceState, DWORD dwBufferSize, DWORD dwResumeIndex, LPCTSTR pszGroupName)
__in WDFDMATRANSACTION __out NTSTATUS * pStatus
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
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
◆ QueryService()
Definition at line 13 of file query.c.
14{
19 DWORD BytesNeeded = 0;
21
26 {
29 }
30
35 goto fail;
36
40 BufSiz,
41 &BytesNeeded);
43 goto fail;
44
46 0,
47 BytesNeeded);
48 if (pServiceInfo ==
NULL)
49 goto fail;
50
54 BytesNeeded,
55 &BytesNeeded))
56 {
57 goto fail;
58 }
59
62 return pServiceInfo;
63
64fail:
70}
static WCHAR ServiceName[]
#define ERROR_INSUFFICIENT_BUFFER
#define SERVICE_QUERY_STATUS
#define SC_MANAGER_CONNECT
struct _SERVICE_STATUS_PROCESS * LPSERVICE_STATUS_PROCESS
BOOL WINAPI QueryServiceStatusEx(SC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Referenced by Query(), and Start().