improved error handling Modified: trunk/reactos/lib/aclui/aclui.c Modified: trunk/reactos/lib/aclui/checklist.c _____
Modified: trunk/reactos/lib/aclui/aclui.c --- trunk/reactos/lib/aclui/aclui.c 2005-09-28 13:20:10 UTC (rev 18135) +++ trunk/reactos/lib/aclui/aclui.c 2005-09-28 15:40:52 UTC (rev 18136) @@ -1,6 +1,6 @@
/* * 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 * modify it under the terms of the GNU Lesser General Public @@ -101,33 +101,41 @@ SID_NAME_USE SidNameUse; DWORD LookupResult; 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; - for (AceListItem = sp->PrincipalsListHead; AceListItem != NULL; AceListItem = AceListItem->Next) + for (AceListItem = sp->PrincipalsListHead; + AceListItem != NULL; + AceListItem = AceListItem->Next) { NextAcePtr = &AceListItem->Next; }
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 */ AceListItem = HeapAlloc(GetProcessHeap(), 0, - sizeof(PRINCIPAL_LISTITEM) + - SidLength + - ((AccountNameSize + DomainNameSize) * sizeof(WCHAR))); + sizeof(PRINCIPAL_LISTITEM) + SidLength + + ((AccountNameSize + DomainNameSize) * sizeof(WCHAR))); if (AceListItem != NULL) { AceListItem->AccountName = (LPWSTR)((ULONG_PTR)(AceListItem + 1) + SidLength); @@ -236,11 +244,10 @@ { if (Domain != NULL) { + SIZE_T Size = (AccountNameSize + DomainName->Length + + Names->Name.Length + 6) * sizeof(WCHAR); AceListItem->DisplayString = (LPWSTR)LocalAlloc(LMEM_FIXED, - (AccountNameSize * sizeof(WCHAR)) + - (DomainName->Length + sizeof(WCHAR)) + - (Names->Name.Length + sizeof(WCHAR)) + - (4 * sizeof(WCHAR))); + Size); if (AceListItem->DisplayString != NULL) { WCHAR *s; @@ -369,6 +376,7 @@ li.state = (Selected ? LVIS_SELECTED : 0); li.stateMask = LVIS_SELECTED; li.pszText = (PrincipalListItem->DisplayString != NULL ? PrincipalListItem->DisplayString : PrincipalListItem->AccountName); + switch (PrincipalListItem->SidNameUse) { case SidTypeUser: @@ -412,7 +420,8 @@
EnableRedrawWindow(sp->hWndPrincipalsList);
- GetClientRect(sp->hWndPrincipalsList, &rcLvClient); + GetClientRect(sp->hWndPrincipalsList, + &rcLvClient);
ListView_SetColumnWidth(sp->hWndPrincipalsList, 0, @@ -424,8 +433,10 @@ { PPRINCIPAL_LISTITEM Selected = (PPRINCIPAL_LISTITEM)ListViewGetSelectedItemData(sp->hWndPrincipalsList) ;
- EnableWindow(sp->hBtnRemove, Selected != NULL); - EnableWindow(sp->hAceCheckList, Selected != NULL); + EnableWindow(sp->hBtnRemove, + Selected != NULL); + EnableWindow(sp->hAceCheckList, + Selected != NULL);
if (Selected != NULL) { @@ -992,13 +1003,16 @@ sp->hiPrincipals, LVSIL_SMALL);
- GetClientRect(sp->hWndPrincipalsList, &rcLvClient); + 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; - ListView_InsertColumn(sp->hWndPrincipalsList, 0, &lvc); + ListView_InsertColumn(sp->hWndPrincipalsList, + 0, + &lvc);
ReloadPrincipalsList(sp);
@@ -1074,9 +1088,9 @@ WINAPI CreateSecurityPage(IN LPSECURITYINFO psi) { - PROPSHEETPAGE psp; + PROPSHEETPAGE psp = {0}; PSECURITY_PAGE sPage; - SI_OBJECT_INFO ObjectInfo; + SI_OBJECT_INFO ObjectInfo = {0}; HRESULT hRet;
if (psi == NULL) @@ -1090,8 +1104,8 @@ /* 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. */ - ZeroMemory(&ObjectInfo, sizeof(ObjectInfo)); - hRet = psi->lpVtbl->GetObjectInformation(psi, &ObjectInfo); + hRet = psi->lpVtbl->GetObjectInformation(psi, + &ObjectInfo);
if (FAILED(hRet)) { @@ -1127,8 +1141,6 @@ sPage->psi = psi; sPage->ObjectInfo = ObjectInfo;
- ZeroMemory(&psp, sizeof(psp)); - psp.dwSize = sizeof(PROPSHEETPAGE); psp.dwFlags = PSP_USECALLBACK; psp.hInstance = hDllInstance; @@ -1169,10 +1181,10 @@ IN LPSECURITYINFO psi) { HRESULT hRet; - SI_OBJECT_INFO ObjectInfo; + SI_OBJECT_INFO ObjectInfo = {0}; PROPSHEETHEADER psh; HPROPSHEETPAGE hPages[1]; - LPWSTR lpCaption; + LPWSTR lpCaption = NULL; BOOL Ret;
if (psi == NULL) @@ -1186,8 +1198,8 @@ /* 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. */ - ZeroMemory(&ObjectInfo, sizeof(ObjectInfo)); - hRet = psi->lpVtbl->GetObjectInformation(psi, &ObjectInfo); + hRet = psi->lpVtbl->GetObjectInformation(psi, + &ObjectInfo);
if (FAILED(hRet)) { @@ -1213,11 +1225,17 @@ /* 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. */ - LoadAndFormatString(hDllInstance, - IDS_PSP_TITLE, - &lpCaption, - ObjectInfo.pszObjectName); - psh.pszCaption = lpCaption; + 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; _____
Modified: trunk/reactos/lib/aclui/checklist.c --- trunk/reactos/lib/aclui/checklist.c 2005-09-28 13:20:10 UTC (rev 18135) +++ trunk/reactos/lib/aclui/checklist.c 2005-09-28 15:40:52 UTC (rev 18136) @@ -1,6 +1,6 @@
/* * 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 * modify it under the terms of the GNU Lesser General Public @@ -177,7 +177,8 @@ CurItem = CurItem->Next) { if ((CurItem->State & CIS_DISABLED) != CIS_DISABLED && - !wcsnicmp(CurItem->Name, SearchText, Count)) + !wcsnicmp(CurItem->Name, + SearchText, Count)) { break; } @@ -762,7 +763,8 @@ rcUpdate, (HBRUSH)(COLOR_WINDOW + 1));
- GetClientRect(infoPtr->hSelf, &rcClient); + GetClientRect(infoPtr->hSelf, + &rcClient);
ScrollPos = GetScrollPos(infoPtr->hSelf, SB_VERT); @@ -1204,7 +1206,8 @@ RECT rcClient; INT VisibleFirst;
- GetClientRect(infoPtr->hSelf, &rcClient); + GetClientRect(infoPtr->hSelf, + &rcClient);
VisibleFirst = GetScrollPos(infoPtr->hSelf, SB_VERT); @@ -1598,8 +1601,11 @@ nPage however also includes the partly cropped list item at the bottom of the control */
- GetClientRect(hwnd, &rcClient); - ScrollLines = max(1, (rcClient.bottom - rcClient.top) / infoPtr->ItemHeight); + GetClientRect(hwnd, + &rcClient); + + ScrollLines = max(1, + (rcClient.bottom - rcClient.top) / infoPtr->ItemHeight);
if (ScrollInfo.nPos + ScrollLines <= ScrollInfo.nMax) { @@ -1622,8 +1628,11 @@ nPage however also includes the partly cropped list item at the bottom of the control */
- GetClientRect(hwnd, &rcClient); - ScrollLines = max(1, (rcClient.bottom - rcClient.top) / infoPtr->ItemHeight); + GetClientRect(hwnd, + &rcClient); + + ScrollLines = max(1, + (rcClient.bottom - rcClient.top) / infoPtr->ItemHeight);
if (ScrollInfo.nPos >= ScrollLines) { @@ -1753,10 +1762,6 @@ } Ret = TRUE; } - else - { - Ret = FALSE; - } break; }
@@ -2165,9 +2170,11 @@ if (!infoPtr->FocusVisible) { /* change the UI status */ - SendMessage(GetAncestor(hwnd, GA_ROOT), + SendMessage(GetAncestor(hwnd, + GA_ROOT), WM_CHANGEUISTATE, - MAKEWPARAM(UIS_INITIALIZE, UISF_HIDEFOCUS), + MAKEWPARAM(UIS_INITIALIZE, + UISF_HIDEFOCUS), 0); }
@@ -2451,7 +2458,8 @@ infoPtr->TextColor[0] = GetSysColor(COLOR_GRAYTEXT); infoPtr->TextColor[1] = GetSysColor(COLOR_WINDOWTEXT);
- GetClientRect(hwnd, &rcClient); + GetClientRect(hwnd, + &rcClient);
infoPtr->CheckBoxLeft[0] = rcClient.right - 30; infoPtr->CheckBoxLeft[1] = rcClient.right - 15; @@ -2535,7 +2543,7 @@ }
BOOL -RegisterCheckListControl(HINSTANCE hInstance) +RegisterCheckListControl(IN HINSTANCE hInstance) { WNDCLASS wc;
@@ -2545,7 +2553,8 @@ wc.cbWndExtra = sizeof(PCHECKLISTWND); wc.hInstance = hInstance; wc.hIcon = NULL; - wc.hCursor = LoadCursor(0, (LPWSTR)IDC_ARROW); + wc.hCursor = LoadCursor(NULL, + (LPWSTR)IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszMenuName = NULL; wc.lpszClassName = L"CHECKLIST_ACLUI";