1 | /* $Id: security.cpp,v 1.8 2001-04-22 10:39:27 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 security API functions for OS/2
|
---|
4 | *
|
---|
5 | * Copyright 1998 Sander van Leeuwen (OS/2 Port)
|
---|
6 | *
|
---|
7 | * Based on Wine code (dlls\advapi32\security.c)
|
---|
8 | *
|
---|
9 | * Copyright original Wine author(s) (????)
|
---|
10 | *
|
---|
11 | * dlls/advapi32/security.c
|
---|
12 | * FIXME: for all functions thunking down to Rtl* functions: implement SetLastError()
|
---|
13 | */
|
---|
14 | #ifdef __WIN32OS2__
|
---|
15 | #include <os2win.h>
|
---|
16 | #include <heapstring.h>
|
---|
17 | #endif
|
---|
18 |
|
---|
19 | #include <string.h>
|
---|
20 |
|
---|
21 | #include "windef.h"
|
---|
22 | #include "winerror.h"
|
---|
23 | #include "heap.h"
|
---|
24 | #include "ntddk.h"
|
---|
25 | #include "ntsecapi.h"
|
---|
26 | #include "debugtools.h"
|
---|
27 |
|
---|
28 | DECLARE_DEBUG_CHANNEL(advapi-security)
|
---|
29 |
|
---|
30 | static BOOL fInitSecurity = FALSE;
|
---|
31 | static BOOL fHasSecurity = FALSE;
|
---|
32 |
|
---|
33 | static BOOL Wine_HasSecurity(void)
|
---|
34 | {
|
---|
35 | //SvL: Let's not check this for every single call please...
|
---|
36 | if(!fInitSecurity)
|
---|
37 | {
|
---|
38 | OSVERSIONINFOA osi;
|
---|
39 | osi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
|
---|
40 | GetVersionExA(&osi);
|
---|
41 | if (osi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
|
---|
42 | fHasSecurity = TRUE;
|
---|
43 | }
|
---|
44 | fInitSecurity = TRUE;
|
---|
45 | }
|
---|
46 | if(!fHasSecurity) {
|
---|
47 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
---|
48 | return FALSE;
|
---|
49 | }
|
---|
50 | return TRUE;
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 | #define CallWin32ToNt(func) \
|
---|
55 | { NTSTATUS ret; \
|
---|
56 | ret = (func); \
|
---|
57 | if (ret !=STATUS_SUCCESS) \
|
---|
58 | { SetLastError (RtlNtStatusToDosError(ret)); return FALSE; } \
|
---|
59 | return TRUE; \
|
---|
60 | }
|
---|
61 |
|
---|
62 | /* ##############################
|
---|
63 | ###### TOKEN FUNCTIONS ######
|
---|
64 | ##############################
|
---|
65 | */
|
---|
66 |
|
---|
67 | /******************************************************************************
|
---|
68 | * OpenProcessToken [ADVAPI32.109]
|
---|
69 | * Opens the access token associated with a process
|
---|
70 | *
|
---|
71 | * PARAMS
|
---|
72 | * ProcessHandle [I] Handle to process
|
---|
73 | * DesiredAccess [I] Desired access to process
|
---|
74 | * TokenHandle [O] Pointer to handle of open access token
|
---|
75 | *
|
---|
76 | * RETURNS STD
|
---|
77 | */
|
---|
78 | BOOL WINAPI
|
---|
79 | OpenProcessToken( HANDLE ProcessHandle, DWORD DesiredAccess,
|
---|
80 | HANDLE *TokenHandle )
|
---|
81 | {
|
---|
82 | if (!Wine_HasSecurity()) return FALSE;
|
---|
83 | CallWin32ToNt(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));
|
---|
84 | }
|
---|
85 |
|
---|
86 | /******************************************************************************
|
---|
87 | * OpenThreadToken [ADVAPI32.114]
|
---|
88 | *
|
---|
89 | * PARAMS
|
---|
90 | * thread []
|
---|
91 | * desiredaccess []
|
---|
92 | * openasself []
|
---|
93 | * thandle []
|
---|
94 | */
|
---|
95 | BOOL WINAPI
|
---|
96 | OpenThreadToken( HANDLE ThreadHandle, DWORD DesiredAccess,
|
---|
97 | BOOL OpenAsSelf, HANDLE *TokenHandle)
|
---|
98 | {
|
---|
99 | if (!Wine_HasSecurity()) return FALSE;
|
---|
100 | CallWin32ToNt (NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
|
---|
101 | }
|
---|
102 |
|
---|
103 | /*************************************************************************
|
---|
104 | * SetThreadToken [ADVAPI32.231]
|
---|
105 | *
|
---|
106 | * Assigns an "impersonation token" to a thread so it can assume the
|
---|
107 | * security privledges of another thread or process. Can also remove
|
---|
108 | * a previously assigned token. Only supported on NT - it's a stub
|
---|
109 | * exactly like this one on Win9X.
|
---|
110 | *
|
---|
111 | */
|
---|
112 |
|
---|
113 | BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
|
---|
114 | {
|
---|
115 | #ifdef __WIN32OS2__
|
---|
116 |
|
---|
117 | dprintf(("SetThreadToken %x %x NOT IMPLEMENTED (FAKED)", thread, token));
|
---|
118 |
|
---|
119 | if (!Wine_HasSecurity()) return FALSE;
|
---|
120 | return TRUE; //pretend it succeeded
|
---|
121 | #else
|
---|
122 | FIXME(__FUNCTION__"(%p, %x): stub\n", thread, token);
|
---|
123 |
|
---|
124 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
---|
125 |
|
---|
126 | return FALSE;
|
---|
127 | #endif
|
---|
128 | }
|
---|
129 |
|
---|
130 | /******************************************************************************
|
---|
131 | * AdjustTokenPrivileges [ADVAPI32.10]
|
---|
132 | *
|
---|
133 | * PARAMS
|
---|
134 | * TokenHandle []
|
---|
135 | * DisableAllPrivileges []
|
---|
136 | * NewState []
|
---|
137 | * BufferLength []
|
---|
138 | * PreviousState []
|
---|
139 | * ReturnLength []
|
---|
140 | */
|
---|
141 | BOOL WINAPI
|
---|
142 | AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
|
---|
143 | PTOKEN_PRIVILEGES NewState, DWORD BufferLength,
|
---|
144 | PTOKEN_PRIVILEGES PreviousState, LPDWORD ReturnLength )
|
---|
145 | {
|
---|
146 | CallWin32ToNt(NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength));
|
---|
147 | }
|
---|
148 |
|
---|
149 | /******************************************************************************
|
---|
150 | * GetTokenInformation [ADVAPI32.66]
|
---|
151 | *
|
---|
152 | * PARAMS
|
---|
153 | * token []
|
---|
154 | * tokeninfoclass []
|
---|
155 | * tokeninfo []
|
---|
156 | * tokeninfolength []
|
---|
157 | * retlen []
|
---|
158 | *
|
---|
159 | */
|
---|
160 | BOOL WINAPI
|
---|
161 | GetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
|
---|
162 | LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen )
|
---|
163 | {
|
---|
164 | CallWin32ToNt (NtQueryInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength, retlen));
|
---|
165 | }
|
---|
166 |
|
---|
167 | /* ##############################
|
---|
168 | ###### SID FUNCTIONS ######
|
---|
169 | ##############################
|
---|
170 | */
|
---|
171 |
|
---|
172 | /******************************************************************************
|
---|
173 | * AllocateAndInitializeSid [ADVAPI32.11]
|
---|
174 | *
|
---|
175 | * PARAMS
|
---|
176 | * pIdentifierAuthority []
|
---|
177 | * nSubAuthorityCount []
|
---|
178 | * nSubAuthority0 []
|
---|
179 | * nSubAuthority1 []
|
---|
180 | * nSubAuthority2 []
|
---|
181 | * nSubAuthority3 []
|
---|
182 | * nSubAuthority4 []
|
---|
183 | * nSubAuthority5 []
|
---|
184 | * nSubAuthority6 []
|
---|
185 | * nSubAuthority7 []
|
---|
186 | * pSid []
|
---|
187 | */
|
---|
188 | BOOL WINAPI
|
---|
189 | AllocateAndInitializeSid( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
|
---|
190 | BYTE nSubAuthorityCount,
|
---|
191 | DWORD nSubAuthority0, DWORD nSubAuthority1,
|
---|
192 | DWORD nSubAuthority2, DWORD nSubAuthority3,
|
---|
193 | DWORD nSubAuthority4, DWORD nSubAuthority5,
|
---|
194 | DWORD nSubAuthority6, DWORD nSubAuthority7,
|
---|
195 | PSID *pSid )
|
---|
196 | {
|
---|
197 | return RtlAllocateAndInitializeSid(
|
---|
198 | pIdentifierAuthority, nSubAuthorityCount,
|
---|
199 | nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
|
---|
200 | nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7,
|
---|
201 | pSid );
|
---|
202 | }
|
---|
203 |
|
---|
204 | /******************************************************************************
|
---|
205 | * FreeSid [ADVAPI32.42]
|
---|
206 | *
|
---|
207 | * PARAMS
|
---|
208 | * pSid []
|
---|
209 | */
|
---|
210 | PVOID WINAPI
|
---|
211 | FreeSid( PSID pSid )
|
---|
212 | {
|
---|
213 | RtlFreeSid(pSid);
|
---|
214 | return NULL; /* is documented like this */
|
---|
215 | }
|
---|
216 |
|
---|
217 | /******************************************************************************
|
---|
218 | * CopySid [ADVAPI32.24]
|
---|
219 | *
|
---|
220 | * PARAMS
|
---|
221 | * nDestinationSidLength []
|
---|
222 | * pDestinationSid []
|
---|
223 | * pSourceSid []
|
---|
224 | */
|
---|
225 | BOOL WINAPI
|
---|
226 | CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
|
---|
227 | {
|
---|
228 | CallWin32ToNt (RtlCopySid( nDestinationSidLength, pDestinationSid, pSourceSid));
|
---|
229 | }
|
---|
230 |
|
---|
231 | /******************************************************************************
|
---|
232 | * IsValidSid [ADVAPI32.80]
|
---|
233 | *
|
---|
234 | * PARAMS
|
---|
235 | * pSid []
|
---|
236 | */
|
---|
237 | BOOL WINAPI
|
---|
238 | IsValidSid( PSID pSid )
|
---|
239 | {
|
---|
240 | CallWin32ToNt (RtlValidSid( pSid));
|
---|
241 | }
|
---|
242 |
|
---|
243 | /******************************************************************************
|
---|
244 | * EqualSid [ADVAPI32.40]
|
---|
245 | *
|
---|
246 | * PARAMS
|
---|
247 | * pSid1 []
|
---|
248 | * pSid2 []
|
---|
249 | */
|
---|
250 | BOOL WINAPI
|
---|
251 | EqualSid( PSID pSid1, PSID pSid2 )
|
---|
252 | {
|
---|
253 | CallWin32ToNt (RtlEqualSid( pSid1, pSid2));
|
---|
254 | }
|
---|
255 |
|
---|
256 | /******************************************************************************
|
---|
257 | * EqualPrefixSid [ADVAPI32.39]
|
---|
258 | */
|
---|
259 | BOOL WINAPI EqualPrefixSid (PSID pSid1, PSID pSid2)
|
---|
260 | {
|
---|
261 | CallWin32ToNt (RtlEqualPrefixSid( pSid1, pSid2));
|
---|
262 | }
|
---|
263 |
|
---|
264 | /******************************************************************************
|
---|
265 | * InitializeSid [ADVAPI32.74]
|
---|
266 | *
|
---|
267 | * PARAMS
|
---|
268 | * pIdentifierAuthority []
|
---|
269 | */
|
---|
270 | BOOL WINAPI
|
---|
271 | InitializeSid (PSID pSid, PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
|
---|
272 | BYTE nSubAuthorityCount)
|
---|
273 | {
|
---|
274 | CallWin32ToNt (RtlInitializeSid( pSid, pIdentifierAuthority, nSubAuthorityCount));
|
---|
275 | }
|
---|
276 |
|
---|
277 | /* ##############################################
|
---|
278 | ###### SECURITY DESCRIPTOR FUNCTIONS ######
|
---|
279 | ##############################################
|
---|
280 | */
|
---|
281 |
|
---|
282 | /******************************************************************************
|
---|
283 | * InitializeSecurityDescriptor [ADVAPI32.73]
|
---|
284 | *
|
---|
285 | * PARAMS
|
---|
286 | * pDescr []
|
---|
287 | * revision []
|
---|
288 | */
|
---|
289 | BOOL WINAPI
|
---|
290 | InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr, DWORD revision )
|
---|
291 | {
|
---|
292 | CallWin32ToNt (RtlCreateSecurityDescriptor(pDescr, revision ));
|
---|
293 | }
|
---|
294 |
|
---|
295 | /******************************************************************************
|
---|
296 | * GetSecurityDescriptorLength [ADVAPI32.55]
|
---|
297 | */
|
---|
298 | DWORD WINAPI GetSecurityDescriptorLength( SECURITY_DESCRIPTOR *pDescr)
|
---|
299 | {
|
---|
300 | return (RtlLengthSecurityDescriptor(pDescr));
|
---|
301 | }
|
---|
302 |
|
---|
303 | /******************************************************************************
|
---|
304 | * GetSecurityDescriptorOwner [ADVAPI32.56]
|
---|
305 | *
|
---|
306 | * PARAMS
|
---|
307 | * pOwner []
|
---|
308 | * lpbOwnerDefaulted []
|
---|
309 | */
|
---|
310 | BOOL WINAPI
|
---|
311 | GetSecurityDescriptorOwner( SECURITY_DESCRIPTOR *pDescr, PSID *pOwner,
|
---|
312 | LPBOOL lpbOwnerDefaulted )
|
---|
313 | {
|
---|
314 | CallWin32ToNt (RtlGetOwnerSecurityDescriptor( pDescr, pOwner, (PBOOLEAN)lpbOwnerDefaulted ));
|
---|
315 | }
|
---|
316 |
|
---|
317 | /******************************************************************************
|
---|
318 | * SetSecurityDescriptorOwner [ADVAPI32]
|
---|
319 | *
|
---|
320 | * PARAMS
|
---|
321 | */
|
---|
322 | BOOL WINAPI SetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
---|
323 | PSID pOwner, BOOL bOwnerDefaulted)
|
---|
324 | {
|
---|
325 | CallWin32ToNt (RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));
|
---|
326 | }
|
---|
327 | /******************************************************************************
|
---|
328 | * GetSecurityDescriptorGroup [ADVAPI32.54]
|
---|
329 | */
|
---|
330 | BOOL WINAPI GetSecurityDescriptorGroup(
|
---|
331 | PSECURITY_DESCRIPTOR SecurityDescriptor,
|
---|
332 | PSID *Group,
|
---|
333 | LPBOOL GroupDefaulted)
|
---|
334 | {
|
---|
335 | CallWin32ToNt (RtlGetGroupSecurityDescriptor(SecurityDescriptor, Group, (PBOOLEAN)GroupDefaulted));
|
---|
336 | }
|
---|
337 | /******************************************************************************
|
---|
338 | * SetSecurityDescriptorGroup
|
---|
339 | */
|
---|
340 | BOOL WINAPI SetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR SecurityDescriptor,
|
---|
341 | PSID Group, BOOL GroupDefaulted)
|
---|
342 | {
|
---|
343 | CallWin32ToNt (RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));
|
---|
344 | }
|
---|
345 |
|
---|
346 | /******************************************************************************
|
---|
347 | * IsValidSecurityDescriptor [ADVAPI32.79]
|
---|
348 | *
|
---|
349 | * PARAMS
|
---|
350 | * lpsecdesc []
|
---|
351 | */
|
---|
352 | BOOL WINAPI
|
---|
353 | IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor )
|
---|
354 | {
|
---|
355 | CallWin32ToNt (RtlValidSecurityDescriptor(SecurityDescriptor));
|
---|
356 | }
|
---|
357 |
|
---|
358 | /******************************************************************************
|
---|
359 | * GetSecurityDescriptorDacl [ADVAPI.91]
|
---|
360 | */
|
---|
361 | BOOL WINAPI GetSecurityDescriptorDacl(
|
---|
362 | IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
---|
363 | OUT LPBOOL lpbDaclPresent,
|
---|
364 | OUT PACL *pDacl,
|
---|
365 | OUT LPBOOL lpbDaclDefaulted)
|
---|
366 | {
|
---|
367 | CallWin32ToNt (RtlGetDaclSecurityDescriptor(pSecurityDescriptor, (PBOOLEAN)lpbDaclPresent,
|
---|
368 | pDacl, (PBOOLEAN)lpbDaclDefaulted));
|
---|
369 | }
|
---|
370 |
|
---|
371 | /******************************************************************************
|
---|
372 | * SetSecurityDescriptorDacl [ADVAPI.224]
|
---|
373 | */
|
---|
374 | BOOL WINAPI
|
---|
375 | SetSecurityDescriptorDacl (
|
---|
376 | PSECURITY_DESCRIPTOR lpsd,
|
---|
377 | BOOL daclpresent,
|
---|
378 | PACL dacl,
|
---|
379 | BOOL dacldefaulted )
|
---|
380 | {
|
---|
381 | CallWin32ToNt (RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ));
|
---|
382 | }
|
---|
383 | /******************************************************************************
|
---|
384 | * GetSecurityDescriptorSacl [ADVAPI.]
|
---|
385 | */
|
---|
386 | BOOL WINAPI GetSecurityDescriptorSacl(
|
---|
387 | IN PSECURITY_DESCRIPTOR lpsd,
|
---|
388 | OUT LPBOOL lpbSaclPresent,
|
---|
389 | OUT PACL *pSacl,
|
---|
390 | OUT LPBOOL lpbSaclDefaulted)
|
---|
391 | {
|
---|
392 | CallWin32ToNt (RtlGetSaclSecurityDescriptor(lpsd, (PBOOLEAN)lpbSaclPresent,
|
---|
393 | pSacl, (PBOOLEAN)lpbSaclDefaulted));
|
---|
394 | }
|
---|
395 |
|
---|
396 | /**************************************************************************
|
---|
397 | * SetSecurityDescriptorSacl [NTDLL.488]
|
---|
398 | */
|
---|
399 | BOOL WINAPI SetSecurityDescriptorSacl (
|
---|
400 | PSECURITY_DESCRIPTOR lpsd,
|
---|
401 | BOOL saclpresent,
|
---|
402 | PACL lpsacl,
|
---|
403 | BOOL sacldefaulted)
|
---|
404 | {
|
---|
405 | CallWin32ToNt (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));
|
---|
406 | }
|
---|
407 | /******************************************************************************
|
---|
408 | * MakeSelfRelativeSD [ADVAPI32.95]
|
---|
409 | *
|
---|
410 | * PARAMS
|
---|
411 | * lpabssecdesc []
|
---|
412 | * lpselfsecdesc []
|
---|
413 | * lpbuflen []
|
---|
414 | */
|
---|
415 | BOOL WINAPI
|
---|
416 | MakeSelfRelativeSD( PSECURITY_DESCRIPTOR lpabssecdesc,
|
---|
417 | PSECURITY_DESCRIPTOR lpselfsecdesc, LPDWORD lpbuflen )
|
---|
418 | {
|
---|
419 | FIXME(__FUNCTION__"(%p,%p,%p),stub!\n",lpabssecdesc,lpselfsecdesc,lpbuflen);
|
---|
420 | return TRUE;
|
---|
421 | }
|
---|
422 |
|
---|
423 | /******************************************************************************
|
---|
424 | * GetSecurityDescriptorControl32 [ADVAPI32]
|
---|
425 | */
|
---|
426 |
|
---|
427 | BOOL WINAPI GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
---|
428 | PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision)
|
---|
429 | { FIXME(__FUNCTION__"(%p,%p,%p),stub!\n",pSecurityDescriptor,pControl,lpdwRevision);
|
---|
430 | return 1;
|
---|
431 | }
|
---|
432 |
|
---|
433 | /* ##############################
|
---|
434 | ###### MISC FUNCTIONS ######
|
---|
435 | ##############################
|
---|
436 | */
|
---|
437 |
|
---|
438 | /******************************************************************************
|
---|
439 | * LookupPrivilegeValue32W [ADVAPI32.93]
|
---|
440 | * Retrieves LUID used on a system to represent the privilege name.
|
---|
441 | *
|
---|
442 | * NOTES
|
---|
443 | * lpLuid should be PLUID
|
---|
444 | *
|
---|
445 | * PARAMS
|
---|
446 | * lpSystemName [I] Address of string specifying the system
|
---|
447 | * lpName [I] Address of string specifying the privilege
|
---|
448 | * lpLuid [I] Address of locally unique identifier
|
---|
449 | *
|
---|
450 | * RETURNS STD
|
---|
451 | */
|
---|
452 | BOOL WINAPI
|
---|
453 | LookupPrivilegeValueW( LPCWSTR lpSystemName, LPCWSTR lpName, LPVOID lpLuid )
|
---|
454 | {
|
---|
455 | FIXME(__FUNCTION__"(%s,%s,%p): stub\n",debugstr_w(lpSystemName),
|
---|
456 | debugstr_w(lpName), lpLuid);
|
---|
457 | return TRUE;
|
---|
458 | }
|
---|
459 |
|
---|
460 | /******************************************************************************
|
---|
461 | * LookupPrivilegeValue32A [ADVAPI32.92]
|
---|
462 | */
|
---|
463 | BOOL WINAPI
|
---|
464 | LookupPrivilegeValueA( LPCSTR lpSystemName, LPCSTR lpName, LPVOID lpLuid )
|
---|
465 | {
|
---|
466 | dprintf(("LookupPrivilegeValueA %s %s %x NOT IMPLEMENTED", lpSystemName, lpName, lpLuid));
|
---|
467 | LPWSTR lpSystemNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpSystemName);
|
---|
468 | LPWSTR lpNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpName);
|
---|
469 | BOOL ret = LookupPrivilegeValueW( lpSystemNameW, lpNameW, lpLuid);
|
---|
470 | HeapFree(GetProcessHeap(), 0, lpNameW);
|
---|
471 | HeapFree(GetProcessHeap(), 0, lpSystemNameW);
|
---|
472 | return ret;
|
---|
473 | }
|
---|
474 |
|
---|
475 | /******************************************************************************
|
---|
476 | * GetFileSecurity32A [ADVAPI32.45]
|
---|
477 | *
|
---|
478 | * Obtains Specified information about the security of a file or directory
|
---|
479 | * The information obtained is constrained by the callers access rights and
|
---|
480 | * privileges
|
---|
481 | */
|
---|
482 | BOOL WINAPI
|
---|
483 | GetFileSecurityA( LPCSTR lpFileName,
|
---|
484 | SECURITY_INFORMATION RequestedInformation,
|
---|
485 | PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
---|
486 | DWORD nLength, LPDWORD lpnLengthNeeded )
|
---|
487 | {
|
---|
488 | FIXME(__FUNCTION__"(%s) : stub\n", debugstr_a(lpFileName));
|
---|
489 | return TRUE;
|
---|
490 | }
|
---|
491 |
|
---|
492 | /******************************************************************************
|
---|
493 | * GetFileSecurity32W [ADVAPI32.46]
|
---|
494 | *
|
---|
495 | * Obtains Specified information about the security of a file or directory
|
---|
496 | * The information obtained is constrained by the callers access rights and
|
---|
497 | * privileges
|
---|
498 | *
|
---|
499 | * PARAMS
|
---|
500 | * lpFileName []
|
---|
501 | * RequestedInformation []
|
---|
502 | * pSecurityDescriptor []
|
---|
503 | * nLength []
|
---|
504 | * lpnLengthNeeded []
|
---|
505 | */
|
---|
506 | BOOL WINAPI
|
---|
507 | GetFileSecurityW( LPCWSTR lpFileName,
|
---|
508 | SECURITY_INFORMATION RequestedInformation,
|
---|
509 | PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
---|
510 | DWORD nLength, LPDWORD lpnLengthNeeded )
|
---|
511 | {
|
---|
512 | FIXME(__FUNCTION__"(%s) : stub\n", debugstr_w(lpFileName) );
|
---|
513 | return TRUE;
|
---|
514 | }
|
---|
515 |
|
---|
516 | /******************************************************************************
|
---|
517 | * SetFileSecurity32A [ADVAPI32.182]
|
---|
518 | * Sets the security of a file or directory
|
---|
519 | */
|
---|
520 | BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
|
---|
521 | SECURITY_INFORMATION RequestedInformation,
|
---|
522 | PSECURITY_DESCRIPTOR pSecurityDescriptor)
|
---|
523 | {
|
---|
524 | FIXME(__FUNCTION__"(%s) : stub\n", debugstr_a(lpFileName));
|
---|
525 | return TRUE;
|
---|
526 | }
|
---|
527 |
|
---|
528 | /******************************************************************************
|
---|
529 | * SetFileSecurity32W [ADVAPI32.183]
|
---|
530 | * Sets the security of a file or directory
|
---|
531 | *
|
---|
532 | * PARAMS
|
---|
533 | * lpFileName []
|
---|
534 | * RequestedInformation []
|
---|
535 | * pSecurityDescriptor []
|
---|
536 | */
|
---|
537 | BOOL WINAPI
|
---|
538 | SetFileSecurityW( LPCWSTR lpFileName,
|
---|
539 | SECURITY_INFORMATION RequestedInformation,
|
---|
540 | PSECURITY_DESCRIPTOR pSecurityDescriptor )
|
---|
541 | {
|
---|
542 | FIXME(__FUNCTION__"(%s) : stub\n", debugstr_w(lpFileName) );
|
---|
543 | return TRUE;
|
---|
544 | }
|
---|
545 |
|
---|
546 | /******************************************************************************
|
---|
547 | * LookupAccountSid32A [ADVAPI32.86]
|
---|
548 | */
|
---|
549 | BOOL WINAPI
|
---|
550 | LookupAccountSidA(
|
---|
551 | IN LPCSTR system,
|
---|
552 | IN PSID sid,
|
---|
553 | OUT LPSTR account,
|
---|
554 | IN OUT LPDWORD accountSize,
|
---|
555 | OUT LPSTR domain,
|
---|
556 | IN OUT LPDWORD domainSize,
|
---|
557 | OUT PSID_NAME_USE name_use )
|
---|
558 | {
|
---|
559 | char * ac = "Administrator";
|
---|
560 | char * dm = "DOMAIN";
|
---|
561 | dprintf(("LookupAccountSidA(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub",
|
---|
562 | sid,
|
---|
563 | account,accountSize,accountSize?*accountSize:0,
|
---|
564 | domain,domainSize,domainSize?*domainSize:0,
|
---|
565 | name_use));
|
---|
566 |
|
---|
567 | if (accountSize) *accountSize = strlen(ac)+1;
|
---|
568 | if (account && (*accountSize > strlen(ac)))
|
---|
569 | strcpy(account, ac);
|
---|
570 |
|
---|
571 | if (domainSize) *domainSize = strlen(dm)+1;
|
---|
572 | if (domain && (*domainSize > strlen(dm)))
|
---|
573 | strcpy(domain,dm);
|
---|
574 |
|
---|
575 | if (name_use) *name_use = SidTypeUser;
|
---|
576 | return TRUE;
|
---|
577 | }
|
---|
578 |
|
---|
579 | /******************************************************************************
|
---|
580 | * LookupAccountSid32W [ADVAPI32.87]
|
---|
581 | *
|
---|
582 | * PARAMS
|
---|
583 | * system []
|
---|
584 | * sid []
|
---|
585 | * account []
|
---|
586 | * accountSize []
|
---|
587 | * domain []
|
---|
588 | * domainSize []
|
---|
589 | * name_use []
|
---|
590 | */
|
---|
591 | BOOL WINAPI
|
---|
592 | LookupAccountSidW(
|
---|
593 | IN LPCWSTR system,
|
---|
594 | IN PSID sid,
|
---|
595 | OUT LPWSTR account,
|
---|
596 | IN OUT LPDWORD accountSize,
|
---|
597 | OUT LPWSTR domain,
|
---|
598 | IN OUT LPDWORD domainSize,
|
---|
599 | OUT PSID_NAME_USE name_use )
|
---|
600 | {
|
---|
601 | char * ac = "Administrator";
|
---|
602 | char * dm = "DOMAIN";
|
---|
603 | dprintf(("LookupAccountSidW(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub",
|
---|
604 | sid,
|
---|
605 | account,accountSize,accountSize?*accountSize:0,
|
---|
606 | domain,domainSize,domainSize?*domainSize:0,
|
---|
607 | name_use));
|
---|
608 |
|
---|
609 | if (accountSize) *accountSize = strlen(ac)+1;
|
---|
610 | if (account && (*accountSize > strlen(ac)))
|
---|
611 | lstrcpyAtoW(account, ac);
|
---|
612 |
|
---|
613 | if (domainSize) *domainSize = strlen(dm)+1;
|
---|
614 | if (domain && (*domainSize > strlen(dm)))
|
---|
615 | lstrcpyAtoW(domain,dm);
|
---|
616 |
|
---|
617 | if (name_use) *name_use = SidTypeUser;
|
---|
618 | return TRUE;
|
---|
619 | }
|
---|
620 |
|
---|
621 | /******************************************************************************
|
---|
622 | * QueryWindows31FilesMigration [ADVAPI32.266]
|
---|
623 | *
|
---|
624 | * PARAMS
|
---|
625 | * x1 []
|
---|
626 | */
|
---|
627 | BOOL WINAPI
|
---|
628 | QueryWindows31FilesMigration( DWORD x1 )
|
---|
629 | {
|
---|
630 | FIXME(__FUNCTION__"(%ld):stub\n",x1);
|
---|
631 | return TRUE;
|
---|
632 | }
|
---|
633 |
|
---|
634 | /******************************************************************************
|
---|
635 | * SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.265]
|
---|
636 | *
|
---|
637 | * PARAMS
|
---|
638 | * x1 []
|
---|
639 | * x2 []
|
---|
640 | * x3 []
|
---|
641 | * x4 []
|
---|
642 | */
|
---|
643 | BOOL WINAPI
|
---|
644 | SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1, DWORD x2, DWORD x3,
|
---|
645 | DWORD x4 )
|
---|
646 | {
|
---|
647 | FIXME(__FUNCTION__"(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1,x2,x3,x4);
|
---|
648 | return TRUE;
|
---|
649 | }
|
---|
650 |
|
---|
651 | /******************************************************************************
|
---|
652 | * LsaOpenPolicy [ADVAPI32.200]
|
---|
653 | *
|
---|
654 | * PARAMS
|
---|
655 | * x1 []
|
---|
656 | * x2 []
|
---|
657 | * x3 []
|
---|
658 | * x4 []
|
---|
659 | */
|
---|
660 | NTSTATUS WINAPI
|
---|
661 | LsaOpenPolicy(PLSA_UNICODE_STRING SystemName,
|
---|
662 | PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
|
---|
663 | ACCESS_MASK DesiredAccess,
|
---|
664 | PLSA_HANDLE PolicyHandle)
|
---|
665 | {
|
---|
666 | FIXME(__FUNCTION__"(%p,%p,0x%08lx,%p):stub\n",
|
---|
667 | SystemName, ObjectAttributes,
|
---|
668 | DesiredAccess, PolicyHandle);
|
---|
669 | return 0xc0000000; /* generic error */
|
---|
670 | }
|
---|
671 |
|
---|
672 | /******************************************************************************
|
---|
673 | * NotifyBootConfigStatus [ADVAPI32.97]
|
---|
674 | *
|
---|
675 | * PARAMS
|
---|
676 | * x1 []
|
---|
677 | */
|
---|
678 | BOOL WINAPI
|
---|
679 | NotifyBootConfigStatus( DWORD x1 )
|
---|
680 | {
|
---|
681 | FIXME(__FUNCTION__"(0x%08lx):stub\n",x1);
|
---|
682 | return 1;
|
---|
683 | }
|
---|
684 |
|
---|
685 | /******************************************************************************
|
---|
686 | * RevertToSelf [ADVAPI32.180]
|
---|
687 | *
|
---|
688 | * PARAMS
|
---|
689 | * void []
|
---|
690 | */
|
---|
691 | BOOL WINAPI
|
---|
692 | RevertToSelf( void )
|
---|
693 | {
|
---|
694 | FIXME(__FUNCTION__"(), stub\n");
|
---|
695 | return TRUE;
|
---|
696 | }
|
---|
697 |
|
---|
698 | /******************************************************************************
|
---|
699 | * ImpersonateSelf [ADVAPI32.71]
|
---|
700 | */
|
---|
701 | BOOL WINAPI
|
---|
702 | ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
---|
703 | {
|
---|
704 | FIXME(__FUNCTION__"(%08x), stub\n", ImpersonationLevel);
|
---|
705 | return TRUE;
|
---|
706 | }
|
---|
707 |
|
---|
708 | /******************************************************************************
|
---|
709 | * AccessCheck32 [ADVAPI32.71]
|
---|
710 | */
|
---|
711 | BOOL WINAPI
|
---|
712 | AccessCheck(PSECURITY_DESCRIPTOR pSecurityDescriptor, HANDLE ClientToken,
|
---|
713 | DWORD DesiredAccess, PGENERIC_MAPPING GenericMapping, PPRIVILEGE_SET PrivilegeSet,
|
---|
714 | LPDWORD PrivilegeSetLength, LPDWORD GrantedAccess, LPBOOL AccessStatus)
|
---|
715 | {
|
---|
716 | FIXME(__FUNCTION__"(%p, %04x, %08lx, %p, %p, %p, %p, %p), stub\n",
|
---|
717 | pSecurityDescriptor, ClientToken, DesiredAccess, GenericMapping,
|
---|
718 | PrivilegeSet, PrivilegeSetLength, GrantedAccess, AccessStatus);
|
---|
719 | *AccessStatus = TRUE;
|
---|
720 | return TRUE;
|
---|
721 | }
|
---|
722 |
|
---|
723 | /*****************************************************************************
|
---|
724 | * Name : InitializeAcl
|
---|
725 | * Purpose : The InitializeAcl function creates a new ACL structure.
|
---|
726 | * An ACL is an access-control list.
|
---|
727 | * Parameters: PACL pAcl address of access-control list
|
---|
728 | * DWORD nAclLength size of access-control list
|
---|
729 | * DWORD dwAclRevision revision level of access-control list
|
---|
730 | * Variables :
|
---|
731 | * Result :
|
---|
732 | * Remark :
|
---|
733 | * Status : UNTESTED STUB
|
---|
734 | *
|
---|
735 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
---|
736 | *****************************************************************************/
|
---|
737 |
|
---|
738 | BOOL WIN32API InitializeAcl(PACL pAcl,
|
---|
739 | DWORD nAclLength,
|
---|
740 | DWORD dwAclRevision)
|
---|
741 | {
|
---|
742 | dprintf(("ADVAPI32: InitializeAcl(%08xh,%08xh,%08xh)",
|
---|
743 | pAcl,
|
---|
744 | nAclLength,
|
---|
745 | dwAclRevision));
|
---|
746 |
|
---|
747 | CallWin32ToNt (RtlCreateAcl(pAcl, nAclLength, dwAclRevision));
|
---|
748 | }
|
---|
749 |
|
---|
750 | /*****************************************************************************
|
---|
751 | * Name : AddAce
|
---|
752 | * Purpose : The AddAce function adds one or more ACEs to a specified ACL.
|
---|
753 | * An ACE is an access-control entry. An ACL is an access-control list.
|
---|
754 | * Parameters: PACL pAcl address of access-control list
|
---|
755 | * DWORD dwAceRevision ACL revision level
|
---|
756 | * DWORD dwStartingAceIndex index of ACE position in ACL
|
---|
757 | * LPVOID pAceList address of one or more ACEs
|
---|
758 | * DWORD nAceListLength size of buffer for ACEs
|
---|
759 | * Variables :
|
---|
760 | * Result :
|
---|
761 | * Remark :
|
---|
762 | * Status : UNTESTED STUB
|
---|
763 | *
|
---|
764 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
---|
765 | *****************************************************************************/
|
---|
766 |
|
---|
767 | BOOL WIN32API AddAce(PACL pAcl,
|
---|
768 | DWORD dwAceRevision,
|
---|
769 | DWORD dwStartingAceIndex,
|
---|
770 | LPVOID pAceList,
|
---|
771 | DWORD nAceListLength)
|
---|
772 | {
|
---|
773 | CallWin32ToNt (RtlAddAce(pAcl, dwAceRevision, dwStartingAceIndex, (PACE_HEADER)pAceList, nAceListLength));
|
---|
774 | }
|
---|
775 |
|
---|
776 | /*****************************************************************************
|
---|
777 | * Name : AddAccessAllowedAce
|
---|
778 | * Purpose : The AddAccessAllowedAce function adds an access-allowed ACE to
|
---|
779 | * an ACL. The access is granted to a specified SID. An ACE is an
|
---|
780 | * access-control entry. An ACL is an access-control list. A SID is
|
---|
781 | * a security identifier.
|
---|
782 | * Parameters: PACL pAcl address of access-control list
|
---|
783 | * DWORD dwAceRevision ACL revision level
|
---|
784 | * DWORD AccessMask access mask
|
---|
785 | * PSID pSid address of security identifier
|
---|
786 | * Variables :
|
---|
787 | * Result :
|
---|
788 | * Remark :
|
---|
789 | * Status : UNTESTED STUB
|
---|
790 | *
|
---|
791 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
---|
792 | *****************************************************************************/
|
---|
793 |
|
---|
794 | BOOL WIN32API AddAccessAllowedAce(PACL pAcl,
|
---|
795 | DWORD dwAceRevision,
|
---|
796 | DWORD AccessMask,
|
---|
797 | PSID pSid)
|
---|
798 | {
|
---|
799 | CallWin32ToNt (RtlAddAccessAllowedAce(pAcl, dwAceRevision, AccessMask, pSid));
|
---|
800 | }
|
---|
801 |
|
---|
802 | /*****************************************************************************
|
---|
803 | * Name : GetAce
|
---|
804 | * Purpose : The GetAce function obtains a pointer to an ACE in an ACL.
|
---|
805 | * An ACE is an access control entry. An ACL is an access control list.
|
---|
806 | * Parameters: PACL pAcl address of access-control list
|
---|
807 | * DWORD dwAceIndex index of ACE to retrieve
|
---|
808 | * LPVOID *pAce address of pointer to ACE
|
---|
809 | * Variables :
|
---|
810 | * Result :
|
---|
811 | * Remark :
|
---|
812 | * Status : UNTESTED STUB
|
---|
813 | *
|
---|
814 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
---|
815 | *****************************************************************************/
|
---|
816 |
|
---|
817 | BOOL WIN32API GetAce(PACL pAcl,
|
---|
818 | DWORD dwAceIndex,
|
---|
819 | LPVOID *pAce)
|
---|
820 | {
|
---|
821 | CallWin32ToNt (RtlGetAce(pAcl, dwAceIndex, pAce));
|
---|
822 | }
|
---|