ReactOS 0.4.16-dev-311-g9382aa2
aclui.c
Go to the documentation of this file.
1/*
2 * ReactOS Access Control List Editor
3 * Copyright (C) 2004-2005 ReactOS Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19/*
20 * PROJECT: ReactOS Access Control List Editor
21 * FILE: lib/aclui/aclui.c
22 * PURPOSE: Access Control List Editor
23 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
24 *
25 * UPDATE HISTORY:
26 * 08/10/2004 Created
27 */
28
29#include "precomp.h"
30
31#include <sddl.h>
32
33#define NDEBUG
34#include <debug.h>
35
36#include "resource.h"
37
39
40#define SIDN_LOOKUPSUCCEEDED (0x101)
42{
47
48static PSID
50{
51 PSID Sid = NULL;
52 switch (AceHeader->AceType)
53 {
55 Sid = (PSID)&((PACCESS_ALLOWED_ACE)AceHeader)->SidStart;
56 break;
57#if 0
59 Sid = (PSID)&((PACCESS_ALLOWED_CALLBACK_ACE)AceHeader)->SidStart;
60 break;
62 Sid = (PSID)&((PACCESS_ALLOWED_CALLBACK_OBJECT_ACE)AceHeader)->SidStart;
63 break;
64#endif
66 Sid = (PSID)&((PACCESS_ALLOWED_OBJECT_ACE)AceHeader)->SidStart;
67 break;
69 Sid = (PSID)&((PACCESS_DENIED_ACE)AceHeader)->SidStart;
70 break;
71#if 0
73 Sid = (PSID)&((PACCESS_DENIED_CALLBACK_ACE)AceHeader)->SidStart;
74 break;
76 Sid = (PSID)&((PACCESS_DENIED_CALLBACK_OBJECT_ACE)AceHeader)->SidStart;
77 break;
78#endif
80 Sid = (PSID)&((PACCESS_DENIED_OBJECT_ACE)AceHeader)->SidStart;
81 break;
82 }
83
84 return Sid;
85}
86
87static VOID
89{
90 DestroySidCacheMgr(sp->SidCacheMgr);
91
92 if (sp->OwnerSid != NULL)
93 LocalFree((HLOCAL)sp->OwnerSid);
94
96 0,
97 sp);
98
100}
101
102static VOID
104 IN PPRINCIPAL_LISTITEM *PrincipalsListHead)
105{
107 PACE_ENTRY AceEntry, NextAceEntry;
108
109 CurItem = *PrincipalsListHead;
110 while (CurItem != NULL)
111 {
112 /* Free all ACEs */
113 AceEntry = CurItem->ACEs;
114 while (AceEntry != NULL)
115 {
116 NextAceEntry = AceEntry->Next;
118 0,
119 AceEntry);
120 AceEntry = NextAceEntry;
121 }
122
123 /* free the SID string if present */
124 if (CurItem->SidReqResult != NULL)
125 {
126 DereferenceSidReqResult(sp->SidCacheMgr,
127 CurItem->SidReqResult);
128 }
129
130 if (CurItem->DisplayString != NULL)
131 {
132 LocalFree((HLOCAL)CurItem->DisplayString);
133 }
134
135 /* free the ACE list item */
136 NextItem = CurItem->Next;
138 0,
139 CurItem);
140 CurItem = NextItem;
141 }
142
143 *PrincipalsListHead = NULL;
144}
145
146static PACE_ENTRY
148 IN PACE_HEADER AceHeader)
149{
150 PACE_ENTRY AceEntry, *AceLink;
151
152 AceEntry = HeapAlloc(GetProcessHeap(),
153 0,
154 sizeof(ACE_ENTRY) + AceHeader->AceSize);
155 if (AceEntry != NULL)
156 {
157 AceEntry->Next = NULL;
158
159 /* copy the ACE */
160 CopyMemory(AceEntry + 1,
161 AceHeader,
162 AceHeader->AceSize);
163
164 /* append it to the list */
165 AceLink = &Principal->ACEs;
166 while (*AceLink != NULL)
167 {
168 AceLink = &(*AceLink)->Next;
169 }
170 *AceLink = AceEntry;
171 }
172
173 return AceEntry;
174}
175
178 IN PSID Sid,
179 IN PACE_HEADER AceHeader)
180{
181 PPRINCIPAL_LISTITEM CurItem;
182
183 for (CurItem = PrincipalsListHead;
184 CurItem != NULL;
185 CurItem = CurItem->Next)
186 {
187 if (EqualSid((PSID)(CurItem + 1),
188 Sid))
189 {
190 if (AddAceToPrincipal(CurItem,
191 AceHeader) != NULL)
192 {
193 return CurItem;
194 }
195
196 /* unable to add the ACE to the principal */
197 break;
198 }
199 }
200
201 return NULL;
202}
203
204static VOID
206 IN PSID Sid,
207 IN PSIDREQRESULT SidRequestResult,
209{
211
212 /* NOTE: this routine may be executed in a different thread
213 than the GUI! */
214
215 if (SidRequestResult != NULL)
216 {
217 SIDLOOKUPNOTIFYINFO LookupInfo;
218
219 LookupInfo.nmh.hwndFrom = sp->hWnd;
220 LookupInfo.nmh.idFrom = 0;
221 LookupInfo.nmh.code = SIDN_LOOKUPSUCCEEDED;
222 LookupInfo.Sid = Sid;
223 LookupInfo.SidRequestResult = SidRequestResult;
224
225 /* notify the page that the sid lookup succeeded */
226 SendMessage(sp->hWnd,
227 WM_NOTIFY,
228 (WPARAM)LookupInfo.nmh.idFrom,
229 (LPARAM)&LookupInfo.nmh);
230 }
231}
232
235 IN PSID Sid,
236 IN PACE_HEADER AceHeader,
237 OUT BOOL *LookupDeferred OPTIONAL)
238{
239 PPRINCIPAL_LISTITEM PrincipalListItem = NULL, *PrincipalLink;
240 PACE_ENTRY AceEntry;
241 BOOL Deferred = FALSE;
242
243 if (!FindSidInPrincipalsListAddAce(sp->PrincipalsListHead,
244 Sid,
245 AceHeader))
246 {
247 DWORD SidLength;
248
249 PrincipalLink = &sp->PrincipalsListHead;
250 while (*PrincipalLink != NULL)
251 {
252 PrincipalLink = &(*PrincipalLink)->Next;
253 }
254
255 SidLength = GetLengthSid(Sid);
256
257 /* allocate the principal */
258 PrincipalListItem = HeapAlloc(GetProcessHeap(),
259 0,
260 sizeof(PRINCIPAL_LISTITEM) + SidLength);
261 if (PrincipalListItem != NULL)
262 {
263 PrincipalListItem->DisplayString = NULL;
264 PrincipalListItem->SidReqResult = NULL;
265
266 CopySid(SidLength,
267 (PSID)(PrincipalListItem + 1),
268 Sid);
269
270 /* allocate some memory for the ACE and copy it */
271 AceEntry = HeapAlloc(GetProcessHeap(),
272 0,
273 sizeof(ACE_ENTRY) + AceHeader->AceSize);
274 if (AceEntry != NULL)
275 {
276 AceEntry->Next = NULL;
277 CopyMemory(AceEntry + 1,
278 AceHeader,
279 AceHeader->AceSize);
280
281 /* add the ACE to the list */
282 PrincipalListItem->ACEs = AceEntry;
283
284 PrincipalListItem->Next = NULL;
285
286 /* append item to the principals list */
287 *PrincipalLink = PrincipalListItem;
288
289 /* lookup the SID now */
290 Deferred = !LookupSidCache(sp->SidCacheMgr,
291 Sid,
293 sp);
294 }
295 else
296 {
298 0,
299 PrincipalListItem);
300 PrincipalListItem = NULL;
301 }
302 }
303 }
304
305 if (PrincipalListItem != NULL && LookupDeferred != NULL)
306 {
307 *LookupDeferred = Deferred;
308 }
309
310 return PrincipalListItem;
311}
312
313static LPWSTR
315{
316 LPWSTR lpDisplayString = NULL;
317
318 if (SidReqResult->SidNameUse == SidTypeUser ||
319 SidReqResult->SidNameUse == SidTypeGroup)
320 {
323 &lpDisplayString,
324 SidReqResult->AccountName,
325 SidReqResult->DomainName,
326 SidReqResult->AccountName);
327 }
328 else
329 {
332 &lpDisplayString,
333 SidReqResult->AccountName);
334 }
335
336 return lpDisplayString;
337}
338
339static LPWSTR
341{
342 LPWSTR lpDisplayString = NULL;
343
344 if (PrincipalListItem->SidReqResult != NULL)
345 {
346 lpDisplayString = GetDisplayStringFromSidRequestResult(PrincipalListItem->SidReqResult);
347 }
348 else
349 {
350 ConvertSidToStringSidW((PSID)(PrincipalListItem + 1),
351 &lpDisplayString);
352 }
353
354 return lpDisplayString;
355}
356
357static LPWSTR
359{
360 LPWSTR lpDisplayString = NULL;
361
362 if (PrincipalListItem->SidReqResult != NULL)
363 {
366 &lpDisplayString,
367 PrincipalListItem->SidReqResult->AccountName);
368 }
369 else
370 {
371 ConvertSidToStringSid((PSID)(PrincipalListItem + 1),
372 &lpDisplayString);
373 }
374
375 return lpDisplayString;
376}
377
378static VOID
381 IN PPRINCIPAL_LISTITEM PrincipalListItem,
382 IN INT Index,
383 IN BOOL Selected)
384{
385 INT ImageIndex = 2;
386
387 if (PrincipalListItem->SidReqResult != NULL)
388 {
389 switch (PrincipalListItem->SidReqResult->SidNameUse)
390 {
391 case SidTypeUser:
392 ImageIndex = 0;
393 break;
395 case SidTypeGroup:
396 ImageIndex = 1;
397 break;
398 default:
399 break;
400 }
401 }
402
404 li->iItem = Index;
405 li->iSubItem = 0;
406 li->state = (Selected ? LVIS_SELECTED : 0);
407 li->stateMask = LVIS_SELECTED;
408 li->pszText = PrincipalListItem->DisplayString;
409 li->iImage = ImageIndex;
410 li->lParam = (LPARAM)PrincipalListItem;
411}
412
413static INT
415 IN PPRINCIPAL_LISTITEM PrincipalListItem,
416 IN INT Index,
417 IN BOOL Selected)
418{
419 LVITEM li;
420 INT Ret;
421
422 if (PrincipalListItem->DisplayString != NULL)
423 {
424 LocalFree((HLOCAL)PrincipalListItem->DisplayString);
425 }
426 PrincipalListItem->DisplayString = GetPrincipalDisplayString(PrincipalListItem);
427
429 sp,
430 PrincipalListItem,
431 Index,
432 Selected);
433
434 Ret = ListView_InsertItem(sp->hWndPrincipalsList,
435 &li);
436
437 return Ret;
438}
439
440static int CALLBACK
442 IN LPARAM lParam2,
443 IN LPARAM lParamSort)
444{
447
448 if (Item1->DisplayString != NULL && Item2->DisplayString != NULL)
449 {
450 return wcscmp(Item1->DisplayString,
451 Item2->DisplayString);
452 }
453
454 return 0;
455}
456
457static VOID
459 IN INT PrincipalIndex,
460 IN PPRINCIPAL_LISTITEM PrincipalListItem,
461 IN PSIDREQRESULT SidReqResult)
462{
463 LVITEM li;
464
465 /* replace the request result structure */
466 if (PrincipalListItem->SidReqResult != NULL)
467 {
468 DereferenceSidReqResult(sp->SidCacheMgr,
469 PrincipalListItem->SidReqResult);
470 }
471
472 ReferenceSidReqResult(sp->SidCacheMgr,
473 SidReqResult);
474 PrincipalListItem->SidReqResult = SidReqResult;
475
476 /* update the display string */
477 if (PrincipalListItem->DisplayString != NULL)
478 {
479 LocalFree((HLOCAL)PrincipalListItem->DisplayString);
480 }
481 PrincipalListItem->DisplayString = GetPrincipalDisplayString(PrincipalListItem);
482
483 /* update the list item */
485 sp,
486 PrincipalListItem,
487 PrincipalIndex,
488 FALSE);
489
490 /* don't change the list item state */
491 li.mask &= ~(LVIF_STATE | LVIF_PARAM);
492
493 (void)ListView_SetItem(sp->hWndPrincipalsList,
494 &li);
495
496 /* sort the principals list view again */
497 (void)ListView_SortItems(sp->hWndPrincipalsList,
499 (LPARAM)sp);
500}
501
502static VOID
504{
507 PACL Dacl = NULL;
508 PSID OwnerSid = NULL;
509 LPTSTR OwnerSidString;
510 DWORD SidLen;
511 HRESULT hRet;
512
513 /* delete the cached ACL */
515 &sp->PrincipalsListHead);
516
517 /* query the ACL */
518 hRet = sp->psi->lpVtbl->GetSecurity(sp->psi,
521 FALSE);
522 if (SUCCEEDED(hRet) && SecurityDescriptor != NULL)
523 {
525 &OwnerSid,
527 {
528 sp->OwnerDefaulted = OwnerDefaulted;
529 if (sp->OwnerSid != NULL)
530 {
531 LocalFree((HLOCAL)sp->OwnerSid);
532 sp->OwnerSid = NULL;
533 }
534
535 SidLen = GetLengthSid(OwnerSid);
536 if (SidLen == 0)
537 goto ClearOwner;
538
539 sp->OwnerSid = (PSID)LocalAlloc(LMEM_FIXED,
540 SidLen);
541 if (sp->OwnerSid != NULL)
542 {
543 if (CopySid(SidLen,
544 sp->OwnerSid,
545 OwnerSid))
546 {
547 /* Lookup the SID now */
548 if (!LookupSidCache(sp->SidCacheMgr,
549 sp->OwnerSid,
551 sp))
552 {
553 /* Lookup was deferred */
554 if (ConvertSidToStringSid(sp->OwnerSid,
555 &OwnerSidString))
556 {
557 SetDlgItemText(sp->hWnd,
558 IDC_OWNER,
559 OwnerSidString);
560 LocalFree((HLOCAL)OwnerSidString);
561 }
562 else
563 goto ClearOwner;
564 }
565 }
566 else
567 goto ClearOwner;
568 }
569 else
570 goto ClearOwner;
571 }
572 else
573 {
574ClearOwner:
575 SetDlgItemText(sp->hWnd,
576 IDC_OWNER,
577 NULL);
578 }
579
582 &Dacl,
583 &DaclDefaulted) &&
584 DaclPresent && Dacl != NULL)
585 {
586 PSID Sid;
587 PACE_HEADER AceHeader;
589
590 for (AceIndex = 0;
591 AceIndex < Dacl->AceCount;
592 AceIndex++)
593 {
594 if (GetAce(Dacl,
595 AceIndex,
596 (LPVOID*)&AceHeader) &&
597 AceHeader != NULL)
598 {
599 BOOL LookupDeferred;
600 PPRINCIPAL_LISTITEM PrincipalListItem;
601
602 Sid = AceHeaderToSID(AceHeader);
603
604 PrincipalListItem = AddPrincipalToList(sp,
605 Sid,
606 AceHeader,
607 &LookupDeferred);
608
609 if (PrincipalListItem != NULL && LookupDeferred)
610 {
612 PrincipalListItem,
613 -1,
614 FALSE);
615 }
616 }
617 }
618 }
620 }
621}
622
623static VOID
625{
627
628 EnableWindow(sp->hBtnRemove,
629 Selected != NULL);
630 EnableWindow(sp->hAceCheckList,
631 Selected != NULL);
632
633 if (Selected != NULL)
634 {
635 LPWSTR szLabel;
636 LPWSTR szDisplayString;
637
638 szDisplayString = GetPrincipalAccountNameString(Selected);
641 &szLabel,
642 szDisplayString))
643 {
644 SetWindowText(sp->hPermissionsForLabel,
645 szLabel);
646
647 LocalFree((HLOCAL)szLabel);
648 }
649
650 LocalFree((HLOCAL)szDisplayString);
651
652 /* FIXME - update the checkboxes */
653 }
654 else
655 {
656 WCHAR szPermissions[255];
657
660 szPermissions,
661 sizeof(szPermissions) / sizeof(szPermissions[0])))
662 {
663 SetWindowText(sp->hPermissionsForLabel,
664 szPermissions);
665 }
666
667 SendMessage(sp->hAceCheckList,
669 0,
670 0);
671 }
672}
673
674static void
676 IN PSIDLOOKUPNOTIFYINFO LookupInfo)
677{
678 PPRINCIPAL_LISTITEM CurItem;
679 LPWSTR DisplayName;
680
681 if (sp->OwnerSid != NULL &&
682 EqualSid(sp->OwnerSid,
683 LookupInfo->Sid))
684 {
685 if (LookupInfo->SidRequestResult != NULL)
686 DisplayName = GetDisplayStringFromSidRequestResult(LookupInfo->SidRequestResult);
687 else if (!ConvertSidToStringSidW(LookupInfo->Sid,
688 &DisplayName))
689 {
690 DisplayName = NULL;
691 }
692
693 if (DisplayName != NULL)
694 {
695 SetDlgItemTextW(sp->hWnd,
696 IDC_OWNER,
697 DisplayName);
698
699 LocalFree((HLOCAL)DisplayName);
700 }
701 }
702
703 for (CurItem = sp->PrincipalsListHead;
704 CurItem != NULL;
705 CurItem = CurItem->Next)
706 {
707 if (EqualSid((PSID)(CurItem + 1),
708 LookupInfo->Sid))
709 {
710 INT PrincipalIndex;
711 LVFINDINFO lvfi;
712
713 /* find the principal in the list */
714 lvfi.flags = LVFI_PARAM;
715 lvfi.lParam = (LPARAM)CurItem;
716 PrincipalIndex = ListView_FindItem(sp->hWndPrincipalsList,
717 -1,
718 &lvfi);
719
720 if (PrincipalIndex != -1)
721 {
722 /* update the principal in the list view control */
724 PrincipalIndex,
725 CurItem,
726 LookupInfo->SidRequestResult);
727
728 if (ListViewGetSelectedItemData(sp->hWndPrincipalsList) == (LPARAM)CurItem)
729 {
731 }
732 }
733 else
734 {
736 CurItem,
737 -1,
738 FALSE);
739 }
740 break;
741 }
742 }
743}
744
745static UINT CALLBACK
747 IN UINT uMsg,
748 IN LPPROPSHEETPAGE ppsp)
749{
750 PSECURITY_PAGE sp = (PSECURITY_PAGE)ppsp->lParam;
751
752 switch (uMsg)
753 {
754 case PSPCB_CREATE:
755 {
756 return TRUE;
757 }
758 case PSPCB_RELEASE:
759 {
761 return FALSE;
762 }
763 }
764
765 return FALSE;
766}
767
768static VOID
770 IN UINT Button,
771 IN HWND hLabel)
772{
773 POINT pt;
774 RECT rcLabel;
775
776 GetWindowRect(hLabel,
777 &rcLabel);
778 pt.y = 0;
779 pt.x = (rcLabel.right - rcLabel.left) / 2;
780 MapWindowPoints(hLabel,
781 hAceCheckList,
782 &pt,
783 1);
784
785 SendMessage(hAceCheckList,
787 Button,
788 pt.x);
789}
790
791static VOID
793 IN GUID *GuidObjectType,
795 OUT SI_ACCESS *DefaultAccess)
796{
797 HRESULT hRet;
798 PSI_ACCESS AccessList;
799 ULONG nAccessList, DefaultAccessIndex;
800 WCHAR szSpecialPermissions[255];
801 BOOLEAN SpecialPermissionsPresent = FALSE;
802 ACCESS_MASK SpecialPermissionsMask = 0;
803
804 /* clear the permissions list */
805
806 SendMessage(sp->hAceCheckList,
807 CLM_CLEAR,
808 0,
809 0);
810
811 /* query the access rights from the server */
812 hRet = sp->psi->lpVtbl->GetAccessRights(sp->psi,
813 GuidObjectType,
814 dwFlags, /* FIXME */
815 &AccessList,
816 &nAccessList,
817 &DefaultAccessIndex);
818 if (SUCCEEDED(hRet) && nAccessList != 0)
819 {
820 LPCWSTR NameStr;
821 PSI_ACCESS CurAccess, LastAccess;
822 WCHAR NameBuffer[MAX_PATH];
823
824 /* save the default access rights to be used when adding ACEs later */
825 if (DefaultAccess != NULL)
826 {
827 *DefaultAccess = AccessList[DefaultAccessIndex];
828 }
829
830 LastAccess = AccessList + nAccessList;
831 for (CurAccess = &AccessList[0];
832 CurAccess != LastAccess;
833 CurAccess++)
834 {
835 if (CurAccess->dwFlags & dwFlags)
836 {
837 /* get the permission name, load it from a string table if necessary */
838 if (IS_INTRESOURCE(CurAccess->pszName))
839 {
840 if (!LoadString(sp->ObjectInfo.hInstance,
841 (UINT)((ULONG_PTR)CurAccess->pszName),
842 NameBuffer,
843 sizeof(NameBuffer) / sizeof(NameBuffer[0])))
844 {
847 NameBuffer,
848 sizeof(NameBuffer) / sizeof(NameBuffer[0]));
849 }
850 NameStr = NameBuffer;
851 }
852 else
853 {
854 NameStr = CurAccess->pszName;
855 }
856
857 SendMessage(sp->hAceCheckList,
859 (WPARAM)CurAccess->mask,
860 (LPARAM)NameStr);
861 }
862 else if (CurAccess->dwFlags & SI_ACCESS_SPECIFIC)
863 {
864 SpecialPermissionsPresent = TRUE;
865 SpecialPermissionsMask |= CurAccess->mask;
866 }
867 }
868 }
869
870 /* add the special permissions check item in case the specific access rights
871 aren't displayed */
872 if (SpecialPermissionsPresent &&
875 szSpecialPermissions,
876 sizeof(szSpecialPermissions) / sizeof(szSpecialPermissions[0])))
877 {
878 /* add the special permissions check item */
879 sp->SpecialPermCheckIndex = (INT)SendMessage(sp->hAceCheckList,
881 (WPARAM)SpecialPermissionsMask,
882 (LPARAM)szSpecialPermissions);
883 if (sp->SpecialPermCheckIndex != -1)
884 {
885 SendMessage(sp->hAceCheckList,
887 (WPARAM)sp->SpecialPermCheckIndex,
889 }
890 }
891}
892
893static VOID
895 IN INT Width,
896 IN INT Height)
897{
898 HWND hWndAllow, hWndDeny, hWndOwnerEdit;
899 RECT rcControl, rcControl2, rcControl3, rcWnd;
900 INT cxWidth, cxEdge, btnSpacing;
901 POINT pt, pt2;
902 HDWP dwp;
903 INT nControls = 8;
904 LVCOLUMN lvc;
905
906 hWndAllow = GetDlgItem(sp->hWnd,
908 hWndDeny = GetDlgItem(sp->hWnd,
910
911 GetWindowRect(sp->hWnd,
912 &rcWnd);
913
914 cxEdge = GetSystemMetrics(SM_CXEDGE);
915
916 /* use the left margin of the principal list view control for all control
917 margins */
918 pt.x = 0;
919 pt.y = 0;
920 MapWindowPoints(sp->hWndPrincipalsList,
921 sp->hWnd,
922 &pt,
923 1);
924 cxWidth = Width - (2 * pt.x);
925
926 if (sp->ObjectInfo.dwFlags & SI_ADVANCED)
927 {
928 nControls += 2;
929 }
930
931 if ((dwp = BeginDeferWindowPos(nControls)))
932 {
933 /* resize the owner edit field */
934 hWndOwnerEdit = GetDlgItem(sp->hWnd,
935 IDC_OWNER);
936 GetWindowRect(hWndOwnerEdit,
937 &rcControl);
938 pt2.x = 0;
939 pt2.y = 0;
940 MapWindowPoints(hWndOwnerEdit,
941 sp->hWnd,
942 &pt2,
943 1);
944 if (!(dwp = DeferWindowPos(dwp,
945 hWndOwnerEdit,
946 NULL,
947 0,
948 0,
949 Width - pt.x - pt2.x,
950 rcControl.bottom - rcControl.top,
952 {
953 goto EndDeferWnds;
954 }
955
956 /* resize the Principal list view */
957 GetWindowRect(sp->hWndPrincipalsList,
958 &rcControl);
959 if (!(dwp = DeferWindowPos(dwp,
960 sp->hWndPrincipalsList,
961 NULL,
962 0,
963 0,
964 cxWidth,
965 rcControl.bottom - rcControl.top,
967 {
968 goto EndDeferWnds;
969 }
970
971 /* move the Add Principal button */
972 GetWindowRect(sp->hBtnAdd,
973 &rcControl);
974 GetWindowRect(sp->hBtnRemove,
975 &rcControl2);
976 btnSpacing = rcControl2.left - rcControl.right;
977 pt2.x = 0;
978 pt2.y = 0;
979 MapWindowPoints(sp->hBtnAdd,
980 sp->hWnd,
981 &pt2,
982 1);
983 if (!(dwp = DeferWindowPos(dwp,
984 sp->hBtnAdd,
985 NULL,
986 pt.x + cxWidth - (rcControl2.right - rcControl2.left) -
987 (rcControl.right - rcControl.left) -
988 btnSpacing - cxEdge,
989 pt2.y,
990 0,
991 0,
993 {
994 goto EndDeferWnds;
995 }
996
997 /* move the Delete Principal button */
998 pt2.x = 0;
999 pt2.y = 0;
1000 MapWindowPoints(sp->hBtnRemove,
1001 sp->hWnd,
1002 &pt2,
1003 1);
1004 if (!(dwp = DeferWindowPos(dwp,
1005 sp->hBtnRemove,
1006 NULL,
1007 pt.x + cxWidth - (rcControl2.right - rcControl2.left) - cxEdge,
1008 pt2.y,
1009 0,
1010 0,
1012 {
1013 goto EndDeferWnds;
1014 }
1015
1016 /* move the Permissions For label */
1017 GetWindowRect(hWndAllow,
1018 &rcControl);
1019 GetWindowRect(hWndDeny,
1020 &rcControl2);
1021 GetWindowRect(sp->hPermissionsForLabel,
1022 &rcControl3);
1023 pt2.x = 0;
1024 pt2.y = 0;
1025 MapWindowPoints(sp->hPermissionsForLabel,
1026 sp->hWnd,
1027 &pt2,
1028 1);
1029 if (!(dwp = DeferWindowPos(dwp,
1030 sp->hPermissionsForLabel,
1031 NULL,
1032 0,
1033 0,
1034 cxWidth - (rcControl2.right - rcControl2.left) -
1035 (rcControl.right - rcControl.left) -
1036 (2 * btnSpacing) - cxEdge,
1037 rcControl3.bottom - rcControl3.top,
1039 {
1040 goto EndDeferWnds;
1041 }
1042
1043 /* move the Allow label */
1044 pt2.x = 0;
1045 pt2.y = 0;
1046 MapWindowPoints(hWndAllow,
1047 sp->hWnd,
1048 &pt2,
1049 1);
1050 if (!(dwp = DeferWindowPos(dwp,
1051 hWndAllow,
1052 NULL,
1053 cxWidth - (rcControl2.right - rcControl2.left) -
1054 (rcControl.right - rcControl.left) -
1055 btnSpacing - cxEdge,
1056 pt2.y,
1057 0,
1058 0,
1060 {
1061 goto EndDeferWnds;
1062 }
1063
1064 /* move the Deny label */
1065 pt2.x = 0;
1066 pt2.y = 0;
1067 MapWindowPoints(hWndDeny,
1068 sp->hWnd,
1069 &pt2,
1070 1);
1071 if (!(dwp = DeferWindowPos(dwp,
1072 hWndDeny,
1073 NULL,
1074 cxWidth - (rcControl2.right - rcControl2.left) - cxEdge,
1075 pt2.y,
1076 0,
1077 0,
1079 {
1080 goto EndDeferWnds;
1081 }
1082
1083 /* resize the Permissions check list box */
1084 GetWindowRect(sp->hAceCheckList,
1085 &rcControl);
1086 GetWindowRect(sp->hBtnAdvanced,
1087 &rcControl2);
1090 &rcControl3);
1091 if (!(dwp = DeferWindowPos(dwp,
1092 sp->hAceCheckList,
1093 NULL,
1094 0,
1095 0,
1096 cxWidth,
1097 ((sp->ObjectInfo.dwFlags & SI_ADVANCED) ?
1098 Height - (rcControl.top - rcWnd.top) -
1099 (rcControl3.bottom - rcControl3.top) - pt.x - btnSpacing :
1100 Height - (rcControl.top - rcWnd.top) - pt.x),
1102 {
1103 goto EndDeferWnds;
1104 }
1105
1106 if (sp->ObjectInfo.dwFlags & SI_ADVANCED)
1107 {
1108 /* move and resize the Advanced label */
1109 if (!(dwp = DeferWindowPos(dwp,
1110 GetDlgItem(sp->hWnd,
1112 NULL,
1113 pt.x,
1114 Height - (rcControl3.bottom - rcControl3.top) - pt.x,
1115 cxWidth - (rcControl2.right - rcControl2.left) - cxEdge,
1116 rcControl3.bottom - rcControl3.top,
1117 SWP_NOZORDER)))
1118 {
1119 goto EndDeferWnds;
1120 }
1121
1122 /* move and resize the Advanced button */
1123 if (!(dwp = DeferWindowPos(dwp,
1124 sp->hBtnAdvanced,
1125 NULL,
1126 cxWidth - (rcControl2.right - rcControl2.left) + pt.x,
1127 Height - (rcControl2.bottom - rcControl2.top) - pt.x,
1128 0,
1129 0,
1131 {
1132 goto EndDeferWnds;
1133 }
1134 }
1135
1136 EndDeferWindowPos(dwp);
1137 }
1138
1139EndDeferWnds:
1140 /* update the width of the principal list view column */
1141 GetClientRect(sp->hWndPrincipalsList,
1142 &rcControl);
1143 lvc.mask = LVCF_WIDTH;
1144 lvc.cx = rcControl.right;
1145 (void)ListView_SetColumn(sp->hWndPrincipalsList,
1146 0,
1147 &lvc);
1148
1149 /* calculate the columns of the allow/deny checkboxes */
1150 SetAceCheckListColumns(sp->hAceCheckList,
1151 CLB_ALLOW,
1152 hWndAllow);
1153 SetAceCheckListColumns(sp->hAceCheckList,
1154 CLB_DENY,
1155 hWndDeny);
1156}
1157
1158static PACE_HEADER
1160 IN PSID pSid)
1161{
1163 DWORD SidLen;
1164 WORD AceSize;
1165
1166 SidLen = GetLengthSid(pSid);
1168 SidStart) + (WORD)SidLen;
1170 0,
1171 AceSize);
1172 if (Ace != NULL)
1173 {
1174 Ace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
1175 Ace->Header.AceFlags = 0; /* FIXME */
1176 Ace->Header.AceSize = AceSize;
1177 Ace->Mask = sp->DefaultAccess.mask;
1178
1179 if (CopySid(SidLen,
1180 (PSID)&Ace->SidStart,
1181 pSid))
1182 {
1183 return &Ace->Header;
1184 }
1185
1187 0,
1188 Ace);
1189 }
1190
1191 return NULL;
1192}
1193
1194static BOOL
1195AddSelectedPrincipal(IN IDsObjectPicker *pDsObjectPicker,
1197 IN PSID pSid,
1199{
1200 PACE_HEADER AceHeader;
1202
1203 AceHeader = BuildDefaultPrincipalAce(sp,
1204 pSid);
1205 if (AceHeader != NULL)
1206 {
1207 PPRINCIPAL_LISTITEM PrincipalListItem;
1208 BOOL LookupDeferred;
1209
1210 PrincipalListItem = AddPrincipalToList(sp,
1211 pSid,
1212 AceHeader,
1213 &LookupDeferred);
1214
1215 if (PrincipalListItem != NULL && LookupDeferred)
1216 {
1218 PrincipalListItem,
1219 -1,
1220 FALSE);
1221 }
1222
1224 0,
1225 AceHeader);
1226 }
1227
1228 return TRUE;
1229}
1230
1231static INT_PTR CALLBACK
1233 IN UINT uMsg,
1236{
1238 INT_PTR Ret = FALSE;
1239
1241 if (sp != NULL || uMsg == WM_INITDIALOG)
1242 {
1243 switch (uMsg)
1244 {
1245 case WM_NOTIFY:
1246 {
1247 NMHDR *pnmh = (NMHDR*)lParam;
1248
1249 if (pnmh->hwndFrom == sp->hWndPrincipalsList)
1250 {
1251 switch (pnmh->code)
1252 {
1253 case LVN_ITEMCHANGED:
1254 {
1256
1257 if ((pnmv->uChanged & LVIF_STATE) &&
1258 ((pnmv->uOldState & (LVIS_FOCUSED | LVIS_SELECTED)) ||
1259 (pnmv->uNewState & (LVIS_FOCUSED | LVIS_SELECTED))))
1260 {
1262 }
1263 break;
1264 }
1265 }
1266 }
1267 else if (pnmh->hwndFrom == sp->hAceCheckList)
1268 {
1269 switch (pnmh->code)
1270 {
1272 {
1274
1275 /* make sure only one of both checkboxes is only checked
1276 at the same time */
1277 if (pcicb->Checked)
1278 {
1279 pcicb->NewState &= ~((pcicb->CheckBox != CLB_DENY) ? CIS_DENY : CIS_ALLOW);
1280 }
1281 break;
1282 }
1283 }
1284 }
1285 else if (pnmh->hwndFrom == sp->hWnd)
1286 {
1287 switch(pnmh->code)
1288 {
1290 {
1293 nmh);
1294
1295 /* a SID lookup succeeded, update the information */
1297 LookupInfo);
1298 break;
1299 }
1300 }
1301 }
1302 break;
1303 }
1304
1305 case WM_COMMAND:
1306 {
1307 switch (LOWORD(wParam))
1308 {
1309 case IDC_ADD_PRINCIPAL:
1310 {
1311 HRESULT hRet;
1312
1313 hRet = InitializeObjectPicker(sp->ServerName,
1314 &sp->ObjectInfo,
1315 &sp->pDsObjectPicker);
1316 if (SUCCEEDED(hRet))
1317 {
1318 hRet = InvokeObjectPickerDialog(sp->pDsObjectPicker,
1319 hwndDlg,
1321 sp);
1322 if (FAILED(hRet))
1323 {
1324 MessageBox(hwndDlg, L"InvokeObjectPickerDialog failed!\n", NULL, 0);
1325 }
1326
1327 /* delete the instance */
1328 FreeObjectPicker(sp->pDsObjectPicker);
1329 }
1330 else
1331 {
1332 MessageBox(hwndDlg, L"InitializeObjectPicker failed!\n", NULL, 0);
1333 }
1334 break;
1335 }
1336
1338 {
1339 PPRINCIPAL_LISTITEM SelectedPrincipal;
1340
1341 SelectedPrincipal = (PPRINCIPAL_LISTITEM)ListViewGetSelectedItemData(sp->hWndPrincipalsList);
1342 if (SelectedPrincipal != NULL)
1343 {
1344 /* FIXME */
1345 }
1346 break;
1347 }
1348 }
1349 break;
1350 }
1351
1352 case WM_SIZE:
1353 {
1355 (INT)LOWORD(lParam),
1356 (INT)HIWORD(lParam));
1357 break;
1358 }
1359
1360 case WM_INITDIALOG:
1361 {
1363 if(sp != NULL)
1364 {
1365 LV_COLUMN lvc;
1366 RECT rcLvClient;
1367
1368 sp->hWnd = hwndDlg;
1369 sp->hWndPrincipalsList = GetDlgItem(hwndDlg, IDC_PRINCIPALS);
1370 sp->hBtnAdd = GetDlgItem(hwndDlg, IDC_ADD_PRINCIPAL);
1371 sp->hBtnRemove = GetDlgItem(hwndDlg, IDC_REMOVE_PRINCIPAL);
1372 sp->hBtnAdvanced = GetDlgItem(hwndDlg, IDC_ADVANCED);
1373 sp->hAceCheckList = GetDlgItem(hwndDlg, IDC_ACE_CHECKLIST);
1374 sp->hPermissionsForLabel = GetDlgItem(hwndDlg, IDC_LABEL_PERMISSIONS_FOR);
1375
1376 sp->SpecialPermCheckIndex = -1;
1377
1378 /* save the pointer to the structure */
1380
1381 (void)ListView_SetExtendedListViewStyleEx(sp->hWndPrincipalsList,
1384
1385 sp->hiPrincipals = ImageList_Create(16,
1386 16,
1388 0,
1389 3);
1390 if (sp->hiPrincipals != NULL)
1391 {
1392 HBITMAP hbmImages;
1393
1394 hbmImages = LoadBitmap(hDllInstance,
1396 if (hbmImages != NULL)
1397 {
1398 ImageList_AddMasked(sp->hiPrincipals,
1399 hbmImages,
1400 RGB(255,
1401 0,
1402 255));
1403
1404 DeleteObject(hbmImages);
1405 }
1406 }
1407
1408 /* setup the listview control */
1409 if (sp->hiPrincipals != NULL)
1410 {
1411 (void)ListView_SetImageList(sp->hWndPrincipalsList,
1412 sp->hiPrincipals,
1413 LVSIL_SMALL);
1414 }
1415
1416 GetClientRect(sp->hWndPrincipalsList,
1417 &rcLvClient);
1418
1419 /* add a column to the list view */
1420 lvc.mask = LVCF_FMT | LVCF_WIDTH;
1421 lvc.fmt = LVCFMT_LEFT;
1422 lvc.cx = rcLvClient.right;
1423 (void)ListView_InsertColumn(sp->hWndPrincipalsList,
1424 0,
1425 &lvc);
1426
1428
1429 ListViewSelectItem(sp->hWndPrincipalsList,
1430 0);
1431
1432 /* calculate the columns of the allow/deny checkboxes */
1433 SetAceCheckListColumns(sp->hAceCheckList,
1434 CLB_ALLOW,
1435 GetDlgItem(hwndDlg, IDC_LABEL_ALLOW));
1436 SetAceCheckListColumns(sp->hAceCheckList,
1437 CLB_DENY,
1438 GetDlgItem(hwndDlg, IDC_LABEL_DENY));
1439
1441 NULL,
1443 ((sp->ObjectInfo.dwFlags & SI_CONTAINER) ? SI_ACCESS_CONTAINER : 0),
1444 &sp->DefaultAccess);
1445
1446 /* hide controls in case the flags aren't present */
1447 if (sp->ObjectInfo.dwFlags & SI_ADVANCED)
1448 {
1449 /* editing the permissions is least the user can do when
1450 the advanced button is showed */
1451 sp->ObjectInfo.dwFlags |= SI_EDIT_PERMS;
1452 }
1453 else
1454 {
1455 ShowWindow(sp->hBtnAdvanced,
1456 SW_HIDE);
1458 SW_HIDE);
1459 }
1460
1461 /* enable quicksearch for the permissions checklist control */
1462 SendMessage(sp->hAceCheckList,
1464 TRUE,
1465 0);
1466
1468 }
1469
1470 Ret = TRUE;
1471 break;
1472 }
1473 }
1474 }
1475 return Ret;
1476}
1477
1478
1479/*
1480 * CreateSecurityPage EXPORTED
1481 *
1482 * @implemented
1483 */
1485WINAPI
1487{
1488 PROPSHEETPAGE psp = {0};
1489 PSECURITY_PAGE sPage;
1490 SI_OBJECT_INFO ObjectInfo = {0};
1491 HANDLE SidCacheMgr;
1492 LPCWSTR SystemName = NULL;
1493 HRESULT hRet;
1494
1495 if (psi == NULL)
1496 {
1498
1499 DPRINT("No ISecurityInformation class passed!\n");
1500 return NULL;
1501 }
1502
1503 /* get the object information from the server. Zero the structure before
1504 because some applications seem to return SUCCESS but only seem to set the
1505 fields they care about. */
1506 hRet = psi->lpVtbl->GetObjectInformation(psi,
1507 &ObjectInfo);
1508
1509 if (FAILED(hRet))
1510 {
1511 SetLastError(hRet);
1512
1513 DPRINT("CreateSecurityPage() failed! Failed to query the object information!\n");
1514 return NULL;
1515 }
1516
1517 if ((ObjectInfo.dwFlags & SI_SERVER_IS_DC) &&
1518 ObjectInfo.pszServerName != NULL &&
1519 ObjectInfo.pszServerName[0] != L'\0')
1520 {
1521 SystemName = ObjectInfo.pszServerName;
1522 }
1523
1524 SidCacheMgr = CreateSidCacheMgr(GetProcessHeap(),
1525 SystemName);
1526 if (SidCacheMgr == NULL)
1527 {
1528 DPRINT("Creating the SID cache failed!\n");
1529 return NULL;
1530 }
1531
1532 hRet = CoInitialize(NULL);
1533 if (FAILED(hRet))
1534 {
1535 DestroySidCacheMgr(SidCacheMgr);
1536 DPRINT("CoInitialize failed!\n");
1537 return NULL;
1538 }
1539
1540 sPage = HeapAlloc(GetProcessHeap(),
1542 sizeof(SECURITY_PAGE));
1543 if (sPage == NULL)
1544 {
1545 DestroySidCacheMgr(SidCacheMgr);
1547
1549
1550 DPRINT("Not enough memory to allocate a SECURITY_PAGE!\n");
1551 return NULL;
1552 }
1553
1554 ZeroMemory(sPage,
1555 sizeof(*sPage));
1556
1557 sPage->psi = psi;
1558 sPage->ObjectInfo = ObjectInfo;
1559 sPage->ServerName = SystemName;
1560 sPage->SidCacheMgr = SidCacheMgr;
1561
1562 psp.dwSize = sizeof(PROPSHEETPAGE);
1563 psp.dwFlags = PSP_USECALLBACK;
1564 psp.hInstance = hDllInstance;
1565 psp.pszTemplate = MAKEINTRESOURCE(IDD_SECPAGE);
1566 psp.pfnDlgProc = SecurityPageProc;
1567 psp.lParam = (LPARAM)sPage;
1568 psp.pfnCallback = SecurityPageCallback;
1569
1570 if (ObjectInfo.dwFlags & SI_PAGE_TITLE)
1571 {
1572 psp.pszTitle = ObjectInfo.pszPageTitle;
1573
1574 if (psp.pszTitle != NULL)
1575 {
1576 psp.dwFlags |= PSP_USETITLE;
1577 }
1578 }
1579 else
1580 {
1581 psp.pszTitle = NULL;
1582 }
1583
1584 /* NOTE: the SECURITY_PAGE structure will be freed by the property page
1585 callback! */
1586
1587 return CreatePropertySheetPage(&psp);
1588}
1589
1590
1591/*
1592 * EditSecurity EXPORTED
1593 *
1594 * @implemented
1595 */
1596BOOL
1597WINAPI
1599 IN LPSECURITYINFO psi)
1600{
1601 HRESULT hRet;
1602 SI_OBJECT_INFO ObjectInfo = {0};
1603 PROPSHEETHEADER psh;
1604 HPROPSHEETPAGE hPages[1];
1605 LPWSTR lpCaption = NULL;
1606 BOOL Ret;
1607
1608 if (psi == NULL)
1609 {
1611
1612 DPRINT("No ISecurityInformation class passed!\n");
1613 return FALSE;
1614 }
1615
1616 /* get the object information from the server. Zero the structure before
1617 because some applications seem to return SUCCESS but only seem to set the
1618 fields they care about. */
1619 hRet = psi->lpVtbl->GetObjectInformation(psi,
1620 &ObjectInfo);
1621
1622 if (FAILED(hRet))
1623 {
1624 SetLastError(hRet);
1625
1626 DPRINT("GetObjectInformation() failed!\n");
1627 return FALSE;
1628 }
1629
1630 /* create the page */
1631 hPages[0] = CreateSecurityPage(psi);
1632 if (hPages[0] == NULL)
1633 {
1634 DPRINT("CreateSecurityPage(), couldn't create property sheet!\n");
1635 return FALSE;
1636 }
1637
1638 psh.dwSize = sizeof(PROPSHEETHEADER);
1639 psh.dwFlags = PSH_DEFAULT;
1640 psh.hwndParent = hwndOwner;
1641 psh.hInstance = hDllInstance;
1642
1643 /* Set the page title to the object name, make sure the format string
1644 has "%1" NOT "%s" because it uses FormatMessage() to automatically
1645 allocate the right amount of memory. */
1648 &lpCaption,
1649 ObjectInfo.pszObjectName))
1650 {
1651 psh.pszCaption = lpCaption;
1652 }
1653 else
1654 {
1655 psh.pszCaption = ObjectInfo.pszObjectName;
1656 }
1657
1658 psh.nPages = sizeof(hPages) / sizeof(HPROPSHEETPAGE);
1659 psh.nStartPage = 0;
1660 psh.phpage = hPages;
1661
1662 Ret = (PropertySheet(&psh) != -1);
1663
1664 if (lpCaption != NULL)
1665 {
1666 LocalFree((HLOCAL)lpCaption);
1667 }
1668
1669 return Ret;
1670}
1671
1672BOOL
1673WINAPI
1677{
1678 switch (dwReason)
1679 {
1680 case DLL_PROCESS_ATTACH:
1681 hDllInstance = hinstDLL;
1682
1683 DisableThreadLibraryCalls(hinstDLL);
1684
1685 if (!RegisterCheckListControl(hinstDLL))
1686 {
1687 DPRINT("Registering the CHECKLIST_ACLUI class failed!\n");
1688 return FALSE;
1689 }
1690 break;
1691
1692 case DLL_PROCESS_DETACH:
1694 break;
1695 }
1696
1697 return TRUE;
1698}
1699
unsigned char BOOLEAN
#define SI_CONTAINER
Definition: accctrl.h:116
#define SI_PAGE_TITLE
Definition: accctrl.h:125
#define SI_ACCESS_CONTAINER
Definition: accctrl.h:140
#define SI_SERVER_IS_DC
Definition: accctrl.h:126
#define SI_ACCESS_SPECIFIC
Definition: accctrl.h:138
#define SI_ACCESS_GENERAL
Definition: accctrl.h:139
#define SI_EDIT_PERMS
Definition: accctrl.h:113
#define SI_ADVANCED
Definition: accctrl.h:118
static VOID DestroySecurityPage(IN PSECURITY_PAGE sp)
Definition: aclui.c:88
static VOID ReloadPrincipalsList(IN PSECURITY_PAGE sp)
Definition: aclui.c:503
static int CALLBACK PrincipalCompare(IN LPARAM lParam1, IN LPARAM lParam2, IN LPARAM lParamSort)
Definition: aclui.c:441
static VOID LoadPermissionsList(IN PSECURITY_PAGE sp, IN GUID *GuidObjectType, IN DWORD dwFlags, OUT SI_ACCESS *DefaultAccess)
Definition: aclui.c:792
static VOID UpdatePrincipalListItem(IN PSECURITY_PAGE sp, IN INT PrincipalIndex, IN PPRINCIPAL_LISTITEM PrincipalListItem, IN PSIDREQRESULT SidReqResult)
Definition: aclui.c:458
static void UpdatePrincipalInfo(IN PSECURITY_PAGE sp, IN PSIDLOOKUPNOTIFYINFO LookupInfo)
Definition: aclui.c:675
struct _SIDLOOKUPNOTIFYINFO SIDLOOKUPNOTIFYINFO
static PACE_ENTRY AddAceToPrincipal(IN PPRINCIPAL_LISTITEM Principal, IN PACE_HEADER AceHeader)
Definition: aclui.c:147
static VOID FreePrincipalsList(IN PSECURITY_PAGE sp, IN PPRINCIPAL_LISTITEM *PrincipalsListHead)
Definition: aclui.c:103
static VOID SetAceCheckListColumns(IN HWND hAceCheckList, IN UINT Button, IN HWND hLabel)
Definition: aclui.c:769
BOOL WINAPI DllMain(IN HINSTANCE hinstDLL, IN DWORD dwReason, IN LPVOID lpvReserved)
Definition: aclui.c:1674
static PSID AceHeaderToSID(IN PACE_HEADER AceHeader)
Definition: aclui.c:49
static VOID UpdateControlStates(IN PSECURITY_PAGE sp)
Definition: aclui.c:624
static VOID CreatePrincipalListItem(OUT LVITEM *li, IN PSECURITY_PAGE sp, IN PPRINCIPAL_LISTITEM PrincipalListItem, IN INT Index, IN BOOL Selected)
Definition: aclui.c:379
static LPWSTR GetPrincipalAccountNameString(IN PPRINCIPAL_LISTITEM PrincipalListItem)
Definition: aclui.c:358
static PPRINCIPAL_LISTITEM FindSidInPrincipalsListAddAce(IN PPRINCIPAL_LISTITEM PrincipalsListHead, IN PSID Sid, IN PACE_HEADER AceHeader)
Definition: aclui.c:177
static INT AddPrincipalListEntry(IN PSECURITY_PAGE sp, IN PPRINCIPAL_LISTITEM PrincipalListItem, IN INT Index, IN BOOL Selected)
Definition: aclui.c:414
struct _SIDLOOKUPNOTIFYINFO * PSIDLOOKUPNOTIFYINFO
#define SIDN_LOOKUPSUCCEEDED
Definition: aclui.c:40
static LPWSTR GetPrincipalDisplayString(IN PPRINCIPAL_LISTITEM PrincipalListItem)
Definition: aclui.c:340
static BOOL AddSelectedPrincipal(IN IDsObjectPicker *pDsObjectPicker, IN HWND hwndParent OPTIONAL, IN PSID pSid, IN PVOID Context OPTIONAL)
Definition: aclui.c:1195
static PPRINCIPAL_LISTITEM AddPrincipalToList(IN PSECURITY_PAGE sp, IN PSID Sid, IN PACE_HEADER AceHeader, OUT BOOL *LookupDeferred OPTIONAL)
Definition: aclui.c:234
static VOID SidLookupCompletion(IN HANDLE SidCacheMgr, IN PSID Sid, IN PSIDREQRESULT SidRequestResult, IN PVOID Context)
Definition: aclui.c:205
static PACE_HEADER BuildDefaultPrincipalAce(IN PSECURITY_PAGE sp, IN PSID pSid)
Definition: aclui.c:1159
static LPWSTR GetDisplayStringFromSidRequestResult(IN PSIDREQRESULT SidReqResult)
Definition: aclui.c:314
static UINT CALLBACK SecurityPageCallback(IN HWND hwnd, IN UINT uMsg, IN LPPROPSHEETPAGE ppsp)
Definition: aclui.c:746
static INT_PTR CALLBACK SecurityPageProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: aclui.c:1232
BOOL WINAPI EditSecurity(IN HWND hwndOwner, IN LPSECURITYINFO psi)
Definition: aclui.c:1598
static VOID ResizeControls(IN PSECURITY_PAGE sp, IN INT Width, IN INT Height)
Definition: aclui.c:894
HPROPSHEETPAGE WINAPI CreateSecurityPage(IN LPSECURITYINFO psi)
Definition: aclui.c:1486
HINSTANCE hDllInstance
Definition: aclui.c:38
interface ISecurityInformation * LPSECURITYINFO
Definition: aclui.h:34
DWORD LoadAndFormatString(IN HINSTANCE hInstance, IN UINT uID, OUT LPTSTR *lpTarget,...)
Definition: misc.c:85
#define IDS_UNKNOWN
Definition: resource.h:7
static VOID FreeObjectPicker(IN IDsObjectPicker *pDsObjectPicker)
Definition: framewnd.c:1119
DWORD dwReason
Definition: misc.cpp:141
@ Ace
Definition: card.h:12
BOOL RegisterCheckListControl(IN HINSTANCE hInstance)
Definition: checklist.c:2594
VOID UnregisterCheckListControl(HINSTANCE hInstance)
Definition: checklist.c:2614
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static HWND hwndParent
Definition: cryptui.c:300
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT InitializeObjectPicker(IN PCWSTR ServerName, IN PSI_OBJECT_INFO ObjectInfo, OUT IDsObjectPicker **pDsObjectPicker)
Definition: misc.c:176
BOOL ListViewSelectItem(IN HWND hwnd, IN INT Index)
Definition: misc.c:160
HRESULT InvokeObjectPickerDialog(IN IDsObjectPicker *pDsObjectPicker, IN HWND hwndParent OPTIONAL, IN POBJPICK_SELECTED_SID SelectedSidCallback, IN PVOID Context OPTIONAL)
Definition: misc.c:249
LPARAM ListViewGetSelectedItemData(IN HWND hwnd)
Definition: misc.c:134
#define CLM_CLEARCHECKBOXES
Definition: precomp.h:133
VOID DestroySidCacheMgr(IN HANDLE SidCacheMgr)
Definition: sidcache.c:676
#define CIS_ALLOW
Definition: precomp.h:117
#define CIS_NONE
Definition: precomp.h:119
struct _NMCHANGEITEMCHECKBOX * PNMCHANGEITEMCHECKBOX
#define CLM_ENABLEQUICKSEARCH
Definition: precomp.h:135
#define CIS_ALLOWDISABLED
Definition: precomp.h:115
#define CIS_DENY
Definition: precomp.h:118
struct _PRINCIPAL_LISTITEM * PPRINCIPAL_LISTITEM
VOID ReferenceSidReqResult(IN HANDLE SidCacheMgr, IN PSIDREQRESULT ReqResult)
Definition: sidcache.c:839
#define CLM_SETCHECKBOXCOLUMN
Definition: precomp.h:131
#define CLB_DENY
Definition: precomp.h:123
#define CLM_ADDITEM
Definition: precomp.h:127
#define CLB_ALLOW
Definition: precomp.h:122
struct _SECURITY_PAGE * PSECURITY_PAGE
#define CLM_SETITEMSTATE
Definition: precomp.h:134
#define CLM_CLEAR
Definition: precomp.h:130
#define CLN_CHANGINGITEMCHECKBOX
Definition: precomp.h:140
#define CIS_DENYDISABLED
Definition: precomp.h:113
HANDLE CreateSidCacheMgr(IN HANDLE Heap, IN LPCWSTR SystemName)
Definition: sidcache.c:596
VOID DereferenceSidReqResult(IN HANDLE SidCacheMgr, IN PSIDREQRESULT ReqResult)
Definition: sidcache.c:855
BOOL LookupSidCache(IN HANDLE SidCacheMgr, IN PSID pSid, IN PSIDREQCOMPLETIONPROC CompletionProc, IN PVOID Context)
Definition: sidcache.c:876
#define IDS_USERFORMAT
Definition: resource.h:22
#define IDC_PRINCIPALS
Definition: resource.h:5
#define IDC_REMOVE_PRINCIPAL
Definition: resource.h:7
#define IDC_LABEL_PERMISSIONS_FOR
Definition: resource.h:13
#define IDS_USERDOMAINFORMAT
Definition: resource.h:21
#define IDC_ADVANCED
Definition: resource.h:11
#define IDS_PERMISSIONS_FOR
Definition: resource.h:19
#define IDS_SPECIAL_PERMISSIONS
Definition: resource.h:18
#define IDD_SECPAGE
Definition: resource.h:3
#define IDC_OWNER
Definition: resource.h:14
#define IDC_ADD_PRINCIPAL
Definition: resource.h:6
#define IDB_USRGRPIMAGES
Definition: resource.h:24
#define IDC_LABEL_ADVANCED
Definition: resource.h:12
#define IDC_LABEL_DENY
Definition: resource.h:10
#define IDS_PSP_TITLE
Definition: resource.h:16
#define IDC_ACE_CHECKLIST
Definition: resource.h:8
#define IDC_LABEL_ALLOW
Definition: resource.h:9
#define IDS_PERMISSIONS
Definition: resource.h:20
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3583
BOOL WINAPI CopySid(DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid)
Definition: security.c:712
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:919
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:829
BOOL WINAPI GetAce(PACL pAcl, DWORD dwAceIndex, LPVOID *pAce)
Definition: security.c:1186
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:563
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static LPDATABLOCK_HEADER NextItem(LPDBLIST lpList)
Definition: clist.c:42
#define pt(x, y)
Definition: drawing.c:79
#define RGB(r, g, b)
Definition: precomp.h:71
switch(r->id)
Definition: btrfs.c:3046
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
pKey DeleteObject()
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
static IN DWORD IN LPVOID lpvReserved
@ SidTypeGroup
Definition: lsa.idl:119
@ SidTypeUser
Definition: lsa.idl:118
@ SidTypeWellKnownGroup
Definition: lsa.idl:122
static PSID pSid
Definition: security.c:74
static HBITMAP
Definition: button.c:44
static const WCHAR sp[]
Definition: suminfo.c:287
struct _SID * PSID
Definition: eventlog.c:35
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
unsigned int UINT
Definition: ndis.h:50
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1605
_In_ BOOLEAN DaclPresent
Definition: rtlfuncs.h:1647
_In_opt_ PSID _In_opt_ BOOLEAN OwnerDefaulted
Definition: rtlfuncs.h:1684
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1145
_In_ BOOLEAN _In_opt_ PACL _In_opt_ BOOLEAN DaclDefaulted
Definition: rtlfuncs.h:1650
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define INT
Definition: polytest.cpp:20
#define PROPSHEETHEADER
Definition: prsht.h:392
#define PSPCB_CREATE
Definition: prsht.h:38
#define CreatePropertySheetPage
Definition: prsht.h:399
#define PSP_USETITLE
Definition: prsht.h:26
#define PSPCB_RELEASE
Definition: prsht.h:37
#define PropertySheet
Definition: prsht.h:400
#define LPPROPSHEETPAGE
Definition: prsht.h:390
#define PSP_USECALLBACK
Definition: prsht.h:30
#define PSH_DEFAULT
Definition: prsht.h:39
#define PROPSHEETPAGE
Definition: prsht.h:389
#define LVSIL_SMALL
Definition: commctrl.h:2304
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2413
#define ListView_SetExtendedListViewStyleEx(hwndLV, dwMask, dw)
Definition: commctrl.h:2731
#define LVFINDINFO
Definition: commctrl.h:2468
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2641
#define LVIF_STATE
Definition: commctrl.h:2317
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2309
#define LVFI_PARAM
Definition: commctrl.h:2441
#define LVCF_WIDTH
Definition: commctrl.h:2592
#define ILC_COLOR32
Definition: commctrl.h:358
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2739
#define ListView_SortItems(hwndLV, _pfnCompare, _lPrm)
Definition: commctrl.h:2708
#define LVIS_SELECTED
Definition: commctrl.h:2324
#define LVITEM
Definition: commctrl.h:2380
#define LVIF_PARAM
Definition: commctrl.h:2316
struct tagNMLISTVIEW * LPNMLISTVIEW
#define LVIF_TEXT
Definition: commctrl.h:2314
#define ListView_SetItem(hwnd, pitem)
Definition: commctrl.h:2406
#define LVCF_FMT
Definition: commctrl.h:2591
#define LVCFMT_LEFT
Definition: commctrl.h:2603
#define ILC_MASK
Definition: commctrl.h:351
#define ListView_SetColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2634
#define LVIF_IMAGE
Definition: commctrl.h:2315
#define LVN_ITEMCHANGED
Definition: commctrl.h:3136
#define LVIS_FOCUSED
Definition: commctrl.h:2323
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2475
#define LVCOLUMN
Definition: commctrl.h:2586
#define LV_COLUMN
Definition: commctrl.h:2552
#define WM_NOTIFY
Definition: richedit.h:61
#define ConvertSidToStringSid
Definition: sddl.h:160
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOL WINAPI GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbDaclPresent, PACL *pDacl, LPBOOL lpbDaclDefaulted)
Definition: sec.c:45
BOOL WINAPI GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pOwner, LPBOOL lpbOwnerDefaulted)
Definition: sec.c:103
#define DPRINT
Definition: sndvol32.h:73
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
Definition: window.h:573
Definition: precomp.h:30
struct _ACE_ENTRY * Next
Definition: precomp.h:31
struct _SIDREQRESULT * SidReqResult
Definition: precomp.h:37
struct _PRINCIPAL_LISTITEM * Next
Definition: precomp.h:36
LPWSTR DisplayString
Definition: precomp.h:39
PACE_ENTRY ACEs
Definition: precomp.h:38
SI_OBJECT_INFO ObjectInfo
Definition: precomp.h:65
HANDLE SidCacheMgr
Definition: precomp.h:70
LPCWSTR ServerName
Definition: precomp.h:74
LPSECURITYINFO psi
Definition: precomp.h:64
PSIDREQRESULT SidRequestResult
Definition: aclui.c:45
ACCESS_MASK mask
Definition: accctrl.h:399
DWORD dwFlags
Definition: accctrl.h:401
LPCWSTR pszName
Definition: accctrl.h:400
LPWSTR pszObjectName
Definition: accctrl.h:391
LPWSTR pszPageTitle
Definition: accctrl.h:392
DWORD dwFlags
Definition: accctrl.h:388
LPWSTR pszServerName
Definition: accctrl.h:390
UINT_PTR idFrom
Definition: winuser.h:3161
UINT code
Definition: winuser.h:3162
HWND hwndFrom
Definition: winuser.h:3160
UINT uNewState
Definition: commctrl.h:3041
UINT uOldState
Definition: commctrl.h:3042
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
int32_t INT_PTR
Definition: typedefs.h:64
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define HIWORD(l)
Definition: typedefs.h:247
#define OUT
Definition: typedefs.h:40
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
_In_ WDFCOLLECTION _In_ ULONG Index
#define ZeroMemory
Definition: winbase.h:1737
#define CopyMemory
Definition: winbase.h:1735
#define LMEM_FIXED
Definition: winbase.h:394
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define SW_HIDE
Definition: winuser.h:771
#define DWLP_USER
Definition: winuser.h:875
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define SM_CXEDGE
Definition: winuser.h:1011
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define WM_SIZE
Definition: winuser.h:1614
#define LoadBitmap
Definition: winuser.h:5823
#define SWP_NOMOVE
Definition: winuser.h:1247
#define WM_COMMAND
Definition: winuser.h:1743
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define SWP_NOSIZE
Definition: winuser.h:1248
#define WM_INITDIALOG
Definition: winuser.h:1742
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SendMessage
Definition: winuser.h:5855
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define LoadString
Definition: winuser.h:5831
#define MessageBox
Definition: winuser.h:5834
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SetWindowText
Definition: winuser.h:5869
#define SWP_NOZORDER
Definition: winuser.h:1250
#define MAKEINTRESOURCE
Definition: winuser.h:591
int WINAPI GetSystemMetrics(_In_ int)
#define SetDlgItemText
Definition: winuser.h:5861
HDWP WINAPI BeginDeferWindowPos(_In_ int)
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:191
_In_ ULONG AceIndex
Definition: rtlfuncs.h:1879
#define ACCESS_DENIED_CALLBACK_ACE_TYPE
Definition: setypes.h:733
#define DACL_SECURITY_INFORMATION
Definition: setypes.h:125
#define ACCESS_ALLOWED_ACE_TYPE
Definition: setypes.h:717
#define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE
Definition: setypes.h:734
#define OWNER_SECURITY_INFORMATION
Definition: setypes.h:123
#define ACCESS_DENIED_ACE_TYPE
Definition: setypes.h:718
#define ACCESS_ALLOWED_OBJECT_ACE_TYPE
Definition: setypes.h:725
#define ACCESS_ALLOWED_CALLBACK_ACE_TYPE
Definition: setypes.h:732
#define SYSTEM_AUDIT_OBJECT_ACE_TYPE
Definition: setypes.h:727
#define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE
Definition: setypes.h:735
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
CHAR * LPTSTR
Definition: xmlstorage.h:192
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185