270 {
271 BOOL dwStatus =
OKAY;
272 SC_HANDLE hService = NULL;
273 DWORD dwBytesNeeded;
274
275
276 if ((hService = OpenService(
hSCMan, lpDriver,
277 SERVICE_ALL_ACCESS)) != NULL)
278 {
279 LPQUERY_SERVICE_CONFIG lpqscBuf;
280
281
282 if ((lpqscBuf = (LPQUERY_SERVICE_CONFIG) LocalAlloc(
283 LPTR, 4096)) != NULL)
284 {
285
286
287 {
288
289 if (QueryServiceConfig(
290 hService,
291 lpqscBuf,
292 4096,
293 &dwBytesNeeded)
294
295
296
297
298
299
300 )
301 {
302
303 printf("Type: [0x%02lx] ", lpqscBuf->dwServiceType);
304 switch (lpqscBuf->dwServiceType) {
305 case SERVICE_WIN32_OWN_PROCESS:
306 printf("The service runs in its own process.");
307 break;
308 case SERVICE_WIN32_SHARE_PROCESS:
309 printf("The service shares a process with other services.");
310 break;
311 case SERVICE_KERNEL_DRIVER:
312 printf("Kernel driver.");
313 break;
314 case SERVICE_FILE_SYSTEM_DRIVER:
315 printf("File system driver.");
316 break;
317 case SERVICE_INTERACTIVE_PROCESS:
318 printf("The service can interact with the desktop.");
319 break;
320 default:
321 printf("Unknown type.");
322 }
323 printf("\nStart Type: [0x%02lx] ", lpqscBuf->dwStartType);
324 switch (lpqscBuf->dwStartType) {
325 case SERVICE_BOOT_START:
326 printf("Boot");
327 break;
328 case SERVICE_SYSTEM_START:
329 printf("System");
330 break;
331 case SERVICE_AUTO_START:
332 printf("Automatic");
333 break;
334 case SERVICE_DEMAND_START:
335 printf("Manual");
336 break;
337 case SERVICE_DISABLED:
338 printf("Disabled");
339 break;
340 default:
341 printf("Unknown.");
342 }
343 printf("\nError Control: [0x%02lx] ", lpqscBuf->dwErrorControl);
344 switch (lpqscBuf->dwErrorControl) {
345 case SERVICE_ERROR_IGNORE:
346 printf("IGNORE: Ignore.");
347 break;
348 case SERVICE_ERROR_NORMAL:
349 printf("NORMAL: Display a message box.");
350 break;
351 case SERVICE_ERROR_SEVERE:
352 printf("SEVERE: Restart with last-known-good config.");
353 break;
354 case SERVICE_ERROR_CRITICAL:
355 printf("CRITICAL: Restart w/ last-known-good config.");
356 break;
357 default:
358 printf("Unknown.");
359 }
360 printf("\nBinary path: %s\n", lpqscBuf->lpBinaryPathName);
361
362 if (lpqscBuf->lpLoadOrderGroup != NULL)
363 printf("Load order grp: %s\n", lpqscBuf->lpLoadOrderGroup);
364 if (lpqscBuf->dwTagId != 0)
365 printf("Tag ID: %ld\n", lpqscBuf->dwTagId);
366 if (lpqscBuf->lpDependencies != NULL)
367 printf("Dependencies: %s\n", lpqscBuf->lpDependencies);
368 if (lpqscBuf->lpServiceStartName != NULL)
369 printf("Start Name: %s\n", lpqscBuf->lpServiceStartName);
370
371
372 }
373
374 }
375 LocalFree(lpqscBuf);
376 } else {
377 dwStatus = GetLastError();
378 }
379 } else {
380 dwStatus = GetLastError();
381 }
382
383 if (hService != NULL) CloseServiceHandle(hService);
384 return dwStatus;
385}