📄 aclui.c
字号:
else
{
NameStr = CurAccess->pszName;
}
SendMessage(sp->hAceCheckList,
CLM_ADDITEM,
(WPARAM)CurAccess->mask,
(LPARAM)NameStr);
}
else if (CurAccess->dwFlags & SI_ACCESS_SPECIFIC)
{
SpecialPermissionsPresent = TRUE;
SpecialPermissionsMask |= CurAccess->mask;
}
}
}
/* add the special permissions check item in case the specific access rights
aren't displayed */
if (SpecialPermissionsPresent &&
LoadString(hDllInstance,
IDS_SPECIAL_PERMISSIONS,
szSpecialPermissions,
sizeof(szSpecialPermissions) / sizeof(szSpecialPermissions[0])))
{
/* add the special permissions check item */
sp->SpecialPermCheckIndex = (INT)SendMessage(sp->hAceCheckList,
CLM_ADDITEM,
(WPARAM)SpecialPermissionsMask,
(LPARAM)szSpecialPermissions);
if (sp->SpecialPermCheckIndex != -1)
{
SendMessage(sp->hAceCheckList,
CLM_SETITEMSTATE,
(WPARAM)sp->SpecialPermCheckIndex,
CIS_ALLOWDISABLED | CIS_DENYDISABLED | CIS_NONE);
}
}
}
static VOID
ResizeControls(IN PSECURITY_PAGE sp,
IN INT Width,
IN INT Height)
{
HWND hWndAllow, hWndDeny, hWndOwnerEdit;
RECT rcControl, rcControl2, rcControl3, rcWnd;
INT cxWidth, cxEdge, btnSpacing;
POINT pt, pt2;
HDWP dwp;
INT nControls = 8;
LVCOLUMN lvc;
hWndAllow = GetDlgItem(sp->hWnd,
IDC_LABEL_ALLOW);
hWndDeny = GetDlgItem(sp->hWnd,
IDC_LABEL_DENY);
GetWindowRect(sp->hWnd,
&rcWnd);
cxEdge = GetSystemMetrics(SM_CXEDGE);
/* use the left margin of the principal list view control for all control
margins */
pt.x = 0;
pt.y = 0;
MapWindowPoints(sp->hWndPrincipalsList,
sp->hWnd,
&pt,
1);
cxWidth = Width - (2 * pt.x);
if (sp->ObjectInfo.dwFlags & SI_ADVANCED)
{
nControls += 2;
}
if ((dwp = BeginDeferWindowPos(nControls)))
{
/* resize the owner edit field */
hWndOwnerEdit = GetDlgItem(sp->hWnd,
IDC_OWNER);
GetWindowRect(hWndOwnerEdit,
&rcControl);
pt2.x = 0;
pt2.y = 0;
MapWindowPoints(hWndOwnerEdit,
sp->hWnd,
&pt2,
1);
if (!(dwp = DeferWindowPos(dwp,
hWndOwnerEdit,
NULL,
0,
0,
Width - pt.x - pt2.x,
rcControl.bottom - rcControl.top,
SWP_NOMOVE | SWP_NOZORDER)))
{
goto EndDeferWnds;
}
/* resize the Principal list view */
GetWindowRect(sp->hWndPrincipalsList,
&rcControl);
if (!(dwp = DeferWindowPos(dwp,
sp->hWndPrincipalsList,
NULL,
0,
0,
cxWidth,
rcControl.bottom - rcControl.top,
SWP_NOMOVE | SWP_NOZORDER)))
{
goto EndDeferWnds;
}
/* move the Add Principal button */
GetWindowRect(sp->hBtnAdd,
&rcControl);
GetWindowRect(sp->hBtnRemove,
&rcControl2);
btnSpacing = rcControl2.left - rcControl.right;
pt2.x = 0;
pt2.y = 0;
MapWindowPoints(sp->hBtnAdd,
sp->hWnd,
&pt2,
1);
if (!(dwp = DeferWindowPos(dwp,
sp->hBtnAdd,
NULL,
pt.x + cxWidth - (rcControl2.right - rcControl2.left) -
(rcControl.right - rcControl.left) -
btnSpacing - cxEdge,
pt2.y,
0,
0,
SWP_NOSIZE | SWP_NOZORDER)))
{
goto EndDeferWnds;
}
/* move the Delete Principal button */
pt2.x = 0;
pt2.y = 0;
MapWindowPoints(sp->hBtnRemove,
sp->hWnd,
&pt2,
1);
if (!(dwp = DeferWindowPos(dwp,
sp->hBtnRemove,
NULL,
pt.x + cxWidth - (rcControl2.right - rcControl2.left) - cxEdge,
pt2.y,
0,
0,
SWP_NOSIZE | SWP_NOZORDER)))
{
goto EndDeferWnds;
}
/* move the Permissions For label */
GetWindowRect(hWndAllow,
&rcControl);
GetWindowRect(hWndDeny,
&rcControl2);
GetWindowRect(sp->hPermissionsForLabel,
&rcControl3);
pt2.x = 0;
pt2.y = 0;
MapWindowPoints(sp->hPermissionsForLabel,
sp->hWnd,
&pt2,
1);
if (!(dwp = DeferWindowPos(dwp,
sp->hPermissionsForLabel,
NULL,
0,
0,
cxWidth - (rcControl2.right - rcControl2.left) -
(rcControl.right - rcControl.left) -
(2 * btnSpacing) - cxEdge,
rcControl3.bottom - rcControl3.top,
SWP_NOMOVE | SWP_NOZORDER)))
{
goto EndDeferWnds;
}
/* move the Allow label */
pt2.x = 0;
pt2.y = 0;
MapWindowPoints(hWndAllow,
sp->hWnd,
&pt2,
1);
if (!(dwp = DeferWindowPos(dwp,
hWndAllow,
NULL,
cxWidth - (rcControl2.right - rcControl2.left) -
(rcControl.right - rcControl.left) -
btnSpacing - cxEdge,
pt2.y,
0,
0,
SWP_NOSIZE | SWP_NOZORDER)))
{
goto EndDeferWnds;
}
/* move the Deny label */
pt2.x = 0;
pt2.y = 0;
MapWindowPoints(hWndDeny,
sp->hWnd,
&pt2,
1);
if (!(dwp = DeferWindowPos(dwp,
hWndDeny,
NULL,
cxWidth - (rcControl2.right - rcControl2.left) - cxEdge,
pt2.y,
0,
0,
SWP_NOSIZE | SWP_NOZORDER)))
{
goto EndDeferWnds;
}
/* resize the Permissions check list box */
GetWindowRect(sp->hAceCheckList,
&rcControl);
GetWindowRect(sp->hBtnAdvanced,
&rcControl2);
GetWindowRect(GetDlgItem(sp->hWnd,
IDC_LABEL_ADVANCED),
&rcControl3);
if (!(dwp = DeferWindowPos(dwp,
sp->hAceCheckList,
NULL,
0,
0,
cxWidth,
((sp->ObjectInfo.dwFlags & SI_ADVANCED) ?
Height - (rcControl.top - rcWnd.top) -
(rcControl3.bottom - rcControl3.top) - pt.x - btnSpacing :
Height - (rcControl.top - rcWnd.top) - pt.x),
SWP_NOMOVE | SWP_NOZORDER)))
{
goto EndDeferWnds;
}
if (sp->ObjectInfo.dwFlags & SI_ADVANCED)
{
/* move and resize the Advanced label */
if (!(dwp = DeferWindowPos(dwp,
GetDlgItem(sp->hWnd,
IDC_LABEL_ADVANCED),
NULL,
pt.x,
Height - (rcControl3.bottom - rcControl3.top) - pt.x,
cxWidth - (rcControl2.right - rcControl2.left) - cxEdge,
rcControl3.bottom - rcControl3.top,
SWP_NOZORDER)))
{
goto EndDeferWnds;
}
/* move and resize the Advanced button */
if (!(dwp = DeferWindowPos(dwp,
sp->hBtnAdvanced,
NULL,
cxWidth - (rcControl2.right - rcControl2.left) + pt.x,
Height - (rcControl2.bottom - rcControl2.top) - pt.x,
0,
0,
SWP_NOSIZE | SWP_NOZORDER)))
{
goto EndDeferWnds;
}
}
EndDeferWindowPos(dwp);
}
EndDeferWnds:
/* update the width of the principal list view column */
GetClientRect(sp->hWndPrincipalsList,
&rcControl);
lvc.mask = LVCF_WIDTH;
lvc.cx = rcControl.right;
(void)ListView_SetColumn(sp->hWndPrincipalsList,
0,
&lvc);
/* calculate the columns of the allow/deny checkboxes */
SetAceCheckListColumns(sp->hAceCheckList,
CLB_ALLOW,
hWndAllow);
SetAceCheckListColumns(sp->hAceCheckList,
CLB_DENY,
hWndDeny);
}
static PACE_HEADER
BuildDefaultPrincipalAce(IN PSECURITY_PAGE sp,
IN PSID pSid)
{
PACCESS_ALLOWED_ACE Ace;
DWORD SidLen;
WORD AceSize;
SidLen = GetLengthSid(pSid);
AceSize = FIELD_OFFSET(ACCESS_ALLOWED_ACE,
SidStart) + (WORD)SidLen;
Ace = HeapAlloc(GetProcessHeap(),
0,
AceSize);
if (Ace != NULL)
{
Ace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
Ace->Header.AceFlags = 0; /* FIXME */
Ace->Header.AceSize = AceSize;
Ace->Mask = sp->DefaultAccess.mask;
if (CopySid(SidLen,
(PSID)&Ace->SidStart,
pSid))
{
return &Ace->Header;
}
HeapFree(GetProcessHeap(),
0,
Ace);
}
return NULL;
}
static BOOL
AddSelectedPrincipal(IN IDsObjectPicker *pDsObjectPicker,
IN HWND hwndParent OPTIONAL,
IN PSID pSid,
IN PVOID Context OPTIONAL)
{
PACE_HEADER AceHeader;
PSECURITY_PAGE sp = (PSECURITY_PAGE)Context;
AceHeader = BuildDefaultPrincipalAce(sp,
pSid);
if (AceHeader != NULL)
{
PPRINCIPAL_LISTITEM PrincipalListItem;
BOOL LookupDeferred;
PrincipalListItem = AddPrincipalToList(sp,
pSid,
AceHeader,
&LookupDeferred);
if (PrincipalListItem != NULL && LookupDeferred)
{
AddPrincipalListEntry(sp,
PrincipalListItem,
-1,
FALSE);
}
HeapFree(GetProcessHeap(),
0,
AceHeader);
}
return TRUE;
}
static INT_PTR CALLBACK
SecurityPageProc(IN HWND hwndDlg,
IN UINT uMsg,
IN WPARAM wParam,
IN LPARAM lParam)
{
PSECURITY_PAGE sp;
INT_PTR Ret = FALSE;
sp = (PSECURITY_PAGE)GetWindowLongPtr(hwndDlg,
DWL_USER);
if (sp != NULL || uMsg == WM_INITDIALOG)
{
switch (uMsg)
{
case WM_NOTIFY:
{
NMHDR *pnmh = (NMHDR*)lParam;
if (pnmh->hwndFrom == sp->hWndPrincipalsList)
{
switch (pnmh->code)
{
case LVN_ITEMCHANGED:
{
LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam;
if ((pnmv->uChanged & LVIF_STATE) &&
((pnmv->uOldState & (LVIS_FOCUSED | LVIS_SELECTED)) ||
(pnmv->uNewState & (LVIS_FOCUSED | LVIS_SELECTED))))
{
UpdateControlStates(sp);
}
break;
}
}
}
else if (pnmh->hwndFrom == sp->hAceCheckList)
{
switch (pnmh->code)
{
case CLN_CHANGINGITEMCHECKBOX:
{
PNMCHANGEITEMCHECKBOX pcicb = (PNMCHANGEITEMCHECKBOX)lParam;
/* make sure only one of both checkboxes is only checked
at the same time */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -