Add some resources from Winehq CVS.
[reactos.git] / reactos / lib / advapi32 / sec / misc.c
1 /* $Id: misc.c,v 1.23 2004/09/06 22:12:25 ekohl Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/advapi32/sec/misc.c
6 * PURPOSE: Miscellaneous security functions
7 */
8
9 #include "advapi32.h"
10 #include <accctrl.h>
11
12 #define NDEBUG
13 #include <debug.h>
14
15
16 /*
17 * @implemented
18 */
19 BOOL STDCALL
20 AreAllAccessesGranted(DWORD GrantedAccess,
21 DWORD DesiredAccess)
22 {
23 return((BOOL)RtlAreAllAccessesGranted(GrantedAccess,
24 DesiredAccess));
25 }
26
27
28 /*
29 * @implemented
30 */
31 BOOL STDCALL
32 AreAnyAccessesGranted(DWORD GrantedAccess,
33 DWORD DesiredAccess)
34 {
35 return((BOOL)RtlAreAnyAccessesGranted(GrantedAccess,
36 DesiredAccess));
37 }
38
39
40 /******************************************************************************
41 * GetFileSecurityA [ADVAPI32.@]
42 *
43 * Obtains Specified information about the security of a file or directory.
44 *
45 * PARAMS
46 * lpFileName [I] Name of the file to get info for
47 * RequestedInformation [I] SE_ flags from "winnt.h"
48 * pSecurityDescriptor [O] Destination for security information
49 * nLength [I] Length of pSecurityDescriptor
50 * lpnLengthNeeded [O] Destination for length of returned security information
51 *
52 * RETURNS
53 * Success: TRUE. pSecurityDescriptor contains the requested information.
54 * Failure: FALSE. lpnLengthNeeded contains the required space to return the info.
55 *
56 * NOTES
57 * The information returned is constrained by the callers access rights and
58 * privileges.
59 *
60 * @implemented
61 */
62 BOOL WINAPI
63 GetFileSecurityA(LPCSTR lpFileName,
64 SECURITY_INFORMATION RequestedInformation,
65 PSECURITY_DESCRIPTOR pSecurityDescriptor,
66 DWORD nLength,
67 LPDWORD lpnLengthNeeded)
68 {
69 UNICODE_STRING FileName;
70 NTSTATUS Status;
71 BOOL bResult;
72
73 Status = RtlCreateUnicodeStringFromAsciiz(&FileName,
74 (LPSTR)lpFileName);
75 if (!NT_SUCCESS(Status))
76 {
77 SetLastError(RtlNtStatusToDosError(Status));
78 return FALSE;
79 }
80
81 bResult = GetFileSecurityW(FileName.Buffer,
82 RequestedInformation,
83 pSecurityDescriptor,
84 nLength,
85 lpnLengthNeeded);
86
87 RtlFreeUnicodeString(&FileName);
88
89 return bResult;
90 }
91
92
93 /*
94 * @implemented
95 */
96 BOOL WINAPI
97 GetFileSecurityW(LPCWSTR lpFileName,
98 SECURITY_INFORMATION RequestedInformation,
99 PSECURITY_DESCRIPTOR pSecurityDescriptor,
100 DWORD nLength,
101 LPDWORD lpnLengthNeeded)
102 {
103 OBJECT_ATTRIBUTES ObjectAttributes;
104 IO_STATUS_BLOCK StatusBlock;
105 UNICODE_STRING FileName;
106 ULONG AccessMask = 0;
107 HANDLE FileHandle;
108 NTSTATUS Status;
109
110 DPRINT("GetFileSecurityW() called\n");
111
112 if (RequestedInformation &
113 (OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION))
114 {
115 AccessMask |= STANDARD_RIGHTS_READ;
116 }
117
118 if (RequestedInformation & SACL_SECURITY_INFORMATION)
119 {
120 AccessMask |= ACCESS_SYSTEM_SECURITY;
121 }
122
123 if (!RtlDosPathNameToNtPathName_U((LPWSTR)lpFileName,
124 &FileName,
125 NULL,
126 NULL))
127 {
128 DPRINT("Invalid path\n");
129 SetLastError(ERROR_BAD_PATHNAME);
130 return FALSE;
131 }
132
133 InitializeObjectAttributes(&ObjectAttributes,
134 &FileName,
135 OBJ_CASE_INSENSITIVE,
136 NULL,
137 NULL);
138
139 Status = NtOpenFile(&FileHandle,
140 AccessMask,
141 &ObjectAttributes,
142 &StatusBlock,
143 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
144 0);
145 if (!NT_SUCCESS(Status))
146 {
147 DPRINT("NtOpenFile() failed (Status %lx)\n", Status);
148 SetLastError(RtlNtStatusToDosError(Status));
149 return FALSE;
150 }
151
152 RtlFreeUnicodeString(&FileName);
153
154 Status = NtQuerySecurityObject(FileHandle,
155 RequestedInformation,
156 pSecurityDescriptor,
157 nLength,
158 lpnLengthNeeded);
159 NtClose(FileHandle);
160
161 if (!NT_SUCCESS(Status))
162 {
163 DPRINT("NtQuerySecurityObject() failed (Status %lx)\n", Status);
164 SetLastError(RtlNtStatusToDosError(Status));
165 return FALSE;
166 }
167
168 return TRUE;
169 }
170
171
172 /*
173 * @implemented
174 */
175 BOOL STDCALL
176 GetKernelObjectSecurity(HANDLE Handle,
177 SECURITY_INFORMATION RequestedInformation,
178 PSECURITY_DESCRIPTOR pSecurityDescriptor,
179 DWORD nLength,
180 LPDWORD lpnLengthNeeded)
181 {
182 NTSTATUS Status;
183
184 Status = NtQuerySecurityObject(Handle,
185 RequestedInformation,
186 pSecurityDescriptor,
187 nLength,
188 lpnLengthNeeded);
189 if (!NT_SUCCESS(Status))
190 {
191 SetLastError(RtlNtStatusToDosError(Status));
192 return(FALSE);
193 }
194 return(TRUE);
195 }
196
197
198 /******************************************************************************
199 * SetFileSecurityW [ADVAPI32.@]
200 * Sets the security of a file or directory
201 *
202 * @unimplemented
203 */
204 BOOL STDCALL
205 SetFileSecurityW (LPCWSTR lpFileName,
206 SECURITY_INFORMATION RequestedInformation,
207 PSECURITY_DESCRIPTOR pSecurityDescriptor)
208 {
209 DPRINT1("SetFileSecurityW : stub\n");
210 return TRUE;
211 }
212
213
214 /******************************************************************************
215 * SetFileSecurityA [ADVAPI32.@]
216 * Sets the security of a file or directory
217 *
218 * @unimplemented
219 */
220 BOOL STDCALL
221 SetFileSecurityA (LPCSTR lpFileName,
222 SECURITY_INFORMATION RequestedInformation,
223 PSECURITY_DESCRIPTOR pSecurityDescriptor)
224 {
225 DPRINT("SetFileSecurityA : stub\n");
226 return TRUE;
227 }
228
229
230 /*
231 * @implemented
232 */
233 BOOL STDCALL
234 SetKernelObjectSecurity(HANDLE Handle,
235 SECURITY_INFORMATION SecurityInformation,
236 PSECURITY_DESCRIPTOR SecurityDescriptor)
237 {
238 NTSTATUS Status;
239
240 Status = NtSetSecurityObject(Handle,
241 SecurityInformation,
242 SecurityDescriptor);
243 if (!NT_SUCCESS(Status))
244 {
245 SetLastError(RtlNtStatusToDosError(Status));
246 return FALSE;
247 }
248 return TRUE;
249 }
250
251
252 /*
253 * @implemented
254 */
255 VOID STDCALL
256 MapGenericMask(PDWORD AccessMask,
257 PGENERIC_MAPPING GenericMapping)
258 {
259 RtlMapGenericMask(AccessMask,
260 GenericMapping);
261 }
262
263
264 /*
265 * @implemented
266 */
267 BOOL STDCALL
268 ImpersonateLoggedOnUser(HANDLE hToken)
269 {
270 SECURITY_QUALITY_OF_SERVICE Qos;
271 OBJECT_ATTRIBUTES ObjectAttributes;
272 HANDLE NewToken;
273 TOKEN_TYPE Type;
274 ULONG ReturnLength;
275 BOOL Duplicated;
276 NTSTATUS Status;
277
278 /* Get the token type */
279 Status = NtQueryInformationToken (hToken,
280 TokenType,
281 &Type,
282 sizeof(TOKEN_TYPE),
283 &ReturnLength);
284 if (!NT_SUCCESS(Status))
285 {
286 SetLastError (RtlNtStatusToDosError (Status));
287 return FALSE;
288 }
289
290 if (Type == TokenPrimary)
291 {
292 /* Create a duplicate impersonation token */
293 Qos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
294 Qos.ImpersonationLevel = SecurityImpersonation;
295 Qos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
296 Qos.EffectiveOnly = FALSE;
297
298 ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
299 ObjectAttributes.RootDirectory = NULL;
300 ObjectAttributes.ObjectName = NULL;
301 ObjectAttributes.Attributes = 0;
302 ObjectAttributes.SecurityDescriptor = NULL;
303 ObjectAttributes.SecurityQualityOfService = &Qos;
304
305 Status = NtDuplicateToken (hToken,
306 TOKEN_IMPERSONATE | TOKEN_QUERY,
307 &ObjectAttributes,
308 FALSE,
309 TokenImpersonation,
310 &NewToken);
311 if (!NT_SUCCESS(Status))
312 {
313 SetLastError (RtlNtStatusToDosError (Status));
314 return FALSE;
315 }
316
317 Duplicated = TRUE;
318 }
319 else
320 {
321 /* User the original impersonation token */
322 NewToken = hToken;
323 Duplicated = FALSE;
324 }
325
326 /* Impersonate the the current thread */
327 Status = NtSetInformationThread (NtCurrentThread (),
328 ThreadImpersonationToken,
329 &NewToken,
330 sizeof(HANDLE));
331
332 if (Duplicated == TRUE)
333 {
334 NtClose (NewToken);
335 }
336
337 if (!NT_SUCCESS(Status))
338 {
339 SetLastError (RtlNtStatusToDosError (Status));
340 return FALSE;
341 }
342
343 return TRUE;
344 }
345
346
347 /*
348 * @implemented
349 */
350 BOOL STDCALL
351 ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
352 {
353 NTSTATUS Status;
354
355 Status = RtlImpersonateSelf(ImpersonationLevel);
356 if (!NT_SUCCESS(Status))
357 {
358 SetLastError(RtlNtStatusToDosError(Status));
359 return FALSE;
360 }
361 return TRUE;
362 }
363
364
365 /*
366 * @implemented
367 */
368 BOOL STDCALL
369 RevertToSelf(VOID)
370 {
371 NTSTATUS Status;
372 HANDLE Token = NULL;
373
374 Status = NtSetInformationThread(NtCurrentThread(),
375 ThreadImpersonationToken,
376 &Token,
377 sizeof(HANDLE));
378 if (!NT_SUCCESS(Status))
379 {
380 SetLastError(RtlNtStatusToDosError(Status));
381 return FALSE;
382 }
383 return TRUE;
384 }
385
386
387 /******************************************************************************
388 * GetUserNameA [ADVAPI32.@]
389 *
390 * Get the current user name.
391 *
392 * PARAMS
393 * lpszName [O] Destination for the user name.
394 * lpSize [I/O] Size of lpszName.
395 *
396 * RETURNS
397 * Success: The length of the user name, including terminating NUL.
398 * Failure: ERROR_MORE_DATA if *lpSize is too small.
399 *
400 * @unimplemented
401 */
402 BOOL WINAPI
403 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
404 {
405 // size_t len;
406 // char name[] = { "Administrator" };
407
408 /* We need to include the null character when determining the size of the buffer. */
409 // len = strlen(name) + 1;
410 // if (len > *lpSize)
411 // {
412 // SetLastError(ERROR_MORE_DATA);
413 // *lpSize = len;
414 // return 0;
415 // }
416
417 // *lpSize = len;
418 // strcpy(lpszName, name);
419 DPRINT1("GetUserNameA: stub\n");
420 return TRUE;
421 }
422
423 /******************************************************************************
424 * GetUserNameW [ADVAPI32.@]
425 *
426 * See GetUserNameA.
427 *
428 * @unimplemented
429 */
430 BOOL WINAPI
431 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
432 {
433 // char name[] = { "Administrator" };
434
435 // DWORD len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
436
437 // if (len > *lpSize)
438 // {
439 // SetLastError(ERROR_MORE_DATA);
440 // *lpSize = len;
441 // return FALSE;
442 // }
443
444 // *lpSize = len;
445 // MultiByteToWideChar( CP_ACP, 0, name, -1, lpszName, len );
446 DPRINT1("GetUserNameW: stub\n");
447 return TRUE;
448 }
449
450
451 /******************************************************************************
452 * LookupAccountSidA [ADVAPI32.@]
453 *
454 * @unimplemented
455 */
456 BOOL STDCALL
457 LookupAccountSidA (LPCSTR lpSystemName,
458 PSID lpSid,
459 LPSTR lpName,
460 LPDWORD cchName,
461 LPSTR lpReferencedDomainName,
462 LPDWORD cchReferencedDomainName,
463 PSID_NAME_USE peUse)
464 {
465 DPRINT1("LookupAccountSidA is unimplemented, but returns success\n");
466 lstrcpynA(lpName, "Administrator", *cchName);
467 lstrcpynA(lpReferencedDomainName, "ReactOS", *cchReferencedDomainName);
468 return TRUE;
469 }
470
471
472 /******************************************************************************
473 * LookupAccountSidW [ADVAPI32.@]
474 *
475 * @unimplemented
476 */
477 BOOL STDCALL
478 LookupAccountSidW (LPCWSTR lpSystemName,
479 PSID lpSid,
480 LPWSTR lpName,
481 LPDWORD cchName,
482 LPWSTR lpReferencedDomainName,
483 LPDWORD cchReferencedDomainName,
484 PSID_NAME_USE peUse)
485 {
486 DPRINT1("LookupAccountSidW is unimplemented, but returns success\n");
487 lstrcpynW(lpName, L"Administrator", *cchName);
488 lstrcpynW(lpReferencedDomainName, L"ReactOS", *cchReferencedDomainName);
489 return TRUE;
490 }
491
492
493 /**********************************************************************
494 * LookupPrivilegeValueA EXPORTED
495 *
496 * @implemented
497 */
498 BOOL STDCALL
499 LookupPrivilegeValueA (LPCSTR lpSystemName,
500 LPCSTR lpName,
501 PLUID lpLuid)
502 {
503 UNICODE_STRING SystemName;
504 UNICODE_STRING Name;
505 BOOL Result;
506
507 /* Remote system? */
508 if (lpSystemName != NULL)
509 {
510 RtlCreateUnicodeStringFromAsciiz (&SystemName,
511 (LPSTR)lpSystemName);
512 }
513
514 /* Check the privilege name is not NULL */
515 if (lpName == NULL)
516 {
517 SetLastError (ERROR_INVALID_PARAMETER);
518 return FALSE;
519 }
520
521 RtlCreateUnicodeStringFromAsciiz (&Name,
522 (LPSTR)lpName);
523
524 Result = LookupPrivilegeValueW ((lpSystemName != NULL) ? SystemName.Buffer : NULL,
525 Name.Buffer,
526 lpLuid);
527
528 RtlFreeUnicodeString (&Name);
529
530 /* Remote system? */
531 if (lpSystemName != NULL)
532 {
533 RtlFreeUnicodeString (&SystemName);
534 }
535
536 return Result;
537 }
538
539
540 /**********************************************************************
541 * LookupPrivilegeValueW EXPORTED
542 *
543 * @unimplemented
544 */
545 BOOL STDCALL
546 LookupPrivilegeValueW (LPCWSTR SystemName,
547 LPCWSTR PrivName,
548 PLUID Luid)
549 {
550 static const WCHAR * const DefaultPrivNames[] =
551 {
552 L"SeCreateTokenPrivilege",
553 L"SeAssignPrimaryTokenPrivilege",
554 L"SeLockMemoryPrivilege",
555 L"SeIncreaseQuotaPrivilege",
556 L"SeUnsolicitedInputPrivilege",
557 L"SeMachineAccountPrivilege",
558 L"SeTcbPrivilege",
559 L"SeSecurityPrivilege",
560 L"SeTakeOwnershipPrivilege",
561 L"SeLoadDriverPrivilege",
562 L"SeSystemProfilePrivilege",
563 L"SeSystemtimePrivilege",
564 L"SeProfileSingleProcessPrivilege",
565 L"SeIncreaseBasePriorityPrivilege",
566 L"SeCreatePagefilePrivilege",
567 L"SeCreatePermanentPrivilege",
568 L"SeBackupPrivilege",
569 L"SeRestorePrivilege",
570 L"SeShutdownPrivilege",
571 L"SeDebugPrivilege",
572 L"SeAuditPrivilege",
573 L"SeSystemEnvironmentPrivilege",
574 L"SeChangeNotifyPrivilege",
575 L"SeRemoteShutdownPrivilege",
576 L"SeUndockPrivilege",
577 L"SeSyncAgentPrivilege",
578 L"SeEnableDelegationPrivilege",
579 L"SeManageVolumePrivilege",
580 L"SeImpersonatePrivilege",
581 L"SeCreateGlobalPrivilege"
582 };
583 unsigned Priv;
584
585 if (NULL != SystemName && L'\0' != *SystemName)
586 {
587 DPRINT1("LookupPrivilegeValueW: not implemented for remote system\n");
588 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
589 return FALSE;
590 }
591
592 for (Priv = 0; Priv < sizeof(DefaultPrivNames) / sizeof(DefaultPrivNames[0]); Priv++)
593 {
594 if (0 == wcscmp(PrivName, DefaultPrivNames[Priv]))
595 {
596 Luid->LowPart = Priv + 1;
597 Luid->HighPart = 0;
598 return TRUE;
599 }
600 }
601
602 DPRINT1("LookupPrivilegeValueW: no such privilege %S\n", PrivName);
603 SetLastError(ERROR_NO_SUCH_PRIVILEGE);
604 return FALSE;
605 }
606
607
608 /**********************************************************************
609 * LookupPrivilegeDisplayNameA EXPORTED
610 *
611 * @unimplemented
612 */
613 BOOL STDCALL
614 LookupPrivilegeDisplayNameA (LPCSTR lpSystemName,
615 LPCSTR lpName,
616 LPSTR lpDisplayName,
617 LPDWORD cbDisplayName,
618 LPDWORD lpLanguageId)
619 {
620 DPRINT1("LookupPrivilegeDisplayNameA: stub\n");
621 SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
622 return FALSE;
623 }
624
625
626 /**********************************************************************
627 * LookupPrivilegeDisplayNameW EXPORTED
628 *
629 * @unimplemented
630 */
631 BOOL STDCALL
632 LookupPrivilegeDisplayNameW (LPCWSTR lpSystemName,
633 LPCWSTR lpName,
634 LPWSTR lpDisplayName,
635 LPDWORD cbDisplayName,
636 LPDWORD lpLanguageId)
637 {
638 DPRINT1("LookupPrivilegeDisplayNameW: stub\n");
639 SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
640 return FALSE;
641 }
642
643
644 /**********************************************************************
645 * LookupPrivilegeNameA EXPORTED
646 *
647 * @unimplemented
648 */
649 BOOL STDCALL
650 LookupPrivilegeNameA (LPCSTR lpSystemName,
651 PLUID lpLuid,
652 LPSTR lpName,
653 LPDWORD cbName)
654 {
655 DPRINT1("LookupPrivilegeNameA: stub\n");
656 SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
657 return FALSE;
658 }
659
660
661 /**********************************************************************
662 * LookupPrivilegeNameW EXPORTED
663 *
664 * @unimplemented
665 */
666 BOOL STDCALL
667 LookupPrivilegeNameW (LPCWSTR lpSystemName,
668 PLUID lpLuid,
669 LPWSTR lpName,
670 LPDWORD cbName)
671 {
672 DPRINT1("LookupPrivilegeNameW: stub\n");
673 SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
674 return FALSE;
675 }
676
677
678 /**********************************************************************
679 * GetNamedSecurityInfoW EXPORTED
680 *
681 * @unimplemented
682 */
683 DWORD STDCALL
684 GetNamedSecurityInfoW(LPWSTR pObjectName,
685 SE_OBJECT_TYPE ObjectType,
686 SECURITY_INFORMATION SecurityInfo,
687 PSID *ppsidOwner,
688 PSID *ppsidGroup,
689 PACL *ppDacl,
690 PACL *ppSacl,
691 PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
692 {
693 DPRINT1("GetNamedSecurityInfoW: stub\n");
694 return ERROR_CALL_NOT_IMPLEMENTED;
695 }
696
697
698 /**********************************************************************
699 * GetNamedSecurityInfoA EXPORTED
700 *
701 * @unimplemented
702 */
703 DWORD STDCALL
704 GetNamedSecurityInfoA(LPSTR pObjectName,
705 SE_OBJECT_TYPE ObjectType,
706 SECURITY_INFORMATION SecurityInfo,
707 PSID *ppsidOwner,
708 PSID *ppsidGroup,
709 PACL *ppDacl,
710 PACL *ppSacl,
711 PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
712 {
713 DPRINT1("GetNamedSecurityInfoA: stub\n");
714 return ERROR_CALL_NOT_IMPLEMENTED;
715 }
716
717
718 /**********************************************************************
719 * SetNamedSecurityInfoW EXPORTED
720 *
721 * @unimplemented
722 */
723 DWORD STDCALL
724 SetNamedSecurityInfoW(LPWSTR pObjectName,
725 SE_OBJECT_TYPE ObjectType,
726 SECURITY_INFORMATION SecurityInfo,
727 PSID psidOwner,
728 PSID psidGroup,
729 PACL pDacl,
730 PACL pSacl)
731 {
732 DPRINT1("SetNamedSecurityInfoW: stub\n");
733 return ERROR_CALL_NOT_IMPLEMENTED;
734 }
735
736
737 /**********************************************************************
738 * SetNamedSecurityInfoA EXPORTED
739 *
740 * @unimplemented
741 */
742 DWORD STDCALL
743 SetNamedSecurityInfoA(LPSTR pObjectName,
744 SE_OBJECT_TYPE ObjectType,
745 SECURITY_INFORMATION SecurityInfo,
746 PSID psidOwner,
747 PSID psidGroup,
748 PACL pDacl,
749 PACL pSacl)
750 {
751 DPRINT1("SetNamedSecurityInfoA: stub\n");
752 return ERROR_CALL_NOT_IMPLEMENTED;
753 }
754
755
756 /**********************************************************************
757 * GetSecurityInfo EXPORTED
758 *
759 * @unimplemented
760 */
761 DWORD STDCALL
762 GetSecurityInfo(HANDLE handle,
763 SE_OBJECT_TYPE ObjectType,
764 SECURITY_INFORMATION SecurityInfo,
765 PSID* ppsidOwner,
766 PSID* ppsidGroup,
767 PACL* ppDacl,
768 PACL* ppSacl,
769 PSECURITY_DESCRIPTOR* ppSecurityDescriptor)
770 {
771 DPRINT1("GetSecurityInfo: stub\n");
772 return ERROR_CALL_NOT_IMPLEMENTED;
773 }
774
775
776 /**********************************************************************
777 * ImpersonateNamedPipeClient EXPORTED
778 *
779 * @implemented
780 */
781 BOOL STDCALL
782 ImpersonateNamedPipeClient(HANDLE hNamedPipe)
783 {
784 IO_STATUS_BLOCK StatusBlock;
785 NTSTATUS Status;
786
787 DPRINT("ImpersonateNamedPipeClient() called\n");
788
789 Status = NtFsControlFile(hNamedPipe,
790 NULL,
791 NULL,
792 NULL,
793 &StatusBlock,
794 FSCTL_PIPE_IMPERSONATE,
795 NULL,
796 0,
797 NULL,
798 0);
799 if (!NT_SUCCESS(Status))
800 {
801 SetLastError(RtlNtStatusToDosError(Status));
802 return FALSE;
803 }
804
805 return TRUE;
806 }
807
808 /* EOF */