📄 aclui.c
字号:
if (pcicb->Checked)
{
pcicb->NewState &= ~((pcicb->CheckBox != CLB_DENY) ? CIS_DENY : CIS_ALLOW);
}
break;
}
}
}
else if (pnmh->hwndFrom == sp->hWnd)
{
switch(pnmh->code)
{
case SIDN_LOOKUPSUCCEEDED:
{
PSIDLOOKUPNOTIFYINFO LookupInfo = CONTAINING_RECORD(lParam,
SIDLOOKUPNOTIFYINFO,
nmh);
/* a SID lookup succeeded, update the information */
UpdatePrincipalInfo(sp,
LookupInfo);
break;
}
}
}
break;
}
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDC_ADD_PRINCIPAL:
{
HRESULT hRet;
hRet = InitializeObjectPicker(sp->ServerName,
&sp->ObjectInfo,
&sp->pDsObjectPicker);
if (SUCCEEDED(hRet))
{
hRet = InvokeObjectPickerDialog(sp->pDsObjectPicker,
hwndDlg,
AddSelectedPrincipal,
sp);
if (FAILED(hRet))
{
MessageBox(hwndDlg, L"InvokeObjectPickerDialog failed!\n", NULL, 0);
}
/* delete the instance */
FreeObjectPicker(sp->pDsObjectPicker);
}
else
{
MessageBox(hwndDlg, L"InitializeObjectPicker failed!\n", NULL, 0);
}
break;
}
case IDC_REMOVE_PRINCIPAL:
{
PPRINCIPAL_LISTITEM SelectedPrincipal;
SelectedPrincipal = (PPRINCIPAL_LISTITEM)ListViewGetSelectedItemData(sp->hWndPrincipalsList);
if (SelectedPrincipal != NULL)
{
/* FIXME */
}
break;
}
}
break;
}
case WM_SIZE:
{
ResizeControls(sp,
(INT)LOWORD(lParam),
(INT)HIWORD(lParam));
break;
}
case WM_INITDIALOG:
{
sp = (PSECURITY_PAGE)((LPPROPSHEETPAGE)lParam)->lParam;
if(sp != NULL)
{
LV_COLUMN lvc;
RECT rcLvClient;
sp->hWnd = hwndDlg;
sp->hWndPrincipalsList = GetDlgItem(hwndDlg, IDC_PRINCIPALS);
sp->hBtnAdd = GetDlgItem(hwndDlg, IDC_ADD_PRINCIPAL);
sp->hBtnRemove = GetDlgItem(hwndDlg, IDC_REMOVE_PRINCIPAL);
sp->hBtnAdvanced = GetDlgItem(hwndDlg, IDC_ADVANCED);
sp->hAceCheckList = GetDlgItem(hwndDlg, IDC_ACE_CHECKLIST);
sp->hPermissionsForLabel = GetDlgItem(hwndDlg, IDC_LABEL_PERMISSIONS_FOR);
sp->SpecialPermCheckIndex = -1;
/* save the pointer to the structure */
SetWindowLongPtr(hwndDlg,
DWL_USER,
(DWORD_PTR)sp);
(void)ListView_SetExtendedListViewStyleEx(sp->hWndPrincipalsList,
LVS_EX_FULLROWSELECT,
LVS_EX_FULLROWSELECT);
sp->hiPrincipals = ImageList_Create(16,
16,
ILC_COLOR32 | ILC_MASK,
0,
3);
if (sp->hiPrincipals != NULL)
{
HBITMAP hbmImages;
hbmImages = LoadBitmap(hDllInstance,
MAKEINTRESOURCE(IDB_USRGRPIMAGES));
if (hbmImages != NULL)
{
ImageList_AddMasked(sp->hiPrincipals,
hbmImages,
RGB(255,
0,
255));
DeleteObject(hbmImages);
}
}
/* setup the listview control */
if (sp->hiPrincipals != NULL)
{
(void)ListView_SetImageList(sp->hWndPrincipalsList,
sp->hiPrincipals,
LVSIL_SMALL);
}
GetClientRect(sp->hWndPrincipalsList,
&rcLvClient);
/* add a column to the list view */
lvc.mask = LVCF_FMT | LVCF_WIDTH;
lvc.fmt = LVCFMT_LEFT;
lvc.cx = rcLvClient.right;
(void)ListView_InsertColumn(sp->hWndPrincipalsList,
0,
&lvc);
ReloadPrincipalsList(sp);
ListViewSelectItem(sp->hWndPrincipalsList,
0);
/* calculate the columns of the allow/deny checkboxes */
SetAceCheckListColumns(sp->hAceCheckList,
CLB_ALLOW,
GetDlgItem(hwndDlg, IDC_LABEL_ALLOW));
SetAceCheckListColumns(sp->hAceCheckList,
CLB_DENY,
GetDlgItem(hwndDlg, IDC_LABEL_DENY));
LoadPermissionsList(sp,
NULL,
SI_ACCESS_GENERAL |
((sp->ObjectInfo.dwFlags & SI_CONTAINER) ? SI_ACCESS_CONTAINER : 0),
&sp->DefaultAccess);
/* hide controls in case the flags aren't present */
if (sp->ObjectInfo.dwFlags & SI_ADVANCED)
{
/* editing the permissions is least the user can do when
the advanced button is showed */
sp->ObjectInfo.dwFlags |= SI_EDIT_PERMS;
}
else
{
ShowWindow(sp->hBtnAdvanced,
SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_LABEL_ADVANCED),
SW_HIDE);
}
/* enable quicksearch for the permissions checklist control */
SendMessage(sp->hAceCheckList,
CLM_ENABLEQUICKSEARCH,
TRUE,
0);
UpdateControlStates(sp);
}
Ret = TRUE;
break;
}
}
}
return Ret;
}
/*
* CreateSecurityPage EXPORTED
*
* @implemented
*/
HPROPSHEETPAGE
WINAPI
CreateSecurityPage(IN LPSECURITYINFO psi)
{
PROPSHEETPAGE psp = {0};
PSECURITY_PAGE sPage;
SI_OBJECT_INFO ObjectInfo = {0};
HANDLE SidCacheMgr;
LPCWSTR SystemName = NULL;
HRESULT hRet;
if (psi == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
DPRINT("No ISecurityInformation class passed!\n");
return NULL;
}
/* get the object information from the server. Zero the structure before
because some applications seem to return SUCCESS but only seem to set the
fields they care about. */
hRet = psi->lpVtbl->GetObjectInformation(psi,
&ObjectInfo);
if (FAILED(hRet))
{
SetLastError(hRet);
DPRINT("CreateSecurityPage() failed! Failed to query the object information!\n");
return NULL;
}
if ((ObjectInfo.dwFlags & SI_SERVER_IS_DC) &&
ObjectInfo.pszServerName != NULL &&
ObjectInfo.pszServerName[0] != L'\0')
{
SystemName = ObjectInfo.pszServerName;
}
SidCacheMgr = CreateSidCacheMgr(GetProcessHeap(),
SystemName);
if (SidCacheMgr == NULL)
{
DPRINT("Creating the SID cache failed!\n");
return NULL;
}
hRet = CoInitialize(NULL);
if (FAILED(hRet))
{
DestroySidCacheMgr(SidCacheMgr);
DPRINT("CoInitialize failed!\n");
return NULL;
}
sPage = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(SECURITY_PAGE));
if (sPage == NULL)
{
DestroySidCacheMgr(SidCacheMgr);
CoUninitialize();
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
DPRINT("Not enough memory to allocate a SECURITY_PAGE!\n");
return NULL;
}
ZeroMemory(sPage,
sizeof(*sPage));
sPage->psi = psi;
sPage->ObjectInfo = ObjectInfo;
sPage->ServerName = SystemName;
sPage->SidCacheMgr = SidCacheMgr;
psp.dwSize = sizeof(PROPSHEETPAGE);
psp.dwFlags = PSP_USECALLBACK;
psp.hInstance = hDllInstance;
psp.pszTemplate = MAKEINTRESOURCE(IDD_SECPAGE);
psp.pfnDlgProc = SecurityPageProc;
psp.lParam = (LPARAM)sPage;
psp.pfnCallback = SecurityPageCallback;
if (ObjectInfo.dwFlags & SI_PAGE_TITLE)
{
psp.pszTitle = ObjectInfo.pszPageTitle;
if (psp.pszTitle != NULL)
{
psp.dwFlags |= PSP_USETITLE;
}
}
else
{
psp.pszTitle = NULL;
}
/* NOTE: the SECURITY_PAGE structure will be freed by the property page
callback! */
return CreatePropertySheetPage(&psp);
}
/*
* EditSecurity EXPORTED
*
* @implemented
*/
BOOL
WINAPI
EditSecurity(IN HWND hwndOwner,
IN LPSECURITYINFO psi)
{
HRESULT hRet;
SI_OBJECT_INFO ObjectInfo = {0};
PROPSHEETHEADER psh;
HPROPSHEETPAGE hPages[1];
LPWSTR lpCaption = NULL;
BOOL Ret;
if (psi == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
DPRINT("No ISecurityInformation class passed!\n");
return FALSE;
}
/* get the object information from the server. Zero the structure before
because some applications seem to return SUCCESS but only seem to set the
fields they care about. */
hRet = psi->lpVtbl->GetObjectInformation(psi,
&ObjectInfo);
if (FAILED(hRet))
{
SetLastError(hRet);
DPRINT("GetObjectInformation() failed!\n");
return FALSE;
}
/* create the page */
hPages[0] = CreateSecurityPage(psi);
if (hPages[0] == NULL)
{
DPRINT("CreateSecurityPage(), couldn't create property sheet!\n");
return FALSE;
}
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_DEFAULT;
psh.hwndParent = hwndOwner;
psh.hInstance = hDllInstance;
/* Set the page title to the object name, make sure the format string
has "%1" NOT "%s" because it uses FormatMessage() to automatically
allocate the right amount of memory. */
if (LoadAndFormatString(hDllInstance,
IDS_PSP_TITLE,
&lpCaption,
ObjectInfo.pszObjectName))
{
psh.pszCaption = lpCaption;
}
else
{
psh.pszCaption = ObjectInfo.pszObjectName;
}
psh.nPages = sizeof(hPages) / sizeof(HPROPSHEETPAGE);
psh.nStartPage = 0;
psh.phpage = hPages;
Ret = (PropertySheet(&psh) != -1);
if (lpCaption != NULL)
{
LocalFree((HLOCAL)lpCaption);
}
return Ret;
}
BOOL
WINAPI
DllMain(IN HINSTANCE hinstDLL,
IN DWORD dwReason,
IN LPVOID lpvReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
hDllInstance = hinstDLL;
DisableThreadLibraryCalls(hinstDLL);
if (!RegisterCheckListControl(hinstDLL))
{
DPRINT("Registering the CHECKLIST_ACLUI class failed!\n");
return FALSE;
}
break;
case DLL_PROCESS_DETACH:
UnregisterCheckListControl(hinstDLL);
break;
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -