ReactOS  0.4.14-dev-50-g13bb5e2
aclui.c File Reference
#include "precomp.h"
#include <sddl.h>
#include <debug.h>
#include "resource.h"
Include dependency graph for aclui.c:

Go to the source code of this file.

Classes

struct  _SIDLOOKUPNOTIFYINFO
 

Macros

#define NDEBUG
 
#define SIDN_LOOKUPSUCCEEDED   (0x101)
 

Typedefs

typedef struct _SIDLOOKUPNOTIFYINFO SIDLOOKUPNOTIFYINFO
 
typedef struct _SIDLOOKUPNOTIFYINFOPSIDLOOKUPNOTIFYINFO
 

Functions

static PSID AceHeaderToSID (IN PACE_HEADER AceHeader)
 
static VOID DestroySecurityPage (IN PSECURITY_PAGE sp)
 
static VOID FreePrincipalsList (IN PSECURITY_PAGE sp, IN PPRINCIPAL_LISTITEM *PrincipalsListHead)
 
static PACE_ENTRY AddAceToPrincipal (IN PPRINCIPAL_LISTITEM Principal, IN PACE_HEADER AceHeader)
 
static PPRINCIPAL_LISTITEM FindSidInPrincipalsListAddAce (IN PPRINCIPAL_LISTITEM PrincipalsListHead, IN PSID Sid, IN PACE_HEADER AceHeader)
 
static VOID SidLookupCompletion (IN HANDLE SidCacheMgr, IN PSID Sid, IN PSIDREQRESULT SidRequestResult, IN PVOID Context)
 
static PPRINCIPAL_LISTITEM AddPrincipalToList (IN PSECURITY_PAGE sp, IN PSID Sid, IN PACE_HEADER AceHeader, OUT BOOL *LookupDeferred OPTIONAL)
 
static LPWSTR GetDisplayStringFromSidRequestResult (IN PSIDREQRESULT SidReqResult)
 
static LPWSTR GetPrincipalDisplayString (IN PPRINCIPAL_LISTITEM PrincipalListItem)
 
static LPWSTR GetPrincipalAccountNameString (IN PPRINCIPAL_LISTITEM PrincipalListItem)
 
static VOID CreatePrincipalListItem (OUT LVITEM *li, IN PSECURITY_PAGE sp, IN PPRINCIPAL_LISTITEM PrincipalListItem, IN INT Index, IN BOOL Selected)
 
static INT AddPrincipalListEntry (IN PSECURITY_PAGE sp, IN PPRINCIPAL_LISTITEM PrincipalListItem, IN INT Index, IN BOOL Selected)
 
static int CALLBACK PrincipalCompare (IN LPARAM lParam1, IN LPARAM lParam2, IN LPARAM lParamSort)
 
static VOID UpdatePrincipalListItem (IN PSECURITY_PAGE sp, IN INT PrincipalIndex, IN PPRINCIPAL_LISTITEM PrincipalListItem, IN PSIDREQRESULT SidReqResult)
 
static VOID ReloadPrincipalsList (IN PSECURITY_PAGE sp)
 
static VOID UpdateControlStates (IN PSECURITY_PAGE sp)
 
static void UpdatePrincipalInfo (IN PSECURITY_PAGE sp, IN PSIDLOOKUPNOTIFYINFO LookupInfo)
 
static UINT CALLBACK SecurityPageCallback (IN HWND hwnd, IN UINT uMsg, IN LPPROPSHEETPAGE ppsp)
 
static VOID SetAceCheckListColumns (IN HWND hAceCheckList, IN UINT Button, IN HWND hLabel)
 
static VOID LoadPermissionsList (IN PSECURITY_PAGE sp, IN GUID *GuidObjectType, IN DWORD dwFlags, OUT SI_ACCESS *DefaultAccess)
 
static VOID ResizeControls (IN PSECURITY_PAGE sp, IN INT Width, IN INT Height)
 
static PACE_HEADER BuildDefaultPrincipalAce (IN PSECURITY_PAGE sp, IN PSID pSid)
 
static BOOL AddSelectedPrincipal (IN IDsObjectPicker *pDsObjectPicker, IN HWND hwndParent OPTIONAL, IN PSID pSid, IN PVOID Context OPTIONAL)
 
static INT_PTR CALLBACK SecurityPageProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
HPROPSHEETPAGE WINAPI CreateSecurityPage (IN LPSECURITYINFO psi)
 
BOOL WINAPI EditSecurity (IN HWND hwndOwner, IN LPSECURITYINFO psi)
 
BOOL WINAPI DllMain (IN HINSTANCE hinstDLL, IN DWORD dwReason, IN LPVOID lpvReserved)
 

Variables

HINSTANCE hDllInstance
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 33 of file aclui.c.

◆ SIDN_LOOKUPSUCCEEDED

#define SIDN_LOOKUPSUCCEEDED   (0x101)

Definition at line 40 of file aclui.c.

Typedef Documentation

◆ PSIDLOOKUPNOTIFYINFO

◆ SIDLOOKUPNOTIFYINFO

Function Documentation

◆ AceHeaderToSID()

static PSID AceHeaderToSID ( IN PACE_HEADER  AceHeader)
static

Definition at line 49 of file aclui.c.

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 }
#define SYSTEM_AUDIT_OBJECT_ACE_TYPE
Definition: setypes.h:695
#define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE
Definition: setypes.h:702
smooth NULL
Definition: ftsmooth.c:416
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1104
#define ACCESS_ALLOWED_ACE_TYPE
Definition: setypes.h:685
#define ACCESS_ALLOWED_OBJECT_ACE_TYPE
Definition: setypes.h:693
#define ACCESS_DENIED_ACE_TYPE
Definition: setypes.h:686
struct _SID * PSID
Definition: eventlog.c:35
#define ACCESS_ALLOWED_CALLBACK_ACE_TYPE
Definition: setypes.h:700
#define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE
Definition: setypes.h:703
#define ACCESS_DENIED_CALLBACK_ACE_TYPE
Definition: setypes.h:701

Referenced by ReloadPrincipalsList().

◆ AddAceToPrincipal()

static PACE_ENTRY AddAceToPrincipal ( IN PPRINCIPAL_LISTITEM  Principal,
IN PACE_HEADER  AceHeader 
)
static

Definition at line 152 of file aclui.c.

154 {
155  PACE_ENTRY AceEntry, *AceLink;
156 
157  AceEntry = HeapAlloc(GetProcessHeap(),
158  0,
159  sizeof(ACE_ENTRY) + AceHeader->AceSize);
160  if (AceEntry != NULL)
161  {
162  AceEntry->Next = NULL;
163 
164  /* copy the ACE */
165  CopyMemory(AceEntry + 1,
166  AceHeader,
167  AceHeader->AceSize);
168 
169  /* append it to the list */
170  AceLink = &Principal->ACEs;
171  while (*AceLink != NULL)
172  {
173  AceLink = &(*AceLink)->Next;
174  }
175  *AceLink = AceEntry;
176  }
177 
178  return AceEntry;
179 }
Definition: precomp.h:29
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CopyMemory
Definition: winbase.h:1633
struct _ACE_ENTRY * Next
Definition: precomp.h:31

Referenced by FindSidInPrincipalsListAddAce().

◆ AddPrincipalListEntry()

static INT AddPrincipalListEntry ( IN PSECURITY_PAGE  sp,
IN PPRINCIPAL_LISTITEM  PrincipalListItem,
IN INT  Index,
IN BOOL  Selected 
)
static

Definition at line 419 of file aclui.c.

423 {
424  LVITEM li;
425  INT Ret;
426 
427  if (PrincipalListItem->DisplayString != NULL)
428  {
429  LocalFree((HLOCAL)PrincipalListItem->DisplayString);
430  }
431  PrincipalListItem->DisplayString = GetPrincipalDisplayString(PrincipalListItem);
432 
434  sp,
435  PrincipalListItem,
436  Index,
437  Selected);
438 
439  Ret = ListView_InsertItem(sp->hWndPrincipalsList,
440  &li);
441 
442  return Ret;
443 }
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2380
static VOID CreatePrincipalListItem(OUT LVITEM *li, IN PSECURITY_PAGE sp, IN PPRINCIPAL_LISTITEM PrincipalListItem, IN INT Index, IN BOOL Selected)
Definition: aclui.c:384
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
static const UCHAR Index[8]
Definition: usbohci.c:18
static LPWSTR GetPrincipalDisplayString(IN PPRINCIPAL_LISTITEM PrincipalListItem)
Definition: aclui.c:345
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define LVITEM
Definition: commctrl.h:2347
static const WCHAR sp[]
Definition: suminfo.c:288

Referenced by AddSelectedPrincipal(), ReloadPrincipalsList(), and UpdatePrincipalInfo().

◆ AddPrincipalToList()

static PPRINCIPAL_LISTITEM AddPrincipalToList ( IN PSECURITY_PAGE  sp,
IN PSID  Sid,
IN PACE_HEADER  AceHeader,
OUT BOOL *LookupDeferred  OPTIONAL 
)
static

Definition at line 239 of file aclui.c.

243 {
244  PPRINCIPAL_LISTITEM PrincipalListItem = NULL, *PrincipalLink;
245  PACE_ENTRY AceEntry;
246  BOOL Deferred = FALSE;
247 
248  if (!FindSidInPrincipalsListAddAce(sp->PrincipalsListHead,
249  Sid,
250  AceHeader))
251  {
252  DWORD SidLength;
253 
254  PrincipalLink = &sp->PrincipalsListHead;
255  while (*PrincipalLink != NULL)
256  {
257  PrincipalLink = &(*PrincipalLink)->Next;
258  }
259 
260  SidLength = GetLengthSid(Sid);
261 
262  /* allocate the principal */
263  PrincipalListItem = HeapAlloc(GetProcessHeap(),
264  0,
265  sizeof(PRINCIPAL_LISTITEM) + SidLength);
266  if (PrincipalListItem != NULL)
267  {
268  PrincipalListItem->DisplayString = NULL;
269  PrincipalListItem->SidReqResult = NULL;
270 
271  CopySid(SidLength,
272  (PSID)(PrincipalListItem + 1),
273  Sid);
274 
275  /* allocate some memory for the ACE and copy it */
276  AceEntry = HeapAlloc(GetProcessHeap(),
277  0,
278  sizeof(ACE_ENTRY) + AceHeader->AceSize);
279  if (AceEntry != NULL)
280  {
281  AceEntry->Next = NULL;
282  CopyMemory(AceEntry + 1,
283  AceHeader,
284  AceHeader->AceSize);
285 
286  /* add the ACE to the list */
287  PrincipalListItem->ACEs = AceEntry;
288 
289  PrincipalListItem->Next = NULL;
290 
291  /* append item to the principals list */
292  *PrincipalLink = PrincipalListItem;
293 
294  /* lookup the SID now */
295  Deferred = !LookupSidCache(sp->SidCacheMgr,
296  Sid,
298  sp);
299  }
300  else
301  {
303  0,
304  PrincipalListItem);
305  PrincipalListItem = NULL;
306  }
307  }
308  }
309 
310  if (PrincipalListItem != NULL && LookupDeferred != NULL)
311  {
312  *LookupDeferred = Deferred;
313  }
314 
315  return PrincipalListItem;
316 }
Definition: precomp.h:29
struct _PRINCIPAL_LISTITEM * Next
Definition: precomp.h:36
static VOID SidLookupCompletion(IN HANDLE SidCacheMgr, IN PSID Sid, IN PSIDREQRESULT SidRequestResult, IN PVOID Context)
Definition: aclui.c:210
LPWSTR DisplayString
Definition: precomp.h:39
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1104
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:798
#define CopyMemory
Definition: winbase.h:1633
unsigned long DWORD
Definition: ntddk_ex.h:95
PACE_ENTRY ACEs
Definition: precomp.h:38
struct _ACE_ENTRY * Next
Definition: precomp.h:31
static PPRINCIPAL_LISTITEM FindSidInPrincipalsListAddAce(IN PPRINCIPAL_LISTITEM PrincipalsListHead, IN PSID Sid, IN PACE_HEADER AceHeader)
Definition: aclui.c:182
BOOL LookupSidCache(IN HANDLE SidCacheMgr, IN PSID pSid, IN PSIDREQCOMPLETIONPROC CompletionProc, IN PVOID Context)
Definition: sidcache.c:872
static const WCHAR sp[]
Definition: suminfo.c:288
BOOL WINAPI CopySid(DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid)
Definition: security.c:591
struct _SIDREQRESULT * SidReqResult
Definition: precomp.h:37
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by AddSelectedPrincipal(), and ReloadPrincipalsList().

◆ AddSelectedPrincipal()

static BOOL AddSelectedPrincipal ( IN IDsObjectPicker *  pDsObjectPicker,
IN HWND hwndParent  OPTIONAL,
IN PSID  pSid,
IN PVOID Context  OPTIONAL 
)
static

Definition at line 1200 of file aclui.c.

1204 {
1205  PACE_HEADER AceHeader;
1207 
1208  AceHeader = BuildDefaultPrincipalAce(sp,
1209  pSid);
1210  if (AceHeader != NULL)
1211  {
1212  PPRINCIPAL_LISTITEM PrincipalListItem;
1213  BOOL LookupDeferred;
1214 
1215  PrincipalListItem = AddPrincipalToList(sp,
1216  pSid,
1217  AceHeader,
1218  &LookupDeferred);
1219 
1220  if (PrincipalListItem != NULL && LookupDeferred)
1221  {
1223  PrincipalListItem,
1224  -1,
1225  FALSE);
1226  }
1227 
1229  0,
1230  AceHeader);
1231  }
1232 
1233  return TRUE;
1234 }
struct _SECURITY_PAGE * PSECURITY_PAGE
#define TRUE
Definition: types.h:120
static PACE_HEADER BuildDefaultPrincipalAce(IN PSECURITY_PAGE sp, IN PSID pSid)
Definition: aclui.c:1164
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static INT AddPrincipalListEntry(IN PSECURITY_PAGE sp, IN PPRINCIPAL_LISTITEM PrincipalListItem, IN INT Index, IN BOOL Selected)
Definition: aclui.c:419
#define GetProcessHeap()
Definition: compat.h:395
static PPRINCIPAL_LISTITEM AddPrincipalToList(IN PSECURITY_PAGE sp, IN PSID Sid, IN PACE_HEADER AceHeader, OUT BOOL *LookupDeferred OPTIONAL)
Definition: aclui.c:239
static PSID pSid
Definition: security.c:74
static const WCHAR sp[]
Definition: suminfo.c:288
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by SecurityPageProc().

◆ BuildDefaultPrincipalAce()

static PACE_HEADER BuildDefaultPrincipalAce ( IN PSECURITY_PAGE  sp,
IN PSID  pSid 
)
static

Definition at line 1164 of file aclui.c.

1166 {
1168  DWORD SidLen;
1169  WORD AceSize;
1170 
1171  SidLen = GetLengthSid(pSid);
1172  AceSize = FIELD_OFFSET(ACCESS_ALLOWED_ACE,
1173  SidStart) + (WORD)SidLen;
1175  0,
1176  AceSize);
1177  if (Ace != NULL)
1178  {
1179  Ace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
1180  Ace->Header.AceFlags = 0; /* FIXME */
1181  Ace->Header.AceSize = AceSize;
1182  Ace->Mask = sp->DefaultAccess.mask;
1183 
1184  if (CopySid(SidLen,
1185  (PSID)&Ace->SidStart,
1186  pSid))
1187  {
1188  return &Ace->Header;
1189  }
1190 
1192  0,
1193  Ace);
1194  }
1195 
1196  return NULL;
1197 }
Definition: card.h:12
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:798
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ACCESS_ALLOWED_ACE_TYPE
Definition: setypes.h:685
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
static PSID pSid
Definition: security.c:74
static const WCHAR sp[]
Definition: suminfo.c:288
BOOL WINAPI CopySid(DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid)
Definition: security.c:591
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by AddSelectedPrincipal().

◆ CreatePrincipalListItem()

static VOID CreatePrincipalListItem ( OUT LVITEM li,
IN PSECURITY_PAGE  sp,
IN PPRINCIPAL_LISTITEM  PrincipalListItem,
IN INT  Index,
IN BOOL  Selected 
)
static

Definition at line 384 of file aclui.c.

389 {
390  INT ImageIndex = 2;
391 
392  if (PrincipalListItem->SidReqResult != NULL)
393  {
394  switch (PrincipalListItem->SidReqResult->SidNameUse)
395  {
396  case SidTypeUser:
397  ImageIndex = 0;
398  break;
400  case SidTypeGroup:
401  ImageIndex = 1;
402  break;
403  default:
404  break;
405  }
406  }
407 
408  li->mask = LVIF_IMAGE | LVIF_PARAM | LVIF_STATE | LVIF_TEXT;
409  li->iItem = Index;
410  li->iSubItem = 0;
411  li->state = (Selected ? LVIS_SELECTED : 0);
412  li->stateMask = LVIS_SELECTED;
413  li->pszText = PrincipalListItem->DisplayString;
414  li->iImage = ImageIndex;
415  li->lParam = (LPARAM)PrincipalListItem;
416 }
int32_t INT
Definition: typedefs.h:56
#define LVIF_TEXT
Definition: commctrl.h:2281
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2291
LONG_PTR LPARAM
Definition: windef.h:208
#define LVIF_IMAGE
Definition: commctrl.h:2282
static const UCHAR Index[8]
Definition: usbohci.c:18
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVIF_STATE
Definition: commctrl.h:2284

Referenced by AddPrincipalListEntry(), and UpdatePrincipalListItem().

◆ CreateSecurityPage()

HPROPSHEETPAGE WINAPI CreateSecurityPage ( IN LPSECURITYINFO  psi)

Definition at line 1491 of file aclui.c.

1492 {
1493  PROPSHEETPAGE psp = {0};
1494  PSECURITY_PAGE sPage;
1495  SI_OBJECT_INFO ObjectInfo = {0};
1496  HANDLE SidCacheMgr;
1497  LPCWSTR SystemName = NULL;
1498  HRESULT hRet;
1499 
1500  if (psi == NULL)
1501  {
1503 
1504  DPRINT("No ISecurityInformation class passed!\n");
1505  return NULL;
1506  }
1507 
1508  /* get the object information from the server. Zero the structure before
1509  because some applications seem to return SUCCESS but only seem to set the
1510  fields they care about. */
1511  hRet = psi->lpVtbl->GetObjectInformation(psi,
1512  &ObjectInfo);
1513 
1514  if (FAILED(hRet))
1515  {
1516  SetLastError(hRet);
1517 
1518  DPRINT("CreateSecurityPage() failed! Failed to query the object information!\n");
1519  return NULL;
1520  }
1521 
1522  if ((ObjectInfo.dwFlags & SI_SERVER_IS_DC) &&
1523  ObjectInfo.pszServerName != NULL &&
1524  ObjectInfo.pszServerName[0] != L'\0')
1525  {
1526  SystemName = ObjectInfo.pszServerName;
1527  }
1528 
1529  SidCacheMgr = CreateSidCacheMgr(GetProcessHeap(),
1530  SystemName);
1531  if (SidCacheMgr == NULL)
1532  {
1533  DPRINT("Creating the SID cache failed!\n");
1534  return NULL;
1535  }
1536 
1537  hRet = CoInitialize(NULL);
1538  if (FAILED(hRet))
1539  {
1540  DestroySidCacheMgr(SidCacheMgr);
1541  DPRINT("CoInitialize failed!\n");
1542  return NULL;
1543  }
1544 
1545  sPage = HeapAlloc(GetProcessHeap(),
1547  sizeof(SECURITY_PAGE));
1548  if (sPage == NULL)
1549  {
1550  DestroySidCacheMgr(SidCacheMgr);
1551  CoUninitialize();
1552 
1554 
1555  DPRINT("Not enough memory to allocate a SECURITY_PAGE!\n");
1556  return NULL;
1557  }
1558 
1559  ZeroMemory(sPage,
1560  sizeof(*sPage));
1561 
1562  sPage->psi = psi;
1563  sPage->ObjectInfo = ObjectInfo;
1564  sPage->ServerName = SystemName;
1565  sPage->SidCacheMgr = SidCacheMgr;
1566 
1567  psp.dwSize = sizeof(PROPSHEETPAGE);
1568  psp.dwFlags = PSP_USECALLBACK;
1569  psp.hInstance = hDllInstance;
1570  psp.pszTemplate = MAKEINTRESOURCE(IDD_SECPAGE);
1571  psp.pfnDlgProc = SecurityPageProc;
1572  psp.lParam = (LPARAM)sPage;
1573  psp.pfnCallback = SecurityPageCallback;
1574 
1575  if (ObjectInfo.dwFlags & SI_PAGE_TITLE)
1576  {
1577  psp.pszTitle = ObjectInfo.pszPageTitle;
1578 
1579  if (psp.pszTitle != NULL)
1580  {
1581  psp.dwFlags |= PSP_USETITLE;
1582  }
1583  }
1584  else
1585  {
1586  psp.pszTitle = NULL;
1587  }
1588 
1589  /* NOTE: the SECURITY_PAGE structure will be freed by the property page
1590  callback! */
1591 
1592  return CreatePropertySheetPage(&psp);
1593 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define MAKEINTRESOURCE
Definition: winuser.h:591
LPWSTR pszServerName
Definition: accctrl.h:390
#define SI_SERVER_IS_DC
Definition: accctrl.h:126
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ZeroMemory
Definition: winbase.h:1635
LPCWSTR ServerName
Definition: precomp.h:74
#define PSP_USECALLBACK
Definition: prsht.h:30
#define SI_PAGE_TITLE
Definition: accctrl.h:125
LPWSTR pszPageTitle
Definition: accctrl.h:392
DWORD dwFlags
Definition: accctrl.h:388
#define IDD_SECPAGE
Definition: resource.h:3
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
void DPRINT(...)
Definition: polytest.cpp:61
#define CreatePropertySheetPage
Definition: prsht.h:381
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LPSECURITYINFO psi
Definition: precomp.h:64
LONG HRESULT
Definition: typedefs.h:77
#define SetLastError(x)
Definition: compat.h:409
HANDLE SidCacheMgr
Definition: precomp.h:70
SI_OBJECT_INFO ObjectInfo
Definition: precomp.h:65
static const WCHAR L[]
Definition: oid.c:1250
#define PSP_USETITLE
Definition: prsht.h:26
static INT_PTR CALLBACK SecurityPageProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: aclui.c:1237
static UINT CALLBACK SecurityPageCallback(IN HWND hwnd, IN UINT uMsg, IN LPPROPSHEETPAGE ppsp)
Definition: aclui.c:751
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
HANDLE CreateSidCacheMgr(IN HANDLE Heap, IN LPCWSTR SystemName)
Definition: sidcache.c:590
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
HINSTANCE hDllInstance
Definition: aclui.c:38
VOID DestroySidCacheMgr(IN HANDLE SidCacheMgr)
Definition: sidcache.c:670
#define PROPSHEETPAGE
Definition: prsht.h:371

Referenced by EditSecurity().

◆ DestroySecurityPage()

static VOID DestroySecurityPage ( IN PSECURITY_PAGE  sp)
static

Definition at line 88 of file aclui.c.

89 {
90  if(sp->hiPrincipals != NULL)
91  {
92  ImageList_Destroy(sp->hiPrincipals);
93  }
94 
95  DestroySidCacheMgr(sp->SidCacheMgr);
96 
97  if (sp->OwnerSid != NULL)
98  LocalFree((HLOCAL)sp->OwnerSid);
99 
101  0,
102  sp);
103 
104  CoUninitialize();
105 }
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
VOID DestroySidCacheMgr(IN HANDLE SidCacheMgr)
Definition: sidcache.c:670
static const WCHAR sp[]
Definition: suminfo.c:288
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by SecurityPageCallback().

◆ DllMain()

BOOL WINAPI DllMain ( IN HINSTANCE  hinstDLL,
IN DWORD  dwReason,
IN LPVOID  lpvReserved 
)

Definition at line 1679 of file aclui.c.

1682 {
1683  switch (dwReason)
1684  {
1685  case DLL_PROCESS_ATTACH:
1686  hDllInstance = hinstDLL;
1687 
1688  DisableThreadLibraryCalls(hinstDLL);
1689 
1690  if (!RegisterCheckListControl(hinstDLL))
1691  {
1692  DPRINT("Registering the CHECKLIST_ACLUI class failed!\n");
1693  return FALSE;
1694  }
1695  break;
1696 
1697  case DLL_PROCESS_DETACH:
1698  UnregisterCheckListControl(hinstDLL);
1699  break;
1700  }
1701 
1702  return TRUE;
1703 }
#define TRUE
Definition: types.h:120
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
VOID UnregisterCheckListControl(HINSTANCE hInstance)
Definition: checklist.c:2614
BOOL RegisterCheckListControl(IN HINSTANCE hInstance)
Definition: checklist.c:2594
DWORD dwReason
Definition: misc.cpp:154
void DPRINT(...)
Definition: polytest.cpp:61
#define DLL_PROCESS_DETACH
Definition: compat.h:119
HINSTANCE hDllInstance
Definition: aclui.c:38

◆ EditSecurity()

BOOL WINAPI EditSecurity ( IN HWND  hwndOwner,
IN LPSECURITYINFO  psi 
)

Definition at line 1603 of file aclui.c.

1605 {
1606  HRESULT hRet;
1607  SI_OBJECT_INFO ObjectInfo = {0};
1608  PROPSHEETHEADER psh;
1609  HPROPSHEETPAGE hPages[1];
1610  LPWSTR lpCaption = NULL;
1611  BOOL Ret;
1612 
1613  if (psi == NULL)
1614  {
1616 
1617  DPRINT("No ISecurityInformation class passed!\n");
1618  return FALSE;
1619  }
1620 
1621  /* get the object information from the server. Zero the structure before
1622  because some applications seem to return SUCCESS but only seem to set the
1623  fields they care about. */
1624  hRet = psi->lpVtbl->GetObjectInformation(psi,
1625  &ObjectInfo);
1626 
1627  if (FAILED(hRet))
1628  {
1629  SetLastError(hRet);
1630 
1631  DPRINT("GetObjectInformation() failed!\n");
1632  return FALSE;
1633  }
1634 
1635  /* create the page */
1636  hPages[0] = CreateSecurityPage(psi);
1637  if (hPages[0] == NULL)
1638  {
1639  DPRINT("CreateSecurityPage(), couldn't create property sheet!\n");
1640  return FALSE;
1641  }
1642 
1643  psh.dwSize = sizeof(PROPSHEETHEADER);
1644  psh.dwFlags = PSH_DEFAULT;
1645  psh.hwndParent = hwndOwner;
1646  psh.hInstance = hDllInstance;
1647 
1648  /* Set the page title to the object name, make sure the format string
1649  has "%1" NOT "%s" because it uses FormatMessage() to automatically
1650  allocate the right amount of memory. */
1652  IDS_PSP_TITLE,
1653  &lpCaption,
1654  ObjectInfo.pszObjectName))
1655  {
1656  psh.pszCaption = lpCaption;
1657  }
1658  else
1659  {
1660  psh.pszCaption = ObjectInfo.pszObjectName;
1661  }
1662 
1663  psh.nPages = sizeof(hPages) / sizeof(HPROPSHEETPAGE);
1664  psh.nStartPage = 0;
1665  psh.phpage = hPages;
1666 
1667  Ret = (PropertySheet(&psh) != -1);
1668 
1669  if (lpCaption != NULL)
1670  {
1671  LocalFree((HLOCAL)lpCaption);
1672  }
1673 
1674  return Ret;
1675 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define IDS_PSP_TITLE
Definition: resource.h:16
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
smooth NULL
Definition: ftsmooth.c:416
#define PROPSHEETHEADER
Definition: prsht.h:374
void DPRINT(...)
Definition: polytest.cpp:61
DWORD LoadAndFormatString(IN HINSTANCE hInstance, IN UINT uID, OUT LPTSTR *lpTarget,...)
Definition: misc.c:86
LPWSTR pszObjectName
Definition: accctrl.h:391
HPROPSHEETPAGE WINAPI CreateSecurityPage(IN LPSECURITYINFO psi)
Definition: aclui.c:1491
LONG HRESULT
Definition: typedefs.h:77
#define SetLastError(x)
Definition: compat.h:409
#define PSH_DEFAULT
Definition: prsht.h:39
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
HINSTANCE hDllInstance
Definition: aclui.c:38
#define PropertySheet
Definition: prsht.h:382
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ FindSidInPrincipalsListAddAce()

static PPRINCIPAL_LISTITEM FindSidInPrincipalsListAddAce ( IN PPRINCIPAL_LISTITEM  PrincipalsListHead,
IN PSID  Sid,
IN PACE_HEADER  AceHeader 
)
static

Definition at line 182 of file aclui.c.

185 {
186  PPRINCIPAL_LISTITEM CurItem;
187 
188  for (CurItem = PrincipalsListHead;
189  CurItem != NULL;
190  CurItem = CurItem->Next)
191  {
192  if (EqualSid((PSID)(CurItem + 1),
193  Sid))
194  {
195  if (AddAceToPrincipal(CurItem,
196  AceHeader) != NULL)
197  {
198  return CurItem;
199  }
200 
201  /* unable to add the ACE to the principal */
202  break;
203  }
204  }
205 
206  return NULL;
207 }
static PACE_ENTRY AddAceToPrincipal(IN PPRINCIPAL_LISTITEM Principal, IN PACE_HEADER AceHeader)
Definition: aclui.c:152
struct _PRINCIPAL_LISTITEM * Next
Definition: precomp.h:36
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:708
smooth NULL
Definition: ftsmooth.c:416
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1104

Referenced by AddPrincipalToList().

◆ FreePrincipalsList()

static VOID FreePrincipalsList ( IN PSECURITY_PAGE  sp,
IN PPRINCIPAL_LISTITEM PrincipalsListHead 
)
static

Definition at line 108 of file aclui.c.

110 {
111  PPRINCIPAL_LISTITEM CurItem, NextItem;
112  PACE_ENTRY AceEntry, NextAceEntry;
113 
114  CurItem = *PrincipalsListHead;
115  while (CurItem != NULL)
116  {
117  /* Free all ACEs */
118  AceEntry = CurItem->ACEs;
119  while (AceEntry != NULL)
120  {
121  NextAceEntry = AceEntry->Next;
123  0,
124  AceEntry);
125  AceEntry = NextAceEntry;
126  }
127 
128  /* free the SID string if present */
129  if (CurItem->SidReqResult != NULL)
130  {
131  DereferenceSidReqResult(sp->SidCacheMgr,
132  CurItem->SidReqResult);
133  }
134 
135  if (CurItem->DisplayString != NULL)
136  {
137  LocalFree((HLOCAL)CurItem->DisplayString);
138  }
139 
140  /* free the ACE list item */
141  NextItem = CurItem->Next;
143  0,
144  CurItem);
145  CurItem = NextItem;
146  }
147 
148  *PrincipalsListHead = NULL;
149 }
Definition: precomp.h:29
struct _PRINCIPAL_LISTITEM * Next
Definition: precomp.h:36
LPWSTR DisplayString
Definition: precomp.h:39
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PACE_ENTRY ACEs
Definition: precomp.h:38
struct _ACE_ENTRY * Next
Definition: precomp.h:31
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static const WCHAR sp[]
Definition: suminfo.c:288
static LPDATABLOCK_HEADER NextItem(LPDBLIST lpList)
Definition: clist.c:42
VOID DereferenceSidReqResult(IN HANDLE SidCacheMgr, IN PSIDREQRESULT ReqResult)
Definition: sidcache.c:851
struct _SIDREQRESULT * SidReqResult
Definition: precomp.h:37
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by ReloadPrincipalsList().

◆ GetDisplayStringFromSidRequestResult()

static LPWSTR GetDisplayStringFromSidRequestResult ( IN PSIDREQRESULT  SidReqResult)
static

Definition at line 319 of file aclui.c.

320 {
321  LPWSTR lpDisplayString = NULL;
322 
323  if (SidReqResult->SidNameUse == SidTypeUser ||
324  SidReqResult->SidNameUse == SidTypeGroup)
325  {
328  &lpDisplayString,
329  SidReqResult->AccountName,
330  SidReqResult->DomainName,
331  SidReqResult->AccountName);
332  }
333  else
334  {
337  &lpDisplayString,
338  SidReqResult->AccountName);
339  }
340 
341  return lpDisplayString;
342 }
#define IDS_USERDOMAINFORMAT
Definition: resource.h:21
#define IDS_USERFORMAT
Definition: resource.h:22
smooth NULL
Definition: ftsmooth.c:416
DWORD LoadAndFormatString(IN HINSTANCE hInstance, IN UINT uID, OUT LPTSTR *lpTarget,...)
Definition: misc.c:86
HINSTANCE hDllInstance
Definition: aclui.c:38
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by GetPrincipalDisplayString(), and UpdatePrincipalInfo().

◆ GetPrincipalAccountNameString()

static LPWSTR GetPrincipalAccountNameString ( IN PPRINCIPAL_LISTITEM  PrincipalListItem)
static

Definition at line 363 of file aclui.c.

364 {
365  LPWSTR lpDisplayString = NULL;
366 
367  if (PrincipalListItem->SidReqResult != NULL)
368  {
371  &lpDisplayString,
372  PrincipalListItem->SidReqResult->AccountName);
373  }
374  else
375  {
376  ConvertSidToStringSid((PSID)(PrincipalListItem + 1),
377  &lpDisplayString);
378  }
379 
380  return lpDisplayString;
381 }
#define IDS_USERFORMAT
Definition: resource.h:22
smooth NULL
Definition: ftsmooth.c:416
DWORD LoadAndFormatString(IN HINSTANCE hInstance, IN UINT uID, OUT LPTSTR *lpTarget,...)
Definition: misc.c:86
#define ConvertSidToStringSid
Definition: sddl.h:160
HINSTANCE hDllInstance
Definition: aclui.c:38
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by UpdateControlStates().

◆ GetPrincipalDisplayString()

static LPWSTR GetPrincipalDisplayString ( IN PPRINCIPAL_LISTITEM  PrincipalListItem)
static

Definition at line 345 of file aclui.c.

346 {
347  LPWSTR lpDisplayString = NULL;
348 
349  if (PrincipalListItem->SidReqResult != NULL)
350  {
351  lpDisplayString = GetDisplayStringFromSidRequestResult(PrincipalListItem->SidReqResult);
352  }
353  else
354  {
355  ConvertSidToStringSidW((PSID)(PrincipalListItem + 1),
356  &lpDisplayString);
357  }
358 
359  return lpDisplayString;
360 }
static LPWSTR GetDisplayStringFromSidRequestResult(IN PSIDREQRESULT SidReqResult)
Definition: aclui.c:319
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3259
smooth NULL
Definition: ftsmooth.c:416
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by AddPrincipalListEntry(), and UpdatePrincipalListItem().

◆ LoadPermissionsList()

static VOID LoadPermissionsList ( IN PSECURITY_PAGE  sp,
IN GUID GuidObjectType,
IN DWORD  dwFlags,
OUT SI_ACCESS DefaultAccess 
)
static

Definition at line 797 of file aclui.c.

801 {
802  HRESULT hRet;
803  PSI_ACCESS AccessList;
804  ULONG nAccessList, DefaultAccessIndex;
805  WCHAR szSpecialPermissions[255];
806  BOOLEAN SpecialPermissionsPresent = FALSE;
807  ACCESS_MASK SpecialPermissionsMask = 0;
808 
809  /* clear the permissions list */
810 
811  SendMessage(sp->hAceCheckList,
812  CLM_CLEAR,
813  0,
814  0);
815 
816  /* query the access rights from the server */
817  hRet = sp->psi->lpVtbl->GetAccessRights(sp->psi,
818  GuidObjectType,
819  dwFlags, /* FIXME */
820  &AccessList,
821  &nAccessList,
822  &DefaultAccessIndex);
823  if (SUCCEEDED(hRet) && nAccessList != 0)
824  {
825  LPCWSTR NameStr;
826  PSI_ACCESS CurAccess, LastAccess;
827  WCHAR NameBuffer[MAX_PATH];
828 
829  /* save the default access rights to be used when adding ACEs later */
830  if (DefaultAccess != NULL)
831  {
832  *DefaultAccess = AccessList[DefaultAccessIndex];
833  }
834 
835  LastAccess = AccessList + nAccessList;
836  for (CurAccess = &AccessList[0];
837  CurAccess != LastAccess;
838  CurAccess++)
839  {
840  if (CurAccess->dwFlags & dwFlags)
841  {
842  /* get the permission name, load it from a string table if necessary */
843  if (IS_INTRESOURCE(CurAccess->pszName))
844  {
845  if (!LoadString(sp->ObjectInfo.hInstance,
846  (UINT)((ULONG_PTR)CurAccess->pszName),
847  NameBuffer,
848  sizeof(NameBuffer) / sizeof(NameBuffer[0])))
849  {
851  IDS_UNKNOWN,
852  NameBuffer,
853  sizeof(NameBuffer) / sizeof(NameBuffer[0]));
854  }
855  NameStr = NameBuffer;
856  }
857  else
858  {
859  NameStr = CurAccess->pszName;
860  }
861 
862  SendMessage(sp->hAceCheckList,
863  CLM_ADDITEM,
864  (WPARAM)CurAccess->mask,
865  (LPARAM)NameStr);
866  }
867  else if (CurAccess->dwFlags & SI_ACCESS_SPECIFIC)
868  {
869  SpecialPermissionsPresent = TRUE;
870  SpecialPermissionsMask |= CurAccess->mask;
871  }
872  }
873  }
874 
875  /* add the special permissions check item in case the specific access rights
876  aren't displayed */
877  if (SpecialPermissionsPresent &&
880  szSpecialPermissions,
881  sizeof(szSpecialPermissions) / sizeof(szSpecialPermissions[0])))
882  {
883  /* add the special permissions check item */
884  sp->SpecialPermCheckIndex = (INT)SendMessage(sp->hAceCheckList,
885  CLM_ADDITEM,
886  (WPARAM)SpecialPermissionsMask,
887  (LPARAM)szSpecialPermissions);
888  if (sp->SpecialPermCheckIndex != -1)
889  {
890  SendMessage(sp->hAceCheckList,
892  (WPARAM)sp->SpecialPermCheckIndex,
894  }
895  }
896 }
ACCESS_MASK mask
Definition: accctrl.h:399
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define INT
Definition: polytest.cpp:20
#define CIS_ALLOWDISABLED
Definition: precomp.h:115
UINT_PTR WPARAM
Definition: windef.h:207
#define CIS_DENYDISABLED
Definition: precomp.h:113
#define CLM_CLEAR
Definition: precomp.h:130
DWORD dwFlags
Definition: accctrl.h:401
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define SI_ACCESS_SPECIFIC
Definition: accctrl.h:138
LONG_PTR LPARAM
Definition: windef.h:208
#define IDS_UNKNOWN
Definition: resource.h:7
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define CLM_SETITEMSTATE
Definition: precomp.h:134
unsigned int UINT
Definition: ndis.h:50
#define CLM_ADDITEM
Definition: precomp.h:127
HINSTANCE hDllInstance
Definition: aclui.c:38
#define IDS_SPECIAL_PERMISSIONS
Definition: resource.h:18
#define SendMessage
Definition: winuser.h:5744
unsigned int ULONG
Definition: retypes.h:1
static const WCHAR sp[]
Definition: suminfo.c:288
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define LoadString
Definition: winuser.h:5720
#define CIS_NONE
Definition: precomp.h:119
#define SUCCEEDED(hr)
Definition: intsafe.h:57
LPCWSTR pszName
Definition: accctrl.h:400

Referenced by SecurityPageProc().

◆ PrincipalCompare()

static int CALLBACK PrincipalCompare ( IN LPARAM  lParam1,
IN LPARAM  lParam2,
IN LPARAM  lParamSort 
)
static

Definition at line 446 of file aclui.c.

449 {
450  PPRINCIPAL_LISTITEM Item1 = (PPRINCIPAL_LISTITEM)lParam1;
451  PPRINCIPAL_LISTITEM Item2 = (PPRINCIPAL_LISTITEM)lParam2;
452 
453  if (Item1->DisplayString != NULL && Item2->DisplayString != NULL)
454  {
455  return wcscmp(Item1->DisplayString,
456  Item2->DisplayString);
457  }
458 
459  return 0;
460 }
LPWSTR DisplayString
Definition: precomp.h:39
smooth NULL
Definition: ftsmooth.c:416
struct _PRINCIPAL_LISTITEM * PPRINCIPAL_LISTITEM
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by UpdatePrincipalListItem().

◆ ReloadPrincipalsList()

static VOID ReloadPrincipalsList ( IN PSECURITY_PAGE  sp)
static

Definition at line 508 of file aclui.c.

509 {
512  PACL Dacl = NULL;
513  PSID OwnerSid = NULL;
514  LPTSTR OwnerSidString;
515  DWORD SidLen;
516  HRESULT hRet;
517 
518  /* delete the cached ACL */
520  &sp->PrincipalsListHead);
521 
522  /* query the ACL */
523  hRet = sp->psi->lpVtbl->GetSecurity(sp->psi,
526  FALSE);
527  if (SUCCEEDED(hRet) && SecurityDescriptor != NULL)
528  {
530  &OwnerSid,
531  &OwnerDefaulted))
532  {
533  sp->OwnerDefaulted = OwnerDefaulted;
534  if (sp->OwnerSid != NULL)
535  {
536  LocalFree((HLOCAL)sp->OwnerSid);
537  sp->OwnerSid = NULL;
538  }
539 
540  SidLen = GetLengthSid(OwnerSid);
541  if (SidLen == 0)
542  goto ClearOwner;
543 
544  sp->OwnerSid = (PSID)LocalAlloc(LMEM_FIXED,
545  SidLen);
546  if (sp->OwnerSid != NULL)
547  {
548  if (CopySid(SidLen,
549  sp->OwnerSid,
550  OwnerSid))
551  {
552  /* Lookup the SID now */
553  if (!LookupSidCache(sp->SidCacheMgr,
554  sp->OwnerSid,
556  sp))
557  {
558  /* Lookup was deferred */
559  if (ConvertSidToStringSid(sp->OwnerSid,
560  &OwnerSidString))
561  {
562  SetDlgItemText(sp->hWnd,
563  IDC_OWNER,
564  OwnerSidString);
565  LocalFree((HLOCAL)OwnerSidString);
566  }
567  else
568  goto ClearOwner;
569  }
570  }
571  else
572  goto ClearOwner;
573  }
574  else
575  goto ClearOwner;
576  }
577  else
578  {
579 ClearOwner:
580  SetDlgItemText(sp->hWnd,
581  IDC_OWNER,
582  NULL);
583  }
584 
586  &DaclPresent,
587  &Dacl,
588  &DaclDefaulted) &&
589  DaclPresent && Dacl != NULL)
590  {
591  PSID Sid;
592  PACE_HEADER AceHeader;
593  ULONG AceIndex;
594 
595  for (AceIndex = 0;
596  AceIndex < Dacl->AceCount;
597  AceIndex++)
598  {
599  if (GetAce(Dacl,
600  AceIndex,
601  (LPVOID*)&AceHeader) &&
602  AceHeader != NULL)
603  {
604  BOOL LookupDeferred;
605  PPRINCIPAL_LISTITEM PrincipalListItem;
606 
607  Sid = AceHeaderToSID(AceHeader);
608 
609  PrincipalListItem = AddPrincipalToList(sp,
610  Sid,
611  AceHeader,
612  &LookupDeferred);
613 
614  if (PrincipalListItem != NULL && LookupDeferred)
615  {
617  PrincipalListItem,
618  -1,
619  FALSE);
620  }
621  }
622  }
623  }
625  }
626 }
_In_opt_ PSID _In_opt_ BOOLEAN OwnerDefaulted
Definition: rtlfuncs.h:1630
_In_ BOOLEAN _In_opt_ PACL _In_opt_ BOOLEAN DaclDefaulted
Definition: rtlfuncs.h:1595
BOOL WINAPI GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbDaclPresent, PACL *pDacl, LPBOOL lpbDaclDefaulted)
Definition: sec.c:45
_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:182
static VOID SidLookupCompletion(IN HANDLE SidCacheMgr, IN PSID Sid, IN PSIDREQRESULT SidRequestResult, IN PVOID Context)
Definition: aclui.c:210
static PSID AceHeaderToSID(IN PACE_HEADER AceHeader)
Definition: aclui.c:49
CHAR * LPTSTR
Definition: xmlstorage.h:192
_In_ BOOLEAN DaclPresent
Definition: rtlfuncs.h:1595
static VOID FreePrincipalsList(IN PSECURITY_PAGE sp, IN PPRINCIPAL_LISTITEM *PrincipalsListHead)
Definition: aclui.c:108
BOOL WINAPI GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pOwner, LPBOOL lpbOwnerDefaulted)
Definition: sec.c:103
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1104
#define LMEM_FIXED
Definition: winbase.h:349
static INT AddPrincipalListEntry(IN PSECURITY_PAGE sp, IN PPRINCIPAL_LISTITEM PrincipalListItem, IN INT Index, IN BOOL Selected)
Definition: aclui.c:419
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:798
LONG HRESULT
Definition: typedefs.h:77
#define ConvertSidToStringSid
Definition: sddl.h:160
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDC_OWNER
Definition: resource.h:14
#define SetDlgItemText
Definition: winuser.h:5750
struct _SID * PSID
Definition: eventlog.c:35
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1553
_In_ ULONG AceIndex
Definition: rtlfuncs.h:1864
BOOL WINAPI GetAce(PACL pAcl, DWORD dwAceIndex, LPVOID *pAce)
Definition: security.c:1065
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static PPRINCIPAL_LISTITEM AddPrincipalToList(IN PSECURITY_PAGE sp, IN PSID Sid, IN PACE_HEADER AceHeader, OUT BOOL *LookupDeferred OPTIONAL)
Definition: aclui.c:239
#define OWNER_SECURITY_INFORMATION
Definition: setypes.h:123
BOOL LookupSidCache(IN HANDLE SidCacheMgr, IN PSID pSid, IN PSIDREQCOMPLETIONPROC CompletionProc, IN PVOID Context)
Definition: sidcache.c:872
unsigned int ULONG
Definition: retypes.h:1
static const WCHAR sp[]
Definition: suminfo.c:288
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
BOOL WINAPI CopySid(DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid)
Definition: security.c:591
#define DACL_SECURITY_INFORMATION
Definition: setypes.h:125
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by SecurityPageProc().

◆ ResizeControls()

static VOID ResizeControls ( IN PSECURITY_PAGE  sp,
IN INT  Width,
IN INT  Height 
)
static

Definition at line 899 of file aclui.c.

902 {
903  HWND hWndAllow, hWndDeny, hWndOwnerEdit;
904  RECT rcControl, rcControl2, rcControl3, rcWnd;
905  INT cxWidth, cxEdge, btnSpacing;
906  POINT pt, pt2;
907  HDWP dwp;
908  INT nControls = 8;
909  LVCOLUMN lvc;
910 
911  hWndAllow = GetDlgItem(sp->hWnd,
913  hWndDeny = GetDlgItem(sp->hWnd,
915 
916  GetWindowRect(sp->hWnd,
917  &rcWnd);
918 
919  cxEdge = GetSystemMetrics(SM_CXEDGE);
920 
921  /* use the left margin of the principal list view control for all control
922  margins */
923  pt.x = 0;
924  pt.y = 0;
925  MapWindowPoints(sp->hWndPrincipalsList,
926  sp->hWnd,
927  &pt,
928  1);
929  cxWidth = Width - (2 * pt.x);
930 
931  if (sp->ObjectInfo.dwFlags & SI_ADVANCED)
932  {
933  nControls += 2;
934  }
935 
936  if ((dwp = BeginDeferWindowPos(nControls)))
937  {
938  /* resize the owner edit field */
939  hWndOwnerEdit = GetDlgItem(sp->hWnd,
940  IDC_OWNER);
941  GetWindowRect(hWndOwnerEdit,
942  &rcControl);
943  pt2.x = 0;
944  pt2.y = 0;
945  MapWindowPoints(hWndOwnerEdit,
946  sp->hWnd,
947  &pt2,
948  1);
949  if (!(dwp = DeferWindowPos(dwp,
950  hWndOwnerEdit,
951  NULL,
952  0,
953  0,
954  Width - pt.x - pt2.x,
955  rcControl.bottom - rcControl.top,
957  {
958  goto EndDeferWnds;
959  }
960 
961  /* resize the Principal list view */
962  GetWindowRect(sp->hWndPrincipalsList,
963  &rcControl);
964  if (!(dwp = DeferWindowPos(dwp,
965  sp->hWndPrincipalsList,
966  NULL,
967  0,
968  0,
969  cxWidth,
970  rcControl.bottom - rcControl.top,
972  {
973  goto EndDeferWnds;
974  }
975 
976  /* move the Add Principal button */
977  GetWindowRect(sp->hBtnAdd,
978  &rcControl);
979  GetWindowRect(sp->hBtnRemove,
980  &rcControl2);
981  btnSpacing = rcControl2.left - rcControl.right;
982  pt2.x = 0;
983  pt2.y = 0;
984  MapWindowPoints(sp->hBtnAdd,
985  sp->hWnd,
986  &pt2,
987  1);
988  if (!(dwp = DeferWindowPos(dwp,
989  sp->hBtnAdd,
990  NULL,
991  pt.x + cxWidth - (rcControl2.right - rcControl2.left) -
992  (rcControl.right - rcControl.left) -
993  btnSpacing - cxEdge,
994  pt2.y,
995  0,
996  0,
998  {
999  goto EndDeferWnds;
1000  }
1001 
1002  /* move the Delete Principal button */
1003  pt2.x = 0;
1004  pt2.y = 0;
1005  MapWindowPoints(sp->hBtnRemove,
1006  sp->hWnd,
1007  &pt2,
1008  1);
1009  if (!(dwp = DeferWindowPos(dwp,
1010  sp->hBtnRemove,
1011  NULL,
1012  pt.x + cxWidth - (rcControl2.right - rcControl2.left) - cxEdge,
1013  pt2.y,
1014  0,
1015  0,
1017  {
1018  goto EndDeferWnds;
1019  }
1020 
1021  /* move the Permissions For label */
1022  GetWindowRect(hWndAllow,
1023  &rcControl);
1024  GetWindowRect(hWndDeny,
1025  &rcControl2);
1026  GetWindowRect(sp->hPermissionsForLabel,
1027  &rcControl3);
1028  pt2.x = 0;
1029  pt2.y = 0;
1030  MapWindowPoints(sp->hPermissionsForLabel,
1031  sp->hWnd,
1032  &pt2,
1033  1);
1034  if (!(dwp = DeferWindowPos(dwp,
1035  sp->hPermissionsForLabel,
1036  NULL,
1037  0,
1038  0,
1039  cxWidth - (rcControl2.right - rcControl2.left) -
1040  (rcControl.right - rcControl.left) -
1041  (2 * btnSpacing) - cxEdge,
1042  rcControl3.bottom - rcControl3.top,
1044  {
1045  goto EndDeferWnds;
1046  }
1047 
1048  /* move the Allow label */
1049  pt2.x = 0;
1050  pt2.y = 0;
1051  MapWindowPoints(hWndAllow,
1052  sp->hWnd,
1053  &pt2,
1054  1);
1055  if (!(dwp = DeferWindowPos(dwp,
1056  hWndAllow,
1057  NULL,
1058  cxWidth - (rcControl2.right - rcControl2.left) -
1059  (rcControl.right - rcControl.left) -
1060  btnSpacing - cxEdge,
1061  pt2.y,
1062  0,
1063  0,
1065  {
1066  goto EndDeferWnds;
1067  }
1068 
1069  /* move the Deny label */
1070  pt2.x = 0;
1071  pt2.y = 0;
1072  MapWindowPoints(hWndDeny,
1073  sp->hWnd,
1074  &pt2,
1075  1);
1076  if (!(dwp = DeferWindowPos(dwp,
1077  hWndDeny,
1078  NULL,
1079  cxWidth - (rcControl2.right - rcControl2.left) - cxEdge,
1080  pt2.y,
1081  0,
1082  0,
1084  {
1085  goto EndDeferWnds;
1086  }
1087 
1088  /* resize the Permissions check list box */
1089  GetWindowRect(sp->hAceCheckList,
1090  &rcControl);
1091  GetWindowRect(sp->hBtnAdvanced,
1092  &rcControl2);
1093  GetWindowRect(GetDlgItem(sp->hWnd,
1095  &rcControl3);
1096  if (!(dwp = DeferWindowPos(dwp,
1097  sp->hAceCheckList,
1098  NULL,
1099  0,
1100  0,
1101  cxWidth,
1102  ((sp->ObjectInfo.dwFlags & SI_ADVANCED) ?
1103  Height - (rcControl.top - rcWnd.top) -
1104  (rcControl3.bottom - rcControl3.top) - pt.x - btnSpacing :
1105  Height - (rcControl.top - rcWnd.top) - pt.x),
1107  {
1108  goto EndDeferWnds;
1109  }
1110 
1111  if (sp->ObjectInfo.dwFlags & SI_ADVANCED)
1112  {
1113  /* move and resize the Advanced label */
1114  if (!(dwp = DeferWindowPos(dwp,
1115  GetDlgItem(sp->hWnd,
1117  NULL,
1118  pt.x,
1119  Height - (rcControl3.bottom - rcControl3.top) - pt.x,
1120  cxWidth - (rcControl2.right - rcControl2.left) - cxEdge,
1121  rcControl3.bottom - rcControl3.top,
1122  SWP_NOZORDER)))
1123  {
1124  goto EndDeferWnds;
1125  }
1126 
1127  /* move and resize the Advanced button */
1128  if (!(dwp = DeferWindowPos(dwp,
1129  sp->hBtnAdvanced,
1130  NULL,
1131  cxWidth - (rcControl2.right - rcControl2.left) + pt.x,
1132  Height - (rcControl2.bottom - rcControl2.top) - pt.x,
1133  0,
1134  0,
1136  {
1137  goto EndDeferWnds;
1138  }
1139  }
1140 
1141  EndDeferWindowPos(dwp);
1142  }
1143 
1144 EndDeferWnds:
1145  /* update the width of the principal list view column */
1146  GetClientRect(sp->hWndPrincipalsList,
1147  &rcControl);
1148  lvc.mask = LVCF_WIDTH;
1149  lvc.cx = rcControl.right;
1150  (void)ListView_SetColumn(sp->hWndPrincipalsList,
1151  0,
1152  &lvc);
1153 
1154  /* calculate the columns of the allow/deny checkboxes */
1155  SetAceCheckListColumns(sp->hAceCheckList,
1156  CLB_ALLOW,
1157  hWndAllow);
1158  SetAceCheckListColumns(sp->hAceCheckList,
1159  CLB_DENY,
1160  hWndDeny);
1161 }
#define ListView_SetColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2601
HDWP WINAPI BeginDeferWindowPos(_In_ int)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define LVCF_WIDTH
Definition: commctrl.h:2559
long y
Definition: polytest.cpp:48
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define CLB_DENY
Definition: precomp.h:123
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
#define CLB_ALLOW
Definition: precomp.h:122
LONG top
Definition: windef.h:292
#define SM_CXEDGE
Definition: winuser.h:998
LONG left
Definition: windef.h:291
#define SWP_NOZORDER
Definition: winuser.h:1232
#define SI_ADVANCED
Definition: accctrl.h:118
LONG right
Definition: windef.h:293
int32_t INT
Definition: typedefs.h:56
#define LVCOLUMN
Definition: commctrl.h:2553
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
smooth NULL
Definition: ftsmooth.c:416
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
int WINAPI GetSystemMetrics(_In_ int)
#define IDC_OWNER
Definition: resource.h:14
#define IDC_LABEL_ADVANCED
Definition: resource.h:12
static VOID SetAceCheckListColumns(IN HWND hAceCheckList, IN UINT Button, IN HWND hLabel)
Definition: aclui.c:774
#define SWP_NOSIZE
Definition: winuser.h:1230
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define IDC_LABEL_DENY
Definition: resource.h:10
#define IDC_LABEL_ALLOW
Definition: resource.h:9
LONG bottom
Definition: windef.h:294
static const WCHAR sp[]
Definition: suminfo.c:288
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

Referenced by SecurityPageProc().

◆ SecurityPageCallback()

static UINT CALLBACK SecurityPageCallback ( IN HWND  hwnd,
IN UINT  uMsg,
IN LPPROPSHEETPAGE  ppsp 
)
static

Definition at line 751 of file aclui.c.

754 {
755  PSECURITY_PAGE sp = (PSECURITY_PAGE)ppsp->lParam;
756 
757  switch (uMsg)
758  {
759  case PSPCB_CREATE:
760  {
761  return TRUE;
762  }
763  case PSPCB_RELEASE:
764  {
766  return FALSE;
767  }
768  }
769 
770  return FALSE;
771 }
struct _SECURITY_PAGE * PSECURITY_PAGE
#define TRUE
Definition: types.h:120
switch(r->id)
Definition: btrfs.c:2932
#define PSPCB_RELEASE
Definition: prsht.h:37
#define PSPCB_CREATE
Definition: prsht.h:38
static const WCHAR sp[]
Definition: suminfo.c:288
static VOID DestroySecurityPage(IN PSECURITY_PAGE sp)
Definition: aclui.c:88

Referenced by CreateSecurityPage().

◆ SecurityPageProc()

static INT_PTR CALLBACK SecurityPageProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 1237 of file aclui.c.

1241 {
1243  INT_PTR Ret = FALSE;
1244 
1246  if (sp != NULL || uMsg == WM_INITDIALOG)
1247  {
1248  switch (uMsg)
1249  {
1250  case WM_NOTIFY:
1251  {
1252  NMHDR *pnmh = (NMHDR*)lParam;
1253 
1254  if (pnmh->hwndFrom == sp->hWndPrincipalsList)
1255  {
1256  switch (pnmh->code)
1257  {
1258  case LVN_ITEMCHANGED:
1259  {
1261 
1262  if ((pnmv->uChanged & LVIF_STATE) &&
1263  ((pnmv->uOldState & (LVIS_FOCUSED | LVIS_SELECTED)) ||
1264  (pnmv->uNewState & (LVIS_FOCUSED | LVIS_SELECTED))))
1265  {
1267  }
1268  break;
1269  }
1270  }
1271  }
1272  else if (pnmh->hwndFrom == sp->hAceCheckList)
1273  {
1274  switch (pnmh->code)
1275  {
1277  {
1279 
1280  /* make sure only one of both checkboxes is only checked
1281  at the same time */
1282  if (pcicb->Checked)
1283  {
1284  pcicb->NewState &= ~((pcicb->CheckBox != CLB_DENY) ? CIS_DENY : CIS_ALLOW);
1285  }
1286  break;
1287  }
1288  }
1289  }
1290  else if (pnmh->hwndFrom == sp->hWnd)
1291  {
1292  switch(pnmh->code)
1293  {
1294  case SIDN_LOOKUPSUCCEEDED:
1295  {
1298  nmh);
1299 
1300  /* a SID lookup succeeded, update the information */
1302  LookupInfo);
1303  break;
1304  }
1305  }
1306  }
1307  break;
1308  }
1309 
1310  case WM_COMMAND:
1311  {
1312  switch (LOWORD(wParam))
1313  {
1314  case IDC_ADD_PRINCIPAL:
1315  {
1316  HRESULT hRet;
1317 
1318  hRet = InitializeObjectPicker(sp->ServerName,
1319  &sp->ObjectInfo,
1320  &sp->pDsObjectPicker);
1321  if (SUCCEEDED(hRet))
1322  {
1323  hRet = InvokeObjectPickerDialog(sp->pDsObjectPicker,
1324  hwndDlg,
1326  sp);
1327  if (FAILED(hRet))
1328  {
1329  MessageBox(hwndDlg, L"InvokeObjectPickerDialog failed!\n", NULL, 0);
1330  }
1331 
1332  /* delete the instance */
1333  FreeObjectPicker(sp->pDsObjectPicker);
1334  }
1335  else
1336  {
1337  MessageBox(hwndDlg, L"InitializeObjectPicker failed!\n", NULL, 0);
1338  }
1339  break;
1340  }
1341 
1342  case IDC_REMOVE_PRINCIPAL:
1343  {
1344  PPRINCIPAL_LISTITEM SelectedPrincipal;
1345 
1346  SelectedPrincipal = (PPRINCIPAL_LISTITEM)ListViewGetSelectedItemData(sp->hWndPrincipalsList);
1347  if (SelectedPrincipal != NULL)
1348  {
1349  /* FIXME */
1350  }
1351  break;
1352  }
1353  }
1354  break;
1355  }
1356 
1357  case WM_SIZE:
1358  {
1360  (INT)LOWORD(lParam),
1361  (INT)HIWORD(lParam));
1362  break;
1363  }
1364 
1365  case WM_INITDIALOG:
1366  {
1368  if(sp != NULL)
1369  {
1370  LV_COLUMN lvc;
1371  RECT rcLvClient;
1372 
1373  sp->hWnd = hwndDlg;
1374  sp->hWndPrincipalsList = GetDlgItem(hwndDlg, IDC_PRINCIPALS);
1375  sp->hBtnAdd = GetDlgItem(hwndDlg, IDC_ADD_PRINCIPAL);
1376  sp->hBtnRemove = GetDlgItem(hwndDlg, IDC_REMOVE_PRINCIPAL);
1377  sp->hBtnAdvanced = GetDlgItem(hwndDlg, IDC_ADVANCED);
1378  sp->hAceCheckList = GetDlgItem(hwndDlg, IDC_ACE_CHECKLIST);
1379  sp->hPermissionsForLabel = GetDlgItem(hwndDlg, IDC_LABEL_PERMISSIONS_FOR);
1380 
1381  sp->SpecialPermCheckIndex = -1;
1382 
1383  /* save the pointer to the structure */
1384  SetWindowLongPtr(hwndDlg, DWLP_USER, (DWORD_PTR)sp);
1385 
1386  (void)ListView_SetExtendedListViewStyleEx(sp->hWndPrincipalsList,
1389 
1390  sp->hiPrincipals = ImageList_Create(16,
1391  16,
1393  0,
1394  3);
1395  if (sp->hiPrincipals != NULL)
1396  {
1397  HBITMAP hbmImages;
1398 
1399  hbmImages = LoadBitmap(hDllInstance,
1401  if (hbmImages != NULL)
1402  {
1403  ImageList_AddMasked(sp->hiPrincipals,
1404  hbmImages,
1405  RGB(255,
1406  0,
1407  255));
1408 
1409  DeleteObject(hbmImages);
1410  }
1411  }
1412 
1413  /* setup the listview control */
1414  if (sp->hiPrincipals != NULL)
1415  {
1416  (void)ListView_SetImageList(sp->hWndPrincipalsList,
1417  sp->hiPrincipals,
1418  LVSIL_SMALL);
1419  }
1420 
1421  GetClientRect(sp->hWndPrincipalsList,
1422  &rcLvClient);
1423 
1424  /* add a column to the list view */
1425  lvc.mask = LVCF_FMT | LVCF_WIDTH;
1426  lvc.fmt = LVCFMT_LEFT;
1427  lvc.cx = rcLvClient.right;
1428  (void)ListView_InsertColumn(sp->hWndPrincipalsList,
1429  0,
1430  &lvc);
1431 
1433 
1434  ListViewSelectItem(sp->hWndPrincipalsList,
1435  0);
1436 
1437  /* calculate the columns of the allow/deny checkboxes */
1438  SetAceCheckListColumns(sp->hAceCheckList,
1439  CLB_ALLOW,
1440  GetDlgItem(hwndDlg, IDC_LABEL_ALLOW));
1441  SetAceCheckListColumns(sp->hAceCheckList,
1442  CLB_DENY,
1443  GetDlgItem(hwndDlg, IDC_LABEL_DENY));
1444 
1446  NULL,
1448  ((sp->ObjectInfo.dwFlags & SI_CONTAINER) ? SI_ACCESS_CONTAINER : 0),
1449  &sp->DefaultAccess);
1450 
1451  /* hide controls in case the flags aren't present */
1452  if (sp->ObjectInfo.dwFlags & SI_ADVANCED)
1453  {
1454  /* editing the permissions is least the user can do when
1455  the advanced button is showed */
1456  sp->ObjectInfo.dwFlags |= SI_EDIT_PERMS;
1457  }
1458  else
1459  {
1460  ShowWindow(sp->hBtnAdvanced,
1461  SW_HIDE);
1463  SW_HIDE);
1464  }
1465 
1466  /* enable quicksearch for the permissions checklist control */
1467  SendMessage(sp->hAceCheckList,
1469  TRUE,
1470  0);
1471 
1473  }
1474 
1475  Ret = TRUE;
1476  break;
1477  }
1478  }
1479  }
1480  return Ret;
1481 }
LPARAM ListViewGetSelectedItemData(IN HWND hwnd)
Definition: misc.c:134
#define SIDN_LOOKUPSUCCEEDED
Definition: aclui.c:40
BOOL ListViewSelectItem(IN HWND hwnd, IN INT Index)
Definition: misc.c:160
struct _SECURITY_PAGE * PSECURITY_PAGE
#define CIS_ALLOW
Definition: precomp.h:117
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define TRUE
Definition: types.h:120
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define SI_CONTAINER
Definition: accctrl.h:116
#define LVCF_WIDTH
Definition: commctrl.h:2559
#define LVSIL_SMALL
Definition: commctrl.h:2271
HRESULT InvokeObjectPickerDialog(IN IDsObjectPicker *pDsObjectPicker, IN HWND hwndParent OPTIONAL, IN POBJPICK_SELECTED_SID SelectedSidCallback, IN PVOID Context OPTIONAL)
Definition: misc.c:249
UINT uNewState
Definition: commctrl.h:3008
#define CLB_DENY
Definition: precomp.h:123
#define CLN_CHANGINGITEMCHECKBOX
Definition: precomp.h:140
#define SI_ACCESS_CONTAINER
Definition: accctrl.h:140
#define SW_HIDE
Definition: winuser.h:762
#define LV_COLUMN
Definition: commctrl.h:2519
#define LVN_ITEMCHANGED
Definition: commctrl.h:3103
#define CLB_ALLOW
Definition: precomp.h:122
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2706
struct _NMCHANGEITEMCHECKBOX * PNMCHANGEITEMCHECKBOX
#define LVCFMT_LEFT
Definition: commctrl.h:2570
static VOID UpdateControlStates(IN PSECURITY_PAGE sp)
Definition: aclui.c:629
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define SI_EDIT_PERMS
Definition: accctrl.h:113
#define IDC_ADD_PRINCIPAL
Definition: resource.h:6
HRESULT InitializeObjectPicker(IN PCWSTR ServerName, IN PSI_OBJECT_INFO ObjectInfo, OUT IDsObjectPicker **pDsObjectPicker)
Definition: misc.c:176
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int32_t INT_PTR
Definition: typedefs.h:62
#define IDC_ADVANCED
Definition: resource.h:11
#define SI_ADVANCED
Definition: accctrl.h:118
LONG right
Definition: windef.h:293
int32_t INT
Definition: typedefs.h:56
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
static VOID ResizeControls(IN PSECURITY_PAGE sp, IN INT Width, IN INT Height)
Definition: aclui.c:899
#define ILC_COLOR32
Definition: commctrl.h:343
UINT code
Definition: winuser.h:3133
static VOID FreeObjectPicker(IN IDsObjectPicker *pDsObjectPicker)
Definition: framewnd.c:1017
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2608
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2276
#define LPPROPSHEETPAGE
Definition: prsht.h:372
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2291
UINT uOldState
Definition: commctrl.h:3009
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define LoadBitmap
Definition: winuser.h:5712
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_SIZE
Definition: winuser.h:1593
LONG HRESULT
Definition: typedefs.h:77
#define IDC_ACE_CHECKLIST
Definition: resource.h:8
#define CIS_DENY
Definition: precomp.h:118
static void UpdatePrincipalInfo(IN PSECURITY_PAGE sp, IN PSIDLOOKUPNOTIFYINFO LookupInfo)
Definition: aclui.c:680
#define RGB(r, g, b)
Definition: wingdi.h:2935
#define IDC_LABEL_PERMISSIONS_FOR
Definition: resource.h:13
struct _PRINCIPAL_LISTITEM * PPRINCIPAL_LISTITEM
#define IDC_LABEL_ADVANCED
Definition: resource.h:12
#define IDC_PRINCIPALS
Definition: resource.h:5
static const WCHAR L[]
Definition: oid.c:1250
static VOID SetAceCheckListColumns(IN HWND hAceCheckList, IN UINT Button, IN HWND hLabel)
Definition: aclui.c:774
#define DWLP_USER
Definition: winuser.h:866
#define ILC_MASK
Definition: commctrl.h:336
#define MessageBox
Definition: winuser.h:5723
#define WM_COMMAND
Definition: winuser.h:1722
HWND hwndFrom
Definition: winuser.h:3131
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define IDC_REMOVE_PRINCIPAL
Definition: resource.h:7
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define LVCF_FMT
Definition: commctrl.h:2558
#define IDC_LABEL_DENY
Definition: resource.h:10
struct tagNMLISTVIEW * LPNMLISTVIEW
#define SI_ACCESS_GENERAL
Definition: accctrl.h:139
#define IDB_USRGRPIMAGES
Definition: resource.h:24
#define CLM_ENABLEQUICKSEARCH
Definition: precomp.h:135
#define IDC_LABEL_ALLOW
Definition: resource.h:9
HINSTANCE hDllInstance
Definition: aclui.c:38
#define ListView_SetExtendedListViewStyleEx(hwndLV, dwMask, dw)
Definition: commctrl.h:2698
#define SendMessage
Definition: winuser.h:5744
#define HIWORD(l)
Definition: typedefs.h:246
static const WCHAR sp[]
Definition: suminfo.c:288
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:563
static HBITMAP
Definition: button.c:44
#define GetWindowLongPtr
Definition: treelist.c:73
static VOID LoadPermissionsList(IN PSECURITY_PAGE sp, IN GUID *GuidObjectType, IN DWORD dwFlags, OUT SI_ACCESS *DefaultAccess)
Definition: aclui.c:797
#define LVIF_STATE
Definition: commctrl.h:2284
static VOID ReloadPrincipalsList(IN PSECURITY_PAGE sp)
Definition: aclui.c:508
#define WM_INITDIALOG
Definition: winuser.h:1721
static BOOL AddSelectedPrincipal(IN IDsObjectPicker *pDsObjectPicker, IN HWND hwndParent OPTIONAL, IN PSID pSid, IN PVOID Context OPTIONAL)
Definition: aclui.c:1200
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define LVIS_FOCUSED
Definition: commctrl.h:2290
#define WM_NOTIFY
Definition: richedit.h:61
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by CreateSecurityPage().

◆ SetAceCheckListColumns()

static VOID SetAceCheckListColumns ( IN HWND  hAceCheckList,
IN UINT  Button,
IN HWND  hLabel 
)
static

Definition at line 774 of file aclui.c.

777 {
778  POINT pt;
779  RECT rcLabel;
780 
781  GetWindowRect(hLabel,
782  &rcLabel);
783  pt.y = 0;
784  pt.x = (rcLabel.right - rcLabel.left) / 2;
785  MapWindowPoints(hLabel,
786  hAceCheckList,
787  &pt,
788  1);
789 
790  SendMessage(hAceCheckList,
792  Button,
793  pt.x);
794 }
#define CLM_SETCHECKBOXCOLUMN
Definition: precomp.h:131
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define pt(x, y)
Definition: drawing.c:79
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define SendMessage
Definition: winuser.h:5744
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
Definition: window.h:572

Referenced by ResizeControls(), and SecurityPageProc().

◆ SidLookupCompletion()

static VOID SidLookupCompletion ( IN HANDLE  SidCacheMgr,
IN PSID  Sid,
IN PSIDREQRESULT  SidRequestResult,
IN PVOID  Context 
)
static

Definition at line 210 of file aclui.c.

214 {
216 
217  /* NOTE: this routine may be executed in a different thread
218  than the GUI! */
219 
220  if (SidRequestResult != NULL)
221  {
222  SIDLOOKUPNOTIFYINFO LookupInfo;
223 
224  LookupInfo.nmh.hwndFrom = sp->hWnd;
225  LookupInfo.nmh.idFrom = 0;
226  LookupInfo.nmh.code = SIDN_LOOKUPSUCCEEDED;
227  LookupInfo.Sid = Sid;
228  LookupInfo.SidRequestResult = SidRequestResult;
229 
230  /* notify the page that the sid lookup succeeded */
231  SendMessage(sp->hWnd,
232  WM_NOTIFY,
233  (WPARAM)LookupInfo.nmh.idFrom,
234  (LPARAM)&LookupInfo.nmh);
235  }
236 }
#define SIDN_LOOKUPSUCCEEDED
Definition: aclui.c:40
struct _SECURITY_PAGE * PSECURITY_PAGE
UINT_PTR WPARAM
Definition: windef.h:207
UINT code
Definition: winuser.h:3133
PSIDREQRESULT SidRequestResult
Definition: aclui.c:45
UINT_PTR idFrom
Definition: winuser.h:3132
smooth NULL
Definition: ftsmooth.c:416
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1104
LONG_PTR LPARAM
Definition: windef.h:208
HWND hwndFrom
Definition: winuser.h:3131
#define SendMessage
Definition: winuser.h:5744
static const WCHAR sp[]
Definition: suminfo.c:288
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by AddPrincipalToList(), and ReloadPrincipalsList().

◆ UpdateControlStates()

static VOID UpdateControlStates ( IN PSECURITY_PAGE  sp)
static

Definition at line 629 of file aclui.c.

630 {
632 
633  EnableWindow(sp->hBtnRemove,
634  Selected != NULL);
635  EnableWindow(sp->hAceCheckList,
636  Selected != NULL);
637 
638  if (Selected != NULL)
639  {
640  LPWSTR szLabel;
641  LPWSTR szDisplayString;
642 
643  szDisplayString = GetPrincipalAccountNameString(Selected);
646  &szLabel,
647  szDisplayString))
648  {
649  SetWindowText(sp->hPermissionsForLabel,
650  szLabel);
651 
652  LocalFree((HLOCAL)szLabel);
653  }
654 
655  LocalFree((HLOCAL)szDisplayString);
656 
657  /* FIXME - update the checkboxes */
658  }
659  else
660  {
661  WCHAR szPermissions[255];
662 
665  szPermissions,
666  sizeof(szPermissions) / sizeof(szPermissions[0])))
667  {
668  SetWindowText(sp->hPermissionsForLabel,
669  szPermissions);
670  }
671 
672  SendMessage(sp->hAceCheckList,
674  0,
675  0);
676  }
677 }
LPARAM ListViewGetSelectedItemData(IN HWND hwnd)
Definition: misc.c:134
#define IDS_PERMISSIONS
Definition: resource.h:20
smooth NULL
Definition: ftsmooth.c:416
DWORD LoadAndFormatString(IN HINSTANCE hInstance, IN UINT uID, OUT LPTSTR *lpTarget,...)
Definition: misc.c:86
#define IDS_PERMISSIONS_FOR
Definition: resource.h:19
static LPWSTR GetPrincipalAccountNameString(IN PPRINCIPAL_LISTITEM PrincipalListItem)
Definition: aclui.c:363
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _PRINCIPAL_LISTITEM * PPRINCIPAL_LISTITEM
#define CLM_CLEARCHECKBOXES
Definition: precomp.h:133
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define SetWindowText
Definition: winuser.h:5758
HINSTANCE hDllInstance
Definition: aclui.c:38
#define SendMessage
Definition: winuser.h:5744
static const WCHAR sp[]
Definition: suminfo.c:288
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define LoadString
Definition: winuser.h:5720

Referenced by SecurityPageProc(), and UpdatePrincipalInfo().

◆ UpdatePrincipalInfo()

static void UpdatePrincipalInfo ( IN PSECURITY_PAGE  sp,
IN PSIDLOOKUPNOTIFYINFO  LookupInfo 
)
static

Definition at line 680 of file aclui.c.

682 {
683  PPRINCIPAL_LISTITEM CurItem;
684  LPWSTR DisplayName;
685 
686  if (sp->OwnerSid != NULL &&
687  EqualSid(sp->OwnerSid,
688  LookupInfo->Sid))
689  {
690  if (LookupInfo->SidRequestResult != NULL)
691  DisplayName = GetDisplayStringFromSidRequestResult(LookupInfo->SidRequestResult);
692  else if (!ConvertSidToStringSidW(LookupInfo->Sid,
693  &DisplayName))
694  {
695  DisplayName = NULL;
696  }
697 
698  if (DisplayName != NULL)
699  {
700  SetDlgItemTextW(sp->hWnd,
701  IDC_OWNER,
702  DisplayName);
703 
704  LocalFree((HLOCAL)DisplayName);
705  }
706  }
707 
708  for (CurItem = sp->PrincipalsListHead;
709  CurItem != NULL;
710  CurItem = CurItem->Next)
711  {
712  if (EqualSid((PSID)(CurItem + 1),
713  LookupInfo->Sid))
714  {
715  INT PrincipalIndex;
716  LVFINDINFO lvfi;
717 
718  /* find the principal in the list */
719  lvfi.flags = LVFI_PARAM;
720  lvfi.lParam = (LPARAM)CurItem;
721  PrincipalIndex = ListView_FindItem(sp->hWndPrincipalsList,
722  -1,
723  &lvfi);
724 
725  if (PrincipalIndex != -1)
726  {
727  /* update the principal in the list view control */
729  PrincipalIndex,
730  CurItem,
731  LookupInfo->SidRequestResult);
732 
733  if (ListViewGetSelectedItemData(sp->hWndPrincipalsList) == (LPARAM)CurItem)
734  {
736  }
737  }
738  else
739  {
741  CurItem,
742  -1,
743  FALSE);
744  }
745  break;
746  }
747  }
748 }
LPARAM ListViewGetSelectedItemData(IN HWND hwnd)
Definition: misc.c:134
static LPWSTR GetDisplayStringFromSidRequestResult(IN PSIDREQRESULT SidReqResult)
Definition: aclui.c:319
struct _PRINCIPAL_LISTITEM * Next
Definition: precomp.h:36
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:708
static VOID UpdateControlStates(IN PSECURITY_PAGE sp)
Definition: aclui.c:629
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3259
int32_t INT
Definition: typedefs.h:56
#define LVFI_PARAM
Definition: commctrl.h:2408
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static INT AddPrincipalListEntry(IN PSECURITY_PAGE sp, IN PPRINCIPAL_LISTITEM PrincipalListItem, IN INT Index, IN BOOL Selected)
Definition: aclui.c:419
#define IDC_OWNER
Definition: resource.h:14
static VOID UpdatePrincipalListItem(IN PSECURITY_PAGE sp, IN INT PrincipalIndex, IN PPRINCIPAL_LISTITEM PrincipalListItem, IN PSIDREQRESULT SidReqResult)
Definition: aclui.c:463
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define LVFINDINFO
Definition: commctrl.h:2435
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2442
static const WCHAR sp[]
Definition: suminfo.c:288
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by SecurityPageProc().

◆ UpdatePrincipalListItem()

static VOID UpdatePrincipalListItem ( IN PSECURITY_PAGE  sp,
IN INT  PrincipalIndex,
IN PPRINCIPAL_LISTITEM  PrincipalListItem,
IN PSIDREQRESULT  SidReqResult 
)
static

Definition at line 463 of file aclui.c.

467 {
468  LVITEM li;
469 
470  /* replace the request result structure */
471  if (PrincipalListItem->SidReqResult != NULL)
472  {
473  DereferenceSidReqResult(sp->SidCacheMgr,
474  PrincipalListItem->SidReqResult);
475  }
476 
477  ReferenceSidReqResult(sp->SidCacheMgr,
478  SidReqResult);
479  PrincipalListItem->SidReqResult = SidReqResult;
480 
481  /* update the display string */
482  if (PrincipalListItem->DisplayString != NULL)
483  {
484  LocalFree((HLOCAL)PrincipalListItem->DisplayString);
485  }
486  PrincipalListItem->DisplayString = GetPrincipalDisplayString(PrincipalListItem);
487 
488  /* update the list item */
490  sp,
491  PrincipalListItem,
492  PrincipalIndex,
493  FALSE);
494 
495  /* don't change the list item state */
496  li.mask &= ~(LVIF_STATE | LVIF_PARAM);
497 
498  (void)ListView_SetItem(sp->hWndPrincipalsList,
499  &li);
500 
501  /* sort the principals list view again */
502  (void)ListView_SortItems(sp->hWndPrincipalsList,
504  (LPARAM)sp);
505 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define ListView_SetItem(hwnd, pitem)
Definition: commctrl.h:2373
static VOID CreatePrincipalListItem(OUT LVITEM *li, IN PSECURITY_PAGE sp, IN PPRINCIPAL_LISTITEM PrincipalListItem, IN INT Index, IN BOOL Selected)
Definition: aclui.c:384
VOID ReferenceSidReqResult(IN HANDLE SidCacheMgr, IN PSIDREQRESULT ReqResult)
Definition: sidcache.c:835
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static LPWSTR GetPrincipalDisplayString(IN PPRINCIPAL_LISTITEM PrincipalListItem)
Definition: aclui.c:345
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static int CALLBACK PrincipalCompare(IN LPARAM lParam1, IN LPARAM lParam2, IN LPARAM lParamSort)
Definition: aclui.c:446
#define ListView_SortItems(hwndLV, _pfnCompare, _lPrm)
Definition: commctrl.h:2675
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVITEM
Definition: commctrl.h:2347
static const WCHAR sp[]
Definition: suminfo.c:288
#define LVIF_STATE
Definition: commctrl.h:2284
VOID DereferenceSidReqResult(IN HANDLE SidCacheMgr, IN PSIDREQRESULT ReqResult)
Definition: sidcache.c:851

Referenced by UpdatePrincipalInfo().

Variable Documentation

◆ hDllInstance