ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
October 2013
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
14 participants
325 discussions
Start a n
N
ew thread
[fireball] 60721: [NTOS] - Correctly compute addresses of MI_VAD_BITMAP and MI_WORKING_SET_LIST. In trunk's MM it went unnoticed because nothing really cares about these two structs.
by fireball@svn.reactos.org
Author: fireball Date: Sun Oct 20 09:41:54 2013 New Revision: 60721 URL:
http://svn.reactos.org/svn/reactos?rev=60721&view=rev
Log: [NTOS] - Correctly compute addresses of MI_VAD_BITMAP and MI_WORKING_SET_LIST. In trunk's MM it went unnoticed because nothing really cares about these two structs. Modified: trunk/reactos/ntoskrnl/include/internal/i386/mm.h Modified: trunk/reactos/ntoskrnl/include/internal/i386/mm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/i386/mm.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/i386/mm.h [iso-8859-1] Sun Oct 20 09:41:54 2013 @@ -96,11 +96,11 @@ #define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE #define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \ MI_HYPERSPACE_PTES * PAGE_SIZE) -#define MI_DUMMY_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \ +#define MI_DUMMY_PTE (PMMPTE)((ULONG_PTR)MI_MAPPING_RANGE_END + \ PAGE_SIZE) -#define MI_VAD_BITMAP (PMMPTE)(MI_DUMMY_PTE + \ +#define MI_VAD_BITMAP (PMMPTE)((ULONG_PTR)MI_DUMMY_PTE + \ PAGE_SIZE) -#define MI_WORKING_SET_LIST (PMMPTE)(MI_VAD_BITMAP + \ +#define MI_WORKING_SET_LIST (PMMPTE)((ULONG_PTR)MI_VAD_BITMAP + \ PAGE_SIZE) /* On x86, these two are the same */
11 years, 2 months
1
0
0
0
[jimtabor] 60720: - Fix ATI test and go.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Sun Oct 20 05:36:36 2013 New Revision: 60720 URL:
http://svn.reactos.org/svn/reactos?rev=60720&view=rev
Log: - Fix ATI test and go. Modified: trunk/rostests/apitests/user32/AttachThreadInput.c Modified: trunk/rostests/apitests/user32/AttachThreadInput.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/AttachThr…
============================================================================== --- trunk/rostests/apitests/user32/AttachThreadInput.c [iso-8859-1] (original) +++ trunk/rostests/apitests/user32/AttachThreadInput.c [iso-8859-1] Sun Oct 20 05:36:36 2013 @@ -357,6 +357,7 @@ { BOOL ret; + trace("Thread hWnd0 0x%p hWnd1 0x%p\n",data[0].hWnd, data[1].hWnd); /* Window 1 is in the foreground */ SetForegroundWindow(data[1].hWnd); SetActiveWindow(data[0].hWnd); @@ -552,13 +553,33 @@ BOOL ret; + //trace("Thread hWnd0 0x%p hWnd1 0x%p\n",data[0].hWnd, data[1].hWnd); + /* First try sending input without attaching. It will go to the foreground */ { SetForegroundWindow(data[1].hWnd); SetActiveWindow(data[0].hWnd); - - ok(GetForegroundWindow() == data[1].hWnd, "wrong foreground\n"); - ok(GetActiveWindow() == data[0].hWnd, "wrong active\n"); + + ok(GetForegroundWindow() == data[1].hWnd, "wrong foreground got 0x%p\n",GetForegroundWindow()); + ok(GetActiveWindow() == data[0].hWnd, "wrong active got 0x%p\n",GetActiveWindow()); + + FlushMessages(); + EMPTY_CACHE_(&data[0].cache); + EMPTY_CACHE_(&data[1].cache); + + keybd_event(VK_SHIFT, 0,0,0); + keybd_event(VK_SHIFT, 0,KEYEVENTF_KEYUP,0); + Sleep(100); + FlushMessages(); + + COMPARE_CACHE_(&data[0].cache, empty_chain); + COMPARE_CACHE_(&data[1].cache, Thread1_chain); + } + + /* Next attach and send input. It will go to the same thread as before */ + { // from to + ret = AttachThreadInput( data[1].tid, data[0].tid , TRUE); + ok(ret==1, "expected AttachThreadInput to succeed\n"); FlushMessages(); EMPTY_CACHE_(&data[0].cache); @@ -572,10 +593,34 @@ COMPARE_CACHE_(&data[0].cache, empty_chain); COMPARE_CACHE_(&data[1].cache, Thread1_chain); } - - /* Next attach and send input. It will go to the same thread as before */ - { - ret = AttachThreadInput( data[1].tid, data[0].tid , TRUE); + + /* Now set foreground and active again. Input will go to thread 0 */ + { + SetForegroundWindow(data[1].hWnd); + SetActiveWindow(data[0].hWnd); + FlushMessages(); + + ok(GetForegroundWindow() == data[0].hWnd, "wrong foreground got 0x%p\n",GetForegroundWindow()); + ok(GetActiveWindow() == data[0].hWnd, "wrong active got 0x%p\n",GetActiveWindow()); + + EMPTY_CACHE_(&data[0].cache); + EMPTY_CACHE_(&data[1].cache); + + keybd_event(VK_SHIFT, 0,0,0); + keybd_event(VK_SHIFT, 0,KEYEVENTF_KEYUP,0); + Sleep(100); + FlushMessages(); + + COMPARE_CACHE_(&data[0].cache, Thread0_chain); + COMPARE_CACHE_(&data[1].cache, empty_chain); + + ret = AttachThreadInput( data[1].tid, data[0].tid , FALSE); + ok(ret==1, "expected AttachThreadInput to succeed\n"); + } + + /* Attach in the opposite order and send input */ + { + ret = AttachThreadInput( data[0].tid, data[1].tid , TRUE); ok(ret==1, "expected AttachThreadInput to succeed\n"); FlushMessages(); @@ -587,16 +632,19 @@ Sleep(100); FlushMessages(); - COMPARE_CACHE_(&data[0].cache, empty_chain); - COMPARE_CACHE_(&data[1].cache, Thread1_chain); - } - - /* Now set foregroung and active again. Input will go to thread 0 */ + COMPARE_CACHE_(&data[0].cache, Thread0_chain); + COMPARE_CACHE_(&data[1].cache, empty_chain); + } + + /* Now set foreground and active again. Input will go to thread 0 */ { SetForegroundWindow(data[1].hWnd); SetActiveWindow(data[0].hWnd); - FlushMessages(); + + ok(GetForegroundWindow() == data[0].hWnd, "wrong foreground got 0x%p\n",GetForegroundWindow()); + ok(GetActiveWindow() == data[0].hWnd, "wrong active got 0x%p\n",GetActiveWindow()); + EMPTY_CACHE_(&data[0].cache); EMPTY_CACHE_(&data[1].cache); @@ -608,45 +656,6 @@ COMPARE_CACHE_(&data[0].cache, Thread0_chain); COMPARE_CACHE_(&data[1].cache, empty_chain); - ret = AttachThreadInput( data[1].tid, data[0].tid , FALSE); - ok(ret==1, "expected AttachThreadInput to succeed\n"); - } - - /* Attach in the opposite order and send input */ - { - ret = AttachThreadInput( data[0].tid, data[1].tid , TRUE); - ok(ret==1, "expected AttachThreadInput to succeed\n"); - - FlushMessages(); - EMPTY_CACHE_(&data[0].cache); - EMPTY_CACHE_(&data[1].cache); - - keybd_event(VK_SHIFT, 0,0,0); - keybd_event(VK_SHIFT, 0,KEYEVENTF_KEYUP,0); - Sleep(100); - FlushMessages(); - - COMPARE_CACHE_(&data[0].cache, Thread0_chain); - COMPARE_CACHE_(&data[1].cache, empty_chain); - } - - /* Now set foregroung and active again. Input will go to thread 0 */ - { - SetForegroundWindow(data[1].hWnd); - SetActiveWindow(data[0].hWnd); - - FlushMessages(); - EMPTY_CACHE_(&data[0].cache); - EMPTY_CACHE_(&data[1].cache); - - keybd_event(VK_SHIFT, 0,0,0); - keybd_event(VK_SHIFT, 0,KEYEVENTF_KEYUP,0); - Sleep(100); - FlushMessages(); - - COMPARE_CACHE_(&data[0].cache, Thread0_chain); - COMPARE_CACHE_(&data[1].cache, empty_chain); - ret = AttachThreadInput( data[0].tid, data[1].tid , FALSE); ok(ret==1, "expected AttachThreadInput to succeed\n"); } @@ -657,9 +666,8 @@ if(!InitThreads()) return; - win_skip("skip Test_SimpleParameters that crash ros\n"); - //Test_SimpleParameters(); - //cleanup_attachments(); + Test_SimpleParameters(); + cleanup_attachments(); Test_Focus(); cleanup_attachments(); Test_UnaffectedMessages();
11 years, 2 months
1
0
0
0
[jimtabor] 60719: - Fix build.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Sun Oct 20 05:31:48 2013 New Revision: 60719 URL:
http://svn.reactos.org/svn/reactos?rev=60719&view=rev
Log: - Fix build. Modified: trunk/reactos/win32ss/user/ntuser/keyboard.c Modified: trunk/reactos/win32ss/user/ntuser/keyboard.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/keyboa…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/keyboard.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/keyboard.c [iso-8859-1] Sun Oct 20 05:31:48 2013 @@ -904,6 +904,13 @@ } if (Wnd) pti = Wnd->head.pti; + /* Init message */ + Msg.hwnd = Wnd ? UserHMGetHandle(Wnd) : NULL; + Msg.wParam = wFixedVk & 0xFF; /* Note: It's simplified by msg queue */ + Msg.lParam = MAKELPARAM(1, wScanCode); + Msg.time = dwTime; + Msg.pt = gpsi->ptCursor; + if ( Msg.message == WM_KEYDOWN || Msg.message == WM_SYSKEYDOWN ) { if ( (Msg.wParam == VK_SHIFT || @@ -915,13 +922,6 @@ //ptiLastInput = pti; } } - - /* Init message */ - Msg.hwnd = Wnd ? UserHMGetHandle(Wnd) : NULL; - Msg.wParam = wFixedVk & 0xFF; /* Note: It's simplified by msg queue */ - Msg.lParam = MAKELPARAM(1, wScanCode); - Msg.time = dwTime; - Msg.pt = gpsi->ptCursor; /* If it is VK_PACKET, high word of wParam is used for wchar */ if (!bPacket)
11 years, 2 months
1
0
0
0
[jimtabor] 60718: [Win32k] - The (ATI) patch CORE-6551. Please oh please use this jira core issue for all bug reports and regressions. - Major rewrite to input message queue. It is now attachable b...
by jimtabor@svn.reactos.org
Author: jimtabor Date: Sun Oct 20 05:16:52 2013 New Revision: 60718 URL:
http://svn.reactos.org/svn/reactos?rev=60718&view=rev
Log: [Win32k] - The (ATI) patch CORE-6551. Please oh please use this jira core issue for all bug reports and regressions. - Major rewrite to input message queue. It is now attachable between threads. After all the hubbub the only thing we pass are all the SetActive/Foreground/Parent/Window wine msg and win tests. But not the message sequence tests. - Pass all but one foreground API User32 ATI test when the message patch is installed. But w/o it, pass all but 8'ish. - Tested XP osk (On-Screen Keyboard) with CMD, it works but is quirky. Need to look into set to top window issues. - AHK issues work long as ATI is used and when it is not the some AHK tests fail. That was why all the hot key changes had been committed before. Still looking into this. - Please test everything and post to the appropriate jira issue reports. I do not have a lot of time anymore to focus hard on many issues, it will take months to do so with just one. Modified: trunk/reactos/win32ss/user/ntuser/desktop.c trunk/reactos/win32ss/user/ntuser/desktop.h trunk/reactos/win32ss/user/ntuser/focus.c trunk/reactos/win32ss/user/ntuser/focus.h trunk/reactos/win32ss/user/ntuser/input.c trunk/reactos/win32ss/user/ntuser/input.h trunk/reactos/win32ss/user/ntuser/keyboard.c trunk/reactos/win32ss/user/ntuser/main.c trunk/reactos/win32ss/user/ntuser/message.c trunk/reactos/win32ss/user/ntuser/misc.c trunk/reactos/win32ss/user/ntuser/msgqueue.c trunk/reactos/win32ss/user/ntuser/msgqueue.h trunk/reactos/win32ss/user/ntuser/object.c trunk/reactos/win32ss/user/ntuser/object.h trunk/reactos/win32ss/user/ntuser/window.c trunk/reactos/win32ss/user/ntuser/winpos.c Modified: trunk/reactos/win32ss/user/ntuser/desktop.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/deskto…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -28,7 +28,7 @@ /* Currently active desktop */ PDESKTOP gpdeskInputDesktop = NULL; HDC ScreenDeviceContext = NULL; -PTHREADINFO gptiDesktopThread; +PTHREADINFO gptiDesktopThread = NULL; HCURSOR gDesktopCursor = NULL; /* OBJECT CALLBACKS **********************************************************/ @@ -833,6 +833,9 @@ TRACE("IntShellHookNotify: No desktop!\n"); return; } + + // Allow other devices have a shot at foreground. + if (Message == HSHELL_APPCOMMAND) ptiLastInput = NULL; // FIXME: System Tray Support. Modified: trunk/reactos/win32ss/user/ntuser/desktop.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/deskto…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/desktop.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/desktop.h [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -69,9 +69,10 @@ DESKTOP_SWITCHDESKTOP | \ DESKTOP_WRITEOBJECTS -extern PDESKTOP InputDesktop; +extern PDESKTOP gpdeskInputDesktop; extern PCLS DesktopWindowClass; extern HDC ScreenDeviceContext; +extern PTHREADINFO gptiForeground; extern PTHREADINFO gptiDesktopThread; typedef struct _SHELL_HOOK_WINDOW Modified: trunk/reactos/win32ss/user/ntuser/focus.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/focus.…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/focus.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/focus.c [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -80,7 +80,7 @@ co_IntMakeWindowActive(PWND Window) { PWND spwndOwner; - if (Window) + if (VerifyWnd(Window)) { // Set last active for window and it's owner. spwndOwner = Window; while (spwndOwner->spwndOwner) @@ -132,6 +132,7 @@ { UINT flags = SWP_NOSIZE | SWP_NOMOVE; if (Window == pwndTemp) flags |= SWP_NOACTIVATE; + //ERR("co_IntSendActivateMessages SetWindowPos! Async %d pti Q == FGQ %d\n",Async,pti->MessageQueue == gpqForeground); co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0, flags); } } @@ -156,8 +157,7 @@ if ( OldTID ) { ptiOld->TIF_flags |= TIF_INACTIVATEAPPMSG; - ptiOld->pClientInfo->dwTIFlags = ptiOld->TIF_flags; - + // Note: Do not set pci flags, this does crash! for (phWnd = List; *phWnd; ++phWnd) { cWindow = ValidateHwndNoErr(*phWnd); @@ -168,13 +168,11 @@ } } ptiOld->TIF_flags &= ~TIF_INACTIVATEAPPMSG; - ptiOld->pClientInfo->dwTIFlags = ptiOld->TIF_flags; } if ( NewTID ) { //// Prevents a resource crash due to reentrance! InAAPM = TRUE; pti->TIF_flags |= TIF_INACTIVATEAPPMSG; - pti->pClientInfo->dwTIFlags = pti->TIF_flags; //// for (phWnd = List; *phWnd; ++phWnd) { @@ -186,7 +184,7 @@ } } } - ExFreePoolWithTag(List, USERTAG_WINDOWLIST); + ExFreePool(List);//ExFreePoolWithTag(List, USERTAG_WINDOWLIST); } } if (WindowPrev) @@ -205,12 +203,11 @@ co_IntMakeWindowActive(Window); - UserDerefObjectCo(Window); - /* FIXME: IntIsWindow */ + co_IntSendMessageNoWait( UserHMGetHandle(Window), WM_NCACTIVATE, - (WPARAM)(gpqForeground ? (Window == gpqForeground->spwndActive) : FALSE), + (WPARAM)(Window == (gpqForeground ? gpqForeground->spwndActive : NULL)), 0); //(LPARAM)hWndPrev); co_IntSendMessageNoWait( UserHMGetHandle(Window), @@ -226,6 +223,7 @@ Window->state &= ~WNDS_NONCPAINT; + UserDerefObjectCo(Window); } return InAAPM; } @@ -294,7 +292,7 @@ } VOID FASTCALL -FindRemoveAsyncMsg(PWND Wnd) +FindRemoveAsyncMsg(PWND Wnd, WPARAM wParam) { PTHREADINFO pti; PUSER_SENT_MESSAGE Message; @@ -311,18 +309,58 @@ Message = CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry); do { + if (IsListEmpty(Entry)) return; + if (!Message) return; + Entry = Message->ListEntry.Flink; + if (Message->Msg.message == WM_ASYNC_SETACTIVEWINDOW && Message->Msg.hwnd == UserHMGetHandle(Wnd) && - Message->Msg.wParam == 0 ) - { - TRACE("ASYNC SAW: Found one in the Sent Msg Queue! %p\n", Message->Msg.hwnd); - RemoveEntryList(Entry); // Purge the entry. - } - Entry = Message->ListEntry.Flink; + Message->Msg.wParam == wParam ) + { + ERR("ASYNC SAW: Found one in the Sent Msg Queue! %p Activate/Deactivate %d\n", Message->Msg.hwnd,!!wParam); + RemoveEntryList(&Message->ListEntry); // Purge the entry. + ExFreePoolWithTag(Message, TAG_USRMSG); + } Message = CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry); } while (Entry != &pti->SentMessagesListHead); } +} + +BOOL FASTCALL +ToggleFGActivate(PTHREADINFO pti) +{ + BOOL Ret; + PPROCESSINFO ppi = pti->ppi; + + Ret = !!(pti->TIF_flags & TIF_ALLOWFOREGROUNDACTIVATE); + if (Ret) + { + pti->TIF_flags &= ~TIF_ALLOWFOREGROUNDACTIVATE; + } + else + Ret = !!(ppi->W32PF_flags & W32PF_ALLOWFOREGROUNDACTIVATE); + + if (Ret) + ppi->W32PF_flags &= ~W32PF_ALLOWFOREGROUNDACTIVATE; + //ERR("ToggleFGActivate is %d\n",Ret); + return Ret; +} + +BOOL FASTCALL +IsAllowedFGActive(PTHREADINFO pti, PWND Wnd) +{ + // Not allowed if one or more,, + if (!ToggleFGActivate(pti) || // bits not set, + pti->rpdesk != gpdeskInputDesktop || // not current Desktop, + pti->MessageQueue == gpqForeground || // if already the queue foreground, + IsFGLocked() || // foreground is locked, + Wnd->ExStyle & WS_EX_NOACTIVATE ) // or,,, does not become the foreground window when the user clicks it. + { + return FALSE; + } + //ERR("IsAllowedFGActive is TRUE\n"); + return TRUE; } /* @@ -339,6 +377,7 @@ gppiInputProvider == ppi || !gpqForeground ) return TRUE; + //ERR("CanForceFG is FALSE\n"); return FALSE; } @@ -356,37 +395,35 @@ * The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo). * No menus are active. */ - -static BOOL FASTCALL +static +BOOL FASTCALL co_IntSetForegroundAndFocusWindow( _In_ PWND Wnd, _In_ BOOL MouseActivate) { - HWND hWnd; + HWND hWnd = Wnd ? UserHMGetHandle(Wnd) : NULL; HWND hWndPrev = NULL; + PWND pWndPrev = NULL; PUSER_MESSAGE_QUEUE PrevForegroundQueue; PTHREADINFO pti; BOOL fgRet = FALSE, Ret = FALSE; - ASSERT_REFS_CO(Wnd); - NT_ASSERT(Wnd != NULL); - - hWnd = UserHMGetHandle(Wnd); - - TRACE("SetForegroundAndFocusWindow(%p, %s)\n", hWnd, (MouseActivate ? "TRUE" : "FALSE")); + if (Wnd) ASSERT_REFS_CO(Wnd); + + //ERR("SetForegroundAndFocusWindow(%x, %s)\n", hWnd, (MouseActivate ? "TRUE" : "FALSE")); PrevForegroundQueue = IntGetFocusMessageQueue(); // Use this active desktop. pti = PsGetCurrentThreadWin32Thread(); if (PrevForegroundQueue) { // Same Window Q as foreground just do active. - //ERR("Same Window Q as foreground just do active.\n"); if (Wnd && Wnd->head.pti->MessageQueue == PrevForegroundQueue) { + //ERR("Same Window Q as foreground just do active.\n"); if (pti->MessageQueue == PrevForegroundQueue) { // Same WQ and TQ go active. //ERR("Same WQ and TQ go active.\n"); - Ret = co_IntSetActiveWindow(Wnd, NULL, MouseActivate, TRUE, FALSE); + Ret = co_IntSetActiveWindow(Wnd, MouseActivate, TRUE, FALSE); } else if (Wnd->head.pti->MessageQueue->spwndActive == Wnd) { // Same WQ and it is active. @@ -396,13 +433,14 @@ else { // Same WQ as FG but not the same TQ send active. //ERR("Same WQ as FG but not the same TQ send active.\n"); - co_IntSendMessageNoWait(hWnd, WM_ASYNC_SETACTIVEWINDOW, (WPARAM)Wnd, (LPARAM)MouseActivate ); + co_IntSendMessage(hWnd, WM_ASYNC_SETACTIVEWINDOW, (WPARAM)Wnd, (LPARAM)MouseActivate ); Ret = TRUE; } return Ret; } hWndPrev = PrevForegroundQueue->spwndActive ? UserHMGetHandle(PrevForegroundQueue->spwndActive) : 0; + pWndPrev = PrevForegroundQueue->spwndActive; } if ( (( !IsFGLocked() || pti->ppi == gppiInputProvider ) && @@ -410,16 +448,29 @@ pti->ppi == ppiScrnSaver ) { - IntSetFocusMessageQueue(Wnd->head.pti->MessageQueue); - gptiForeground = Wnd->head.pti; - TRACE("Set Foreground pti 0x%p Q 0x%p\n",Wnd->head.pti, Wnd->head.pti->MessageQueue); + + //ToggleFGActivate(pti); // win.c line 2662 fail + if (Wnd) + { + IntSetFocusMessageQueue(Wnd->head.pti->MessageQueue); + gptiForeground = Wnd->head.pti; + //ERR("Set Foreground pti 0x%p Q 0x%p hWnd 0x%p\n",Wnd->head.pti, Wnd->head.pti->MessageQueue,Wnd->head.h); + } + else + { + IntSetFocusMessageQueue(NULL); + gptiForeground = NULL; + //ERR("Set Foreground pti 0x0 Q 0x0 hWnd 0x0\n"); + } /* Henri Verbeet, What happens is that we get the WM_WINE_SETACTIVEWINDOW message sent by the other thread after we already changed the foreground window back to our own window. */ - FindRemoveAsyncMsg(Wnd); // Do this to fix test_SFW todos! + //ERR("SFAFW: 1\n"); + FindRemoveAsyncMsg(Wnd, 0); // Do this to fix test_SFW todos! + fgRet = TRUE; } @@ -428,34 +479,41 @@ { if (PrevForegroundQueue && fgRet && - Wnd->head.pti->MessageQueue != PrevForegroundQueue && PrevForegroundQueue->spwndActive) { //ERR("SFGW: Send NULL to 0x%x\n",hWndPrev); if (pti->MessageQueue == PrevForegroundQueue) { //ERR("SFGW: TI same as Prev TI\n"); - co_IntSetActiveWindow(NULL, NULL, FALSE, TRUE, FALSE); - } - else - co_IntSendMessageNoWait(hWndPrev, WM_ASYNC_SETACTIVEWINDOW, 0, 0 ); - } - } + co_IntSetActiveWindow(NULL, FALSE, TRUE, FALSE); + } + else if (pWndPrev) + { + //ERR("SFGW Deactivate: TI not same as Prev TI\n"); + // No real reason to wait here. + co_IntSendMessageNoWait(hWndPrev, WM_ASYNC_SETACTIVEWINDOW, 0, 0 ); + } + } + } + + if (!Wnd) return FALSE; // Always return false. if (pti->MessageQueue == Wnd->head.pti->MessageQueue) { - Ret = co_IntSetActiveWindow(Wnd, NULL, MouseActivate, TRUE, FALSE); + //ERR("Same PQ and WQ go active.\n"); + Ret = co_IntSetActiveWindow(Wnd, MouseActivate, TRUE, FALSE); } else if (Wnd->head.pti->MessageQueue->spwndActive == Wnd) { + //ERR("Same Active and Wnd.\n"); Ret = TRUE; } else { + //ERR("Activate Not same PQ and WQ and Wnd.\n"); co_IntSendMessageNoWait(hWnd, WM_ASYNC_SETACTIVEWINDOW, (WPARAM)Wnd, (LPARAM)MouseActivate ); Ret = TRUE; } - return Ret && fgRet; } @@ -500,7 +558,7 @@ } BOOL FASTCALL -co_IntSetActiveWindow(PWND Wnd OPTIONAL, HWND * Prev, BOOL bMouse, BOOL bFocus, BOOL Async) +co_IntSetActiveWindow(PWND Wnd OPTIONAL, BOOL bMouse, BOOL bFocus, BOOL Async) { PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; @@ -509,38 +567,83 @@ HWND hWnd = 0; BOOL InAAPM; CBTACTIVATESTRUCT cbt; - + //ERR("co_IntSetActiveWindow 1\n"); if (Wnd) { ASSERT_REFS_CO(Wnd); hWnd = UserHMGetHandle(Wnd); if ((Wnd->style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE; if (Wnd == UserGetDesktopWindow()) return FALSE; - } - + //ERR("co_IntSetActiveWindow 1a hWnd 0x%p\n",hWnd); + } + + //ERR("co_IntSetActiveWindow 2\n"); pti = PsGetCurrentThreadWin32Thread(); ThreadQueue = pti->MessageQueue; ASSERT(ThreadQueue != 0); hWndPrev = ThreadQueue->spwndActive ? UserHMGetHandle(ThreadQueue->spwndActive) : NULL; - if (Prev) *Prev = hWndPrev; - if (hWndPrev == hWnd) return TRUE; pWndChg = ThreadQueue->spwndActive; // Keep to notify of a preemptive switch. - if (Wnd) - { - if (ThreadQueue != Wnd->head.pti->MessageQueue) - { - PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue(); + while (Wnd) + { + BOOL Ret, DoFG, AllowFG; + + if (Wnd->state & WNDS_BEINGACTIVATED) return TRUE; + + if (ThreadQueue == Wnd->head.pti->MessageQueue) + { + if (IsAllowedFGActive(pti, Wnd)) + { + DoFG = TRUE; + } + else + { + //ERR("co_IntSetActiveWindow 3 Go Out!\n"); + break; + } + AllowFG = !pti->cVisWindows; // Nothing is visable. + //ERR("co_IntSetActiveWindow 3a DoFG = %d AllowFG = %d\n",DoFG,AllowFG); + } + else //if (ThreadQueue != Wnd->head.pti->MessageQueue) + { + //PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue(); // Rule 1 & 4, We are foreground so set this FG window or NULL foreground.... - if (!ForegroundQueue || ForegroundQueue == ThreadQueue) - { - return co_IntSetForegroundAndFocusWindow(Wnd, bMouse); - } - } - - if (Wnd->state & WNDS_BEINGACTIVATED) return TRUE; + //if (!ForegroundQueue || ForegroundQueue == ThreadQueue) + if (!gpqForeground || gpqForeground == ThreadQueue) + { + DoFG = TRUE; + } + else + DoFG = FALSE; + if (DoFG) + { + if (pti->TIF_flags & TIF_ALLOWFOREGROUNDACTIVATE || pti->cVisWindows) + AllowFG = TRUE; + else + AllowFG = FALSE; + } + else + AllowFG = FALSE; + //ERR("co_IntSetActiveWindow 3b DoFG = %d AllowFG = %d\n",DoFG,AllowFG); + } + Ret = FALSE; + if (DoFG) + { + pti->TIF_flags |= TIF_ALLOWFOREGROUNDACTIVATE; + //ERR("co_IntSetActiveWindow 3c FG set\n"); + Ret = co_IntSetForegroundAndFocusWindow(Wnd, bMouse); + if (AllowFG) + { + pti->TIF_flags |= TIF_ALLOWFOREGROUNDACTIVATE; + } + else + { + pti->TIF_flags &= ~TIF_ALLOWFOREGROUNDACTIVATE; + } + } + return Ret; } /* Call CBT hook chain */ @@ -562,14 +665,16 @@ if (WndPrev) { if (ThreadQueue == gpqForeground) gpqForegroundPrev = ThreadQueue; - if (!co_IntSendDeactivateMessages(hWndPrev, hWnd)) return FALSE; - } + if (!co_IntSendDeactivateMessages(UserHMGetHandle(WndPrev), hWnd)) return FALSE; + } + + WndPrev = ThreadQueue->spwndActive; // Again keep to save changing active. // While in calling message proc or hook: // Fail if a preemptive switch was made, current active not made previous, // focus window is dead or no longer the same thread queue. if ( ThreadQueue->spwndActivePrev != ThreadQueue->spwndActive || - pWndChg != ThreadQueue->spwndActive || + pWndChg != WndPrev || (Wnd && !VerifyWnd(Wnd)) || ThreadQueue != pti->MessageQueue ) { @@ -582,6 +687,8 @@ if (Wnd) Wnd->state |= WNDS_BEINGACTIVATED; IntNotifyWinEvent(EVENT_SYSTEM_FOREGROUND, Wnd, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); + //// Breaks Atl-Esc/Tab via User32. + ////FindRemoveAsyncMsg(Wnd,(WPARAM)Wnd); // Clear out activate ASYNC messages. /* check if the specified window can be set in the input data of a given queue */ if ( !Wnd || ThreadQueue == Wnd->head.pti->MessageQueue) @@ -589,6 +696,8 @@ /* set the current thread active window */ ThreadQueue->spwndActive = Wnd; } + + WndPrev = VerifyWnd(ThreadQueue->spwndActivePrev); // Now should be set but verify it again. InAAPM = co_IntSendActivateMessages(WndPrev, Wnd, bMouse, Async); @@ -610,14 +719,38 @@ if (InAAPM) { pti->TIF_flags &= ~TIF_INACTIVATEAPPMSG; - pti->pClientInfo->dwTIFlags = pti->TIF_flags; } // FIXME: Used in the menu loop!!! //ThreadQueue->QF_flags |= QF_ACTIVATIONCHANGE; + //ERR("co_IntSetActiveWindow Exit\n"); if (Wnd) Wnd->state &= ~WNDS_BEINGACTIVATED; return (ThreadQueue->spwndActive == Wnd); +} + +BOOL FASTCALL +UserSetActiveWindow(PWND Wnd) +{ + if (Wnd) // Must have a window! + { + if ((Wnd->style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE; + + return co_IntSetActiveWindow(Wnd, FALSE, TRUE, FALSE); + } + /* + Yes your eye are not deceiving you~! + + First part of wines Win.c test_SetActiveWindow: + + flush_events( TRUE ); + ShowWindow(hwnd, SW_HIDE); + SetFocus(0); + SetActiveWindow(0); + check_wnd_state(0, 0, 0, 0); <-- This should pass if ShowWindow does it's job!!! As of 10/28/2012 it does! + + */ + return FALSE; } HWND FASTCALL @@ -653,17 +786,10 @@ } /* Check if we can set the focus to this window */ - pwndTop = Window; - for (;;) + for (pwndTop = Window; pwndTop != NULL; pwndTop = pwndTop->spwndParent) { if (pwndTop->style & (WS_MINIMIZED|WS_DISABLED)) return 0; - if (!pwndTop->spwndParent || pwndTop->spwndParent == UserGetDesktopWindow()) - { - if ((pwndTop->style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return 0; - break; - } - if (pwndTop->spwndParent == UserGetMessageWindow()) return 0; - pwndTop = pwndTop->spwndParent; + if ((pwndTop->style & (WS_POPUP|WS_CHILD)) != WS_CHILD) break; } if (co_HOOK_CallHooks( WH_CBT, HCBT_SETFOCUS, (WPARAM)Window->head.h, (LPARAM)hWndPrev)) @@ -676,8 +802,13 @@ if (pwndTop != ThreadQueue->spwndActive) { PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue(); // Keep it based on desktop. - if (ThreadQueue != ForegroundQueue) // HACK see rule 2 & 3. - { + if (ThreadQueue != ForegroundQueue && IsAllowedFGActive(pti, pwndTop)) // Rule 2 & 3. + { + //ERR("SetFocus: Set Foreground!\n"); + if (!(pwndTop->style & WS_VISIBLE)) + { + pti->ppi->W32PF_flags |= W32PF_ALLOWFOREGROUNDACTIVATE; + } if (!co_IntSetForegroundAndFocusWindow(pwndTop, FALSE)) { ERR("SetFocus: Set Foreground and Focus Failed!\n"); @@ -688,7 +819,8 @@ /* Set Active when it is needed. */ if (pwndTop != ThreadQueue->spwndActive) { - if (!co_IntSetActiveWindow(pwndTop, NULL, FALSE, FALSE, FALSE)) + //ERR("SetFocus: Set Active!\n"); + if (!co_IntSetActiveWindow(pwndTop, FALSE, FALSE, FALSE)) { ERR("SetFocus: Set Active Failed!\n"); return 0; @@ -714,8 +846,6 @@ } else /* NULL hwnd passed in */ { -// if (!hWndPrev) return 0; /* nothing to do */ - if (co_HOOK_CallHooks( WH_CBT, HCBT_SETFOCUS, (WPARAM)0, (LPARAM)hWndPrev)) { ERR("SetFocus: 2 WH_CBT Call Hook return!\n"); @@ -857,7 +987,7 @@ BOOL FASTCALL co_IntSetForegroundWindow(PWND Window) { - ASSERT_REFS_CO(Window); + if (Window) ASSERT_REFS_CO(Window); return co_IntSetForegroundAndFocusWindow(Window, FALSE); } @@ -937,12 +1067,13 @@ } if (dwProcessId == ASFW_ANY) { // All processes will be enabled to set the foreground window. + //ERR("ptiLastInput is CLEARED!!\n"); ptiLastInput = NULL; } else { // Rule #3, last input event in force. - ERR("Fixme: ptiLastInput is SET!!\n"); - //ptiLastInput = ppi->ptiList; + ERR("ptiLastInput is SET!!\n"); + //ptiLastInput = ppi->ptiList; // See CORE-6384 & CORE-7030. ObDereferenceObject(Process); } return TRUE; @@ -962,7 +1093,7 @@ RETURN( UserGetForegroundWindow()); CLEANUP: - TRACE("Leave NtUserGetForegroundWindow, ret=%p\n", _ret_); + TRACE("Leave NtUserGetForegroundWindow, ret=%p\n",_ret_); UserLeave(); END_CLEANUP; } @@ -993,7 +1124,7 @@ { hWndPrev = gptiCurrent->MessageQueue->spwndActive ? UserHMGetHandle(gptiCurrent->MessageQueue->spwndActive) : NULL; if (Window) UserRefObjectCo(Window, &Ref); - co_IntSetActiveWindow(Window, NULL, FALSE, TRUE, FALSE); + UserSetActiveWindow(Window); if (Window) UserDerefObjectCo(Window); RETURN( hWndPrev ? (IntIsWindow(hWndPrev) ? hWndPrev : 0) : 0 ); } Modified: trunk/reactos/win32ss/user/ntuser/focus.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/focus.…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/focus.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/focus.h [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -2,6 +2,7 @@ extern PUSER_MESSAGE_QUEUE gpqForeground; extern PUSER_MESSAGE_QUEUE gpqForegroundPrev; +extern PTHREADINFO ptiLastInput; /* * These functions take the window handles from current message queue. @@ -18,7 +19,8 @@ HWND FASTCALL UserGetActiveWindow(VOID); BOOL FASTCALL co_IntMouseActivateWindow(PWND Window); BOOL FASTCALL co_IntSetForegroundWindow(PWND Window); -BOOL FASTCALL co_IntSetActiveWindow(PWND,HWND *,BOOL,BOOL,BOOL); BOOL FASTCALL co_IntSetForegroundWindowMouse(PWND Window); +BOOL FASTCALL co_IntSetActiveWindow(PWND,BOOL,BOOL,BOOL); +BOOL FASTCALL UserSetActiveWindow(PWND Wnd); BOOL FASTCALL IntLockSetForegroundWindow(UINT uLockCode); BOOL FASTCALL IntAllowSetForegroundWindow(DWORD dwProcessId); Modified: trunk/reactos/win32ss/user/ntuser/input.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/input.…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/input.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/input.c [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -402,24 +402,47 @@ return ret; } -PTHREADINFO FASTCALL -IsThreadAttach(PTHREADINFO ptiTo) -{ +BOOL +FASTCALL +IsRemoveAttachThread(PTHREADINFO pti) +{ + NTSTATUS Status; PATTACHINFO pai; - - if (!gpai) return NULL; - - pai = gpai; + BOOL Ret = TRUE; + PTHREADINFO ptiFrom = NULL, ptiTo = NULL; + do { - if (pai->pti2 == ptiTo) break; - pai = pai->paiNext; - } while (pai); - - if (!pai) return NULL; - - // Return ptiFrom. - return pai->pti1; + if (!gpai) return TRUE; + + pai = gpai; // Bottom of the list. + + do + { + if (pai->pti2 == pti) + { + ptiFrom = pai->pti1; + ptiTo = pti; + break; + } + if (pai->pti1 == pti) + { + ptiFrom = pti; + ptiTo = pai->pti2; + break; + } + pai = pai->paiNext; + + } while (pai); + + if (!pai && !ptiFrom && !ptiTo) break; + + Status = UserAttachThreadInput(ptiFrom, ptiTo, FALSE); + if (!NT_SUCCESS(Status)) Ret = FALSE; + + } while (Ret); + + return Ret; } NTSTATUS FASTCALL @@ -454,43 +477,51 @@ paiCount++; ERR("Attach Allocated! ptiFrom 0x%p ptiTo 0x%p paiCount %d\n",ptiFrom,ptiTo,paiCount); - if (ptiTo->MessageQueue == ptiFrom->MessageQueue) + if (ptiTo->MessageQueue != ptiFrom->MessageQueue) + { + + ptiTo->MessageQueue->iCursorLevel -= ptiFrom->iCursorLevel; + + // FIXME: conditions? + if (ptiTo->MessageQueue == gpqForeground) + { + ERR("ptiTo is Foreground\n"); + } + else + { + ERR("ptiTo NOT Foreground\n"); + } + + if (ptiFrom->MessageQueue == gpqForeground) + { + ERR("ptiFrom is Foreground\n"); + ptiTo->MessageQueue->spwndActive = ptiFrom->MessageQueue->spwndActive; + ptiTo->MessageQueue->spwndFocus = ptiFrom->MessageQueue->spwndFocus; + ptiTo->MessageQueue->CursorObject = ptiFrom->MessageQueue->CursorObject; + ptiTo->MessageQueue->spwndCapture = ptiFrom->MessageQueue->spwndCapture; + ptiTo->MessageQueue->QF_flags ^= ((ptiTo->MessageQueue->QF_flags ^ ptiFrom->MessageQueue->QF_flags) & QF_CAPTURELOCKED); + ptiTo->MessageQueue->CaretInfo = ptiFrom->MessageQueue->CaretInfo; + IntSetFocusMessageQueue(NULL); + IntSetFocusMessageQueue(ptiTo->MessageQueue); + gptiForeground = ptiTo; + } + else + { + ERR("ptiFrom NOT Foreground\n"); + } + + MsqDestroyMessageQueue(ptiFrom); + + ptiFrom->MessageQueue = ptiTo->MessageQueue; + + ptiFrom->MessageQueue->cThreads++; + ERR("ptiTo S Share count %d\n", ptiFrom->MessageQueue->cThreads); + + IntReferenceMessageQueue(ptiTo->MessageQueue); + } + else { ERR("Attach Threads are already associated!\n"); - } - - ptiTo->MessageQueue->iCursorLevel -= ptiFrom->iCursorLevel; - - /* Keep the original queue in pqAttach (ie do not trash it in a second attachment) */ - if (ptiFrom->pqAttach == NULL) - ptiFrom->pqAttach = ptiFrom->MessageQueue; - ptiFrom->MessageQueue = ptiTo->MessageQueue; - - ptiFrom->MessageQueue->cThreads++; - ERR("ptiTo S Share count %lu\n", ptiFrom->MessageQueue->cThreads); - - // FIXME: conditions? - if (ptiFrom->pqAttach == gpqForeground) - { - ERR("ptiFrom is Foreground\n"); - ptiFrom->MessageQueue->spwndActive = ptiFrom->pqAttach->spwndActive; - ptiFrom->MessageQueue->spwndFocus = ptiFrom->pqAttach->spwndFocus; - ptiFrom->MessageQueue->CursorObject = ptiFrom->pqAttach->CursorObject; - ptiFrom->MessageQueue->spwndCapture = ptiFrom->pqAttach->spwndCapture; - ptiFrom->MessageQueue->QF_flags ^= ((ptiFrom->MessageQueue->QF_flags ^ ptiFrom->pqAttach->QF_flags) & QF_CAPTURELOCKED); - ptiFrom->MessageQueue->CaretInfo = ptiFrom->pqAttach->CaretInfo; - } - else - { - ERR("ptiFrom NOT Foreground\n"); - } - if (ptiTo->MessageQueue == gpqForeground) - { - ERR("ptiTo is Foreground\n"); - } - else - { - ERR("ptiTo NOT Foreground\n"); } } else /* If clear, unlink and free it. */ @@ -518,41 +549,31 @@ } if (!Hit) return STATUS_INVALID_PARAMETER; - - ASSERT(ptiFrom->pqAttach); ERR("Attach Free! ptiFrom 0x%p ptiTo 0x%p paiCount %d\n",ptiFrom,ptiTo,paiCount); - - /* Search list and check if the thread is attached one more time */ - pai = gpai; - while(pai) - { - /* If the thread is attached again , we are done */ - if (pai->pti1 == ptiFrom) - { - ptiFrom->MessageQueue->cThreads--; - ERR("ptiTo L Share count %lu\n", ptiFrom->MessageQueue->cThreads); - /* Use the message queue of the last attachment */ - ptiFrom->MessageQueue = pai->pti2->MessageQueue; - ptiFrom->MessageQueue->CursorObject = NULL; - ptiFrom->MessageQueue->spwndActive = NULL; - ptiFrom->MessageQueue->spwndFocus = NULL; - ptiFrom->MessageQueue->spwndCapture = NULL; - return STATUS_SUCCESS; - } - pai = pai->paiNext; - } - - ptiFrom->MessageQueue->cThreads--; - ERR("ptiTo E Share count %lu\n", ptiFrom->MessageQueue->cThreads); - ptiFrom->MessageQueue = ptiFrom->pqAttach; - // FIXME: conditions? - ptiFrom->MessageQueue->CursorObject = NULL; - ptiFrom->MessageQueue->spwndActive = NULL; - ptiFrom->MessageQueue->spwndFocus = NULL; - ptiFrom->MessageQueue->spwndCapture = NULL; - ptiFrom->pqAttach = NULL; - ptiTo->MessageQueue->iCursorLevel -= ptiFrom->iCursorLevel; + + if (ptiTo->MessageQueue == ptiFrom->MessageQueue) + { + if (gptiForeground == ptiFrom) + { + ERR("ptiTo is now pti FG.\n"); + // MessageQueue foreground is set so switch threads. + gptiForeground = ptiTo; + } + ptiTo->MessageQueue->cThreads--; + ERR("ptiTo E Share count %d\n", ptiTo->MessageQueue->cThreads); + ASSERT(ptiTo->MessageQueue->cThreads >= 1); + + IntDereferenceMessageQueue(ptiTo->MessageQueue); + + ptiFrom->MessageQueue = MsqCreateMessageQueue(ptiFrom); + + ptiTo->MessageQueue->iCursorLevel -= ptiFrom->iCursorLevel; + } + else + { + ERR("Detaching Threads are not associated!\n"); + } } /* Note that key state, which can be ascertained by calls to the GetKeyState or GetKeyboardState function, is reset after a call to AttachThreadInput. Modified: trunk/reactos/win32ss/user/ntuser/input.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/input.…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/input.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/input.h [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -63,7 +63,7 @@ BOOL FASTCALL IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt); DWORD NTAPI CreateSystemThreads(UINT Type); NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO,PTHREADINFO,BOOL); -PTHREADINFO FASTCALL IsThreadAttach(PTHREADINFO); +BOOL FASTCALL IsRemoveAttachThread(PTHREADINFO); VOID FASTCALL DoTheScreenSaver(VOID); #define ThreadHasInputAccess(W32Thread) (TRUE) Modified: trunk/reactos/win32ss/user/ntuser/keyboard.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/keyboa…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/keyboard.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/keyboard.c [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -825,6 +825,7 @@ TRACE("HotKey Processed\n"); bPostMsg = FALSE; } + wFixedVk = IntFixVk(wSimpleVk, bExt); /* LSHIFT + EXT = RSHIFT */ if (wSimpleVk == VK_SHIFT) /* shift can't be extended */ bExt = FALSE; @@ -892,23 +893,31 @@ } else if (pFocusQueue && bPostMsg) { - PWND Wnd = pFocusQueue->spwndFocus; - if (!Wnd) - { - // Focus can be null so going with Active. WM_SYSKEYXXX last wine Win test_keyboard_input. + PWND Wnd = pFocusQueue->spwndFocus; // SysInit..... + + pti = pFocusQueue->ptiKeyboard; + + if (!Wnd && pFocusQueue->spwndActive) // SysInit..... + { + // Going with Active. WM_SYSKEYXXX last wine Win test_keyboard_input. Wnd = pFocusQueue->spwndActive; } - - if ( !Wnd || Wnd->state2 & WNDS2_INDESTROY || Wnd->state & WNDS_DESTROYED ) - { - ERR("ProcessKeyEvent Active Focus window is dead!\n"); - return FALSE; - } - - pti = Wnd->head.pti; + if (Wnd) pti = Wnd->head.pti; + + if ( Msg.message == WM_KEYDOWN || Msg.message == WM_SYSKEYDOWN ) + { + if ( (Msg.wParam == VK_SHIFT || + Msg.wParam == VK_CONTROL || + Msg.wParam == VK_MENU ) && + !IS_KEY_DOWN(gafAsyncKeyState, Msg.wParam)) + { + ERR("Set last input\n"); + //ptiLastInput = pti; + } + } /* Init message */ - Msg.hwnd = UserHMGetHandle(Wnd); + Msg.hwnd = Wnd ? UserHMGetHandle(Wnd) : NULL; Msg.wParam = wFixedVk & 0xFF; /* Note: It's simplified by msg queue */ Msg.lParam = MAKELPARAM(1, wScanCode); Msg.time = dwTime; @@ -934,6 +943,7 @@ /* Post a keyboard message */ TRACE("Posting keyboard msg %u wParam 0x%x lParam 0x%x\n", Msg.message, Msg.wParam, Msg.lParam); + if (!Wnd) {ERR("Window is NULL\n");} MsqPostMessage(pti, &Msg, TRUE, QS_KEY, 0); } @@ -956,9 +966,9 @@ /* Find the target thread whose locale is in effect */ pFocusQueue = IntGetFocusMessageQueue(); - if (pFocusQueue && pFocusQueue->ptiOwner) - { - pKl = pFocusQueue->ptiOwner->KeyboardLayout; + if (pFocusQueue && pFocusQueue->ptiKeyboard) + { + pKl = pFocusQueue->ptiKeyboard->KeyboardLayout; } if (!pKl) @@ -1039,9 +1049,9 @@ /* Find the target thread whose locale is in effect */ pFocusQueue = IntGetFocusMessageQueue(); - if (pFocusQueue && pFocusQueue->ptiOwner) - { - pKl = pFocusQueue->ptiOwner->KeyboardLayout; + if (pFocusQueue && pFocusQueue->ptiKeyboard) + { + pKl = pFocusQueue->ptiKeyboard->KeyboardLayout; } if (!pKl) Modified: trunk/reactos/win32ss/user/ntuser/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/main.c…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/main.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/main.c [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -154,6 +154,9 @@ ppiCurrent->W32PF_flags |= W32PF_SCREENSAVER; } + // Fixme check if this process is allowed. + ppiCurrent->W32PF_flags |= W32PF_ALLOWFOREGROUNDACTIVATE; // Starting application it will get toggled off. + /* Create pools for GDI object attributes */ ppiCurrent->pPoolDcAttr = GdiPoolCreate(sizeof(DC_ATTR), 'acdG'); ppiCurrent->pPoolBrushAttr = GdiPoolCreate(sizeof(BRUSH_ATTR), 'arbG'); @@ -275,14 +278,17 @@ RtlZeroMemory(ptiCurrent, sizeof(THREADINFO)); + /* Initialize the THREADINFO */ + PsSetThreadWin32Thread(Thread, ptiCurrent); + IntReferenceThreadInfo(ptiCurrent); + ptiCurrent->pEThread = Thread; + ptiCurrent->ppi = PsGetCurrentProcessWin32Process(); pTeb->Win32ThreadInfo = ptiCurrent; ptiCurrent->pClientInfo = (PCLIENTINFO)pTeb->Win32ClientInfo; TRACE_CH(UserThread, "Allocated pti 0x%p for TID %p\n", ptiCurrent, Thread->Cid.UniqueThread); - /* Initialize the THREADINFO */ - IntReferenceThreadInfo(ptiCurrent); InitializeListHead(&ptiCurrent->WindowListHead); InitializeListHead(&ptiCurrent->W32CallbackListHead); InitializeListHead(&ptiCurrent->PostedMessagesListHead); @@ -294,8 +300,6 @@ { InitializeListHead(&ptiCurrent->aphkStart[i]); } - ptiCurrent->pEThread = Thread; - ptiCurrent->ppi = PsGetCurrentProcessWin32Process(); ptiCurrent->ptiSibling = ptiCurrent->ppi->ptiList; ptiCurrent->ppi->ptiList = ptiCurrent; ptiCurrent->ppi->cThreads++; @@ -307,7 +311,7 @@ { goto error; } - Status = ObReferenceObjectByHandle(ptiCurrent->hEventQueueClient, 0, + Status = ObReferenceObjectByHandle(ptiCurrent->hEventQueueClient, 0, ExEventObjectType, KernelMode, (PVOID*)&ptiCurrent->pEventQueueServer, NULL); if (!NT_SUCCESS(Status)) @@ -319,7 +323,7 @@ KeQueryTickCount(&LargeTickCount); ptiCurrent->timeLast = LargeTickCount.u.LowPart; - + ptiCurrent->MessageQueue = MsqCreateMessageQueue(ptiCurrent); if(ptiCurrent->MessageQueue == NULL) { @@ -419,8 +423,14 @@ /* mark the thread as fully initialized */ ptiCurrent->TIF_flags |= TIF_GUITHREADINITIALIZED; + + if (!(ptiCurrent->ppi->W32PF_flags & (W32PF_ALLOWFOREGROUNDACTIVATE | W32PF_APPSTARTING)) && + (gptiForeground && gptiForeground->ppi == ptiCurrent->ppi )) + { + ptiCurrent->TIF_flags |= TIF_ALLOWFOREGROUNDACTIVATE; + } ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags; - + ERR_CH(UserThread,"UserCreateW32Thread pti 0x%p\n",ptiCurrent); return STATUS_SUCCESS; error: @@ -483,27 +493,10 @@ ppiCurrent = ptiCurrent->ppi; ASSERT(ppiCurrent); - // ptiTo - if (IsThreadAttach(ptiCurrent)) - { - PTHREADINFO ptiFrom = IsThreadAttach(ptiCurrent); - TRACE_CH(UserThread,"Attached Thread ptiTo is getting switched!\n"); - UserAttachThreadInput(ptiFrom, ptiCurrent, FALSE); - } - - // ptiFrom - if (ptiCurrent->pqAttach && ptiCurrent->MessageQueue) - { - PTHREADINFO ptiTo; - ptiTo = ptiCurrent->MessageQueue->ptiOwner; - TRACE_CH(UserThread,"Attached Thread ptiFrom is getting switched!\n"); - if (ptiTo) UserAttachThreadInput( ptiCurrent, ptiTo, FALSE); - else - { - // eThread maybe okay but Win32Thread already made NULL! - ERR_CH(UserThread,"Attached Thread ptiFrom did not switch due to ptiTo is NULL!\n"); - } - } + IsRemoveAttachThread(ptiCurrent); + + ptiCurrent->TIF_flags |= TIF_DONTATTACHQUEUE; + ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags; /* Decrement thread count and check if its 0 */ ppiCurrent->cThreads--; @@ -553,9 +546,10 @@ */ co_DestroyThreadWindows(Thread); - if (ppiCurrent && ppiCurrent->ptiList == ptiCurrent && !ptiCurrent->ptiSibling) - { - //ERR_CH(UserThread,"DestroyProcessClasses\n"); + if (ppiCurrent && ppiCurrent->ptiList == ptiCurrent && !ptiCurrent->ptiSibling && + ppiCurrent->W32PF_flags & W32PF_CLASSESREGISTERED) + { + ERR_CH(UserThread,"DestroyProcessClasses\n"); /* no process windows should exist at this point, or the function will assert! */ DestroyProcessClasses(ppiCurrent); ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED; @@ -592,8 +586,24 @@ if (ptiCurrent->KeyboardLayout) UserDereferenceObject(ptiCurrent->KeyboardLayout); - IntSetThreadDesktop(NULL, TRUE); - + if (gptiForeground == ptiCurrent) + { +// IntNotifyWinEvent(EVENT_OBJECT_FOCUS, NULL, OBJID_CLIENT, CHILDID_SELF, 0); +// IntNotifyWinEvent(EVENT_SYSTEM_FOREGROUND, NULL, OBJID_WINDOW, CHILDID_SELF, 0); + + gptiForeground = NULL; + } + + // Fixes CORE-6384 & CORE-7030. +/* if (ptiLastInput == ptiCurrent) + { + if (!ppiCurrent->ptiList) + ptiLastInput = gptiForeground; + else + ptiLastInput = ppiCurrent->ptiList; + ERR_CH(UserThread,"DTI: ptiLastInput is Cleared!!\n"); + } +*/ TRACE_CH(UserThread,"Freeing pti 0x%p\n", ptiCurrent); /* Free the THREADINFO */ Modified: trunk/reactos/win32ss/user/ntuser/message.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/messag…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/message.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/message.c [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -502,13 +502,7 @@ IdlePing(VOID) { PPROCESSINFO ppi = PsGetCurrentProcessWin32Process(); - PUSER_MESSAGE_QUEUE ForegroundQueue; - PTHREADINFO pti, ptiForeground = NULL; - - ForegroundQueue = IntGetFocusMessageQueue(); - - if (ForegroundQueue) - ptiForeground = ForegroundQueue->ptiOwner; + PTHREADINFO pti; pti = PsGetCurrentThreadWin32Thread(); @@ -516,7 +510,7 @@ { pti->pClientInfo->cSpins = 0; // Reset spins. - if ( pti->pDeskInfo && pti == ptiForeground ) + if ( pti->pDeskInfo && pti == gptiForeground ) { if ( pti->fsHooks & HOOKID_TO_FLAG(WH_FOREGROUNDIDLE) || pti->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_FOREGROUNDIDLE) ) @@ -602,13 +596,14 @@ { LRESULT lRes; USER_REFERENCE_ENTRY Ref; +// PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); if (!pWnd || pWnd == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP pWnd == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND return 0; - TRACE("Internal Event Msg %u hWnd %p\n", msg, pWnd->head.h); + TRACE("Internal Event Msg %p hWnd 0x%x\n",msg,pWnd->head.h); switch(msg) { @@ -632,7 +627,7 @@ { PWND Window = (PWND)wparam; if (wparam) UserRefObjectCo(Window, &Ref); - lRes = (LRESULT)co_IntSetActiveWindow(Window,NULL,(BOOL)lparam,TRUE,TRUE); + lRes = (LRESULT)co_IntSetActiveWindow(Window,(BOOL)lparam,TRUE,TRUE); if (wparam) UserDerefObjectCo(Window); return lRes; } @@ -751,6 +746,14 @@ /* * Internal version of PeekMessage() doing all the work + * + * MSDN: + * Sent messages + * Posted messages + * Input (hardware) messages and system internal events + * Sent messages (again) + * WM_PAINT messages + * WM_TIMER messages */ BOOL FASTCALL co_IntPeekMessage( PMSG Msg, @@ -770,7 +773,7 @@ RemoveMessages = RemoveMsg & PM_REMOVE; ProcessMask = HIWORD(RemoveMsg); - + /* Hint, "If wMsgFilterMin and wMsgFilterMax are both zero, PeekMessage returns all available messages (that is, no range filtering is performed)". */ if (!ProcessMask) ProcessMask = (QS_ALLPOSTMESSAGE|QS_ALLINPUT); @@ -1083,6 +1086,19 @@ return TRUE; } +PTHREADINFO FASTCALL +IntSendTo(PWND Window, PTHREADINFO ptiCur, UINT Msg) +{ + if ( ptiCur ) + { + if ( Window->head.pti->MessageQueue == ptiCur->MessageQueue ) + { + return NULL; + } + } + return Window->head.pti; +} + BOOL FASTCALL UserPostMessage( HWND Wnd, UINT Msg, @@ -1192,11 +1208,11 @@ if (WM_QUIT == Msg) { - MsqPostQuitMessage(Window->head.pti, wParam); + MsqPostQuitMessage(pti, wParam); } else { - MsqPostMessage(Window->head.pti, &Message, FALSE, QS_POSTMESSAGE, 0); + MsqPostMessage(pti, &Message, FALSE, QS_POSTMESSAGE, 0); } } return TRUE; @@ -1230,7 +1246,7 @@ PMSGMEMORY MsgMemoryEntry; INT lParamBufferSize; LPARAM lParamPacked; - PTHREADINFO Win32Thread; + PTHREADINFO Win32Thread, ptiSendTo = NULL; ULONG_PTR Hi, Lo, Result = 0; DECLARE_RETURN(LRESULT); USER_REFERENCE_ENTRY Ref; @@ -1246,8 +1262,9 @@ Win32Thread = PsGetCurrentThreadWin32Thread(); - if ( Win32Thread && - Window->head.pti == Win32Thread) + ptiSendTo = IntSendTo(Window, Win32Thread, Msg); + + if ( !ptiSendTo ) { if (Win32Thread->TIF_flags & TIF_INCLEANUP) { @@ -1333,7 +1350,7 @@ RETURN( TRUE); } - if (uFlags & SMTO_ABORTIFHUNG && MsqIsHung(Window->head.pti)) + if (uFlags & SMTO_ABORTIFHUNG && MsqIsHung(ptiSendTo/*Window->head.pti*/)) { // FIXME: Set window hung and add to a list. /* FIXME: Set a LastError? */ @@ -1349,7 +1366,7 @@ do { - Status = co_MsqSendMessage( Window->head.pti, + Status = co_MsqSendMessage( ptiSendTo, //Window->head.pti, hWnd, Msg, wParam, @@ -1361,7 +1378,7 @@ } while ((STATUS_TIMEOUT == Status) && (uFlags & SMTO_NOTIMEOUTIFNOTHUNG) && - !MsqIsHung(Window->head.pti)); // FIXME: Set window hung and add to a list. + !MsqIsHung(ptiSendTo/*Window->head.pti*/)); // FIXME: Set window hung and add to a list. if (STATUS_TIMEOUT == Status) { @@ -1491,7 +1508,7 @@ PMSGMEMORY MsgMemoryEntry; INT lParamBufferSize; LPARAM lParamPacked; - PTHREADINFO Win32Thread; + PTHREADINFO Win32Thread, ptiSendTo = NULL; DECLARE_RETURN(LRESULT); USER_REFERENCE_ENTRY Ref; PUSER_SENT_MESSAGE Message; @@ -1519,9 +1536,11 @@ { RETURN(FALSE); } + + ptiSendTo = IntSendTo(Window, Win32Thread, Msg); if (Msg & 0x80000000 && - Window->head.pti == Win32Thread) + !ptiSendTo) { if (Win32Thread->TIF_flags & TIF_INCLEANUP) RETURN( FALSE); @@ -1542,14 +1561,14 @@ lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam); } - if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, Window->head.pti != Win32Thread))) + if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, !!ptiSendTo))) { ERR("Failed to pack message parameters\n"); RETURN( FALSE); } /* If it can be sent now, then send it. */ - if (Window->head.pti == Win32Thread) + if ( !ptiSendTo ) { if (Win32Thread->TIF_flags & TIF_INCLEANUP) { @@ -1599,7 +1618,7 @@ } } - if (Window->head.pti == Win32Thread) + if ( !ptiSendTo) { if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE))) { @@ -1622,7 +1641,7 @@ Message->Result = 0; Message->lResult = 0; Message->QS_Flags = 0; - Message->ptiReceiver = Window->head.pti; + Message->ptiReceiver = ptiSendTo; //Window->head.pti; Message->ptiSender = NULL; // mjmartin, you are right! This is null. Message->ptiCallBackSender = Win32Thread; Message->DispatchingListEntry.Flink = NULL; @@ -1633,10 +1652,10 @@ Message->QS_Flags = QS_SENDMESSAGE; if (Msg & 0x80000000) // Higher priority event message! - InsertHeadList(&Window->head.pti->SentMessagesListHead, &Message->ListEntry); + InsertHeadList(&ptiSendTo->SentMessagesListHead/*&Window->head.pti->SentMessagesListHead*/, &Message->ListEntry); else - InsertTailList(&Window->head.pti->SentMessagesListHead, &Message->ListEntry); - MsqWakeQueue(Window->head.pti, QS_SENDMESSAGE, TRUE); + InsertTailList(&ptiSendTo->SentMessagesListHead/*&Window->head.pti->SentMessagesListHead*/, &Message->ListEntry); + MsqWakeQueue(ptiSendTo/*Window->head.pti*/, QS_SENDMESSAGE, TRUE); RETURN(TRUE); @@ -1674,7 +1693,7 @@ pti = PsGetCurrentThreadWin32Thread(); - if ( Window->head.pti->MessageQueue != pti->MessageQueue && + if ( IntSendTo(Window, pti, Msg) && FindMsgMemory(Msg) == 0 ) { Result = UserPostMessage(hWnd, Msg, wParam, lParam); Modified: trunk/reactos/win32ss/user/ntuser/misc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/misc.c…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/misc.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/misc.c [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -662,8 +662,11 @@ ASSERT(pti->pDeskInfo == pti->rpdesk->pDeskInfo); /*too bad we still get this assertion*/ + + // Why? Not all flags are passed to the user and doing so could crash the system........ + /* ASSERT(pci->dwTIFlags == pti->TIF_flags); */ - if(pci->dwTIFlags != pti->TIF_flags) +/* if(pci->dwTIFlags != pti->TIF_flags) { ERR("pci->dwTIFlags(0x%x) doesn't match pti->TIF_flags(0x%x)\n", pci->dwTIFlags, pti->TIF_flags); if(showCaller) @@ -673,6 +676,7 @@ } pci->dwTIFlags = pti->TIF_flags; } +*/ } void Modified: trunk/reactos/win32ss/user/ntuser/msgqueue.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/msgque…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/msgqueue.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/msgqueue.c [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -404,7 +404,6 @@ { ERR("This Message Queue is in Destroy!\n"); } - pti->pcti->fsWakeBits |= MessageBits; pti->pcti->fsChangeBits |= MessageBits; @@ -475,6 +474,10 @@ { if (--pti->nCntsQBits[QSRosHotKey] == 0) ClrMask |= QS_HOTKEY; } + if (MessageBits & QS_EVENT) + { + if (--pti->nCntsQBits[QSRosEvent] == 0) ClrMask |= QS_EVENT; + } pti->pcti->fsWakeBits &= ~ClrMask; pti->pcti->fsChangeBits &= ~ClrMask; @@ -506,6 +509,7 @@ { LARGE_INTEGER LargeTickCount; MSLLHOOKSTRUCT MouseHookData; +// PDESKTOP pDesk; PWND pwnd, pwndDesktop; HDC hdcScreen; PTHREADINFO pti; @@ -549,6 +553,7 @@ /* Get the desktop window */ pwndDesktop = UserGetDesktopWindow(); if (!pwndDesktop) return; +// pDesk = pwndDesktop->head.rpdesk; /* Check if the mouse is captured */ Msg->hwnd = IntGetCaptureWindow(); @@ -626,6 +631,7 @@ } else { + //if (!IntGetCaptureWindow()) ptiLastInput = pti; TRACE("Posting mouse message to hwnd=%p!\n", UserHMGetHandle(pwnd)); MsqPostMessage(pti, Msg, TRUE, QS_MOUSEBUTTON, 0); } @@ -661,7 +667,7 @@ } BOOLEAN FASTCALL -co_MsqDispatchOneSentMessage(_In_ PTHREADINFO pti) +co_MsqDispatchOneSentMessage(PTHREADINFO pti) { PUSER_SENT_MESSAGE SaveMsg, Message; PLIST_ENTRY Entry; @@ -910,12 +916,6 @@ } ptiSender = PsGetCurrentThreadWin32Thread(); - - IntReferenceMessageQueue(ptiReceiver->MessageQueue); - /* Take reference on this MessageQueue if its a callback. It will be released - when message is processed or removed from target hwnd MessageQueue */ - if (CompletionCallback) - IntReferenceMessageQueue(ptiSender->MessageQueue); Message->Msg.hwnd = hwnd; Message->Msg.message = Msg; @@ -1180,6 +1180,12 @@ PUSER_MESSAGE Message; PUSER_MESSAGE_QUEUE MessageQueue; + if ( pti->TIF_flags & TIF_INCLEANUP || pti->MessageQueue->QF_flags & QF_INDESTROY ) + { + ERR("Post Msg; Thread or Q is Dead!\n"); + return; + } + if(!(Message = MsqCreateMessage(Msg))) { return; @@ -1189,6 +1195,7 @@ if (dwQEvent) { + ERR("Post Msg; System Qeued Event Message!\n"); InsertHeadList(&pti->PostedMessagesListHead, &Message->ListEntry); } @@ -1206,7 +1213,7 @@ if (Msg->message == WM_HOTKEY) MessageBits |= QS_HOTKEY; // Justin Case, just set it. Message->dwQEvent = dwQEvent; Message->QS_Flags = MessageBits; - //Message->pti = pti; Fixed in ATI changes. See CORE-6551 + Message->pti = pti; MsqWakeQueue(pti, MessageBits, (MessageBits & QS_TIMER ? FALSE : TRUE)); } @@ -1254,7 +1261,7 @@ IntTrackMouseMove(PWND pwndTrack, PDESKTOP pDesk, PMSG msg, USHORT hittest) { // PWND pwndTrack = IntChildrenWindowFromPoint(pwndMsg, msg->pt.x, msg->pt.y); - hittest = (USHORT)GetNCHitEx(pwndTrack, msg->pt); /// @todo WTF is this??? +// hittest = (USHORT)GetNCHitEx(pwndTrack, msg->pt); /// @todo WTF is this??? if ( pDesk->spwndTrack != pwndTrack || // Change with tracking window or msg->message != WM_MOUSEMOVE || // Mouse click changes or @@ -1491,7 +1498,7 @@ hook.dwExtraInfo = 0 /* extra_info */ ; co_HOOK_CallHooks( WH_CBT, HCBT_CLICKSKIPPED, message, (LPARAM)&hook ); - ERR("WH_MOUSE dorpped mouse message!\n"); + ERR("WH_MOUSE dropped mouse message!\n"); /* Remove and skip message */ *RemoveMessages = TRUE; @@ -1805,7 +1812,7 @@ ListHead = &pti->PostedMessagesListHead; if (IsListEmpty(CurrentEntry)) return FALSE; - + CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry); do @@ -1880,9 +1887,8 @@ BOOLEAN FASTCALL MsqInitializeMessageQueue(PTHREADINFO pti, PUSER_MESSAGE_QUEUE MessageQueue) { - MessageQueue->ptiOwner = pti; MessageQueue->CaretInfo = (PTHRDCARETINFO)(MessageQueue + 1); - InitializeListHead(&MessageQueue->HardwareMessagesListHead); + InitializeListHead(&MessageQueue->HardwareMessagesListHead); // Keep here! MessageQueue->spwndFocus = NULL; MessageQueue->iCursorLevel = 0; MessageQueue->CursorObject = NULL; @@ -1900,7 +1906,7 @@ PLIST_ENTRY CurrentEntry; PUSER_MESSAGE CurrentMessage; PUSER_SENT_MESSAGE CurrentSentMessage; - + /* cleanup posted messages */ while (!IsListEmpty(&pti->PostedMessagesListHead)) { @@ -1936,7 +1942,7 @@ if (CurrentSentMessage->Msg.lParam) ExFreePool((PVOID)CurrentSentMessage->Msg.lParam); } - + /* free the message */ ExFreePool(CurrentSentMessage); } @@ -1999,16 +2005,16 @@ pti->nCntsQBits[QSRosPostMessage] = 0; pti->nCntsQBits[QSRosSendMessage] = 0; pti->nCntsQBits[QSRosHotKey] = 0; - -} - + pti->nCntsQBits[QSRosEvent] = 0; +} + VOID FASTCALL MsqCleanupMessageQueue(PTHREADINFO pti) { PUSER_MESSAGE_QUEUE MessageQueue; MessageQueue = pti->MessageQueue; - MessageQueue->cThreads--; + MessageQueue->cThreads--; if (MessageQueue->cThreads) { @@ -2033,6 +2039,7 @@ IntGetSysCursorInfo()->CurrentCursorObject = NULL; } + ERR("DereferenceObject pCursor\n"); UserDereferenceObject(pCursor); } Modified: trunk/reactos/win32ss/user/ntuser/msgqueue.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/msgque…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/msgqueue.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/msgqueue.h [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -42,7 +42,6 @@ /* Reference counter, only access this variable with interlocked functions! */ LONG References; - PTHREADINFO ptiOwner; // temp.. /* Desktop that the message queue is attached to */ struct _DESKTOP *Desktop; Modified: trunk/reactos/win32ss/user/ntuser/object.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/object…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/object.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/object.c [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -548,6 +548,13 @@ #endif } + +HANDLE FASTCALL ValidateHandleNoErr(HANDLE handle, HANDLE_TYPE type) +{ + if (handle) return (PWND)UserGetObjectNoErr(gHandleTable, handle, type); + return NULL; +} + /* * NtUserValidateHandleSecure * Modified: trunk/reactos/win32ss/user/ntuser/object.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/object…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/object.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/object.h [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -18,6 +18,7 @@ BOOL FASTCALL UserObjectInDestroy(HANDLE); void DbgUserDumpHandleTable(); VOID FASTCALL UserSetObjectOwner(PVOID obj, HANDLE_TYPE type, PVOID owner); +HANDLE FASTCALL ValidateHandleNoErr(HANDLE handle, HANDLE_TYPE type); static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry) Modified: trunk/reactos/win32ss/user/ntuser/window.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/window…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/window.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/window.c [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -123,7 +123,12 @@ styleNew = (pwnd->style | set_bits) & ~clear_bits; if (styleNew == styleOld) return styleNew; pwnd->style = styleNew; - if ((styleOld ^ styleNew) & WS_VISIBLE) DceResetActiveDCEs( pwnd ); + if ((styleOld ^ styleNew) & WS_VISIBLE) // State Change. + { + if (styleOld & WS_VISIBLE) pwnd->head.pti->cVisWindows--; + if (styleNew & WS_VISIBLE) pwnd->head.pti->cVisWindows++; + DceResetActiveDCEs( pwnd ); + } return styleOld; } @@ -159,21 +164,16 @@ BOOL FASTCALL IntIsWindowVisible(PWND Wnd) { - BOOL Ret = TRUE; - do - { - if (!(Wnd->style & WS_VISIBLE)) - { - Ret = FALSE; - break; - } - if (Wnd->spwndParent != NULL) - Wnd = Wnd->spwndParent; - else - break; - } - while (Wnd != NULL); - return Ret; + PWND Temp = Wnd; + for (;;) + { + if (!Temp) return TRUE; + if (!(Temp->style & WS_VISIBLE)) break; + if (Temp->style & WS_MINIMIZE && Temp != Wnd) break; + if (Temp->fnid == FNID_DESKTOP) return TRUE; + Temp = Temp->spwndParent; + } + return FALSE; } PWND FASTCALL @@ -436,6 +436,7 @@ } Window->state2 |= WNDS2_INDESTROY; Window->style &= ~WS_VISIBLE; + Window->head.pti->cVisWindows--; IntNotifyWinEvent(EVENT_OBJECT_DESTROY, Window, OBJID_WINDOW, CHILDID_SELF, 0); @@ -497,9 +498,6 @@ /* flush the message queue */ MsqRemoveWindowMessagesFromQueue(Window); - NT_ASSERT(Window->head.pti); - IntDereferenceMessageQueue(Window->head.pti->MessageQueue); - /* from now on no messages can be sent to this window anymore */ Window->state |= WNDS_DESTROYED; Window->fnid |= FNID_FREED; @@ -578,6 +576,7 @@ GreDeleteObject(Window->hrgnClip); Window->hrgnClip = NULL; } + Window->head.pti->cWindows--; // ASSERT(Window != NULL); UserFreeWindowInfo(Window->head.pti, Window); @@ -1098,8 +1097,8 @@ Wnd->head.pti == WndNewOwner->head.pti || WndOldOwner->head.pti != WndNewOwner->head.pti ) { - ERR("ProcessOwnerSwap Old out.\n"); - //UserAttachThreadInput(Wnd->head.pti, WndOldOwner->head.pti, FALSE); + //ERR("ProcessOwnerSwap Old out.\n"); + UserAttachThreadInput(Wnd->head.pti, WndOldOwner->head.pti, FALSE); } } } @@ -1110,8 +1109,8 @@ if (!WndOldOwner || WndOldOwner->head.pti != WndNewOwner->head.pti ) { - ERR("ProcessOwnerSwap New in.\n"); - //UserAttachThreadInput(Wnd->head.pti, WndNewOwner->head.pti, TRUE); + //ERR("ProcessOwnerSwap New in.\n"); + UserAttachThreadInput(Wnd->head.pti, WndNewOwner->head.pti, TRUE); } } } @@ -1140,6 +1139,8 @@ goto Error; } + /* if parent belongs to a different thread and the window isn't */ + /* top-level, attach the two threads */ IntProcessOwnerSwap(Wnd, WndNewOwner, WndOldOwner); if (IntValidateOwnerDepth(Wnd, WndNewOwner)) @@ -1186,6 +1187,7 @@ /* Some applications try to set a child as a parent */ if (IntIsChildWindow(Wnd, WndNewParent)) { + TRACE("IntSetParent try to set a child as a parent.\n"); EngSetLastError( ERROR_INVALID_PARAMETER ); return NULL; } @@ -1196,6 +1198,7 @@ { if (Wnd == pWndExam) { + TRACE("IntSetParent Failed Test for set parent to parent!\n"); EngSetLastError(ERROR_INVALID_PARAMETER); return NULL; } @@ -1210,7 +1213,10 @@ /* Window must belong to current process */ if (Wnd->head.pti->ppi != PsGetCurrentProcessWin32Process()) + { + ERR("IntSetParent Window must belong to current process!\n"); return NULL; + } WndOldParent = Wnd->spwndParent; @@ -1249,22 +1255,31 @@ } + if ( WndNewParent == co_GetDesktopWindow(Wnd) && + !(Wnd->style & WS_CLIPSIBLINGS) ) + { + Wnd->style |= WS_CLIPSIBLINGS; + DceResetActiveDCEs(Wnd); + } + + /* if parent belongs to a different thread and the window isn't */ + /* top-level, attach the two threads */ if ((Wnd->style & (WS_CHILD|WS_POPUP)) == WS_CHILD) { if ( Wnd->spwndParent != co_GetDesktopWindow(Wnd)) { if (Wnd->head.pti != WndOldParent->head.pti) { - ERR("SetParent Old out.\n"); - //UserAttachThreadInput(Wnd->head.pti, WndOldParent->head.pti, FALSE); + //ERR("SetParent Old out.\n"); + UserAttachThreadInput(Wnd->head.pti, WndOldParent->head.pti, FALSE); } } if ( WndNewParent != co_GetDesktopWindow(Wnd)) { if (Wnd->head.pti != WndNewParent->head.pti) { - ERR("SetParent New in.\n"); - //UserAttachThreadInput(Wnd->head.pti, WndNewParent->head.pti, TRUE); + //ERR("SetParent New in.\n"); + UserAttachThreadInput(Wnd->head.pti, WndNewParent->head.pti, TRUE); } } } @@ -1278,10 +1293,11 @@ * in the z-order and send the expected WM_WINDOWPOSCHANGING and * WM_WINDOWPOSCHANGED notification messages. */ + //ERR("IntSetParent SetWindowPos 1\n"); co_WinPosSetWindowPos( Wnd, (0 == (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOP : HWND_TOPMOST), pt.x, pt.y, 0, 0, swFlags); - + //ERR("IntSetParent SetWindowPos 2\n"); if (WasVisible) co_WinPosShowWindow(Wnd, SW_SHOWNORMAL); return WndOldParent; @@ -1302,6 +1318,7 @@ if (hWndChild == IntGetDesktopWindow()) { + ERR("UserSetParent Access Denied!\n"); EngSetLastError(ERROR_ACCESS_DENIED); return( NULL); } @@ -1310,6 +1327,7 @@ { if (!(WndParent = UserGetWindowObject(hWndNewParent))) { + ERR("UserSetParent Bad New Parent!\n"); return( NULL); } } @@ -1323,6 +1341,7 @@ if (!(Wnd = UserGetWindowObject(hWndChild))) { + ERR("UserSetParent Bad Child!\n"); return( NULL); } @@ -1762,12 +1781,13 @@ pWnd->InternalPos.MaxPos.x = pWnd->InternalPos.MaxPos.y = -1; pWnd->InternalPos.IconPos.x = pWnd->InternalPos.IconPos.y = -1; - IntReferenceMessageQueue(pWnd->head.pti->MessageQueue); if (pWnd->spwndParent != NULL && Cs->hwndParent != 0) { pWnd->HideFocus = pWnd->spwndParent->HideFocus; pWnd->HideAccel = pWnd->spwndParent->HideAccel; } + + pWnd->head.pti->cWindows++; if (Class->hIcon && !Class->hIconSm) { @@ -1962,8 +1982,8 @@ Class->atomClassName != gpsi->atomSysClass[ICLS_IME] && pti != pWnd->spwndOwner->head.pti) { - ERR("CreateWindow Owner in.\n"); - //UserAttachThreadInput(pti, pWnd->spwndOwner->head.pti, TRUE); + //ERR("CreateWindow Owner in.\n"); + UserAttachThreadInput(pti, pWnd->spwndOwner->head.pti, TRUE); } } @@ -2203,6 +2223,15 @@ Cs->lpszName = (LPCWSTR) WindowName; Cs->lpszClass = (LPCWSTR) ClassName; + if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD) + { + if (ParentWindow != co_GetDesktopWindow(Window)) + { + Cs->x += ParentWindow->rcClient.left; + Cs->y += ParentWindow->rcClient.top; + } + } + /* Send the WM_GETMINMAXINFO message */ Size.cx = Cs->cx; Size.cy = Cs->cy; @@ -2220,6 +2249,7 @@ Window->rcWindow.top = Cs->y; Window->rcWindow.right = Cs->x + Size.cx; Window->rcWindow.bottom = Cs->y + Size.cy; +/* if (0 != (Window->style & WS_CHILD) && ParentWindow) { // ERR("co_UserCreateWindowEx(): Offset rcWindow\n"); @@ -2227,6 +2257,7 @@ ParentWindow->rcClient.left, ParentWindow->rcClient.top); } +*/ Window->rcClient = Window->rcWindow; /* Link the window */ @@ -2239,8 +2270,7 @@ IntLinkHwnd(Window, hwndInsertAfter); } - // Remove flags that are retro. - if (!(Window->state2 & WNDS2_WIN31COMPAT)) // FIXME: support version flags. + if (!(Window->state2 & WNDS2_WIN31COMPAT)) { if (Class->style & CS_PARENTDC && !(ParentWindow->style & WS_CLIPCHILDREN)) Window->style &= ~(WS_CLIPSIBLINGS | WS_CLIPCHILDREN); @@ -2252,8 +2282,8 @@ { if (pti != Window->spwndParent->head.pti) { - ERR("CreateWindow Parent in.\n"); - //UserAttachThreadInput(pti, Window->spwndParent->head.pti, TRUE); + //ERR("CreateWindow Parent in.\n"); + UserAttachThreadInput(pti, Window->spwndParent->head.pti, TRUE); } } } @@ -2267,14 +2297,19 @@ } /* Send the WM_NCCALCSIZE message */ + { + // RECT rc; MaxPos.x = Window->rcWindow.left; MaxPos.y = Window->rcWindow.top; Result = co_WinPosGetNonClientSize(Window, &Window->rcWindow, &Window->rcClient); + //rc = Window->rcWindow; + //Result = co_IntSendMessageNoWait(Window->head.h, WM_NCCALCSIZE, FALSE, (LPARAM)&rc); + //Window->rcClient = rc; RECTL_vOffsetRect(&Window->rcWindow, MaxPos.x - Window->rcWindow.left, MaxPos.y - Window->rcWindow.top); - + } /* Send the WM_CREATE message. */ Result = co_IntSendMessage(UserHMGetHandle(Window), WM_CREATE, 0, (LPARAM) Cs); @@ -2593,8 +2628,8 @@ { if (Window->spwndOwner) { - ERR("DestroyWindow Owner out.\n"); - //UserAttachThreadInput(Window->head.pti, Window->spwndOwner->head.pti, FALSE); + //ERR("DestroyWindow Owner out.\n"); + UserAttachThreadInput(Window->head.pti, Window->spwndOwner->head.pti, FALSE); } } } @@ -2632,8 +2667,8 @@ { if (!IntIsTopLevelWindow(Window)) { - ERR("DestroyWindow Parent out.\n"); - //UserAttachThreadInput(Window->head.pti, Window->spwndParent->head.pti, FALSE); + //ERR("DestroyWindow Parent out.\n"); + UserAttachThreadInput(Window->head.pti, Window->spwndParent->head.pti, FALSE); } } } @@ -3377,8 +3412,11 @@ if (ti->pDeskInfo) { ti->pDeskInfo->hShellWindow = hwndShell; + ti->pDeskInfo->spwndShell = WndShell; ti->pDeskInfo->ppiShellProcess = ti->ppi; } + + UserRegisterHotKey(WndShell, SC_TASKLIST, MOD_CONTROL, VK_ESCAPE); UserDerefObjectCo(WndShell); @@ -3579,6 +3617,12 @@ else Window->ExStyle &= ~WS_EX_WINDOWEDGE; + if ((Style.styleOld ^ Style.styleNew) & WS_VISIBLE) + { + if (Style.styleOld & WS_VISIBLE) Window->head.pti->cVisWindows--; + if (Style.styleNew & WS_VISIBLE) Window->head.pti->cVisWindows++; + DceResetActiveDCEs( Window ); + } Window->style = (DWORD)Style.styleNew; co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_STYLE, (LPARAM) &Style); break; Modified: trunk/reactos/win32ss/user/ntuser/winpos.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/winpos…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/winpos.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/winpos.c [iso-8859-1] Sun Oct 20 05:16:52 2013 @@ -237,6 +237,7 @@ if (!(pWndSetActive->ExStyle & WS_EX_TOOLWINDOW) ) { UserRefObjectCo(pWndSetActive, &Ref); + //ERR("ActivateOtherWindowMin Set FG 1\n"); co_IntSetForegroundWindow(pWndSetActive); UserDerefObjectCo(pWndSetActive); //ERR("AOWM 2 Exit Good\n"); @@ -273,6 +274,7 @@ if ((pWndSetActive = pWndTemp)) { UserRefObjectCo(pWndSetActive, &Ref); + //ERR("ActivateOtherWindowMin Set FG 2\n"); co_IntSetForegroundWindow(pWndSetActive); UserDerefObjectCo(pWndSetActive); //ERR("AOWM 3 Exit Good\n"); @@ -299,7 +301,7 @@ if (style & WS_MINIMIZE) return FALSE; if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE; return TRUE; - /* FIXME: This window could be disable because the child that closed + /* FIXME: This window could be disable because the child that closed was a popup. */ //return !(style & WS_DISABLED); } @@ -314,7 +316,6 @@ co_WinPosActivateOtherWindow(PWND Wnd) { PWND WndTo = NULL; - HWND Fg, previous; USER_REFERENCE_ENTRY Ref; ASSERT_REFS_CO(Wnd); @@ -345,25 +346,23 @@ if (WndTo) UserRefObjectCo(WndTo, &Ref); - Fg = UserGetForegroundWindow(); - if ((!Fg || Wnd->head.h == Fg) && WndTo) // FIXME: Ok if WndTo is NULL?? No, rule #4. - { - /* FIXME: Wine can pass WndTo = NULL to co_IntSetForegroundWindow. Hmm... */ + if (!gpqForeground || Wnd == gpqForeground->spwndActive) + { + /* ReactOS can pass WndTo = NULL to co_IntSetForegroundWindow and returns FALSE. */ + //ERR("WinPosActivateOtherWindow Set FG 0x%p\n",WndTo); if (co_IntSetForegroundWindow(WndTo)) { - UserDerefObjectCo(WndTo); + if (WndTo) UserDerefObjectCo(WndTo); return; } } - - if (!co_IntSetActiveWindow(WndTo,&previous,FALSE,TRUE,FALSE) || /* Ok for WndTo to be NULL here */ - !previous) - { - co_IntSetActiveWindow(0,NULL,FALSE,TRUE,FALSE); + //ERR("WinPosActivateOtherWindow Set Active 0x%p\n",WndTo); + if (!co_IntSetActiveWindow(WndTo,FALSE,TRUE,FALSE)) /* Ok for WndTo to be NULL here */ + { + co_IntSetActiveWindow(0,FALSE,TRUE,FALSE); } if (WndTo) UserDerefObjectCo(WndTo); } - UINT FASTCALL @@ -1131,11 +1130,71 @@ ClientRect->bottom = WindowRect->bottom; } } +/*********************************************************************** + * get_valid_rects + * + * Compute the valid rects from the old and new client rect and WVR_* flags. + * Helper for WM_NCCALCSIZE handling. + */ +static +VOID FASTCALL +get_valid_rects( RECTL *old_client, RECTL *new_client, UINT flags, RECTL *valid ) +{ + int cx, cy; + + if (flags & WVR_REDRAW) + { + RECTL_vSetEmptyRect( &valid[0] ); + RECTL_vSetEmptyRect( &valid[1] ); + return; + } + + if (flags & WVR_VALIDRECTS) + { + if (!RECTL_bIntersectRect( &valid[0], &valid[0], new_client ) || + !RECTL_bIntersectRect( &valid[1], &valid[1], old_client )) + { + RECTL_vSetEmptyRect( &valid[0] ); + RECTL_vSetEmptyRect( &valid[1] ); + return; + } + flags = WVR_ALIGNLEFT | WVR_ALIGNTOP; + } + else + { + valid[0] = *new_client; + valid[1] = *old_client; + } + + /* make sure the rectangles have the same size */ + cx = min( valid[0].right - valid[0].left, valid[1].right - valid[1].left ); + cy = min( valid[0].bottom - valid[0].top, valid[1].bottom - valid[1].top ); + + if (flags & WVR_ALIGNBOTTOM) + { + valid[0].top = valid[0].bottom - cy; + valid[1].top = valid[1].bottom - cy; + } + else + { + valid[0].bottom = valid[0].top + cy; + valid[1].bottom = valid[1].top + cy; + } + if (flags & WVR_ALIGNRIGHT) + { + valid[0].left = valid[0].right - cx; + valid[1].left = valid[1].right - cx; + } + else + { + valid[0].right = valid[0].left + cx; + valid[1].right = valid[1].left + cx; + } +} static LONG FASTCALL -co_WinPosDoNCCALCSize(PWND Window, PWINDOWPOS WinPos, - RECT* WindowRect, RECT* ClientRect) +co_WinPosDoNCCALCSize(PWND Window, PWINDOWPOS WinPos, RECTL* WindowRect, RECTL* ClientRect, RECTL* validRects) { PWND Parent; UINT wvrFlags = 0; @@ -1148,9 +1207,10 @@ NCCALCSIZE_PARAMS params; WINDOWPOS winposCopy; - params.rgrc[0] = *WindowRect; - params.rgrc[1] = Window->rcWindow; - params.rgrc[2] = Window->rcClient; + params.rgrc[0] = *WindowRect; // new coordinates of a window that has been moved or resized + params.rgrc[1] = Window->rcWindow; // window before it was moved or resized + params.rgrc[2] = Window->rcClient; // client area before the window was moved or resized + Parent = Window->spwndParent; if (0 != (Window->style & WS_CHILD) && Parent) { @@ -1161,6 +1221,7 @@ RECTL_vOffsetRect(&(params.rgrc[2]), - Parent->rcClient.left, - Parent->rcClient.top); } + params.lppos = &winposCopy; winposCopy = *WinPos; @@ -1170,7 +1231,7 @@ if (params.rgrc[0].left <= params.rgrc[0].right && params.rgrc[0].top <= params.rgrc[0].bottom) { - *ClientRect = params.rgrc[0]; + *ClientRect = params.rgrc[0]; // First rectangle contains the coordinates of the new client rectangle resulting from the move or resize if ((Window->style & WS_CHILD) && Parent) { RECTL_vOffsetRect(ClientRect, Parent->rcClient.left, @@ -1179,21 +1240,30 @@ FixClientRect(ClientRect, WindowRect); } - /* FIXME: WVR_ALIGNxxx */ - if (ClientRect->left != Window->rcClient.left || ClientRect->top != Window->rcClient.top) { WinPos->flags &= ~SWP_NOCLIENTMOVE; } - if ((ClientRect->right - ClientRect->left != - Window->rcClient.right - Window->rcClient.left) || - (ClientRect->bottom - ClientRect->top != - Window->rcClient.bottom - Window->rcClient.top)) + if (ClientRect->right - ClientRect->left != + Window->rcClient.right - Window->rcClient.left) { WinPos->flags &= ~SWP_NOCLIENTSIZE; } + else + wvrFlags &= ~WVR_HREDRAW; + + if (ClientRect->bottom - ClientRect->top != + Window->rcClient.bottom - Window->rcClient.top) + { + WinPos->flags &= ~SWP_NOCLIENTSIZE; + } + else + wvrFlags &= ~WVR_VREDRAW; + + validRects[0] = params.rgrc[1]; // second rectangle contains the valid destination rectangle + validRects[1] = params.rgrc[2]; // third rectangle contains the valid source rectangle } else { @@ -1204,6 +1274,13 @@ WinPos->flags &= ~SWP_NOCLIENTMOVE; } } + + if (WinPos->flags & (SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_SHOWWINDOW | SWP_HIDEWINDOW)) + { + RECTL_vSetEmptyRect( &validRects[0] ); + RECTL_vSetEmptyRect( &validRects[1] ); + } + else get_valid_rects( &Window->rcClient, ClientRect, wvrFlags, validRects ); return wvrFlags; } @@ -1215,13 +1292,44 @@ PRECTL WindowRect, PRECTL ClientRect) { - INT X, Y; - ASSERT_REFS_CO(Window); + /* Send WM_WINDOWPOSCHANGING message */ + if (!(WinPos->flags & SWP_NOSENDCHANGING)) { co_IntSendMessageNoWait(Window->head.h, WM_WINDOWPOSCHANGING, 0, (LPARAM) WinPos); + } + + /* Calculate new position and size */ + + *WindowRect = Window->rcWindow; + *ClientRect = (Window->style & WS_MINIMIZE) ? Window->rcWindow : Window->rcClient; + + if (!(WinPos->flags & SWP_NOSIZE)) + { + if (Window->style & WS_MINIMIZE) + { + WindowRect->right = WindowRect->left + UserGetSystemMetrics(SM_CXICON); + WindowRect->bottom = WindowRect->top + UserGetSystemMetrics(SM_CYICON); + } + else + { + WindowRect->right = WindowRect->left + WinPos->cx; + WindowRect->bottom = WindowRect->top + WinPos->cy; + } + } +#if 0 + if (!(WinPos->flags & SWP_NOMOVE)) + { + WindowRect->left = WinPos->x; + WindowRect->top = WinPos->y; + WindowRect->right += WinPos->x - Window->rcWindow.left; + WindowRect->bottom += WinPos->y - Window->rcWindow.top; + RECTL_vOffsetRect(ClientRect, + WinPos->x - Window->rcWindow.left, + WinPos->y - Window->rcWindow.top); + } *WindowRect = Window->rcWindow; @@ -1232,22 +1340,26 @@ WindowRect->right = WindowRect->left + WinPos->cx; WindowRect->bottom = WindowRect->top + WinPos->cy; } - +#endif if (!(WinPos->flags & SWP_NOMOVE)) { + INT X, Y; PWND Parent; X = WinPos->x; Y = WinPos->y; + //ERR("Not SWP_NOMOVE\n"); Parent = Window->spwndParent; - if ((0 != (Window->style & WS_CHILD)) && Parent) - { + if ((0 != (Window->style & WS_CHILD)) && Parent && + Parent != Window->head.rpdesk->pDeskInfo->spwnd) + { + //ERR("Not SWP_NOMOVE Parent client offset\n"); X += Parent->rcClient.left; Y += Parent->rcClient.top; } - WindowRect->left = X; - WindowRect->top = Y; - WindowRect->right += X - Window->rcWindow.left; + WindowRect->left = X; + WindowRect->top = Y; + WindowRect->right += X - Window->rcWindow.left; WindowRect->bottom += Y - Window->rcWindow.top; RECTL_vOffsetRect(ClientRect, X - Window->rcWindow.left, @@ -1255,6 +1367,10 @@ } WinPos->flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE; + + TRACE( "hwnd %p, after %p, swp %d,%d %dx%d flags %08x\n", + WinPos->hwnd, WinPos->hwndInsertAfter, WinPos->x, WinPos->y, + WinPos->cx, WinPos->cy, WinPos->flags ); return TRUE; } @@ -1396,6 +1512,21 @@ BOOL FASTCALL WinPosFixupFlags(WINDOWPOS *WinPos, PWND Wnd) { + PWND Parent; + POINT pt; + + /* Finally make sure that all coordinates are valid */ + if (WinPos->x < -32768) WinPos->x = -32768; + else if (WinPos->x > 32767) WinPos->x = 32767; + if (WinPos->y < -32768) WinPos->y = -32768; + else if (WinPos->y > 32767) WinPos->y = 32767; + + WinPos->cx = max(WinPos->cx, 0); + WinPos->cy = max(WinPos->cy, 0); + + Parent = UserGetAncestor( Wnd, GA_PARENT ); + if (!IntIsWindowVisible( Parent )) WinPos->flags |= SWP_NOREDRAW; + if (Wnd->style & WS_VISIBLE) { WinPos->flags &= ~SWP_SHOWWINDOW; @@ -1407,9 +1538,6 @@ WinPos->flags |= SWP_NOREDRAW; } - WinPos->cx = max(WinPos->cx, 0); - WinPos->cy = max(WinPos->cy, 0); - /* Check for right size */ if (Wnd->rcWindow.right - Wnd->rcWindow.left == WinPos->cx && Wnd->rcWindow.bottom - Wnd->rcWindow.top == WinPos->cy) @@ -1417,10 +1545,15 @@ WinPos->flags |= SWP_NOSIZE; } + pt.x = WinPos->x; + pt.y = WinPos->y; + IntClientToScreen( Parent, &pt ); +// ERR("WPFU C2S wpx %d wpy %d ptx %d pty %d\n",WinPos->x,WinPos->y,pt.x,pt.y); /* Check for right position */ - if (Wnd->rcWindow.left == WinPos->x && - Wnd->rcWindow.top == WinPos->y) - { + if (Wnd->rcWindow.left == pt.x && + Wnd->rcWindow.top == pt.y) + { +// ERR("In right pos\n"); WinPos->flags |= SWP_NOMOVE; } @@ -1526,6 +1659,7 @@ WINDOWPOS WinPos; RECTL NewWindowRect; RECTL NewClientRect; + RECTL valid_rects[2]; PROSRGNDATA VisRgn; HRGN VisBefore = NULL; HRGN VisAfter = NULL; @@ -1543,7 +1677,7 @@ ASSERT_REFS_CO(Window); - /* FIXME: Get current active window from active queue. */ + /* FIXME: Get current active window from active queue. Why? since r2915. */ bPointerInWindow = IntPtInWindow(Window, gpsi->ptCursor.x, gpsi->ptCursor.y); @@ -1555,6 +1689,27 @@ WinPos.cy = cy; WinPos.flags = flags; + if ( flags & SWP_ASYNCWINDOWPOS ) + { + LRESULT lRes; + PWINDOWPOS ppos = ExAllocatePoolWithTag(PagedPool, sizeof(WINDOWPOS), USERTAG_SWP); + if ( ppos ) + { + WinPos.flags &= ~SWP_ASYNCWINDOWPOS; // Clear flag. + *ppos = WinPos; + /* Yes it's a pointer inside Win32k! */ + lRes = co_IntSendMessageNoWait( WinPos.hwnd, WM_ASYNC_SETWINDOWPOS, 0, (LPARAM)ppos); + /* We handle this the same way as Event Hooks and Hooks. */ + if ( !lRes ) + { + ExFreePoolWithTag(ppos, USERTAG_SWP); + return FALSE; + } + return TRUE; + } + return FALSE; + } + co_WinPosDoWinPosChanging(Window, &WinPos, &NewWindowRect, &NewClientRect); // HWND_NOTOPMOST is redirected in WinPosFixupFlags. @@ -1610,9 +1765,11 @@ } } - WvrFlags = co_WinPosDoNCCALCSize(Window, &WinPos, &NewWindowRect, &NewClientRect); - - TRACE("co_WinPosDoNCCALCSize returned %lu\n", WvrFlags); + WvrFlags = co_WinPosDoNCCALCSize(Window, &WinPos, &NewWindowRect, &NewClientRect, valid_rects); + +// ERR("co_WinPosDoNCCALCSize returned 0x%x\n valid dest: %d %d %d %d\n valid src : %d %d %d %d\n", WvrFlags, +// valid_rects[0].left,valid_rects[0].top,valid_rects[0].right,valid_rects[0].bottom, +// valid_rects[1].left,valid_rects[1].top,valid_rects[1].right,valid_rects[1].bottom); /* Validate link windows. (also take into account shell window in hwndShellWindow) */ if (!(WinPos.flags & SWP_NOZORDER) && WinPos.hwnd != UserGetShellWindow()) @@ -1624,6 +1781,7 @@ if ((ParentWindow = Window->spwndParent)) // Must have a Parent window! { + //ERR("SetWindowPos has parent window.\n"); if (WinPos.hwndInsertAfter == HWND_TOPMOST) { InsertAfterWindow = NULL; @@ -1682,20 +1840,8 @@ OldWindowRect = Window->rcWindow; OldClientRect = Window->rcClient; - - if (OldClientRect.bottom - OldClientRect.top == - NewClientRect.bottom - NewClientRect.top) - { - WvrFlags &= ~WVR_VREDRAW; - } - - if (OldClientRect.right - OldClientRect.left == - NewClientRect.right - NewClientRect.left) - { - WvrFlags &= ~WVR_HREDRAW; - } - - /* FIXME: Actually do something with WVR_VALIDRECTS */ + //ERR("SetWindowPos OldWindowRect: %d %d %d %d\n", OldWindowRect.left,OldWindowRect.top,OldWindowRect.right,OldWindowRect.bottom); + //ERR("SetWindowPos OldClientRect: %d %d %d %d\n", OldClientRect.left,OldClientRect.top,OldClientRect.right,OldClientRect.bottom); if (NewClientRect.left != OldClientRect.left || NewClientRect.top != OldClientRect.top) @@ -1707,6 +1853,9 @@ Window->rcWindow = NewWindowRect; Window->rcClient = NewClientRect; + + //ERR("SetWindowPos NewWindowRect: %d %d %d %d\n", NewWindowRect.left,NewWindowRect.top,NewWindowRect.right,NewWindowRect.bottom); + //ERR("SetWindowPos NewClientRect: %d %d %d %d\n", NewClientRect.left,NewClientRect.top,NewClientRect.right,NewClientRect.bottom); /* erase parent when hiding or resizing child */ if (WinPos.flags & SWP_HIDEWINDOW) @@ -1721,6 +1870,7 @@ co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (WPARAM)Window->head.h, 0); Window->style &= ~WS_VISIBLE; //IntSetStyle( Window, 0, WS_VISIBLE ); + Window->head.pti->cVisWindows--; IntNotifyWinEvent(EVENT_OBJECT_HIDE, Window, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); } else if (WinPos.flags & SWP_SHOWWINDOW) @@ -1729,6 +1879,7 @@ co_IntShellHookNotify(HSHELL_WINDOWCREATED, (WPARAM)Window->head.h, 0); Window->style |= WS_VISIBLE; //IntSetStyle( Window, WS_VISIBLE, 0 ); + Window->head.pti->cVisWindows++; IntNotifyWinEvent(EVENT_OBJECT_SHOW, Window, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); } @@ -1955,7 +2106,10 @@ else { //ERR("SetWindowPos Set FG Window!\n"); - co_IntSetForegroundWindow(Window); + if (Window->state & WNDS_BEINGACTIVATED) // Inside SAW? + co_IntSetActiveWindow(Window, FALSE, TRUE, FALSE); // Fixes Api AttachThreadInput tests. + else + co_IntSetForegroundWindow(Window); // Fixes SW_HIDE issues. Wine win test_SetActiveWindow & test_SetForegroundWindow. } } @@ -2036,7 +2190,7 @@ co_IntSendMessageNoWait(UserHMGetHandle(Wnd), WM_SIZE, wParam, lParam); - if (Wnd->spwndParent == UserGetDesktopWindow()) // Wnd->spwndParent->fnid != FNID_DESKTOP ) + if (Wnd->spwndParent == UserGetDesktopWindow()) // Wnd->spwndParent->fnid == FNID_DESKTOP ) lParam = MAKELONG(Wnd->rcClient.left, Wnd->rcClient.top); else lParam = MAKELONG(Wnd->rcClient.left-Wnd->spwndParent->rcClient.left, Wnd->rcClient.top-Wnd->spwndParent->rcClient.top); @@ -2056,9 +2210,9 @@ LONG style; PWND Parent; PTHREADINFO pti; - // BOOL ShowOwned = FALSE; // HRGN VisibleRgn; - + //ERR("co_WinPosShowWindow START\n"); + BOOL ShowOwned = FALSE; ASSERT_REFS_CO(Wnd); pti = PsGetCurrentThreadWin32Thread(); @@ -2071,6 +2225,7 @@ { if (!WasVisible) { + //ERR("co_WinPosShowWindow Exit Bad\n"); return(FALSE); } Swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE; @@ -2091,11 +2246,12 @@ Swp |= SWP_NOACTIVATE; if (!(style & WS_MINIMIZE)) { - //IntShowOwnedPopups(Wnd, FALSE ); + IntShowOwnedPopups(Wnd, FALSE ); // Fix wine Win test_SetFocus todo #1 & #2, if (Cmd == SW_SHOWMINIMIZED) { + //ERR("co_WinPosShowWindow Set focus 1\n"); if ((style & (WS_CHILD | WS_POPUP)) == WS_CHILD) co_UserSetFocus(Wnd->spwndParent); else @@ -2114,7 +2270,10 @@ Swp |= SWP_FRAMECHANGED; } else //// + { + //ERR("co_WinPosShowWindow Exit Good\n"); return TRUE; + } Swp |= SWP_NOSIZE | SWP_NOMOVE; } break; @@ -2125,7 +2284,7 @@ Swp |= SWP_SHOWWINDOW; if (!(style & WS_MAXIMIZE)) { - //ShowOwned = TRUE; + ShowOwned = TRUE; Swp |= co_WinPosMinMaximize(Wnd, SW_MAXIMIZE, &NewPos) | SWP_FRAMECHANGED; @@ -2139,7 +2298,10 @@ Swp |= SWP_FRAMECHANGED; } else //// + { + //ERR("co_WinPosShowWindow Exit Good 1\n"); return TRUE; + } Swp |= SWP_NOSIZE | SWP_NOMOVE; } break; @@ -2177,7 +2339,10 @@ Swp |= SWP_FRAMECHANGED; } else //// + { + //ERR("co_WinPosShowWindow Exit Good 3\n"); return TRUE; + } Swp |= SWP_NOSIZE | SWP_NOMOVE; } if ( style & WS_CHILD && @@ -2187,6 +2352,7 @@ break; default: + //ERR("co_WinPosShowWindow Exit Good 4\n"); return WasVisible; } @@ -2214,7 +2380,8 @@ Wnd->pcls->style & CS_SAVEBITS && ((Cmd == SW_SHOW) || (Cmd == SW_NORMAL))) { - co_IntSetActiveWindow(Wnd,NULL,FALSE,TRUE,FALSE); + ERR("WinPosShowWindow Set active\n"); + UserSetActiveWindow(Wnd); Swp |= SWP_NOACTIVATE | SWP_NOZORDER; } #endif @@ -2242,7 +2409,7 @@ if ( EventMsg ) IntNotifyWinEvent(EventMsg, Wnd, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); - //if ( ShowOwned ) IntShowOwnedPopups(Wnd, TRUE ); + if ( ShowOwned ) IntShowOwnedPopups(Wnd, TRUE ); if ((Cmd == SW_HIDE) || (Cmd == SW_MINIMIZE)) { @@ -2281,6 +2448,7 @@ // Fix wine Win test_SetFocus todo #3, if (!(style & WS_CHILD)) co_IntSendMessageNoWait(UserHMGetHandle(Wnd), WM_ACTIVATE, WA_ACTIVE, 0); } + //ERR("co_WinPosShowWindow EXIT\n"); return(WasVisible); }
11 years, 2 months
1
0
0
0
[aandrejevic] 60717: [FAST486] Create a macro SWAP (swaps two variables) to shorten the code. Implement the BSWAP instruction.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Sun Oct 20 00:55:31 2013 New Revision: 60717 URL:
http://svn.reactos.org/svn/reactos?rev=60717&view=rev
Log: [FAST486] Create a macro SWAP (swaps two variables) to shorten the code. Implement the BSWAP instruction. Modified: branches/ntvdm/lib/fast486/common.h branches/ntvdm/lib/fast486/extraops.c branches/ntvdm/lib/fast486/extraops.h branches/ntvdm/lib/fast486/opcodes.c Modified: branches/ntvdm/lib/fast486/common.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/common.h?rev=…
============================================================================== --- branches/ntvdm/lib/fast486/common.h [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/common.h [iso-8859-1] Sun Oct 20 00:55:31 2013 @@ -54,6 +54,7 @@ {\ x = !x;\ } +#define SWAP(x, y) { (x) ^= (y); (y) ^= (x); (x) ^= (y); } #define PAGE_ALIGN(x) ((x) & 0xFFFFF000) #define PAGE_OFFSET(x) ((x) & 0x00000FFF) Modified: branches/ntvdm/lib/fast486/extraops.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.c?re…
============================================================================== --- branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] Sun Oct 20 00:55:31 2013 @@ -238,14 +238,14 @@ NULL, // Invalid NULL, // Invalid NULL, // Invalid - NULL, // TODO: OPCODE 0xC8 NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xC9 NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xCA NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xCB NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xCC NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xCD NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xCE NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xCF NOT IMPLEMENTED + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, NULL, // Invalid NULL, // Invalid NULL, // Invalid @@ -1021,6 +1021,23 @@ return Fast486WriteModrmByteOperands(State, &ModRegRm, FALSE, Value); } +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBswap) +{ + PUCHAR Pointer; + + NO_LOCK_PREFIX(); + + /* Get a pointer to the value */ + Pointer = (PUCHAR)&State->GeneralRegs[Opcode & 0x07].Long; + + /* Swap the byte order */ + SWAP(Pointer[0], Pointer[3]); + SWAP(Pointer[1], Pointer[2]); + + /* Return success */ + return TRUE; +} + FAST486_OPCODE_HANDLER(Fast486OpcodeExtended) { UCHAR SecondOpcode; Modified: branches/ntvdm/lib/fast486/extraops.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.h?re…
============================================================================== --- branches/ntvdm/lib/fast486/extraops.h [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.h [iso-8859-1] Sun Oct 20 00:55:31 2013 @@ -35,6 +35,7 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBtc); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeConditionalJmp); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeConditionalSet); +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBswap); FAST486_OPCODE_HANDLER(Fast486OpcodeExtended); #endif // _EXTRAOPS_H_ Modified: branches/ntvdm/lib/fast486/opcodes.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opcodes.c?rev…
============================================================================== --- branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] Sun Oct 20 00:55:31 2013 @@ -2743,9 +2743,7 @@ if (!(Opcode & FAST486_OPCODE_WRITE_REG)) { /* Swap the order */ - FirstValue ^= SecondValue; - SecondValue ^= FirstValue; - FirstValue ^= SecondValue; + SWAP(FirstValue, SecondValue); } /* Calculate the result */ @@ -2806,9 +2804,7 @@ if (!(Opcode & FAST486_OPCODE_WRITE_REG)) { /* Swap the order */ - FirstValue ^= SecondValue; - SecondValue ^= FirstValue; - FirstValue ^= SecondValue; + SWAP(FirstValue, SecondValue); } /* Calculate the result */ @@ -2846,9 +2842,7 @@ if (!(Opcode & FAST486_OPCODE_WRITE_REG)) { /* Swap the order */ - FirstValue ^= SecondValue; - SecondValue ^= FirstValue; - FirstValue ^= SecondValue; + SWAP(FirstValue, SecondValue); } /* Calculate the result */ @@ -3067,9 +3061,7 @@ if (!(Opcode & FAST486_OPCODE_WRITE_REG)) { /* Swap the order */ - FirstValue ^= SecondValue; - SecondValue ^= FirstValue; - FirstValue ^= SecondValue; + SWAP(FirstValue, SecondValue); } /* Calculate the result */ @@ -3138,9 +3130,7 @@ if (!(Opcode & FAST486_OPCODE_WRITE_REG)) { /* Swap the order */ - FirstValue ^= SecondValue; - SecondValue ^= FirstValue; - FirstValue ^= SecondValue; + SWAP(FirstValue, SecondValue); } /* Calculate the result */ @@ -3187,9 +3177,7 @@ if (!(Opcode & FAST486_OPCODE_WRITE_REG)) { /* Swap the order */ - FirstValue ^= SecondValue; - SecondValue ^= FirstValue; - FirstValue ^= SecondValue; + SWAP(FirstValue, SecondValue); } /* Calculate the result */
11 years, 2 months
1
0
0
0
[aandrejevic] 60716: [FAST486] Implement BT, BTS, BTR and BTC.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Sun Oct 20 00:25:41 2013 New Revision: 60716 URL:
http://svn.reactos.org/svn/reactos?rev=60716&view=rev
Log: [FAST486] Implement BT, BTS, BTR and BTC. Modified: branches/ntvdm/lib/fast486/extraops.c branches/ntvdm/lib/fast486/extraops.h Modified: branches/ntvdm/lib/fast486/extraops.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.c?re…
============================================================================== --- branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] Sun Oct 20 00:25:41 2013 @@ -201,7 +201,7 @@ Fast486ExtOpcodePushFs, Fast486ExtOpcodePopFs, NULL, // Invalid - NULL, // TODO: OPCODE 0xA3 NOT IMPLEMENTED + Fast486ExtOpcodeBitTest, NULL, // TODO: OPCODE 0xA4 NOT IMPLEMENTED NULL, // TODO: OPCODE 0xA5 NOT IMPLEMENTED NULL, // Invalid @@ -209,7 +209,7 @@ Fast486ExtOpcodePushGs, Fast486ExtOpcodePopGs, NULL, // TODO: OPCODE 0xAA NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xAB NOT IMPLEMENTED + Fast486ExtOpcodeBts, NULL, // TODO: OPCODE 0xAC NOT IMPLEMENTED NULL, // TODO: OPCODE 0xAD NOT IMPLEMENTED NULL, // TODO: OPCODE 0xAE NOT IMPLEMENTED @@ -217,7 +217,7 @@ Fast486ExtOpcodeCmpXchgByte, Fast486ExtOpcodeCmpXchg, NULL, // TODO: OPCODE 0xB2 NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xB3 NOT IMPLEMENTED + Fast486ExtOpcodeBtr, NULL, // TODO: OPCODE 0xB4 NOT IMPLEMENTED NULL, // TODO: OPCODE 0xB5 NOT IMPLEMENTED NULL, // TODO: OPCODE 0xB6 NOT IMPLEMENTED @@ -225,7 +225,7 @@ NULL, // TODO: OPCODE 0xB8 NOT IMPLEMENTED NULL, // TODO: OPCODE 0xB9 NOT IMPLEMENTED NULL, // TODO: OPCODE 0xBA NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xBB NOT IMPLEMENTED + Fast486ExtOpcodeBtc, NULL, // TODO: OPCODE 0xBC NOT IMPLEMENTED NULL, // TODO: OPCODE 0xBD NOT IMPLEMENTED NULL, // TODO: OPCODE 0xBE NOT IMPLEMENTED @@ -318,6 +318,77 @@ return Fast486LoadSegment(State, FAST486_REG_FS, LOWORD(NewSelector)); } +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBitTest) +{ + BOOLEAN OperandSize, AddressSize; + FAST486_MOD_REG_RM ModRegRm; + UINT DataSize; + ULONG BitNumber; + + OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); + + /* Get the number of bits */ + if (OperandSize) DataSize = 32; + else DataSize = 16; + + /* Get the operands */ + if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) + { + /* Exception occurred */ + return FALSE; + } + + /* Get the bit number */ + BitNumber = OperandSize ? State->GeneralRegs[ModRegRm.Register].Long + : (ULONG)State->GeneralRegs[ModRegRm.Register].LowWord; + + if (ModRegRm.Memory) + { + /* + * For memory operands, add the bit offset divided by + * the data size to the address + */ + ModRegRm.MemoryAddress += BitNumber / DataSize; + } + + /* Normalize the bit number */ + BitNumber &= (1 << DataSize) - 1; + + if (OperandSize) + { + ULONG Dummy, Value; + + /* Read the value */ + if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, &Dummy, &Value)) + { + /* Exception occurred */ + return FALSE; + } + + /* Set CF to the bit value */ + State->Flags.Cf = (Value >> BitNumber) & 1; + } + else + { + USHORT Dummy, Value; + + /* Read the value */ + if (!Fast486ReadModrmWordOperands(State, &ModRegRm, &Dummy, &Value)) + { + /* Exception occurred */ + return FALSE; + } + + /* Set CF to the bit value */ + State->Flags.Cf = (Value >> BitNumber) & 1; + } + + /* Return success */ + return TRUE; +} + FAST486_OPCODE_HANDLER(Fast486ExtOpcodePushGs) { /* Call the internal API */ @@ -336,6 +407,97 @@ /* Call the internal API */ return Fast486LoadSegment(State, FAST486_REG_GS, LOWORD(NewSelector)); +} + +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBts) +{ + BOOLEAN OperandSize, AddressSize; + FAST486_MOD_REG_RM ModRegRm; + UINT DataSize; + ULONG BitNumber; + + OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); + + /* Get the number of bits */ + if (OperandSize) DataSize = 32; + else DataSize = 16; + + /* Get the operands */ + if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) + { + /* Exception occurred */ + return FALSE; + } + + /* Get the bit number */ + BitNumber = OperandSize ? State->GeneralRegs[ModRegRm.Register].Long + : (ULONG)State->GeneralRegs[ModRegRm.Register].LowWord; + + if (ModRegRm.Memory) + { + /* + * For memory operands, add the bit offset divided by + * the data size to the address + */ + ModRegRm.MemoryAddress += BitNumber / DataSize; + } + + /* Normalize the bit number */ + BitNumber &= (1 << DataSize) - 1; + + if (OperandSize) + { + ULONG Dummy, Value; + + /* Read the value */ + if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, &Dummy, &Value)) + { + /* Exception occurred */ + return FALSE; + } + + /* Set CF to the bit value */ + State->Flags.Cf = (Value >> BitNumber) & 1; + + /* Set the bit */ + Value |= 1 << BitNumber; + + /* Write back the result */ + if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Value)) + { + /* Exception occurred */ + return FALSE; + } + } + else + { + USHORT Dummy, Value; + + /* Read the value */ + if (!Fast486ReadModrmWordOperands(State, &ModRegRm, &Dummy, &Value)) + { + /* Exception occurred */ + return FALSE; + } + + /* Set CF to the bit value */ + State->Flags.Cf = (Value >> BitNumber) & 1; + + /* Set the bit */ + Value |= 1 << BitNumber; + + /* Write back the result */ + if (!Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Value)) + { + /* Exception occurred */ + return FALSE; + } + } + + /* Return success */ + return TRUE; } FAST486_OPCODE_HANDLER(Fast486ExtOpcodeCmpXchgByte) @@ -343,7 +505,7 @@ FAST486_MOD_REG_RM ModRegRm; UCHAR Accumulator = State->GeneralRegs[FAST486_REG_EAX].LowByte; UCHAR Source, Destination, Result; - BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;; + BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; TOGGLE_ADSIZE(AddressSize); @@ -478,7 +640,188 @@ /* Return success */ return TRUE; - +} + +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBtr) +{ + BOOLEAN OperandSize, AddressSize; + FAST486_MOD_REG_RM ModRegRm; + UINT DataSize; + ULONG BitNumber; + + OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); + + /* Get the number of bits */ + if (OperandSize) DataSize = 32; + else DataSize = 16; + + /* Get the operands */ + if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) + { + /* Exception occurred */ + return FALSE; + } + + /* Get the bit number */ + BitNumber = OperandSize ? State->GeneralRegs[ModRegRm.Register].Long + : (ULONG)State->GeneralRegs[ModRegRm.Register].LowWord; + + if (ModRegRm.Memory) + { + /* + * For memory operands, add the bit offset divided by + * the data size to the address + */ + ModRegRm.MemoryAddress += BitNumber / DataSize; + } + + /* Normalize the bit number */ + BitNumber &= (1 << DataSize) - 1; + + if (OperandSize) + { + ULONG Dummy, Value; + + /* Read the value */ + if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, &Dummy, &Value)) + { + /* Exception occurred */ + return FALSE; + } + + /* Set CF to the bit value */ + State->Flags.Cf = (Value >> BitNumber) & 1; + + /* Clear the bit */ + Value &= ~(1 << BitNumber); + + /* Write back the result */ + if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Value)) + { + /* Exception occurred */ + return FALSE; + } + } + else + { + USHORT Dummy, Value; + + /* Read the value */ + if (!Fast486ReadModrmWordOperands(State, &ModRegRm, &Dummy, &Value)) + { + /* Exception occurred */ + return FALSE; + } + + /* Set CF to the bit value */ + State->Flags.Cf = (Value >> BitNumber) & 1; + + /* Clear the bit */ + Value &= ~(1 << BitNumber); + + /* Write back the result */ + if (!Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Value)) + { + /* Exception occurred */ + return FALSE; + } + } + + /* Return success */ + return TRUE; +} + +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBtc) +{ + BOOLEAN OperandSize, AddressSize; + FAST486_MOD_REG_RM ModRegRm; + UINT DataSize; + ULONG BitNumber; + + OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); + + /* Get the number of bits */ + if (OperandSize) DataSize = 32; + else DataSize = 16; + + /* Get the operands */ + if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) + { + /* Exception occurred */ + return FALSE; + } + + /* Get the bit number */ + BitNumber = OperandSize ? State->GeneralRegs[ModRegRm.Register].Long + : (ULONG)State->GeneralRegs[ModRegRm.Register].LowWord; + + if (ModRegRm.Memory) + { + /* + * For memory operands, add the bit offset divided by + * the data size to the address + */ + ModRegRm.MemoryAddress += BitNumber / DataSize; + } + + /* Normalize the bit number */ + BitNumber &= (1 << DataSize) - 1; + + if (OperandSize) + { + ULONG Dummy, Value; + + /* Read the value */ + if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, &Dummy, &Value)) + { + /* Exception occurred */ + return FALSE; + } + + /* Set CF to the bit value */ + State->Flags.Cf = (Value >> BitNumber) & 1; + + /* Toggle the bit */ + Value ^= 1 << BitNumber; + + /* Write back the result */ + if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Value)) + { + /* Exception occurred */ + return FALSE; + } + } + else + { + USHORT Dummy, Value; + + /* Read the value */ + if (!Fast486ReadModrmWordOperands(State, &ModRegRm, &Dummy, &Value)) + { + /* Exception occurred */ + return FALSE; + } + + /* Set CF to the bit value */ + State->Flags.Cf = (Value >> BitNumber) & 1; + + /* Toggle the bit */ + Value ^= 1 << BitNumber; + + /* Write back the result */ + if (!Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Value)) + { + /* Exception occurred */ + return FALSE; + } + } + + /* Return success */ + return TRUE; } FAST486_OPCODE_HANDLER(Fast486ExtOpcodeConditionalJmp) Modified: branches/ntvdm/lib/fast486/extraops.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.h?re…
============================================================================== --- branches/ntvdm/lib/fast486/extraops.h [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.h [iso-8859-1] Sun Oct 20 00:25:41 2013 @@ -25,10 +25,14 @@ /* DEFINES ********************************************************************/ FAST486_OPCODE_HANDLER(Fast486ExtOpcodePushFs); FAST486_OPCODE_HANDLER(Fast486ExtOpcodePopFs); +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBitTest); FAST486_OPCODE_HANDLER(Fast486ExtOpcodePushGs); FAST486_OPCODE_HANDLER(Fast486ExtOpcodePopGs); +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBts); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeCmpXchgByte); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeCmpXchg); +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBtr); +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBtc); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeConditionalJmp); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeConditionalSet); FAST486_OPCODE_HANDLER(Fast486OpcodeExtended);
11 years, 2 months
1
0
0
0
[aandrejevic] 60715: [FAST486] Fix more prefix handling. Create the macros TOGGLE_ADSIZE and TOGGLE_OPSIZE to shorten the code.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Sat Oct 19 23:43:53 2013 New Revision: 60715 URL:
http://svn.reactos.org/svn/reactos?rev=60715&view=rev
Log: [FAST486] Fix more prefix handling. Create the macros TOGGLE_ADSIZE and TOGGLE_OPSIZE to shorten the code. Modified: branches/ntvdm/lib/fast486/common.h branches/ntvdm/lib/fast486/extraops.c branches/ntvdm/lib/fast486/opcodes.c branches/ntvdm/lib/fast486/opgroups.c Modified: branches/ntvdm/lib/fast486/common.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/common.h?rev=…
============================================================================== --- branches/ntvdm/lib/fast486/common.h [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/common.h [iso-8859-1] Sat Oct 19 23:43:53 2013 @@ -45,6 +45,14 @@ {\ Fast486Exception(State, FAST486_EXCEPTION_UD);\ return FALSE;\ +} +#define TOGGLE_OPSIZE(x) if (State->PrefixFlags & FAST486_PREFIX_OPSIZE)\ +{\ + x = !x;\ +} +#define TOGGLE_ADSIZE(x) if (State->PrefixFlags & FAST486_PREFIX_ADSIZE)\ +{\ + x = !x;\ } #define PAGE_ALIGN(x) ((x) & 0xFFFFF000) Modified: branches/ntvdm/lib/fast486/extraops.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.c?re…
============================================================================== --- branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] Sat Oct 19 23:43:53 2013 @@ -345,11 +345,7 @@ UCHAR Source, Destination, Result; BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -399,17 +395,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -500,18 +487,8 @@ LONG Offset = 0; BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + TOGGLE_OPSIZE(Size); + NO_LOCK_PREFIX(); /* Make sure this is the right instruction */ ASSERT((Opcode & 0xF0) == 0x80); @@ -620,11 +597,7 @@ BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; FAST486_MOD_REG_RM ModRegRm; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The OPSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) Modified: branches/ntvdm/lib/fast486/opcodes.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opcodes.c?rev…
============================================================================== --- branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] Sat Oct 19 23:43:53 2013 @@ -466,12 +466,7 @@ ULONG Value; BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); /* Make sure this is the right instruction */ @@ -505,12 +500,7 @@ ULONG Value; BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); /* Make sure this is the right instruction */ @@ -555,12 +545,7 @@ ULONG Value; BOOLEAN Size = State->SegmentRegs[FAST486_REG_SS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); /* Make sure this is the right instruction */ @@ -579,13 +564,6 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeNop) { - if (State->PrefixFlags & ~(FAST486_PREFIX_OPSIZE | FAST486_PREFIX_REP)) - { - /* Allowed prefixes are REP and OPSIZE */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } - if (State->PrefixFlags & FAST486_PREFIX_REP) { /* Idle cycle */ @@ -600,12 +578,7 @@ INT Reg = Opcode & 0x07; BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); /* Make sure this is the right instruction */ @@ -952,12 +925,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xF7) == 0xE5); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); if (Opcode == 0xE5) @@ -1047,12 +1015,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xF7) == 0xE7); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); if (Opcode == 0xE7) @@ -1122,12 +1085,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xF8) == 0xB8); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); if (Size) @@ -1206,20 +1164,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFD) == 0x00); - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } - else if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -1266,17 +1211,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -1397,12 +1333,7 @@ ASSERT(Opcode == 0x05); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -1469,11 +1400,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFD) == 0x08); - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -1518,17 +1445,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -1643,12 +1561,7 @@ ASSERT(Opcode == 0x0D); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -1711,11 +1624,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFD) == 0x20); - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -1760,17 +1669,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -1880,12 +1780,7 @@ ASSERT(Opcode == 0x25); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -1948,11 +1843,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFD) == 0x30); - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -1997,17 +1888,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -2122,12 +2004,7 @@ ASSERT(Opcode == 0x35); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -2190,11 +2067,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x84); - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -2235,17 +2108,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -2349,12 +2213,7 @@ ASSERT(Opcode == 0xA9); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -2412,11 +2271,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x86); - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -2467,17 +2322,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -2593,11 +2439,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFD) == 0x10); - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -2648,17 +2490,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -2792,12 +2625,7 @@ ASSERT(Opcode == 0x15); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -2893,11 +2721,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFD) == 0x18); - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -2954,17 +2778,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -3106,12 +2921,7 @@ ASSERT(Opcode == 0x1D); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -3235,11 +3045,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xED) == 0x28); - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -3304,17 +3110,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -3475,12 +3272,7 @@ ASSERT((Opcode & 0xEF) == 0x2D); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -3649,12 +3441,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x60); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); /* Push all the registers in order */ @@ -3693,12 +3480,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x61); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); /* Pop all the registers in reverse order */ @@ -3745,11 +3527,7 @@ return FALSE; } - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -3797,12 +3575,7 @@ ASSERT(Opcode == 0x68); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -3844,17 +3617,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Fetch the parameters */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -3981,11 +3745,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFD) == 0x88); - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -4024,17 +3784,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -4100,17 +3851,8 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x8C); - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -4152,17 +3894,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -4207,17 +3940,8 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x8E); - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the address size */ - AddressSize = !AddressSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the operand size */ - OperandSize = !OperandSize; - } + TOGGLE_ADSIZE(AddressSize); + TOGGLE_OPSIZE(OperandSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -4267,12 +3991,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x98); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); if (Size) @@ -4303,12 +4022,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x99); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); if (Size) @@ -4338,12 +4052,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x9A); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); /* Fetch the offset */ @@ -4412,12 +4121,7 @@ BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size; NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* This OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); /* Check for VM86 mode when IOPL is not 3 */ if (State->Flags.Vm && (State->Flags.Iopl != 3)) @@ -4439,12 +4143,7 @@ ULONG NewFlags; NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* This OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); /* Pop the new flags */ if (!Fast486StackPop(State, &NewFlags)) @@ -4597,12 +4296,7 @@ ASSERT((Opcode & 0xFE) == 0xC2); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Opcode == 0xC2) { @@ -4639,11 +4333,7 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -4735,12 +4425,7 @@ ASSERT(Opcode == 0xC8); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (!Fast486FetchWord(State, &FrameSize)) { @@ -4799,12 +4484,7 @@ ASSERT(Opcode == 0xC9); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -4841,12 +4521,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFE) == 0xCA); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); if (Opcode == 0xCA) @@ -4966,12 +4641,7 @@ ASSERT(Opcode == 0xCF); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); /* Pop EIP */ if (!Fast486StackPop(State, &InstPtr)) @@ -5234,11 +4904,7 @@ UCHAR Value; BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); /* Read a byte from DS:[(E)BX + AL] */ if (!Fast486ReadMemory(State, @@ -5271,12 +4937,7 @@ ASSERT((Opcode >= 0xE0) && (Opcode <= 0xE2)); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) Condition = ((--State->GeneralRegs[FAST486_REG_ECX].Long) != 0); else Condition = ((--State->GeneralRegs[FAST486_REG_ECX].LowWord) != 0); @@ -5319,12 +4980,7 @@ ASSERT(Opcode == 0xE3); NO_LOCK_PREFIX(); - - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) Condition = (State->GeneralRegs[FAST486_REG_ECX].Long == 0); else Condition = (State->GeneralRegs[FAST486_REG_ECX].LowWord == 0); @@ -5352,12 +5008,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xE8); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); if (Size) @@ -5413,12 +5064,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xE9); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); if (Size) @@ -5462,12 +5108,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xEA); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } - + TOGGLE_OPSIZE(Size); NO_LOCK_PREFIX(); /* Fetch the offset */ @@ -5517,11 +5158,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xA0); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -5561,11 +5198,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xA1); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -5615,11 +5248,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xA2); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -5658,11 +5287,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xA3); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - Size = !Size; - } + TOGGLE_OPSIZE(Size); if (Size) { @@ -5726,17 +5351,8 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFE) == 0xA4); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); if (State->PrefixFlags & FAST486_PREFIX_SEG) { @@ -5920,17 +5536,8 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFE) == 0xA6); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); if (State->PrefixFlags & FAST486_PREFIX_SEG) { @@ -6065,17 +5672,8 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFE) == 0xAA); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); /* Calculate the size */ if (Opcode == 0xAA) DataSize = sizeof(UCHAR); @@ -6205,17 +5803,8 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFE) == 0xAC); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); if (State->PrefixFlags & FAST486_PREFIX_SEG) { @@ -6290,17 +5879,8 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFE) == 0xAE); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); /* Calculate the size */ if (Opcode == 0xAE) DataSize = sizeof(UCHAR); @@ -6400,17 +5980,8 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFE) == 0x6C); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); /* Calculate the size */ if (Opcode == 0x6C) DataSize = sizeof(UCHAR); @@ -6548,17 +6119,8 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFE) == 0x6E); - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); /* Calculate the size */ if (Opcode == 0x6E) DataSize = sizeof(UCHAR); Modified: branches/ntvdm/lib/fast486/opgroups.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opgroups.c?re…
============================================================================== --- branches/ntvdm/lib/fast486/opgroups.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/opgroups.c [iso-8859-1] Sat Oct 19 23:43:53 2013 @@ -297,11 +297,7 @@ FAST486_MOD_REG_RM ModRegRm; BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -342,17 +338,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -426,17 +413,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -505,17 +483,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -559,11 +528,7 @@ FAST486_MOD_REG_RM ModRegRm; BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -607,17 +572,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -682,11 +638,7 @@ FAST486_MOD_REG_RM ModRegRm; BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -721,17 +673,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -786,11 +729,7 @@ FAST486_MOD_REG_RM ModRegRm; BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -823,18 +762,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -884,11 +813,7 @@ FAST486_MOD_REG_RM ModRegRm; BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -924,17 +849,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -992,11 +908,7 @@ FAST486_MOD_REG_RM ModRegRm; BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -1131,17 +1043,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -1386,11 +1289,7 @@ FAST486_MOD_REG_RM ModRegRm; BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -1446,17 +1345,8 @@ OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) - { - /* The OPSIZE prefix toggles the size */ - OperandSize = !OperandSize; - } - - if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) - { - /* The ADSIZE prefix toggles the size */ - AddressSize = !AddressSize; - } + TOGGLE_OPSIZE(OperandSize); + TOGGLE_ADSIZE(AddressSize); if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) {
11 years, 2 months
1
0
0
0
[aandrejevic] 60714: [FAST486] Fix prefix handling. Create a macro NO_LOCK_PREFIX to shorten the code.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Sat Oct 19 23:03:40 2013 New Revision: 60714 URL:
http://svn.reactos.org/svn/reactos?rev=60714&view=rev
Log: [FAST486] Fix prefix handling. Create a macro NO_LOCK_PREFIX to shorten the code. Modified: branches/ntvdm/lib/fast486/common.h branches/ntvdm/lib/fast486/opcodes.c Modified: branches/ntvdm/lib/fast486/common.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/common.h?rev=…
============================================================================== --- branches/ntvdm/lib/fast486/common.h [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/common.h [iso-8859-1] Sat Oct 19 23:03:40 2013 @@ -40,6 +40,12 @@ #define GET_SEGMENT_RPL(s) ((s) & 3) #define GET_SEGMENT_INDEX(s) ((s) & 0xFFF8) #define EXCEPTION_HAS_ERROR_CODE(x) (((x) == 8) || ((x) >= 10 && (x) <= 14)) + +#define NO_LOCK_PREFIX() if (State->PrefixFlags & FAST486_PREFIX_LOCK)\ +{\ + Fast486Exception(State, FAST486_EXCEPTION_UD);\ + return FALSE;\ +} #define PAGE_ALIGN(x) ((x) & 0xFFFFF000) #define PAGE_OFFSET(x) ((x) & 0x00000FFF) Modified: branches/ntvdm/lib/fast486/opcodes.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opcodes.c?rev…
============================================================================== --- branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] Sat Oct 19 23:03:40 2013 @@ -472,12 +472,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); /* Make sure this is the right instruction */ ASSERT((Opcode & 0xF8) == 0x40); @@ -516,12 +511,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); /* Make sure this is the right instruction */ ASSERT((Opcode & 0xF8) == 0x48); @@ -551,12 +541,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodePushReg) { - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); /* Make sure this is the right instruction */ ASSERT((Opcode & 0xF8) == 0x50); @@ -576,12 +561,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); /* Make sure this is the right instruction */ ASSERT((Opcode & 0xF8) == 0x58); @@ -626,12 +606,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); /* Make sure this is the right instruction */ ASSERT((Opcode & 0xF8) == 0x90); @@ -983,12 +958,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (Opcode == 0xE5) { @@ -1083,12 +1053,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (Opcode == 0xE7) { @@ -1163,12 +1128,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (Size) { @@ -1318,17 +1278,6 @@ OperandSize = !OperandSize; } - if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_OPSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } - /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -1447,12 +1396,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x05); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -1530,15 +1474,6 @@ /* The ADSIZE prefix toggles the size */ AddressSize = !AddressSize; } - else if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -1595,17 +1530,6 @@ OperandSize = !OperandSize; } - if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_OPSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } - /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -1718,12 +1642,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x0D); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -1797,15 +1716,6 @@ /* The ADSIZE prefix toggles the size */ AddressSize = !AddressSize; } - else if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -1862,17 +1772,6 @@ OperandSize = !OperandSize; } - if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_OPSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } - /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -1949,12 +1848,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x24); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (!Fast486FetchByte(State, &SecondValue)) { @@ -1985,12 +1879,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x25); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -2064,15 +1953,6 @@ /* The ADSIZE prefix toggles the size */ AddressSize = !AddressSize; } - else if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -2129,17 +2009,6 @@ OperandSize = !OperandSize; } - if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_OPSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } - /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -2252,12 +2121,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x35); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -2331,15 +2195,6 @@ /* The ADSIZE prefix toggles the size */ AddressSize = !AddressSize; } - else if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -2392,17 +2247,6 @@ OperandSize = !OperandSize; } - if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_OPSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } - /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -2504,12 +2348,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xA9); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -2578,15 +2417,6 @@ /* The ADSIZE prefix toggles the size */ AddressSize = !AddressSize; } - else if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -2647,17 +2477,6 @@ { /* The OPSIZE prefix toggles the operand size */ OperandSize = !OperandSize; - } - - if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_OPSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; } /* Get the operands */ @@ -2778,15 +2597,6 @@ { /* The ADSIZE prefix toggles the size */ AddressSize = !AddressSize; - } - else if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; } /* Get the operands */ @@ -2850,17 +2660,6 @@ OperandSize = !OperandSize; } - if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_OPSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } - /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -2992,12 +2791,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x15); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -3311,12 +3105,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x1D); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -3451,15 +3240,6 @@ /* The ADSIZE prefix toggles the size */ AddressSize = !AddressSize; } - else if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -3536,17 +3316,6 @@ OperandSize = !OperandSize; } - if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_OPSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } - /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { @@ -3705,12 +3474,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xEF) == 0x2D); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -3891,12 +3655,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); /* Push all the registers in order */ for (i = 0; i < FAST486_NUM_GEN_REGS; i++) @@ -3940,12 +3699,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); /* Pop all the registers in reverse order */ for (i = FAST486_NUM_GEN_REGS - 1; i >= 0; i--) @@ -4042,12 +3796,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0x68); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -4237,15 +3986,6 @@ /* The ADSIZE prefix toggles the size */ AddressSize = !AddressSize; } - else if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } /* Get the operands */ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) @@ -4294,17 +4034,6 @@ { /* The OPSIZE prefix toggles the operand size */ OperandSize = !OperandSize; - } - - if (State->PrefixFlags - & ~(FAST486_PREFIX_ADSIZE - | FAST486_PREFIX_OPSIZE - | FAST486_PREFIX_SEG - | FAST486_PREFIX_LOCK)) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; } /* Get the operands */ @@ -4544,12 +4273,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (Size) { @@ -4585,12 +4309,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (Size) { @@ -4625,12 +4344,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); /* Fetch the offset */ if (Size) @@ -4697,12 +4411,7 @@ { BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size; - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -4729,12 +4438,7 @@ INT Cpl = Fast486GetCurrentPrivLevel(State); ULONG NewFlags; - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -4892,12 +4596,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode & 0xFE) == 0xC2); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -5035,12 +4734,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xC8); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -5104,12 +4798,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xC9); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -5158,12 +4847,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (Opcode == 0xCA) { @@ -5281,12 +4965,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xCF); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -5495,12 +5174,7 @@ UCHAR Base; UCHAR Value = State->GeneralRegs[FAST486_REG_EAX].LowByte; - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); /* Fetch the base */ if (!Fast486FetchByte(State, &Base)) @@ -5534,12 +5208,7 @@ UCHAR Base; UCHAR Value = State->GeneralRegs[FAST486_REG_EAX].LowByte; - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); /* Fetch the base */ if (!Fast486FetchByte(State, &Base)) @@ -5601,12 +5270,7 @@ /* Make sure this is the right instruction */ ASSERT((Opcode >= 0xE0) && (Opcode <= 0xE2)); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -5654,12 +5318,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xE3); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) { @@ -5699,12 +5358,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (Size) { @@ -5765,12 +5419,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); if (Size) { @@ -5819,12 +5468,7 @@ Size = !Size; } - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); /* Fetch the offset */ if (Size) @@ -6063,12 +5707,7 @@ /* Make sure this is the right instruction */ ASSERT(Opcode == 0xD6); - if (State->PrefixFlags & FAST486_PREFIX_LOCK) - { - /* Invalid prefix */ - Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } + NO_LOCK_PREFIX(); /* Set all the bits of AL to CF */ State->GeneralRegs[FAST486_REG_EAX].LowByte = State->Flags.Cf ? 0xFF : 0x00;
11 years, 2 months
1
0
0
0
[jimtabor] 60713: - Remove a mislaid artifact.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Sat Oct 19 19:08:41 2013 New Revision: 60713 URL:
http://svn.reactos.org/svn/reactos?rev=60713&view=rev
Log: - Remove a mislaid artifact. Modified: trunk/reactos/win32ss/user/user32/windows/prop.c Modified: trunk/reactos/win32ss/user/user32/windows/prop.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
============================================================================== --- trunk/reactos/win32ss/user/user32/windows/prop.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/prop.c [iso-8859-1] Sat Oct 19 19:08:41 2013 @@ -53,7 +53,6 @@ for (i = 0; i < pWnd->PropListItems; i++ ) { Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry); - if (!Property) break; if (Property->Atom == Atom) { return(Property);
11 years, 2 months
1
0
0
0
[aandrejevic] 60712: [FAST486] Implement CMPXCHG.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Sat Oct 19 18:56:58 2013 New Revision: 60712 URL:
http://svn.reactos.org/svn/reactos?rev=60712&view=rev
Log: [FAST486] Implement CMPXCHG. Modified: branches/ntvdm/lib/fast486/extraops.c branches/ntvdm/lib/fast486/extraops.h Modified: branches/ntvdm/lib/fast486/extraops.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.c?re…
============================================================================== --- branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] Sat Oct 19 18:56:58 2013 @@ -214,8 +214,8 @@ NULL, // TODO: OPCODE 0xAD NOT IMPLEMENTED NULL, // TODO: OPCODE 0xAE NOT IMPLEMENTED NULL, // TODO: OPCODE 0xAF NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xB0 NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xB1 NOT IMPLEMENTED + Fast486ExtOpcodeCmpXchgByte, + Fast486ExtOpcodeCmpXchg, NULL, // TODO: OPCODE 0xB2 NOT IMPLEMENTED NULL, // TODO: OPCODE 0xB3 NOT IMPLEMENTED NULL, // TODO: OPCODE 0xB4 NOT IMPLEMENTED @@ -338,6 +338,162 @@ return Fast486LoadSegment(State, FAST486_REG_GS, LOWORD(NewSelector)); } +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeCmpXchgByte) +{ + FAST486_MOD_REG_RM ModRegRm; + UCHAR Accumulator = State->GeneralRegs[FAST486_REG_EAX].LowByte; + UCHAR Source, Destination, Result; + BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;; + + if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) + { + /* The ADSIZE prefix toggles the size */ + AddressSize = !AddressSize; + } + + /* Get the operands */ + if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) + { + /* Exception occurred */ + return FALSE; + } + + /* Read the operands */ + if (!Fast486ReadModrmByteOperands(State, &ModRegRm, &Source, &Destination)) + { + /* Exception occurred */ + return FALSE; + } + + /* Compare AL with the destination */ + Result = Accumulator - Destination; + + /* Update the flags */ + State->Flags.Cf = Accumulator < Destination; + State->Flags.Of = ((Accumulator & SIGN_FLAG_BYTE) != (Destination & SIGN_FLAG_BYTE)) + && ((Accumulator & SIGN_FLAG_BYTE) != (Result & SIGN_FLAG_BYTE)); + State->Flags.Af = (Accumulator & 0x0F) < (Destination & 0x0F); + State->Flags.Zf = (Result == 0) ? TRUE : FALSE; + State->Flags.Sf = (Result & SIGN_FLAG_BYTE) ? TRUE : FALSE; + State->Flags.Pf = Fast486CalculateParity(Result); + + if (State->Flags.Zf) + { + /* Load the source operand into the destination */ + return Fast486WriteModrmByteOperands(State, &ModRegRm, FALSE, Source); + } + else + { + /* Load the destination into AL */ + State->GeneralRegs[FAST486_REG_EAX].LowByte = Destination; + } + + /* Return success */ + return TRUE; +} + +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeCmpXchg) +{ + FAST486_MOD_REG_RM ModRegRm; + BOOLEAN OperandSize, AddressSize; + + OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; + + if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) + { + /* The OPSIZE prefix toggles the size */ + OperandSize = !OperandSize; + } + + if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) + { + /* The ADSIZE prefix toggles the size */ + AddressSize = !AddressSize; + } + + /* Get the operands */ + if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) + { + /* Exception occurred */ + return FALSE; + } + + if (OperandSize) + { + ULONG Source, Destination, Result; + ULONG Accumulator = State->GeneralRegs[FAST486_REG_EAX].Long; + + /* Read the operands */ + if (!Fast486ReadModrmDwordOperands(State, &ModRegRm, &Source, &Destination)) + { + /* Exception occurred */ + return FALSE; + } + + /* Compare EAX with the destination */ + Result = Accumulator - Destination; + + /* Update the flags */ + State->Flags.Cf = Accumulator < Destination; + State->Flags.Of = ((Accumulator & SIGN_FLAG_LONG) != (Destination & SIGN_FLAG_LONG)) + && ((Accumulator & SIGN_FLAG_LONG) != (Result & SIGN_FLAG_LONG)); + State->Flags.Af = (Accumulator & 0x0F) < (Destination & 0x0F); + State->Flags.Zf = (Result == 0) ? TRUE : FALSE; + State->Flags.Sf = (Result & SIGN_FLAG_LONG) ? TRUE : FALSE; + State->Flags.Pf = Fast486CalculateParity(Result); + + if (State->Flags.Zf) + { + /* Load the source operand into the destination */ + return Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Source); + } + else + { + /* Load the destination into EAX */ + State->GeneralRegs[FAST486_REG_EAX].Long = Destination; + } + } + else + { + USHORT Source, Destination, Result; + USHORT Accumulator = State->GeneralRegs[FAST486_REG_EAX].LowWord; + + /* Read the operands */ + if (!Fast486ReadModrmWordOperands(State, &ModRegRm, &Source, &Destination)) + { + /* Exception occurred */ + return FALSE; + } + + /* Compare AX with the destination */ + Result = Accumulator - Destination; + + /* Update the flags */ + State->Flags.Cf = Accumulator < Destination; + State->Flags.Of = ((Accumulator & SIGN_FLAG_WORD) != (Destination & SIGN_FLAG_WORD)) + && ((Accumulator & SIGN_FLAG_WORD) != (Result & SIGN_FLAG_WORD)); + State->Flags.Af = (Accumulator & 0x0F) < (Destination & 0x0F); + State->Flags.Zf = (Result == 0) ? TRUE : FALSE; + State->Flags.Sf = (Result & SIGN_FLAG_WORD) ? TRUE : FALSE; + State->Flags.Pf = Fast486CalculateParity(Result); + + if (State->Flags.Zf) + { + /* Load the source operand into the destination */ + return Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Source); + } + else + { + /* Load the destination into AX */ + State->GeneralRegs[FAST486_REG_EAX].LowWord = Destination; + } + } + + /* Return success */ + return TRUE; + +} + FAST486_OPCODE_HANDLER(Fast486ExtOpcodeConditionalJmp) { BOOLEAN Jump = FALSE; Modified: branches/ntvdm/lib/fast486/extraops.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.h?re…
============================================================================== --- branches/ntvdm/lib/fast486/extraops.h [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.h [iso-8859-1] Sat Oct 19 18:56:58 2013 @@ -27,6 +27,8 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodePopFs); FAST486_OPCODE_HANDLER(Fast486ExtOpcodePushGs); FAST486_OPCODE_HANDLER(Fast486ExtOpcodePopGs); +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeCmpXchgByte); +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeCmpXchg); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeConditionalJmp); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeConditionalSet); FAST486_OPCODE_HANDLER(Fast486OpcodeExtended);
11 years, 2 months
1
0
0
0
← Newer
1
...
7
8
9
10
11
12
13
...
33
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Results per page:
10
25
50
100
200