Release 980927
[wine] / win32 / advapi.c
1 /*
2  * Win32 advapi functions
3  *
4  * Copyright 1995 Sven Verdoolaege
5  */
6
7 #include <unistd.h>
8 #include <time.h>
9 #include "windows.h"
10 #include "winerror.h"
11 #include "shell.h"
12 #include "heap.h"
13 #include "debug.h"
14
15 /***********************************************************************
16  *           StartServiceCtrlDispatcherA   [ADVAPI32.196]
17  */
18 BOOL32 WINAPI StartServiceCtrlDispatcher32A(LPSERVICE_TABLE_ENTRY32A servent)
19 {
20         FIXME(advapi,"(%p '%s'): STUB.\n",servent,servent->lpServiceName);
21         return TRUE;
22 }
23
24 /***********************************************************************
25  *           StartServiceCtrlDispatcherW   [ADVAPI32.197]
26  */
27 BOOL32 WINAPI StartServiceCtrlDispatcher32W(LPSERVICE_TABLE_ENTRY32W servent)
28 {
29         char    buffer[200];
30
31         lstrcpynWtoA(buffer,servent->lpServiceName,200);
32         FIXME(advapi,"(%p '%s'): STUB.\n",servent,buffer);
33         return TRUE;
34 }
35
36
37 /******************************************************************************
38  * OpenProcessToken [ADVAPI32.109]
39  * Opens the access token associated with a process
40  *
41  * PARAMS
42  *    ProcessHandle [I] Handle to process
43  *    DesiredAccess [I] Desired access to process
44  *    TokenHandle   [O] Pointer to handle of open access token
45  *
46  * RETURNS STD
47  */
48 BOOL32 WINAPI OpenProcessToken( HANDLE32 ProcessHandle, DWORD DesiredAccess,
49                                 HANDLE32 *TokenHandle )
50 {
51     FIXME(advapi,"(%08x,%08lx,%p): stub\n",ProcessHandle,DesiredAccess,
52           TokenHandle);
53     return TRUE;
54 }
55
56
57 /***********************************************************************
58  *           OpenThreadToken            [ADVAPI32.114]
59  */
60 BOOL32 WINAPI OpenThreadToken( HANDLE32 thread,DWORD desiredaccess,
61                                BOOL32 openasself,HANDLE32 *thandle )
62 {
63         FIXME(advapi,"(%08x,%08lx,%d,%p): stub!\n",
64               thread,desiredaccess,openasself,thandle);
65         return TRUE;
66 }
67
68
69 /******************************************************************************
70  * LookupPrivilegeValue32A                                        [ADVAPI32.92]
71  */
72 BOOL32 WINAPI LookupPrivilegeValue32A( LPCSTR lpSystemName, 
73                                        LPCSTR lpName, LPVOID lpLuid)
74 {
75     LPWSTR lpSystemNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpSystemName);
76     LPWSTR lpNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpName);
77     BOOL32 ret = LookupPrivilegeValue32W( lpSystemNameW, lpNameW, lpLuid);
78     HeapFree(GetProcessHeap(), 0, lpNameW);
79     HeapFree(GetProcessHeap(), 0, lpSystemNameW);
80     return ret;
81 }
82
83
84 /******************************************************************************
85  * LookupPrivilegeValue32W                                        [ADVAPI32.93]
86  * Retrieves LUID used on a system to represent the privilege name.
87  *
88  * NOTES
89  *    lpLuid should be PLUID
90  *
91  * PARAMS
92  *    lpSystemName [I] Address of string specifying the system
93  *    lpName       [I] Address of string specifying the privilege
94  *    lpLuid       [I] Address of locally unique identifier
95  *
96  * RETURNS STD
97  */
98 BOOL32 WINAPI LookupPrivilegeValue32W( LPCWSTR lpSystemName,
99                                        LPCWSTR lpName, LPVOID lpLuid )
100 {
101     FIXME(advapi,"(%s,%s,%p): stub\n",debugstr_w(lpSystemName), 
102                   debugstr_w(lpName), lpLuid);
103     return TRUE;
104 }
105
106
107 /***********************************************************************
108  *           AdjustTokenPrivileges   [ADVAPI32.10]
109  */
110 BOOL32 WINAPI AdjustTokenPrivileges(HANDLE32 TokenHandle,BOOL32 DisableAllPrivileges,
111         LPVOID NewState,DWORD BufferLength,LPVOID PreviousState,
112         LPDWORD ReturnLength )
113 {
114         return TRUE;
115 }
116
117 /***********************************************************************
118  *           GetTokenInformation        [ADVAPI32.66]
119  */
120 BOOL32 WINAPI GetTokenInformation(
121         HANDLE32 token,TOKEN_INFORMATION_CLASS tokeninfoclass,LPVOID tokeninfo,
122         DWORD tokeninfolength,LPDWORD retlen
123 ) {
124         FIXME(advapi,"(%08x,%d,%p,%ld,%p): stub\n",
125               token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
126         return TRUE;
127 }
128
129
130 /******************************************************************************
131  * OpenSCManager32A [ADVAPI32.110]
132  */
133 HANDLE32 WINAPI OpenSCManager32A( LPCSTR lpMachineName, LPCSTR lpDatabaseName,
134                                   DWORD dwDesiredAccess )
135 {
136     LPWSTR lpMachineNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpMachineName);
137     LPWSTR lpDatabaseNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpDatabaseName);
138     DWORD ret = OpenSCManager32W(lpMachineNameW,lpDatabaseNameW,
139                                  dwDesiredAccess);
140     HeapFree(GetProcessHeap(),0,lpDatabaseNameW);
141     HeapFree(GetProcessHeap(),0,lpMachineNameW);
142     return ret;
143 }
144
145
146 /******************************************************************************
147  * OpenSCManager32W [ADVAPI32.111]
148  * Establishes a connection to the service control manager and opens database
149  *
150  * NOTES
151  *    This should return a SC_HANDLE
152  *
153  * PARAMS
154  *    lpMachineName   [I] Pointer to machine name string
155  *    lpDatabaseName  [I] Pointer to database name string
156  *    dwDesiredAccess [I] Type of access
157  *
158  * RETURNS
159  *    Success: Handle to service control manager database
160  *    Failure: NULL
161  */
162 HANDLE32 WINAPI OpenSCManager32W( LPCWSTR lpMachineName, LPCWSTR lpDatabaseName,
163                                   DWORD dwDesiredAccess )
164 {
165     FIXME(advapi,"(%s,%s,0x%08lx): stub\n", debugstr_w(lpMachineName), 
166           debugstr_w(lpDatabaseName), dwDesiredAccess);
167     return 1;
168 }
169
170
171 BOOL32 WINAPI AllocateLocallyUniqueId(LPLUID lpluid) {
172         lpluid->LowPart = time(NULL);
173         lpluid->HighPart = 0;
174         return TRUE;
175 }
176
177
178 /******************************************************************************
179  * ControlService [ADVAPI32.23]
180  * Sends a control code to a Win32-based service.
181  *
182  * NOTES
183  *    hService should be SC_HANDLE
184  *
185  * RETURNS STD
186  */
187 BOOL32 WINAPI ControlService( HANDLE32 hService, DWORD dwControl, 
188                               LPSERVICE_STATUS lpServiceStatus )
189 {
190     FIXME(advapi, "(%d,%ld,%p): stub\n",hService,dwControl,lpServiceStatus);
191     return TRUE;
192 }
193
194
195 /******************************************************************************
196  * CloseServiceHandle [ADVAPI32.22]
197  * Close handle to service or service control manager
198  *
199  * PARAMS
200  *    hSCObject [I] Handle to service or service control manager database
201  *
202  * NOTES
203  *    hSCObject should be SC_HANDLE
204  *
205  * RETURNS STD
206  */
207 BOOL32 WINAPI CloseServiceHandle( HANDLE32 hSCObject )
208 {
209     FIXME(advapi, "(%d): stub\n", hSCObject);
210     return TRUE;
211 }
212
213
214 /******************************************************************************
215  * GetFileSecurityA [32.45]
216  * Obtains Specified information about the security of a file or directory
217  * The information obtained is constrained by the callers acces rights and
218  * priviliges
219  */
220
221 BOOL32 WINAPI GetFileSecurity32A( LPCSTR lpFileName,
222                                 SECURITY_INFORMATION RequestedInformation,
223                                 LPSECURITY_DESCRIPTOR pSecurityDescriptor,
224                                 DWORD nLength,
225                                 LPDWORD lpnLengthNeeded)
226 {
227   FIXME(advapi, "(%s) : stub\n", debugstr_a(lpFileName));
228   return TRUE;
229 }
230
231 /******************************************************************************
232  * GetFileSecurityiW [32.46]
233  * Obtains Specified information about the security of a file or directory
234  * The information obtained is constrained by the callers acces rights and
235  * priviliges
236  */
237
238 BOOL32 WINAPI GetFileSecurity32W( LPCWSTR lpFileName,
239                                 SECURITY_INFORMATION RequestedInformation,
240                                 LPSECURITY_DESCRIPTOR pSecurityDescriptor,
241                                 DWORD nLength,
242                                 LPDWORD lpnLengthNeeded)
243 {
244   FIXME(advapi, "(%s) : stub\n", debugstr_w(lpFileName) ); 
245   return TRUE;
246 }
247
248 /******************************************************************************
249  * SetFileSecurityA [32.182]
250  * Sets the security of a file or directory
251  */
252
253 BOOL32 WINAPI SetFileSecurity32A( LPCSTR lpFileName,
254                                 SECURITY_INFORMATION RequestedInformation,
255                                 LPSECURITY_DESCRIPTOR pSecurityDescriptor)
256 {
257   FIXME(advapi, "(%s) : stub\n", debugstr_a(lpFileName));
258   return TRUE;
259 }
260
261 /******************************************************************************
262  * SetFileSecurityW [32.183]
263  * Sets the security of a file or directory
264  */
265
266 BOOL32 WINAPI SetFileSecurity32W( LPCWSTR lpFileName,
267                                 SECURITY_INFORMATION RequestedInformation,
268                                 LPSECURITY_DESCRIPTOR pSecurityDescriptor)
269 {
270   FIXME(advapi, "(%s) : stub\n", debugstr_w(lpFileName) ); 
271   return TRUE;
272 }
273
274 /******************************************************************************
275  * OpenService32A [ADVAPI32.112]
276  */
277 HANDLE32 WINAPI OpenService32A( HANDLE32 hSCManager, LPCSTR lpServiceName,
278                                 DWORD dwDesiredAccess )
279 {
280     LPWSTR lpServiceNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpServiceName);
281     DWORD ret = OpenService32W( hSCManager, lpServiceNameW, dwDesiredAccess);
282     HeapFree(GetProcessHeap(),0,lpServiceNameW);
283     return ret;
284 }
285
286
287 /******************************************************************************
288  * OpenService32W [ADVAPI32.113]
289  * Opens a handle to an existing service
290  *
291  * NOTES
292  *    The return value should be SC_HANDLE
293  *    hSCManager should be SC_HANDLE
294  *
295  * RETURNS
296  *    Success: Handle to the service
297  *    Failure: NULL
298  */
299 HANDLE32 WINAPI OpenService32W( HANDLE32 hSCManager, LPCWSTR lpServiceName,
300                                 DWORD dwDesiredAccess )
301 {
302     FIXME(advapi, "(%d,%p,%ld): stub\n",hSCManager, lpServiceName,
303           dwDesiredAccess);
304     return 1;
305 }
306
307
308 /******************************************************************************
309  * CreateServiceA [ADVAPI32.28]
310  */
311 DWORD WINAPI CreateServiceA( DWORD hSCManager, LPCSTR lpServiceName,
312                              LPCSTR lpDisplayName, DWORD dwDesiredAccess, 
313                              DWORD dwServiceType, DWORD dwStartType, 
314                              DWORD dwErrorControl, LPCSTR lpBinaryPathName,
315                              LPCSTR lpLoadOrderGroup, LPDWORD lpdwTagId, 
316                              LPCSTR lpDependencies, LPCSTR lpServiceStartName, 
317                              LPCSTR lpPassword )
318 {
319     FIXME(advapi, "(%ld,%s,%s,...): stub\n", 
320           hSCManager, debugstr_a(lpServiceName), debugstr_a(lpDisplayName));
321     return 1;
322 }
323
324
325 /******************************************************************************
326  * DeleteService [ADVAPI32.31]
327  *
328  * PARAMS
329  *    hService [I] Handle to service
330  *
331  * RETURNS STD
332  *
333  * NOTES
334  *    hService should be SC_HANDLE
335  */
336 BOOL32 WINAPI DeleteService( HANDLE32 hService )
337 {
338     FIXME(advapi, "(%d): stub\n",hService);
339     return TRUE;
340 }
341
342
343 /******************************************************************************
344  * StartService32A [ADVAPI32.195]
345  *
346  * NOTES
347  *    How do we convert lpServiceArgVectors to use the 32W version?
348  */
349 BOOL32 WINAPI StartService32A( HANDLE32 hService, DWORD dwNumServiceArgs,
350                                LPCSTR *lpServiceArgVectors )
351 {
352     FIXME(advapi, "(%d,%ld,%p): stub\n",hService,dwNumServiceArgs,lpServiceArgVectors);
353     return TRUE;
354 }
355
356
357 /******************************************************************************
358  * StartService32W [ADVAPI32.198]
359  * Starts a service
360  *
361  * PARAMS
362  *    hService            [I] Handle of service
363  *    dwNumServiceArgs    [I] Number of arguments
364  *    lpServiceArgVectors [I] Address of array of argument string pointers
365  *
366  * RETURNS STD
367  *
368  * NOTES
369  *    hService should be SC_HANDLE
370  */
371 BOOL32 WINAPI StartService32W( HANDLE32 hService, DWORD dwNumServiceArgs,
372                                LPCWSTR *lpServiceArgVectors )
373 {
374     FIXME(advapi, "(%d,%ld,%p): stub\n",hService,dwNumServiceArgs,
375           lpServiceArgVectors);
376     return TRUE;
377 }
378
379
380 /******************************************************************************
381  * DeregisterEventSource [ADVAPI32.32]
382  * Closes a handle to the specified event log
383  *
384  * PARAMS
385  *    hEventLog [I] Handle to event log
386  *
387  * RETURNS STD
388  */
389 BOOL32 WINAPI DeregisterEventSource( HANDLE32 hEventLog )
390 {
391     FIXME(advapi, "(%d): stub\n",hEventLog);
392     return TRUE;
393 }
394
395
396 /******************************************************************************
397  * RegisterEventSource32A [ADVAPI32.174]
398  */
399 HANDLE32 WINAPI RegisterEventSource32A( LPCSTR lpUNCServerName, 
400                                         LPCSTR lpSourceName )
401 {
402     LPWSTR lpUNCServerNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpUNCServerName);
403     LPWSTR lpSourceNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpSourceName);
404     HANDLE32 ret = RegisterEventSource32W(lpUNCServerNameW,lpSourceNameW);
405     HeapFree(GetProcessHeap(),0,lpSourceNameW);
406     HeapFree(GetProcessHeap(),0,lpUNCServerNameW);
407     return ret;
408 }
409
410
411 /******************************************************************************
412  * RegisterEventSource32W [ADVAPI32.175]
413  * Returns a registered handle to an event log
414  *
415  * PARAMS
416  *    lpUNCServerName [I] Server name for source
417  *    lpSourceName    [I] Source name for registered handle
418  *
419  * RETURNS
420  *    Success: Handle
421  *    Failure: NULL
422  */
423 HANDLE32 WINAPI RegisterEventSource32W( LPCWSTR lpUNCServerName, 
424                                         LPCWSTR lpSourceName )
425 {
426     FIXME(advapi, "(%s,%s): stub\n", debugstr_w(lpUNCServerName),
427           debugstr_w(lpSourceName));
428     return 1;
429 }
430