ReactOS 0.4.16-dev-112-g52265ae
depend.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/sc/depend.c
5 * PURPOSE:
6 * COPYRIGHT: Copyright 2016 Eric Kohl
7 *
8 */
9
10#include "sc.h"
11
13{
14 SC_HANDLE hManager = NULL;
15 SC_HANDLE hService = NULL;
16 BOOL bResult = TRUE;
17 DWORD BufferSize = 0;
18 DWORD EntriesRead = 0;
20 DWORD i;
21
22 hManager = OpenSCManager(NULL,
23 NULL,
25 if (hManager == NULL)
26 {
27 _tprintf(_T("[SC] OpenSCManager FAILED %lu:\n\n"), GetLastError());
28 bResult = FALSE;
29 goto done;
30 }
31
33 if (hService == NULL)
34 {
35 _tprintf(_T("[SC] OpenService FAILED %lu:\n\n"), GetLastError());
36 bResult = FALSE;
37 goto done;
38 }
39
40 if (!EnumDependentServices(hService,
42 NULL,
43 0,
45 &EntriesRead))
46 {
47 if (BufferSize == 0)
48 {
49 _tprintf(_T("[SC] EnumDependentServices FAILED %lu:\n\n"), GetLastError());
50 bResult = FALSE;
51 goto done;
52 }
53 }
54
56 if (pBuffer == NULL)
57 {
59 _tprintf(_T("[SC] HeapAlloc FAILED %lu:\n\n"), GetLastError());
60 bResult = FALSE;
61 goto done;
62 }
63
64 if (!EnumDependentServices(hService,
66 pBuffer,
69 &EntriesRead))
70 {
71 _tprintf(_T("[SC] EnumDependentServices FAILED %lu:\n\n"), GetLastError());
72 bResult = FALSE;
73 goto done;
74 }
75
76 _tprintf(_T("Enum: entriesRead = %lu\n"), EntriesRead);
77
78 for (i = 0; i < EntriesRead; i++)
79 {
80 _tprintf(_T("\n"));
81 _tprintf(_T("SERVICE_NAME: %s\n"), pBuffer[i].lpServiceName);
82 _tprintf(_T("DISPLAY_NAME: %s\n"), pBuffer[i].lpDisplayName);
84 }
85
86done:
87 if (bResult == FALSE)
89
90 if (pBuffer != NULL)
92
93 if (hService)
94 CloseServiceHandle(hService);
95
96 if (hManager)
97 CloseServiceHandle(hManager);
98
99 return bResult;
100}
VOID PrintServiceStatus(LPSERVICE_STATUS pStatus)
Definition: print.c:39
static WCHAR ServiceName[]
Definition: browser.c:19
static SERVICE_STATUS ServiceStatus
Definition: browser.c:22
BOOL EnumDepend(LPCTSTR ServiceName)
Definition: depend.c:12
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
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
Definition: glfuncs.h:248
#define _tprintf
Definition: tchar.h:506
DWORD ReportLastError(void)
Definition: loadlib.c:67
PVOID pBuffer
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
#define _T(x)
Definition: vfdio.h:22
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2790
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SERVICE_STATE_ALL
Definition: winsvc.h:52
#define OpenSCManager
Definition: winsvc.h:575
#define EnumDependentServices
Definition: winsvc.h:570
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
#define SERVICE_ENUMERATE_DEPENDENTS
Definition: winsvc.h:56
#define OpenService
Definition: winsvc.h:576
const CHAR * LPCTSTR
Definition: xmlstorage.h:193