mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
improved error handling
svn path=/trunk/; revision=18136
This commit is contained in:
parent
7d4df5c225
commit
294680db96
2 changed files with 85 additions and 58 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS Access Control List Editor
|
* ReactOS Access Control List Editor
|
||||||
* Copyright (C) 2004 ReactOS Team
|
* Copyright (C) 2004-2005 ReactOS Team
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -101,33 +101,41 @@ AddPrincipalToList(IN PSECURITY_PAGE sp,
|
||||||
SID_NAME_USE SidNameUse;
|
SID_NAME_USE SidNameUse;
|
||||||
DWORD LookupResult;
|
DWORD LookupResult;
|
||||||
PPRINCIPAL_LISTITEM AceListItem, *NextAcePtr;
|
PPRINCIPAL_LISTITEM AceListItem, *NextAcePtr;
|
||||||
|
|
||||||
|
AccountNameSize = 0;
|
||||||
|
DomainNameSize = 0;
|
||||||
|
|
||||||
|
/* calculate the size of the buffer we need to calculate */
|
||||||
|
if (!LookupAccountSid(sp->ServerName,
|
||||||
|
Sid,
|
||||||
|
NULL,
|
||||||
|
&AccountNameSize,
|
||||||
|
NULL,
|
||||||
|
&DomainNameSize,
|
||||||
|
&SidNameUse))
|
||||||
|
{
|
||||||
|
LookupResult = GetLastError();
|
||||||
|
if (LookupResult != ERROR_NONE_MAPPED)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NextAcePtr = &sp->PrincipalsListHead;
|
NextAcePtr = &sp->PrincipalsListHead;
|
||||||
for (AceListItem = sp->PrincipalsListHead; AceListItem != NULL; AceListItem = AceListItem->Next)
|
for (AceListItem = sp->PrincipalsListHead;
|
||||||
|
AceListItem != NULL;
|
||||||
|
AceListItem = AceListItem->Next)
|
||||||
{
|
{
|
||||||
NextAcePtr = &AceListItem->Next;
|
NextAcePtr = &AceListItem->Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
SidLength = GetLengthSid(Sid);
|
SidLength = GetLengthSid(Sid);
|
||||||
|
|
||||||
AccountNameSize = 0;
|
|
||||||
DomainNameSize = 0;
|
|
||||||
|
|
||||||
/* calculate the size of the buffer we need to calculate */
|
|
||||||
LookupAccountSid(sp->ServerName,
|
|
||||||
Sid,
|
|
||||||
NULL,
|
|
||||||
&AccountNameSize,
|
|
||||||
NULL,
|
|
||||||
&DomainNameSize,
|
|
||||||
&SidNameUse);
|
|
||||||
|
|
||||||
/* allocate the ace */
|
/* allocate the ace */
|
||||||
AceListItem = HeapAlloc(GetProcessHeap(),
|
AceListItem = HeapAlloc(GetProcessHeap(),
|
||||||
0,
|
0,
|
||||||
sizeof(PRINCIPAL_LISTITEM) +
|
sizeof(PRINCIPAL_LISTITEM) + SidLength +
|
||||||
SidLength +
|
((AccountNameSize + DomainNameSize) * sizeof(WCHAR)));
|
||||||
((AccountNameSize + DomainNameSize) * sizeof(WCHAR)));
|
|
||||||
if (AceListItem != NULL)
|
if (AceListItem != NULL)
|
||||||
{
|
{
|
||||||
AceListItem->AccountName = (LPWSTR)((ULONG_PTR)(AceListItem + 1) + SidLength);
|
AceListItem->AccountName = (LPWSTR)((ULONG_PTR)(AceListItem + 1) + SidLength);
|
||||||
|
@ -236,11 +244,10 @@ AddPrincipalToList(IN PSECURITY_PAGE sp,
|
||||||
{
|
{
|
||||||
if (Domain != NULL)
|
if (Domain != NULL)
|
||||||
{
|
{
|
||||||
|
SIZE_T Size = (AccountNameSize + DomainName->Length +
|
||||||
|
Names->Name.Length + 6) * sizeof(WCHAR);
|
||||||
AceListItem->DisplayString = (LPWSTR)LocalAlloc(LMEM_FIXED,
|
AceListItem->DisplayString = (LPWSTR)LocalAlloc(LMEM_FIXED,
|
||||||
(AccountNameSize * sizeof(WCHAR)) +
|
Size);
|
||||||
(DomainName->Length + sizeof(WCHAR)) +
|
|
||||||
(Names->Name.Length + sizeof(WCHAR)) +
|
|
||||||
(4 * sizeof(WCHAR)));
|
|
||||||
if (AceListItem->DisplayString != NULL)
|
if (AceListItem->DisplayString != NULL)
|
||||||
{
|
{
|
||||||
WCHAR *s;
|
WCHAR *s;
|
||||||
|
@ -369,6 +376,7 @@ AddPrincipalListEntry(IN PSECURITY_PAGE sp,
|
||||||
li.state = (Selected ? LVIS_SELECTED : 0);
|
li.state = (Selected ? LVIS_SELECTED : 0);
|
||||||
li.stateMask = LVIS_SELECTED;
|
li.stateMask = LVIS_SELECTED;
|
||||||
li.pszText = (PrincipalListItem->DisplayString != NULL ? PrincipalListItem->DisplayString : PrincipalListItem->AccountName);
|
li.pszText = (PrincipalListItem->DisplayString != NULL ? PrincipalListItem->DisplayString : PrincipalListItem->AccountName);
|
||||||
|
|
||||||
switch (PrincipalListItem->SidNameUse)
|
switch (PrincipalListItem->SidNameUse)
|
||||||
{
|
{
|
||||||
case SidTypeUser:
|
case SidTypeUser:
|
||||||
|
@ -412,7 +420,8 @@ FillPrincipalsList(IN PSECURITY_PAGE sp)
|
||||||
|
|
||||||
EnableRedrawWindow(sp->hWndPrincipalsList);
|
EnableRedrawWindow(sp->hWndPrincipalsList);
|
||||||
|
|
||||||
GetClientRect(sp->hWndPrincipalsList, &rcLvClient);
|
GetClientRect(sp->hWndPrincipalsList,
|
||||||
|
&rcLvClient);
|
||||||
|
|
||||||
ListView_SetColumnWidth(sp->hWndPrincipalsList,
|
ListView_SetColumnWidth(sp->hWndPrincipalsList,
|
||||||
0,
|
0,
|
||||||
|
@ -424,8 +433,10 @@ UpdateControlStates(IN PSECURITY_PAGE sp)
|
||||||
{
|
{
|
||||||
PPRINCIPAL_LISTITEM Selected = (PPRINCIPAL_LISTITEM)ListViewGetSelectedItemData(sp->hWndPrincipalsList);
|
PPRINCIPAL_LISTITEM Selected = (PPRINCIPAL_LISTITEM)ListViewGetSelectedItemData(sp->hWndPrincipalsList);
|
||||||
|
|
||||||
EnableWindow(sp->hBtnRemove, Selected != NULL);
|
EnableWindow(sp->hBtnRemove,
|
||||||
EnableWindow(sp->hAceCheckList, Selected != NULL);
|
Selected != NULL);
|
||||||
|
EnableWindow(sp->hAceCheckList,
|
||||||
|
Selected != NULL);
|
||||||
|
|
||||||
if (Selected != NULL)
|
if (Selected != NULL)
|
||||||
{
|
{
|
||||||
|
@ -992,13 +1003,16 @@ SecurityPageProc(IN HWND hwndDlg,
|
||||||
sp->hiPrincipals,
|
sp->hiPrincipals,
|
||||||
LVSIL_SMALL);
|
LVSIL_SMALL);
|
||||||
|
|
||||||
GetClientRect(sp->hWndPrincipalsList, &rcLvClient);
|
GetClientRect(sp->hWndPrincipalsList,
|
||||||
|
&rcLvClient);
|
||||||
|
|
||||||
/* add a column to the list view */
|
/* add a column to the list view */
|
||||||
lvc.mask = LVCF_FMT | LVCF_WIDTH;
|
lvc.mask = LVCF_FMT | LVCF_WIDTH;
|
||||||
lvc.fmt = LVCFMT_LEFT;
|
lvc.fmt = LVCFMT_LEFT;
|
||||||
lvc.cx = rcLvClient.right;
|
lvc.cx = rcLvClient.right;
|
||||||
ListView_InsertColumn(sp->hWndPrincipalsList, 0, &lvc);
|
ListView_InsertColumn(sp->hWndPrincipalsList,
|
||||||
|
0,
|
||||||
|
&lvc);
|
||||||
|
|
||||||
ReloadPrincipalsList(sp);
|
ReloadPrincipalsList(sp);
|
||||||
|
|
||||||
|
@ -1074,9 +1088,9 @@ HPROPSHEETPAGE
|
||||||
WINAPI
|
WINAPI
|
||||||
CreateSecurityPage(IN LPSECURITYINFO psi)
|
CreateSecurityPage(IN LPSECURITYINFO psi)
|
||||||
{
|
{
|
||||||
PROPSHEETPAGE psp;
|
PROPSHEETPAGE psp = {0};
|
||||||
PSECURITY_PAGE sPage;
|
PSECURITY_PAGE sPage;
|
||||||
SI_OBJECT_INFO ObjectInfo;
|
SI_OBJECT_INFO ObjectInfo = {0};
|
||||||
HRESULT hRet;
|
HRESULT hRet;
|
||||||
|
|
||||||
if (psi == NULL)
|
if (psi == NULL)
|
||||||
|
@ -1090,8 +1104,8 @@ CreateSecurityPage(IN LPSECURITYINFO psi)
|
||||||
/* get the object information from the server. Zero the structure before
|
/* get the object information from the server. Zero the structure before
|
||||||
because some applications seem to return SUCCESS but only seem to set the
|
because some applications seem to return SUCCESS but only seem to set the
|
||||||
fields they care about. */
|
fields they care about. */
|
||||||
ZeroMemory(&ObjectInfo, sizeof(ObjectInfo));
|
hRet = psi->lpVtbl->GetObjectInformation(psi,
|
||||||
hRet = psi->lpVtbl->GetObjectInformation(psi, &ObjectInfo);
|
&ObjectInfo);
|
||||||
|
|
||||||
if (FAILED(hRet))
|
if (FAILED(hRet))
|
||||||
{
|
{
|
||||||
|
@ -1127,8 +1141,6 @@ CreateSecurityPage(IN LPSECURITYINFO psi)
|
||||||
sPage->psi = psi;
|
sPage->psi = psi;
|
||||||
sPage->ObjectInfo = ObjectInfo;
|
sPage->ObjectInfo = ObjectInfo;
|
||||||
|
|
||||||
ZeroMemory(&psp, sizeof(psp));
|
|
||||||
|
|
||||||
psp.dwSize = sizeof(PROPSHEETPAGE);
|
psp.dwSize = sizeof(PROPSHEETPAGE);
|
||||||
psp.dwFlags = PSP_USECALLBACK;
|
psp.dwFlags = PSP_USECALLBACK;
|
||||||
psp.hInstance = hDllInstance;
|
psp.hInstance = hDllInstance;
|
||||||
|
@ -1169,10 +1181,10 @@ EditSecurity(IN HWND hwndOwner,
|
||||||
IN LPSECURITYINFO psi)
|
IN LPSECURITYINFO psi)
|
||||||
{
|
{
|
||||||
HRESULT hRet;
|
HRESULT hRet;
|
||||||
SI_OBJECT_INFO ObjectInfo;
|
SI_OBJECT_INFO ObjectInfo = {0};
|
||||||
PROPSHEETHEADER psh;
|
PROPSHEETHEADER psh;
|
||||||
HPROPSHEETPAGE hPages[1];
|
HPROPSHEETPAGE hPages[1];
|
||||||
LPWSTR lpCaption;
|
LPWSTR lpCaption = NULL;
|
||||||
BOOL Ret;
|
BOOL Ret;
|
||||||
|
|
||||||
if (psi == NULL)
|
if (psi == NULL)
|
||||||
|
@ -1186,8 +1198,8 @@ EditSecurity(IN HWND hwndOwner,
|
||||||
/* get the object information from the server. Zero the structure before
|
/* get the object information from the server. Zero the structure before
|
||||||
because some applications seem to return SUCCESS but only seem to set the
|
because some applications seem to return SUCCESS but only seem to set the
|
||||||
fields they care about. */
|
fields they care about. */
|
||||||
ZeroMemory(&ObjectInfo, sizeof(ObjectInfo));
|
hRet = psi->lpVtbl->GetObjectInformation(psi,
|
||||||
hRet = psi->lpVtbl->GetObjectInformation(psi, &ObjectInfo);
|
&ObjectInfo);
|
||||||
|
|
||||||
if (FAILED(hRet))
|
if (FAILED(hRet))
|
||||||
{
|
{
|
||||||
|
@ -1213,11 +1225,17 @@ EditSecurity(IN HWND hwndOwner,
|
||||||
/* Set the page title to the object name, make sure the format string
|
/* Set the page title to the object name, make sure the format string
|
||||||
has "%1" NOT "%s" because it uses FormatMessage() to automatically
|
has "%1" NOT "%s" because it uses FormatMessage() to automatically
|
||||||
allocate the right amount of memory. */
|
allocate the right amount of memory. */
|
||||||
LoadAndFormatString(hDllInstance,
|
if (LoadAndFormatString(hDllInstance,
|
||||||
IDS_PSP_TITLE,
|
IDS_PSP_TITLE,
|
||||||
&lpCaption,
|
&lpCaption,
|
||||||
ObjectInfo.pszObjectName);
|
ObjectInfo.pszObjectName))
|
||||||
psh.pszCaption = lpCaption;
|
{
|
||||||
|
psh.pszCaption = lpCaption;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
psh.pszCaption = ObjectInfo.pszObjectName;
|
||||||
|
}
|
||||||
|
|
||||||
psh.nPages = sizeof(hPages) / sizeof(HPROPSHEETPAGE);
|
psh.nPages = sizeof(hPages) / sizeof(HPROPSHEETPAGE);
|
||||||
psh.nStartPage = 0;
|
psh.nStartPage = 0;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS Access Control List Editor
|
* ReactOS Access Control List Editor
|
||||||
* Copyright (C) 2004 ReactOS Team
|
* Copyright (C) 2004-2005 ReactOS Team
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -177,7 +177,8 @@ FindCheckItem(IN PCHECKLISTWND infoPtr,
|
||||||
CurItem = CurItem->Next)
|
CurItem = CurItem->Next)
|
||||||
{
|
{
|
||||||
if ((CurItem->State & CIS_DISABLED) != CIS_DISABLED &&
|
if ((CurItem->State & CIS_DISABLED) != CIS_DISABLED &&
|
||||||
!wcsnicmp(CurItem->Name, SearchText, Count))
|
!wcsnicmp(CurItem->Name,
|
||||||
|
SearchText, Count))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -762,7 +763,8 @@ PaintControl(IN PCHECKLISTWND infoPtr,
|
||||||
rcUpdate,
|
rcUpdate,
|
||||||
(HBRUSH)(COLOR_WINDOW + 1));
|
(HBRUSH)(COLOR_WINDOW + 1));
|
||||||
|
|
||||||
GetClientRect(infoPtr->hSelf, &rcClient);
|
GetClientRect(infoPtr->hSelf,
|
||||||
|
&rcClient);
|
||||||
|
|
||||||
ScrollPos = GetScrollPos(infoPtr->hSelf,
|
ScrollPos = GetScrollPos(infoPtr->hSelf,
|
||||||
SB_VERT);
|
SB_VERT);
|
||||||
|
@ -1204,7 +1206,8 @@ MapItemToRect(IN PCHECKLISTWND infoPtr,
|
||||||
RECT rcClient;
|
RECT rcClient;
|
||||||
INT VisibleFirst;
|
INT VisibleFirst;
|
||||||
|
|
||||||
GetClientRect(infoPtr->hSelf, &rcClient);
|
GetClientRect(infoPtr->hSelf,
|
||||||
|
&rcClient);
|
||||||
|
|
||||||
VisibleFirst = GetScrollPos(infoPtr->hSelf,
|
VisibleFirst = GetScrollPos(infoPtr->hSelf,
|
||||||
SB_VERT);
|
SB_VERT);
|
||||||
|
@ -1598,8 +1601,11 @@ CheckListWndProc(IN HWND hwnd,
|
||||||
nPage however also includes the partly cropped list
|
nPage however also includes the partly cropped list
|
||||||
item at the bottom of the control */
|
item at the bottom of the control */
|
||||||
|
|
||||||
GetClientRect(hwnd, &rcClient);
|
GetClientRect(hwnd,
|
||||||
ScrollLines = max(1, (rcClient.bottom - rcClient.top) / infoPtr->ItemHeight);
|
&rcClient);
|
||||||
|
|
||||||
|
ScrollLines = max(1,
|
||||||
|
(rcClient.bottom - rcClient.top) / infoPtr->ItemHeight);
|
||||||
|
|
||||||
if (ScrollInfo.nPos + ScrollLines <= ScrollInfo.nMax)
|
if (ScrollInfo.nPos + ScrollLines <= ScrollInfo.nMax)
|
||||||
{
|
{
|
||||||
|
@ -1622,8 +1628,11 @@ CheckListWndProc(IN HWND hwnd,
|
||||||
nPage however also includes the partly cropped list
|
nPage however also includes the partly cropped list
|
||||||
item at the bottom of the control */
|
item at the bottom of the control */
|
||||||
|
|
||||||
GetClientRect(hwnd, &rcClient);
|
GetClientRect(hwnd,
|
||||||
ScrollLines = max(1, (rcClient.bottom - rcClient.top) / infoPtr->ItemHeight);
|
&rcClient);
|
||||||
|
|
||||||
|
ScrollLines = max(1,
|
||||||
|
(rcClient.bottom - rcClient.top) / infoPtr->ItemHeight);
|
||||||
|
|
||||||
if (ScrollInfo.nPos >= ScrollLines)
|
if (ScrollInfo.nPos >= ScrollLines)
|
||||||
{
|
{
|
||||||
|
@ -1753,10 +1762,6 @@ CheckListWndProc(IN HWND hwnd,
|
||||||
}
|
}
|
||||||
Ret = TRUE;
|
Ret = TRUE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Ret = FALSE;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2165,9 +2170,11 @@ CheckListWndProc(IN HWND hwnd,
|
||||||
if (!infoPtr->FocusVisible)
|
if (!infoPtr->FocusVisible)
|
||||||
{
|
{
|
||||||
/* change the UI status */
|
/* change the UI status */
|
||||||
SendMessage(GetAncestor(hwnd, GA_ROOT),
|
SendMessage(GetAncestor(hwnd,
|
||||||
|
GA_ROOT),
|
||||||
WM_CHANGEUISTATE,
|
WM_CHANGEUISTATE,
|
||||||
MAKEWPARAM(UIS_INITIALIZE, UISF_HIDEFOCUS),
|
MAKEWPARAM(UIS_INITIALIZE,
|
||||||
|
UISF_HIDEFOCUS),
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2451,7 +2458,8 @@ CheckListWndProc(IN HWND hwnd,
|
||||||
infoPtr->TextColor[0] = GetSysColor(COLOR_GRAYTEXT);
|
infoPtr->TextColor[0] = GetSysColor(COLOR_GRAYTEXT);
|
||||||
infoPtr->TextColor[1] = GetSysColor(COLOR_WINDOWTEXT);
|
infoPtr->TextColor[1] = GetSysColor(COLOR_WINDOWTEXT);
|
||||||
|
|
||||||
GetClientRect(hwnd, &rcClient);
|
GetClientRect(hwnd,
|
||||||
|
&rcClient);
|
||||||
|
|
||||||
infoPtr->CheckBoxLeft[0] = rcClient.right - 30;
|
infoPtr->CheckBoxLeft[0] = rcClient.right - 30;
|
||||||
infoPtr->CheckBoxLeft[1] = rcClient.right - 15;
|
infoPtr->CheckBoxLeft[1] = rcClient.right - 15;
|
||||||
|
@ -2535,7 +2543,7 @@ CheckListWndProc(IN HWND hwnd,
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
RegisterCheckListControl(HINSTANCE hInstance)
|
RegisterCheckListControl(IN HINSTANCE hInstance)
|
||||||
{
|
{
|
||||||
WNDCLASS wc;
|
WNDCLASS wc;
|
||||||
|
|
||||||
|
@ -2545,7 +2553,8 @@ RegisterCheckListControl(HINSTANCE hInstance)
|
||||||
wc.cbWndExtra = sizeof(PCHECKLISTWND);
|
wc.cbWndExtra = sizeof(PCHECKLISTWND);
|
||||||
wc.hInstance = hInstance;
|
wc.hInstance = hInstance;
|
||||||
wc.hIcon = NULL;
|
wc.hIcon = NULL;
|
||||||
wc.hCursor = LoadCursor(0, (LPWSTR)IDC_ARROW);
|
wc.hCursor = LoadCursor(NULL,
|
||||||
|
(LPWSTR)IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||||
wc.lpszMenuName = NULL;
|
wc.lpszMenuName = NULL;
|
||||||
wc.lpszClassName = L"CHECKLIST_ACLUI";
|
wc.lpszClassName = L"CHECKLIST_ACLUI";
|
||||||
|
|
Loading…
Reference in a new issue