Fix bug with pasting Wine clipboard content to external applications,
[wine] / dlls / advapi32 / service.c
1 /*
2  * Win32 advapi functions
3  *
4  * Copyright 1995 Sven Verdoolaege
5  */
6
7 #include <time.h>
8
9 #include "windef.h"
10 #include "winsvc.h"
11 #include "winerror.h"
12 #include "heap.h"
13 #include "debugtools.h"
14
15 DEFAULT_DEBUG_CHANNEL(advapi)
16
17 /******************************************************************************
18  * EnumServicesStatus32A [ADVAPI32.38]
19  */
20 BOOL WINAPI
21 EnumServicesStatusA( SC_HANDLE hSCManager, DWORD dwServiceType,
22                        DWORD dwServiceState, LPENUM_SERVICE_STATUSA lpServices,
23                        DWORD cbBufSize, LPDWORD pcbBytesNeeded,
24                        LPDWORD lpServicesReturned, LPDWORD lpResumeHandle )
25 {       FIXME("%x type=%lx state=%lx %p %lx %p %p %p\n", hSCManager, 
26                 dwServiceType, dwServiceState, lpServices, cbBufSize,
27                 pcbBytesNeeded, lpServicesReturned,  lpResumeHandle);
28         SetLastError (ERROR_ACCESS_DENIED);
29         return 0;
30 }
31
32 /******************************************************************************
33  * StartServiceCtrlDispatcher32A [ADVAPI32.196]
34  */
35 BOOL WINAPI
36 StartServiceCtrlDispatcherA( LPSERVICE_TABLE_ENTRYA servent )
37 {       LPSERVICE_TABLE_ENTRYA ptr = servent;
38
39         while (ptr->lpServiceName)
40         { FIXME("%s at %p\n", ptr->lpServiceName, ptr);
41           ptr++;
42         }
43         return TRUE;
44 }
45
46 /******************************************************************************
47  * StartServiceCtrlDispatcher32W [ADVAPI32.197]
48  *
49  * PARAMS
50  *   servent []
51  */
52 BOOL WINAPI
53 StartServiceCtrlDispatcherW( LPSERVICE_TABLE_ENTRYW servent )
54 {       LPSERVICE_TABLE_ENTRYW ptr = servent;
55         LPSERVICE_MAIN_FUNCTIONW fpMain;
56         
57         while (ptr->lpServiceName)
58         { FIXME("%s at %p): STUB.\n", debugstr_w(ptr->lpServiceName),ptr);
59           fpMain = ptr->lpServiceProc;
60           fpMain(0,NULL);       /* try to start the service */
61           ptr++;
62         }
63         return TRUE;
64 }
65
66 /******************************************************************************
67  * RegisterServiceCtrlHandlerA [ADVAPI32.176]
68  */
69 SERVICE_STATUS_HANDLE WINAPI
70 RegisterServiceCtrlHandlerA( LPCSTR lpServiceName,
71                              LPHANDLER_FUNCTION lpfHandler )
72 {       FIXME("%s %p\n", lpServiceName, lpfHandler);
73         return 0xcacacafe;      
74 }
75
76 /******************************************************************************
77  * RegisterServiceCtrlHandlerW [ADVAPI32.177]
78  *
79  * PARAMS
80  *   lpServiceName []
81  *   lpfHandler    []
82  */
83 SERVICE_STATUS_HANDLE WINAPI
84 RegisterServiceCtrlHandlerW( LPCWSTR lpServiceName, 
85                              LPHANDLER_FUNCTION lpfHandler )
86 {       FIXME("%s %p\n", debugstr_w(lpServiceName), lpfHandler);
87         return 0xcacacafe;      
88 }
89
90 /******************************************************************************
91  * SetServiceStatus [ADVAPI32.192]
92  *
93  * PARAMS
94  *   hService []
95  *   lpStatus []
96  */
97 BOOL WINAPI
98 SetServiceStatus( SERVICE_STATUS_HANDLE hService, LPSERVICE_STATUS lpStatus )
99 {       FIXME("%lx %p\n",hService, lpStatus);
100         TRACE("\tType:%lx\n",lpStatus->dwServiceType);
101         TRACE("\tState:%lx\n",lpStatus->dwCurrentState);
102         TRACE("\tControlAccepted:%lx\n",lpStatus->dwControlsAccepted);
103         TRACE("\tExitCode:%lx\n",lpStatus->dwWin32ExitCode);
104         TRACE("\tServiceExitCode:%lx\n",lpStatus->dwServiceSpecificExitCode);
105         TRACE("\tCheckPoint:%lx\n",lpStatus->dwCheckPoint);
106         TRACE("\tWaitHint:%lx\n",lpStatus->dwWaitHint);
107         return TRUE;
108 }
109
110 /******************************************************************************
111  * OpenSCManager32A [ADVAPI32.110]
112  */
113 SC_HANDLE WINAPI
114 OpenSCManagerA( LPCSTR lpMachineName, LPCSTR lpDatabaseName,
115                   DWORD dwDesiredAccess )
116 {   
117     LPWSTR lpMachineNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpMachineName);
118     LPWSTR lpDatabaseNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpDatabaseName);
119     DWORD ret = OpenSCManagerW(lpMachineNameW,lpDatabaseNameW,
120                                  dwDesiredAccess);
121     HeapFree(GetProcessHeap(),0,lpDatabaseNameW);
122     HeapFree(GetProcessHeap(),0,lpMachineNameW);
123     return ret;
124 }
125
126 /******************************************************************************
127  * OpenSCManager32W [ADVAPI32.111]
128  * Establishes a connection to the service control manager and opens database
129  *
130  * NOTES
131  *   This should return a SC_HANDLE
132  *
133  * PARAMS
134  *   lpMachineName   [I] Pointer to machine name string
135  *   lpDatabaseName  [I] Pointer to database name string
136  *   dwDesiredAccess [I] Type of access
137  *
138  * RETURNS
139  *   Success: Handle to service control manager database
140  *   Failure: NULL
141  */
142 SC_HANDLE WINAPI
143 OpenSCManagerW( LPCWSTR lpMachineName, LPCWSTR lpDatabaseName,
144                   DWORD dwDesiredAccess )
145 {
146     FIXME("(%s,%s,0x%08lx): stub\n", debugstr_w(lpMachineName), 
147           debugstr_w(lpDatabaseName), dwDesiredAccess);
148     return 1;
149 }
150
151
152 /******************************************************************************
153  * AllocateLocallyUniqueId [ADVAPI32.12]
154  *
155  * PARAMS
156  *   lpluid []
157  */
158 BOOL WINAPI
159 AllocateLocallyUniqueId( PLUID lpluid )
160 {
161         lpluid->LowPart = time(NULL);
162         lpluid->HighPart = 0;
163         return TRUE;
164 }
165
166
167 /******************************************************************************
168  * ControlService [ADVAPI32.23]
169  * Sends a control code to a Win32-based service.
170  *
171  * PARAMS
172  *   hService        []
173  *   dwControl       []
174  *   lpServiceStatus []
175  *
176  * RETURNS STD
177  */
178 BOOL WINAPI
179 ControlService( SC_HANDLE hService, DWORD dwControl, 
180                 LPSERVICE_STATUS lpServiceStatus )
181 {
182     FIXME("(%d,%ld,%p): stub\n",hService,dwControl,lpServiceStatus);
183     return TRUE;
184 }
185
186
187 /******************************************************************************
188  * CloseServiceHandle [ADVAPI32.22]
189  * Close handle to service or service control manager
190  *
191  * PARAMS
192  *   hSCObject [I] Handle to service or service control manager database
193  *
194  * RETURNS STD
195  */
196 BOOL WINAPI
197 CloseServiceHandle( SC_HANDLE hSCObject )
198 {
199     FIXME("(%d): stub\n", hSCObject);
200     return TRUE;
201 }
202
203
204 /******************************************************************************
205  * OpenService32A [ADVAPI32.112]
206  */
207 SC_HANDLE WINAPI
208 OpenServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName, 
209                 DWORD dwDesiredAccess )
210 {
211     LPWSTR lpServiceNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpServiceName);
212     DWORD ret = OpenServiceW( hSCManager, lpServiceNameW, dwDesiredAccess);
213     HeapFree(GetProcessHeap(),0,lpServiceNameW);
214     return ret;
215 }
216
217
218 /******************************************************************************
219  * OpenService32W [ADVAPI32.113]
220  * Opens a handle to an existing service
221  *
222  * PARAMS
223  *   hSCManager      []
224  *   lpServiceName   []
225  *   dwDesiredAccess []
226  *
227  * RETURNS
228  *    Success: Handle to the service
229  *    Failure: NULL
230  */
231 SC_HANDLE WINAPI
232 OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName,
233                DWORD dwDesiredAccess)
234 {
235     FIXME("(%d,%p,%ld): stub\n",hSCManager, lpServiceName,
236           dwDesiredAccess);
237     return 1;
238 }
239
240
241 /******************************************************************************
242  * CreateService32A [ADVAPI32.29]
243  */
244 SC_HANDLE WINAPI
245 CreateServiceA( DWORD hSCManager, LPCSTR lpServiceName,
246                   LPCSTR lpDisplayName, DWORD dwDesiredAccess, 
247                   DWORD dwServiceType, DWORD dwStartType, 
248                   DWORD dwErrorControl, LPCSTR lpBinaryPathName,
249                   LPCSTR lpLoadOrderGroup, LPDWORD lpdwTagId, 
250                   LPCSTR lpDependencies, LPCSTR lpServiceStartName, 
251                   LPCSTR lpPassword )
252 {
253     FIXME("(%ld,%s,%s,...): stub\n", 
254           hSCManager, debugstr_a(lpServiceName), debugstr_a(lpDisplayName));
255     return 1;
256 }
257
258
259 /******************************************************************************
260  * DeleteService [ADVAPI32.31]
261  *
262  * PARAMS
263  *    hService [I] Handle to service
264  *
265  * RETURNS STD
266  *
267  */
268 BOOL WINAPI
269 DeleteService( SC_HANDLE hService )
270 {
271     FIXME("(%d): stub\n",hService);
272     return TRUE;
273 }
274
275
276 /******************************************************************************
277  * StartService32A [ADVAPI32.195]
278  *
279  * NOTES
280  *    How do we convert lpServiceArgVectors to use the 32W version?
281  */
282 BOOL WINAPI
283 StartServiceA( SC_HANDLE hService, DWORD dwNumServiceArgs,
284                  LPCSTR *lpServiceArgVectors )
285 {
286     FIXME("(%d,%ld,%p): stub\n",hService,dwNumServiceArgs,lpServiceArgVectors);
287     return TRUE;
288 }
289
290
291 /******************************************************************************
292  * StartService32W [ADVAPI32.198]
293  * Starts a service
294  *
295  * PARAMS
296  *   hService            [I] Handle of service
297  *   dwNumServiceArgs    [I] Number of arguments
298  *   lpServiceArgVectors [I] Address of array of argument string pointers
299  *
300  * RETURNS STD
301  *
302  */
303 BOOL WINAPI
304 StartServiceW( SC_HANDLE hService, DWORD dwNumServiceArgs,
305                  LPCWSTR *lpServiceArgVectors )
306 {
307     FIXME("(%d,%ld,%p): stub\n",hService,dwNumServiceArgs,
308           lpServiceArgVectors);
309     return TRUE;
310 }
311
312 /******************************************************************************
313  * QueryServiceStatus [ADVAPI32.123]
314  *
315  * PARAMS
316  *   hService        []
317  *   lpservicestatus []
318  *   
319  */
320 BOOL WINAPI
321 QueryServiceStatus( SC_HANDLE hService, LPSERVICE_STATUS lpservicestatus )
322 {
323         FIXME("(%d,%p),stub!\n",hService,lpservicestatus);
324         return TRUE;
325 }
326