Author: tfaber Date: Tue Oct 21 12:43:15 2014 New Revision: 64865
URL: http://svn.reactos.org/svn/reactos?rev=64865&view=rev Log: [WIN32K] - Remove bug-hiding list macros that accept NULL in LIST_ENTRYs. CORE-8668 #resolve
Modified: trunk/reactos/win32ss/gdi/ntgdi/misc.h trunk/reactos/win32ss/user/ntuser/cursoricon.c trunk/reactos/win32ss/user/ntuser/desktop.c
Modified: trunk/reactos/win32ss/gdi/ntgdi/misc.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/misc.h?re... ============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/misc.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/misc.h [iso-8859-1] Tue Oct 21 12:43:15 2014 @@ -162,15 +162,3 @@
#define ROUND_UP(n, align) \ ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) - -#define LIST_FOR_EACH(elem, list, type, field) \ - for ((elem) = CONTAINING_RECORD((list)->Flink, type, field); \ - &(elem)->field != (list) && ((&((elem)->field)) != NULL); \ - (elem) = CONTAINING_RECORD((elem)->field.Flink, type, field)) - -#define LIST_FOR_EACH_SAFE(cursor, cursor2, list, type, field) \ - for ((cursor) = CONTAINING_RECORD((list)->Flink, type, field), \ - (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field); \ - &(cursor)->field != (list); \ - (cursor) = (cursor2), \ - (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field))
Modified: trunk/reactos/win32ss/user/ntuser/cursoricon.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/cursori... ============================================================================== --- trunk/reactos/win32ss/user/ntuser/cursoricon.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/cursoricon.c [iso-8859-1] Tue Oct 21 12:43:15 2014 @@ -144,12 +144,16 @@ ReferenceCurIconByProcess(PCURICON_OBJECT CurIcon) { PPROCESSINFO Win32Process; + PLIST_ENTRY ListEntry; PCURICON_PROCESS Current;
Win32Process = PsGetCurrentProcessWin32Process();
- LIST_FOR_EACH(Current, &CurIcon->ProcessList, CURICON_PROCESS, ListEntry) - { + ListEntry = CurIcon->ProcessList.Flink; + while (ListEntry != &CurIcon->ProcessList) + { + Current = CONTAINING_RECORD(ListEntry, CURICON_PROCESS, ListEntry); + ListEntry = ListEntry->Flink; if (Current->Process == Win32Process) { /* Already registered for this process */ @@ -173,10 +177,14 @@ IntFindExistingCurIconObject(HMODULE hModule, HRSRC hRsrc, LONG cx, LONG cy) { + PLIST_ENTRY ListEntry; PCURICON_OBJECT CurIcon;
- LIST_FOR_EACH(CurIcon, &gCurIconList, CURICON_OBJECT, ListEntry) - { + ListEntry = gCurIconList.Flink; + while (ListEntry != &gCurIconList) + { + CurIcon = CONTAINING_RECORD(ListEntry, CURICON_OBJECT, ListEntry); + ListEntry = ListEntry->Flink;
// if (NT_SUCCESS(UserReferenceObjectByPointer(Object, TYPE_CURSOR))) // <- huh???? // UserReferenceObject( CurIcon); @@ -247,7 +255,8 @@ PSYSTEM_CURSORINFO CurInfo; HBITMAP bmpMask, bmpColor; BOOLEAN Ret, bListEmpty, bFound = FALSE; - PCURICON_PROCESS Current = NULL; + PLIST_ENTRY ListEntry; + PCURICON_PROCESS Current;
/* For handles created without any data (error handling) */ if(IsListEmpty(&CurIcon->ProcessList)) @@ -255,8 +264,11 @@
/* Now find this process in the list of processes referencing this object and remove it from that list */ - LIST_FOR_EACH(Current, &CurIcon->ProcessList, CURICON_PROCESS, ListEntry) - { + ListEntry = CurIcon->ProcessList.Flink; + while (ListEntry != &CurIcon->ProcessList) + { + Current = CONTAINING_RECORD(ListEntry, CURICON_PROCESS, ListEntry); + ListEntry = ListEntry->Flink; if (Current->Process == ppi) { bFound = TRUE;
Modified: trunk/reactos/win32ss/user/ntuser/desktop.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/desktop... ============================================================================== --- trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] Tue Oct 21 12:43:15 2014 @@ -806,12 +806,17 @@ UserBuildShellHookHwndList(PDESKTOP Desktop) { ULONG entries=0; + PLIST_ENTRY ListEntry; PSHELL_HOOK_WINDOW Current; HWND* list;
/* FIXME: If we save nb elements in desktop, we dont have to loop to find nb entries */ - LIST_FOR_EACH(Current, &Desktop->ShellHookWindows, SHELL_HOOK_WINDOW, ListEntry) + ListEntry = Desktop->ShellHookWindows.Flink; + while (ListEntry != &Desktop->ShellHookWindows) + { + ListEntry = ListEntry->Flink; entries++; + }
if (!entries) return NULL;
@@ -820,8 +825,13 @@ { HWND* cursor = list;
- LIST_FOR_EACH(Current, &Desktop->ShellHookWindows, SHELL_HOOK_WINDOW, ListEntry) + ListEntry = Desktop->ShellHookWindows.Flink; + while (ListEntry != &Desktop->ShellHookWindows) + { + Current = CONTAINING_RECORD(ListEntry, SHELL_HOOK_WINDOW, ListEntry); + ListEntry = ListEntry->Flink; *cursor++ = Current->hWnd; + }
*cursor = NULL; /* Nullterm list */ } @@ -930,10 +940,14 @@ { PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); PDESKTOP Desktop = pti->rpdesk; + PLIST_ENTRY ListEntry; PSHELL_HOOK_WINDOW Current;
- LIST_FOR_EACH(Current, &Desktop->ShellHookWindows, SHELL_HOOK_WINDOW, ListEntry) - { + ListEntry = Desktop->ShellHookWindows.Flink; + while (ListEntry != &Desktop->ShellHookWindows) + { + Current = CONTAINING_RECORD(ListEntry, SHELL_HOOK_WINDOW, ListEntry); + ListEntry = ListEntry->Flink; if (Current->hWnd == hWnd) { RemoveEntryList(&Current->ListEntry);