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
April 2014
----- 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
15 participants
492 discussions
Start a n
N
ew thread
[ekohl] 62697: [USETUP] Add a default pagefile entry to the registry.
by ekohl@svn.reactos.org
Author: ekohl Date: Wed Apr 9 21:49:30 2014 New Revision: 62697 URL:
http://svn.reactos.org/svn/reactos?rev=62697&view=rev
Log: [USETUP] Add a default pagefile entry to the registry. Modified: trunk/reactos/base/setup/usetup/interface/usetup.c trunk/reactos/base/setup/usetup/registry.c trunk/reactos/base/setup/usetup/registry.h Modified: trunk/reactos/base/setup/usetup/interface/usetup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/interfac…
============================================================================== --- trunk/reactos/base/setup/usetup/interface/usetup.c [iso-8859-1] (original) +++ trunk/reactos/base/setup/usetup/interface/usetup.c [iso-8859-1] Wed Apr 9 21:49:30 2014 @@ -70,6 +70,8 @@ static UNICODE_STRING DestinationArcPath; static UNICODE_STRING DestinationRootPath; +static WCHAR DestinationDriveLetter; + /* Path to the active partition (boot manager) */ static UNICODE_STRING SystemRootPath; @@ -1588,6 +1590,8 @@ 0ULL, TRUE); } + + DestinationDriveLetter = (WCHAR)PartitionList->CurrentPartition->DriveLetter[0]; return SELECT_FILE_SYSTEM_PAGE; } @@ -3335,6 +3339,9 @@ return QUIT_PAGE; } + /* Set the default pagefile entry */ + SetDefaultPagefile(DestinationDriveLetter); + /* Update the mounted devices list */ SetMountedDeviceValues(PartitionList); Modified: trunk/reactos/base/setup/usetup/registry.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/registry…
============================================================================== --- trunk/reactos/base/setup/usetup/registry.c [iso-8859-1] (original) +++ trunk/reactos/base/setup/usetup/registry.c [iso-8859-1] Wed Apr 9 21:49:30 2014 @@ -763,4 +763,38 @@ return TRUE; } + +VOID +SetDefaultPagefile(WCHAR Drive) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management"); + UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"PagingFiles"); + WCHAR ValueBuffer[] = L"?:\\pagefile.sys 0 0\0"; + HANDLE KeyHandle; + NTSTATUS Status; + + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = NtOpenKey(&KeyHandle, + KEY_ALL_ACCESS, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) + return; + + ValueBuffer[0] = Drive; + + NtSetValueKey(KeyHandle, + &ValueName, + 0, + REG_MULTI_SZ, + (PVOID)&ValueBuffer, + sizeof(ValueBuffer)); + + NtClose(KeyHandle); +} + /* EOF */ Modified: trunk/reactos/base/setup/usetup/registry.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/registry…
============================================================================== --- trunk/reactos/base/setup/usetup/registry.h [iso-8859-1] (original) +++ trunk/reactos/base/setup/usetup/registry.h [iso-8859-1] Wed Apr 9 21:49:30 2014 @@ -38,4 +38,7 @@ BOOLEAN SetMountedDeviceValue(CHAR Letter, ULONG Signature, LARGE_INTEGER StartingOffset); +VOID +SetDefaultPagefile(WCHAR Drive); + /* EOF */
10 years, 8 months
1
0
0
0
[jimtabor] 62696: [NtUser|User32] - Sync port (more) from wine to update code before move and test. See CORE-7447.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Wed Apr 9 20:50:03 2014 New Revision: 62696 URL:
http://svn.reactos.org/svn/reactos?rev=62696&view=rev
Log: [NtUser|User32] - Sync port (more) from wine to update code before move and test. See CORE-7447. Modified: trunk/reactos/win32ss/user/ntuser/defwnd.c trunk/reactos/win32ss/user/user32/windows/defwnd.c Modified: trunk/reactos/win32ss/user/ntuser/defwnd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/defwnd…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/defwnd.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/defwnd.c [iso-8859-1] Wed Apr 9 20:50:03 2014 @@ -169,19 +169,19 @@ IntGetClientRect(pWnd, &Rect); IntMapWindowPoints(pWnd, (style & WS_CHILD ? IntGetParent(pWnd) : NULL), (LPPOINT) &Rect, 2); - if (! (Pos->flags & SWP_NOCLIENTMOVE)) + if (!(Pos->flags & SWP_NOCLIENTMOVE)) { co_IntSendMessage(UserHMGetHandle(pWnd), WM_MOVE, 0, MAKELONG(Rect.left, Rect.top)); } - if (! (Pos->flags & SWP_NOCLIENTSIZE)) + if (!(Pos->flags & SWP_NOCLIENTSIZE) || (Pos->flags & SWP_STATECHANGED)) { - WPARAM wp = SIZE_RESTORED; - - if (style & WS_MAXIMIZE) wp = SIZE_MAXIMIZED; - else if (style & WS_MINIMIZE) wp = SIZE_MINIMIZED; - - co_IntSendMessage(UserHMGetHandle(pWnd), WM_SIZE, wp, MAKELONG(Rect.right - Rect.left, Rect.bottom - Rect.top)); + if (style & WS_MINIMIZE) co_IntSendMessage(UserHMGetHandle(pWnd), WM_SIZE, SIZE_MINIMIZED, 0 ); + else + { + WPARAM wp = (style & WS_MAXIMIZE) ? SIZE_MAXIMIZED : SIZE_RESTORED; + co_IntSendMessage(UserHMGetHandle(pWnd), WM_SIZE, wp, MAKELONG(Rect.right - Rect.left, Rect.bottom - Rect.top)); + } } return 0; } @@ -200,6 +200,15 @@ NtGdiSelectBrush( hdc, hbrush ); } +VOID FASTCALL +UserDrawMovingFrame(HDC hdc, + RECTL *rect, + BOOL thickframe) +{ + if (thickframe) UserDrawWindowFrame(hdc, rect, UserGetSystemMetrics(SM_CXFRAME), UserGetSystemMetrics(SM_CYFRAME)); + else UserDrawWindowFrame(hdc, rect, 1, 1); +} + LRESULT FASTCALL DefWndHandleSysCommand(PWND pWnd, WPARAM wParam, LPARAM lParam) { @@ -216,6 +225,12 @@ switch (wParam & 0xfff0) { + case SC_MOVE: + case SC_SIZE: + //DefWndDoSizeMove(pWnd, wParam); + ERR("SC_MOVESIZE\n"); + break; + case SC_SCREENSAVE: ERR("Screensaver Called!\n"); UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_START_SCREENSAVE, 0); // always lParam 0 == not Secure @@ -302,8 +317,10 @@ return (LRESULT) DefWndControlColor((HDC)wParam, HIWORD(lParam)); case WM_GETHOTKEY: + //ERR("WM_GETHOTKEY\n"); return DefWndGetHotKey(Wnd); case WM_SETHOTKEY: + //ERR("WM_SETHOTKEY\n"); return DefWndSetHotKey(Wnd, wParam); case WM_NCHITTEST: Modified: trunk/reactos/win32ss/user/user32/windows/defwnd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
============================================================================== --- trunk/reactos/win32ss/user/user32/windows/defwnd.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/defwnd.c [iso-8859-1] Wed Apr 9 20:50:03 2014 @@ -153,7 +153,7 @@ } } -#if 0 // Moved to Win32k +#if 0 VOID DefWndSetRedraw(HWND hWnd, WPARAM wParam) { @@ -344,6 +344,7 @@ } SetCursorPos( pt.x, pt.y ); DefWndHandleSetCursor(hWnd, (WPARAM)hWnd, MAKELONG(hittest, WM_MOUSEMOVE), Style); + //SendMessageW(hWnd, WM_SETCURSOR, (WPARAM)hWnd, MAKELONG(hittest, WM_MOUSEMOVE)); return hittest; } @@ -419,7 +420,7 @@ // // Show window contents while dragging the window, get flag from registry data. // - SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0); + SystemParametersInfoW(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0); pt.x = GET_X_LPARAM(dwPoint); pt.y = GET_Y_LPARAM(dwPoint); @@ -450,11 +451,11 @@ SetCapture(hwnd); hittest = DefWndStartSizeMove(hwnd, Wnd, wParam, &capturePoint); if (!hittest) - { + { ReleaseCapture(); return; - } - } + } + } } /* Get min/max info */ @@ -515,7 +516,7 @@ } IntNotifyWinEvent( EVENT_SYSTEM_MOVESIZESTART, hwnd, OBJID_WINDOW, CHILDID_SELF, 0); - SendMessageA( hwnd, WM_ENTERSIZEMOVE, 0, 0 ); + SendMessageW( hwnd, WM_ENTERSIZEMOVE, 0, 0 ); NtUserxSetGUIThreadHandle(MSQ_STATE_MOVESIZE, hwnd); if (GetCapture() != hwnd) SetCapture( hwnd ); @@ -703,8 +704,8 @@ } NtUserxSetGUIThreadHandle(MSQ_STATE_MOVESIZE, NULL); - SendMessageA( hwnd, WM_EXITSIZEMOVE, 0, 0 ); - SendMessageA( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L); + SendMessageW( hwnd, WM_EXITSIZEMOVE, 0, 0 ); + SendMessageW( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L); /* window moved or resized */ if (moved) @@ -744,7 +745,7 @@ if( !moved ) { if( Style & WS_SYSMENU ) - SendMessageA( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y)); + SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y)); } } }
10 years, 8 months
1
0
0
0
[tfaber] 62695: [KMTESTS:NPFS] - Add some (pretty incomplete) tests for NPFS Create, Connect and Read/Write operations CORE-7451
by tfaber@svn.reactos.org
Author: tfaber Date: Wed Apr 9 18:00:33 2014 New Revision: 62695 URL:
http://svn.reactos.org/svn/reactos?rev=62695&view=rev
Log: [KMTESTS:NPFS] - Add some (pretty incomplete) tests for NPFS Create, Connect and Read/Write operations CORE-7451 Added: trunk/rostests/kmtests/npfs/ (with props) trunk/rostests/kmtests/npfs/NpfsConnect.c (with props) trunk/rostests/kmtests/npfs/NpfsCreate.c (with props) trunk/rostests/kmtests/npfs/NpfsHelpers.c (with props) trunk/rostests/kmtests/npfs/NpfsReadWrite.c (with props) trunk/rostests/kmtests/npfs/npfs.h (with props) Modified: trunk/rostests/kmtests/CMakeLists.txt trunk/rostests/kmtests/kmtest_drv/testlist.c Modified: trunk/rostests/kmtests/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/CMakeLists.txt?re…
============================================================================== --- trunk/rostests/kmtests/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/kmtests/CMakeLists.txt [iso-8859-1] Wed Apr 9 18:00:33 2014 @@ -28,6 +28,10 @@ example/Example.c example/KernelType.c + npfs/NpfsConnect.c + npfs/NpfsCreate.c + npfs/NpfsHelpers.c + npfs/NpfsReadWrite.c ntos_ex/ExCallback.c ntos_ex/ExDoubleList.c ntos_ex/ExFastMutex.c Modified: trunk/rostests/kmtests/kmtest_drv/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kmtest_drv/testli…
============================================================================== --- trunk/rostests/kmtests/kmtest_drv/testlist.c [iso-8859-1] (original) +++ trunk/rostests/kmtests/kmtest_drv/testlist.c [iso-8859-1] Wed Apr 9 18:00:33 2014 @@ -38,6 +38,9 @@ KMT_TESTFUNC Test_KeTimer; KMT_TESTFUNC Test_KernelType; KMT_TESTFUNC Test_MmSection; +KMT_TESTFUNC Test_NpfsConnect; +KMT_TESTFUNC Test_NpfsCreate; +KMT_TESTFUNC Test_NpfsReadWrite; KMT_TESTFUNC Test_ObReference; KMT_TESTFUNC Test_ObType; KMT_TESTFUNC Test_ObTypeClean; @@ -89,6 +92,9 @@ { "KeTimer", Test_KeTimer }, { "-KernelType", Test_KernelType }, { "MmSection", Test_MmSection }, + { "NpfsConnect", Test_NpfsConnect }, + { "NpfsCreate", Test_NpfsCreate }, + { "NpfsReadWrite", Test_NpfsReadWrite }, { "ObReference", Test_ObReference }, { "ObType", Test_ObType }, { "-ObTypeClean", Test_ObTypeClean }, Propchange: trunk/rostests/kmtests/npfs/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Wed Apr 9 18:00:33 2014 @@ -0,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+) Propchange: trunk/rostests/kmtests/npfs/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details. Propchange: trunk/rostests/kmtests/npfs/ ------------------------------------------------------------------------------ bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/rostests/kmtests/npfs/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Added: trunk/rostests/kmtests/npfs/NpfsConnect.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/npfs/NpfsConnect.…
============================================================================== --- trunk/rostests/kmtests/npfs/NpfsConnect.c (added) +++ trunk/rostests/kmtests/npfs/NpfsConnect.c [iso-8859-1] Wed Apr 9 18:00:33 2014 @@ -0,0 +1,272 @@ +/* + * PROJECT: ReactOS kernel-mode tests + * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory + * PURPOSE: Kernel-Mode Test Suite NPFS Connect test + * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org> + */ + +#include <kmt_test.h> +#include "npfs.h" + +#define MAX_INSTANCES 5 +#define IN_QUOTA 4096 +#define OUT_QUOTA 4096 + +#define CheckServer(ServerHandle, State) \ + NpCheckServerPipe(ServerHandle, \ + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, \ + MAX_INSTANCES, 1, \ + IN_QUOTA, 0, \ + OUT_QUOTA, OUT_QUOTA, \ + State) + +#define CheckClient(ClientHandle, State) \ + NpCheckClientPipe(ClientHandle, \ + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, \ + MAX_INSTANCES, 1, \ + IN_QUOTA, 0, \ + OUT_QUOTA, OUT_QUOTA, \ + State) + +static +VOID +ConnectPipe( + IN OUT PTHREAD_CONTEXT Context) +{ + HANDLE ClientHandle; + + ClientHandle = NULL; + Context->Connect.Status = NpOpenPipe(&ClientHandle, + Context->Connect.PipePath, + FILE_PIPE_FULL_DUPLEX); + Context->Connect.ClientHandle = ClientHandle; +} + +static +VOID +ListenPipe( + IN OUT PTHREAD_CONTEXT Context) +{ + Context->Listen.Status = NpListenPipe(Context->Listen.ServerHandle); +} + +static +BOOLEAN +CheckConnectPipe( + IN PTHREAD_CONTEXT Context, + IN PCWSTR PipePath, + IN ULONG MilliSeconds) +{ + Context->Work = ConnectPipe; + Context->Connect.PipePath = PipePath; + return TriggerWork(Context, MilliSeconds); +} + +static +BOOLEAN +CheckListenPipe( + IN PTHREAD_CONTEXT Context, + IN HANDLE ServerHandle, + IN ULONG MilliSeconds) +{ + Context->Work = ListenPipe; + Context->Listen.ServerHandle = ServerHandle; + return TriggerWork(Context, MilliSeconds); +} + +static +VOID +TestConnect( + IN HANDLE ServerHandle, + IN PCWSTR PipePath) +{ + NTSTATUS Status; + THREAD_CONTEXT ConnectContext; + THREAD_CONTEXT ListenContext; + BOOLEAN Okay; + HANDLE ClientHandle; + + StartWorkerThread(&ConnectContext); + StartWorkerThread(&ListenContext); + + /* Server should start out listening */ + CheckServer(ServerHandle, FILE_PIPE_LISTENING_STATE); + + /* Connect a client */ + ClientHandle = NULL; + Okay = CheckConnectPipe(&ConnectContext, PipePath, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_SUCCESS); + if (NT_SUCCESS(ConnectContext.Connect.Status)) + { + ClientHandle = ConnectContext.Connect.ClientHandle; + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + } + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /* Connect another client */ + Okay = CheckConnectPipe(&ConnectContext, PipePath, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_PIPE_NOT_AVAILABLE); + if (NT_SUCCESS(ConnectContext.Connect.Status)) + ObCloseHandle(ConnectContext.Connect.ClientHandle, KernelMode); + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /* Disconnecting the client should fail */ + Status = NpDisconnectPipe(ClientHandle); + ok_eq_hex(Status, STATUS_ILLEGAL_FUNCTION); + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /* Listening on the client should fail */ + Status = NpListenPipe(ClientHandle); + ok_eq_hex(Status, STATUS_ILLEGAL_FUNCTION); + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /* Close client */ + if (ClientHandle) + ObCloseHandle(ClientHandle, KernelMode); + CheckServer(ServerHandle, FILE_PIPE_CLOSING_STATE); + + /* Connecting a client now should fail */ + Okay = CheckConnectPipe(&ConnectContext, PipePath, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_PIPE_NOT_AVAILABLE); + if (NT_SUCCESS(ConnectContext.Connect.Status)) + ObCloseHandle(ConnectContext.Connect.ClientHandle, KernelMode); + CheckServer(ServerHandle, FILE_PIPE_CLOSING_STATE); + + /* Listening should fail */ + Okay = CheckListenPipe(&ListenContext, ServerHandle, 100); + ok_bool_true(Okay, "CheckListenPipe returned"); + if (!skip(Okay, "Listen succeeded unexpectedly\n")) + CheckServer(ServerHandle, FILE_PIPE_CLOSING_STATE); + + /* Disconnect server */ + Status = NpDisconnectPipe(ServerHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + CheckServer(ServerHandle, FILE_PIPE_DISCONNECTED_STATE); + + /* Disconnecting again should fail */ + Status = NpDisconnectPipe(ServerHandle); + ok_eq_hex(Status, STATUS_PIPE_DISCONNECTED); + CheckServer(ServerHandle, FILE_PIPE_DISCONNECTED_STATE); + + /* Connecting a client now should fail */ + Okay = CheckConnectPipe(&ConnectContext, PipePath, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_PIPE_NOT_AVAILABLE); + if (NT_SUCCESS(ConnectContext.Connect.Status)) + ObCloseHandle(ConnectContext.Connect.ClientHandle, KernelMode); + CheckServer(ServerHandle, FILE_PIPE_DISCONNECTED_STATE); + + /**************************************************************************/ + /* Now listen again */ + Okay = CheckListenPipe(&ListenContext, ServerHandle, 100); + ok_bool_false(Okay, "CheckListenPipe returned"); + //blocks: CheckServer(ServerHandle, FILE_PIPE_LISTENING_STATE); + + /* Connect client */ + ClientHandle = NULL; + Okay = CheckConnectPipe(&ConnectContext, PipePath, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_SUCCESS); + if (NT_SUCCESS(ConnectContext.Connect.Status)) + { + ClientHandle = ConnectContext.Connect.ClientHandle; + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + } + Okay = WaitForWork(&ListenContext, 100); + ok_bool_true(Okay, "WaitForWork returned"); + ok_eq_hex(ListenContext.Listen.Status, STATUS_SUCCESS); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /* Listening again should fail */ + Okay = CheckListenPipe(&ListenContext, ServerHandle, 100); + ok_bool_true(Okay, "CheckListenPipe returned"); + ok_eq_hex(ListenContext.Listen.Status, STATUS_PIPE_CONNECTED); + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /* Disconnect server */ + Status = NpDisconnectPipe(ServerHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + NpQueryPipe(ClientHandle, STATUS_PIPE_DISCONNECTED); + CheckServer(ServerHandle, FILE_PIPE_DISCONNECTED_STATE); + + /* Close client */ + if (ClientHandle) + ObCloseHandle(ClientHandle, KernelMode); + CheckServer(ServerHandle, FILE_PIPE_DISCONNECTED_STATE); + + /**************************************************************************/ + /* Listen once more */ + Okay = CheckListenPipe(&ListenContext, ServerHandle, 100); + ok_bool_false(Okay, "CheckListenPipe returned"); + //blocks: CheckServer(ServerHandle, FILE_PIPE_LISTENING_STATE); + + /* Connect client */ + ClientHandle = NULL; + Okay = CheckConnectPipe(&ConnectContext, PipePath, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_SUCCESS); + if (NT_SUCCESS(ConnectContext.Connect.Status)) + { + ClientHandle = ConnectContext.Connect.ClientHandle; + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + } + Okay = WaitForWork(&ListenContext, 100); + ok_bool_true(Okay, "WaitForWork returned"); + ok_eq_hex(ListenContext.Listen.Status, STATUS_SUCCESS); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /* Close server */ + Status = ObCloseHandle(ServerHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + CheckClient(ClientHandle, FILE_PIPE_CLOSING_STATE); + + /* Close client */ + if (ClientHandle) + ObCloseHandle(ClientHandle, KernelMode); + + FinishWorkerThread(&ListenContext); + FinishWorkerThread(&ConnectContext); +} + +static KSTART_ROUTINE RunTest; +static +VOID +NTAPI +RunTest( + IN PVOID Context) +{ + NTSTATUS Status; + HANDLE ServerHandle; + + UNREFERENCED_PARAMETER(Context); + + ServerHandle = INVALID_HANDLE_VALUE; + Status = NpCreatePipe(&ServerHandle, + DEVICE_NAMED_PIPE L"\\KmtestNpfsConnectTestPipe", + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, + MAX_INSTANCES, + IN_QUOTA, + OUT_QUOTA); + ok_eq_hex(Status, STATUS_SUCCESS); + ok(ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "ServerHandle = %p\n", ServerHandle); + if (!skip(NT_SUCCESS(Status) && ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "No pipe\n")) + { + CheckServer(ServerHandle, FILE_PIPE_LISTENING_STATE); + TestConnect(ServerHandle, DEVICE_NAMED_PIPE L"\\KmtestNpfsConnectTestPipe"); + } +} + +START_TEST(NpfsConnect) +{ + PKTHREAD Thread; + + Thread = KmtStartThread(RunTest, NULL); + KmtFinishThread(Thread, NULL); +} Propchange: trunk/rostests/kmtests/npfs/NpfsConnect.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rostests/kmtests/npfs/NpfsCreate.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/npfs/NpfsCreate.c…
============================================================================== --- trunk/rostests/kmtests/npfs/NpfsCreate.c (added) +++ trunk/rostests/kmtests/npfs/NpfsCreate.c [iso-8859-1] Wed Apr 9 18:00:33 2014 @@ -0,0 +1,118 @@ +/* + * PROJECT: ReactOS kernel-mode tests + * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory + * PURPOSE: Kernel-Mode Test Suite NPFS Create test + * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org> + */ + +#include <kmt_test.h> +#include "npfs.h" + +static +VOID +TestCreateNamedPipe(VOID) +{ + NTSTATUS Status; + HANDLE ServerHandle; + ULONG MaxInstances; + ULONG InQuota, OutQuota; + ULONG Quotas[] = { 0, 1, 2, 1024, PAGE_SIZE - 1, PAGE_SIZE, PAGE_SIZE + 1, 2 * PAGE_SIZE, 8 * PAGE_SIZE, 64 * PAGE_SIZE, 64 * PAGE_SIZE + 1, 128 * PAGE_SIZE }; + ULONG i; + LARGE_INTEGER Timeout; + + /* Invalid pipe name */ + MaxInstances = 1; + InQuota = 4096; + OutQuota = 4096; + ServerHandle = INVALID_HANDLE_VALUE; + Status = NpCreatePipe(&ServerHandle, + DEVICE_NAMED_PIPE L"", + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, + MaxInstances, + InQuota, + OutQuota); + ok_eq_hex(Status, STATUS_OBJECT_NAME_INVALID); + ok_eq_pointer(ServerHandle, INVALID_HANDLE_VALUE); + if (ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE) + ObCloseHandle(ServerHandle, KernelMode); + + ServerHandle = INVALID_HANDLE_VALUE; + Status = NpCreatePipe(&ServerHandle, + DEVICE_NAMED_PIPE L"\\", + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, + MaxInstances, + InQuota, + OutQuota); + ok_eq_hex(Status, STATUS_OBJECT_NAME_INVALID); + ok_eq_pointer(ServerHandle, INVALID_HANDLE_VALUE); + if (ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE) + ObCloseHandle(ServerHandle, KernelMode); + + ServerHandle = INVALID_HANDLE_VALUE; + Status = NpCreatePipe(&ServerHandle, + DEVICE_NAMED_PIPE L"\\\\", + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, + MaxInstances, + InQuota, + OutQuota); + ok_eq_hex(Status, STATUS_OBJECT_NAME_INVALID); + ok_eq_pointer(ServerHandle, INVALID_HANDLE_VALUE); + if (ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE) + ObCloseHandle(ServerHandle, KernelMode); + + /* Test in-quota */ + MaxInstances = 1; + OutQuota = 4096; + for (i = 0; i < RTL_NUMBER_OF(Quotas); i++) + { + InQuota = Quotas[i]; + ServerHandle = INVALID_HANDLE_VALUE; + Status = NpCreatePipe(&ServerHandle, + DEVICE_NAMED_PIPE L"\\KmtestNpfsCreateTestPipe", + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, + MaxInstances, + InQuota, + OutQuota); + ok_eq_hex(Status, STATUS_SUCCESS); + ok(ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "ServerHandle = %p\n", ServerHandle); + if (!skip(NT_SUCCESS(Status) && ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "No pipe\n")) + { + NpCheckServerPipe(ServerHandle, + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, + MaxInstances, 1, + InQuota, 0, + OutQuota, OutQuota, + FILE_PIPE_LISTENING_STATE); + ObCloseHandle(ServerHandle, KernelMode); + Timeout.QuadPart = -100 * 1000 * 10; + Status = KeDelayExecutionThread(KernelMode, FALSE, &Timeout); + ok_eq_hex(Status, STATUS_SUCCESS); + } + } +} + +static +VOID +TestCreate(VOID) +{ +} + +static KSTART_ROUTINE RunTest; +static +VOID +NTAPI +RunTest( + IN PVOID Context) +{ + UNREFERENCED_PARAMETER(Context); + TestCreateNamedPipe(); + TestCreate(); +} + +START_TEST(NpfsCreate) +{ + PKTHREAD Thread; + + Thread = KmtStartThread(RunTest, NULL); + KmtFinishThread(Thread, NULL); +} Propchange: trunk/rostests/kmtests/npfs/NpfsCreate.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rostests/kmtests/npfs/NpfsHelpers.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/npfs/NpfsHelpers.…
============================================================================== --- trunk/rostests/kmtests/npfs/NpfsHelpers.c (added) +++ trunk/rostests/kmtests/npfs/NpfsHelpers.c [iso-8859-1] Wed Apr 9 18:00:33 2014 @@ -0,0 +1,774 @@ +/* + * PROJECT: ReactOS kernel-mode tests + * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory + * PURPOSE: Kernel-Mode Test Suite Helper functions for NPFS tests + * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org> + */ + +#include <kmt_test.h> +#include "npfs.h" + +NTSTATUS +NpCreatePipeEx( + OUT PHANDLE ServerHandle, + IN PCWSTR PipePath, + IN ULONG ReadMode, + IN ULONG CompletionMode, + IN ULONG NamedPipeType, + IN ULONG ShareAccess, + IN ULONG MaximumInstances, + IN ULONG InboundQuota, + IN ULONG OutboundQuota, + IN ACCESS_MASK DesiredAccess, + IN ULONG Disposition, + IN ULONG CreateOptions, + IN PLARGE_INTEGER DefaultTimeout OPTIONAL) +{ + UNICODE_STRING ObjectName; + OBJECT_ATTRIBUTES ObjectAttributes; + NAMED_PIPE_CREATE_PARAMETERS Params; + IO_STATUS_BLOCK IoStatusBlock; + NTSTATUS Status; + + RtlInitUnicodeString(&ObjectName, PipePath); + InitializeObjectAttributes(&ObjectAttributes, + &ObjectName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + + Params.NamedPipeType = NamedPipeType; + Params.ReadMode = ReadMode; + Params.CompletionMode = CompletionMode; + Params.MaximumInstances = MaximumInstances; + Params.InboundQuota = InboundQuota; + Params.OutboundQuota = OutboundQuota; + if (DefaultTimeout) + { + Params.DefaultTimeout.QuadPart = DefaultTimeout->QuadPart; + Params.TimeoutSpecified = TRUE; + } + else + { + Params.DefaultTimeout.QuadPart = 0; + Params.TimeoutSpecified = FALSE; + } + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + Status = IoCreateFile(ServerHandle, + DesiredAccess, + &ObjectAttributes, + &IoStatusBlock, + NULL, /* AllocationSize */ + 0, /* FileAttributes */ + ShareAccess, + Disposition, + CreateOptions, + NULL, /* EaBuffer */ + 0, /* EaLength */ + CreateFileTypeNamedPipe, + &Params, + 0); + if (NT_SUCCESS(Status)) + { + ok_eq_hex(IoStatusBlock.Status, Status); + ok_eq_ulongptr(IoStatusBlock.Information, FILE_CREATED); + } + else + { + ok_eq_hex(IoStatusBlock.Status, 0x55555555UL); + ok_eq_ulongptr(IoStatusBlock.Information, 0x5555555555555555ULL); + } + return Status; +} + +NTSTATUS +NpCreatePipe( + OUT PHANDLE ServerHandle, + PCWSTR PipePath, + ULONG ReadMode, + ULONG CompletionMode, + ULONG NamedPipeType, + ULONG NamedPipeConfiguration, + ULONG MaximumInstances, + ULONG InboundQuota, + ULONG OutboundQuota) +{ + ULONG ShareAccess; + LARGE_INTEGER DefaultTimeout; + + if (NamedPipeConfiguration == FILE_PIPE_INBOUND) + ShareAccess = FILE_SHARE_WRITE; + else if (NamedPipeConfiguration == FILE_PIPE_OUTBOUND) + ShareAccess = FILE_SHARE_READ; + else if (NamedPipeConfiguration == FILE_PIPE_FULL_DUPLEX) + ShareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE; + + DefaultTimeout.QuadPart = -50 * 1000 * 10; + + return NpCreatePipeEx(ServerHandle, + PipePath, + ReadMode, + CompletionMode, + NamedPipeType, + ShareAccess, + MaximumInstances, + InboundQuota, + OutboundQuota, + SYNCHRONIZE | GENERIC_READ | GENERIC_WRITE, + FILE_OPEN_IF, + FILE_SYNCHRONOUS_IO_NONALERT, + &DefaultTimeout); +} + +NTSTATUS +NpOpenPipeEx( + OUT PHANDLE ClientHandle, + IN PCWSTR PipePath, + IN ACCESS_MASK DesiredAccess, + IN ULONG ShareAccess, + IN ULONG Disposition, + IN ULONG CreateOptions) +{ + UNICODE_STRING ObjectName; + OBJECT_ATTRIBUTES ObjectAttributes; + NTSTATUS Status; + IO_STATUS_BLOCK IoStatusBlock; + + RtlInitUnicodeString(&ObjectName, PipePath); + InitializeObjectAttributes(&ObjectAttributes, + &ObjectName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + Status = IoCreateFile(ClientHandle, + DesiredAccess, + &ObjectAttributes, + &IoStatusBlock, + NULL, /* AllocationSize */ + 0, /* FileAttributes */ + ShareAccess, + Disposition, + CreateOptions, + NULL, /* EaBuffer */ + 0, /* EaLength */ + CreateFileTypeNone, + NULL, + 0); + if (NT_SUCCESS(Status)) + { + ok(Status != STATUS_PENDING, "IoCreateFile returned pending\n"); + ok_eq_hex(IoStatusBlock.Status, Status); + ok_eq_ulongptr(IoStatusBlock.Information, FILE_OPENED); + } + else + { + ok_eq_hex(IoStatusBlock.Status, 0x55555555UL); + ok_eq_ulongptr(IoStatusBlock.Information, 0x5555555555555555ULL); + } + return Status; +} + +NTSTATUS +NpOpenPipe( + OUT PHANDLE ClientHandle, + IN PCWSTR PipePath, + IN ULONG NamedPipeConfiguration) +{ + ULONG ShareAccess; + + if (NamedPipeConfiguration == FILE_PIPE_INBOUND) + ShareAccess = FILE_SHARE_WRITE; + else if (NamedPipeConfiguration == FILE_PIPE_OUTBOUND) + ShareAccess = FILE_SHARE_READ; + else if (NamedPipeConfiguration == FILE_PIPE_FULL_DUPLEX) + ShareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE; + + return NpOpenPipeEx(ClientHandle, + PipePath, + SYNCHRONIZE | GENERIC_READ | GENERIC_WRITE, + ShareAccess, + FILE_OPEN, + FILE_SYNCHRONOUS_IO_NONALERT); +} + +NTSTATUS +NpControlPipe( + IN HANDLE ServerHandle, + IN ULONG FsControlCode, + IN PVOID InputBuffer, + IN ULONG InputBufferLength) +{ + NTSTATUS Status; + IO_STATUS_BLOCK IoStatusBlock; + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + Status = ZwFsControlFile(ServerHandle, + NULL, + NULL, + NULL, + &IoStatusBlock, + FsControlCode, + InputBuffer, + InputBufferLength, + NULL, + 0); + if (Status == STATUS_PENDING) + { + Status = ZwWaitForSingleObject(ServerHandle, + FALSE, + NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = IoStatusBlock.Status; + } + if (NT_SUCCESS(Status)) + { + ok_eq_hex(IoStatusBlock.Status, Status); + ok_eq_ulongptr(IoStatusBlock.Information, 0); + } + else + { + ok_eq_hex(IoStatusBlock.Status, 0x55555555UL); + ok_eq_ulongptr(IoStatusBlock.Information, 0x5555555555555555ULL); + } + return Status; +} + +NTSTATUS +NpWaitPipe( + IN PCWSTR PipeName, + IN PLARGE_INTEGER Timeout) +{ + NTSTATUS Status; + HANDLE RootHandle; + UNICODE_STRING RootDirectoryName = RTL_CONSTANT_STRING(DEVICE_NAMED_PIPE); + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK IoStatusBlock; + PFILE_PIPE_WAIT_FOR_BUFFER WaitForBuffer; + ULONG NameLength; + ULONG BufferSize; + + InitializeObjectAttributes(&ObjectAttributes, + &RootDirectoryName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + Status = IoCreateFile(&RootHandle, + FILE_READ_ATTRIBUTES | SYNCHRONIZE, + &ObjectAttributes, + &IoStatusBlock, + NULL, + 0, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_OPEN, + FILE_SYNCHRONOUS_IO_NONALERT, + NULL, + 0, + CreateFileTypeNone, + NULL, + 0); + if (!NT_SUCCESS(Status)) + { + ok_eq_hex(IoStatusBlock.Status, 0x55555555UL); + ok_eq_ulongptr(IoStatusBlock.Information, 0x5555555555555555ULL); + return Status; + } + ok(Status != STATUS_PENDING, "IoCreateFile returned pending\n"); + ok_eq_hex(IoStatusBlock.Status, Status); + ok_eq_ulongptr(IoStatusBlock.Information, FILE_OPENED); + + NameLength = wcslen(PipeName) * sizeof(WCHAR); + BufferSize = FIELD_OFFSET(FILE_PIPE_WAIT_FOR_BUFFER, + Name[NameLength / sizeof(WCHAR)]); + WaitForBuffer = ExAllocatePoolWithTag(NonPagedPool, BufferSize, 'WPmK'); + if (WaitForBuffer == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + if (Timeout) + { + WaitForBuffer->Timeout.QuadPart = Timeout->QuadPart; + WaitForBuffer->TimeoutSpecified = TRUE; + } + else + { + WaitForBuffer->Timeout.QuadPart = 0; + WaitForBuffer->TimeoutSpecified = FALSE; + } + WaitForBuffer->NameLength = NameLength; + RtlCopyMemory(WaitForBuffer->Name, PipeName, NameLength); + Status = NpControlPipe(RootHandle, + FSCTL_PIPE_WAIT, + WaitForBuffer, + BufferSize); + ExFreePoolWithTag(WaitForBuffer, 'WPmK'); + return Status; +} + +NTSTATUS +NpReadPipe( + IN HANDLE PipeHandle, + OUT PVOID Buffer, + IN ULONG BufferSize, + OUT PULONG_PTR BytesRead) +{ + NTSTATUS Status; + IO_STATUS_BLOCK IoStatusBlock; + BOOLEAN PendingReturned = FALSE; + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + Status = ZwReadFile(PipeHandle, + NULL, + NULL, + NULL, + &IoStatusBlock, + Buffer, + BufferSize, + NULL, + NULL); + if (Status == STATUS_PENDING) + { + Status = ZwWaitForSingleObject(PipeHandle, + FALSE, + NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = IoStatusBlock.Status; + PendingReturned = TRUE; + } + if (NT_SUCCESS(Status)) + { + ok_eq_hex(IoStatusBlock.Status, Status); + *BytesRead = IoStatusBlock.Information; + } + else + { + if (PendingReturned) + { + ok_eq_hex(IoStatusBlock.Status, Status); + ok_eq_ulongptr(IoStatusBlock.Information, 0); + } + else + { + ok_eq_hex(IoStatusBlock.Status, 0x55555555UL); + ok_eq_ulongptr(IoStatusBlock.Information, 0x5555555555555555ULL); + } + *BytesRead = 0; + } + return Status; +} + +NTSTATUS +NpWritePipe( + IN HANDLE PipeHandle, + IN const VOID *Buffer, + IN ULONG BufferSize, + OUT PULONG_PTR BytesWritten) +{ + NTSTATUS Status; + IO_STATUS_BLOCK IoStatusBlock; + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + Status = ZwWriteFile(PipeHandle, + NULL, + NULL, + NULL, + &IoStatusBlock, + (PVOID)Buffer, + BufferSize, + NULL, + NULL); + if (Status == STATUS_PENDING) + { + Status = ZwWaitForSingleObject(PipeHandle, + FALSE, + NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = IoStatusBlock.Status; + } + if (NT_SUCCESS(Status)) + { + ok_eq_hex(IoStatusBlock.Status, Status); + *BytesWritten = IoStatusBlock.Information; + } + else + { + ok_eq_hex(IoStatusBlock.Status, 0x55555555UL); + ok_eq_ulongptr(IoStatusBlock.Information, 0x5555555555555555ULL); + *BytesWritten = 0; + } + return Status; +} + +static +BOOLEAN +CheckBuffer( + PVOID Buffer, + SIZE_T Size, + UCHAR Value) +{ + PUCHAR Array = Buffer; + SIZE_T i; + + for (i = 0; i < Size; i++) + if (Array[i] != Value) + { + trace("Expected %x, found %x at offset %lu\n", Value, Array[i], (ULONG)i); + return FALSE; + } + return TRUE; +} + +#define ok_eq_print_(value, expected, spec, FileAndLine) \ + KmtOk((value) == (expected), FileAndLine, #value " = " spec ", expected " spec "\n", value, expected) +#define ok_eq_ulong_(value, expected) ok_eq_print_(value, expected, "%lu", FileAndLine) +#define ok_eq_ulonglong_(value, expected) ok_eq_print_(value, expected, "%I64u", FileAndLine) +#ifndef _WIN64 +#define ok_eq_ulongptr_(value, expected) ok_eq_print_(value, (ULONG_PTR)(expected), "%lu", FileAndLine) +#elif defined _WIN64 +#define ok_eq_ulongptr_(value, expected) ok_eq_print_(value, (ULONG_PTR)(expected), "%I64u", FileAndLine) +#endif +#define ok_eq_hex_(value, expected) ok_eq_print_(value, expected, "0x%08lx", FileAndLine) + +VOID +NpCheckServerPipe_( + IN HANDLE ServerHandle, + /* PipeInformation */ + IN ULONG ReadMode, + IN ULONG CompletionMode, + /* PipeLocalInformation */ + IN ULONG NamedPipeType, + IN ULONG NamedPipeConfiguration, + IN ULONG MaximumInstances, + IN ULONG CurrentInstances, + IN ULONG InboundQuota, + IN ULONG ReadDataAvailable, + IN ULONG OutboundQuota, + IN ULONG WriteQuotaAvailable, + IN ULONG NamedPipeState, + /* PipeRemoteInformation */ + /* */ + IN PCSTR FileAndLine) +{ + NTSTATUS Status; + IO_STATUS_BLOCK IoStatusBlock; + FILE_PIPE_INFORMATION PipeInfo; + FILE_PIPE_LOCAL_INFORMATION PipeLocalInfo; + FILE_PIPE_REMOTE_INFORMATION PipeRemoteInfo; + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + RtlFillMemory(&PipeInfo, sizeof(PipeInfo), 0x55); + Status = ZwQueryInformationFile(ServerHandle, + &IoStatusBlock, + &PipeInfo, + sizeof(PipeInfo), + FilePipeInformation); + ok_eq_hex_(Status, STATUS_SUCCESS); + ok_eq_hex_(IoStatusBlock.Status, STATUS_SUCCESS); + ok_eq_ulongptr_(IoStatusBlock.Information, sizeof(PipeInfo)); + ok_eq_ulong_(PipeInfo.ReadMode, ReadMode); + ok_eq_ulong_(PipeInfo.CompletionMode, CompletionMode); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + RtlFillMemory(&PipeLocalInfo, sizeof(PipeLocalInfo), 0x55); + Status = ZwQueryInformationFile(ServerHandle, + &IoStatusBlock, + &PipeLocalInfo, + sizeof(PipeLocalInfo), + FilePipeLocalInformation); + ok_eq_hex_(Status, STATUS_SUCCESS); + ok_eq_hex_(IoStatusBlock.Status, STATUS_SUCCESS); + ok_eq_ulongptr_(IoStatusBlock.Information, sizeof(PipeLocalInfo)); + ok_eq_ulong_(PipeLocalInfo.NamedPipeType, NamedPipeType); + ok_eq_ulong_(PipeLocalInfo.NamedPipeConfiguration, NamedPipeConfiguration); + ok_eq_ulong_(PipeLocalInfo.MaximumInstances, MaximumInstances); + ok_eq_ulong_(PipeLocalInfo.CurrentInstances, CurrentInstances); + ok_eq_ulong_(PipeLocalInfo.InboundQuota, InboundQuota); + ok_eq_ulong_(PipeLocalInfo.ReadDataAvailable, ReadDataAvailable); + ok_eq_ulong_(PipeLocalInfo.OutboundQuota, OutboundQuota); + ok_eq_ulong_(PipeLocalInfo.WriteQuotaAvailable, WriteQuotaAvailable); + ok_eq_ulong_(PipeLocalInfo.NamedPipeState, NamedPipeState); + ok_eq_ulong_(PipeLocalInfo.NamedPipeEnd, (ULONG)FILE_PIPE_SERVER_END); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + RtlFillMemory(&PipeRemoteInfo, sizeof(PipeRemoteInfo), 0x55); + Status = ZwQueryInformationFile(ServerHandle, + &IoStatusBlock, + &PipeRemoteInfo, + sizeof(PipeRemoteInfo), + FilePipeInformation); + ok_eq_hex_(Status, STATUS_SUCCESS); + ok_eq_hex_(IoStatusBlock.Status, STATUS_SUCCESS); + ok_eq_ulongptr_(IoStatusBlock.Information, RTL_SIZEOF_THROUGH_FIELD(FILE_PIPE_REMOTE_INFORMATION, CollectDataTime)); + ok_eq_ulonglong_(PipeRemoteInfo.CollectDataTime.QuadPart, 0ULL); + ok_eq_ulong_(PipeRemoteInfo.MaximumCollectionCount, 0x55555555UL); +} + +VOID +NpCheckClientPipe_( + IN HANDLE ClientHandle, + /* PipeInformation */ + IN ULONG ReadMode, + IN ULONG CompletionMode, + /* PipeLocalInformation */ + IN ULONG NamedPipeType, + IN ULONG NamedPipeConfiguration, + IN ULONG MaximumInstances, + IN ULONG CurrentInstances, + IN ULONG InboundQuota, + IN ULONG ReadDataAvailable, + IN ULONG OutboundQuota, + IN ULONG WriteQuotaAvailable, + IN ULONG NamedPipeState, + /* PipeRemoteInformation */ + /* */ + IN PCSTR FileAndLine) +{ + NTSTATUS Status; + IO_STATUS_BLOCK IoStatusBlock; + FILE_PIPE_INFORMATION PipeInfo; + FILE_PIPE_LOCAL_INFORMATION PipeLocalInfo; + FILE_PIPE_REMOTE_INFORMATION PipeRemoteInfo; + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + RtlFillMemory(&PipeInfo, sizeof(PipeInfo), 0x55); + Status = ZwQueryInformationFile(ClientHandle, + &IoStatusBlock, + &PipeInfo, + sizeof(PipeInfo), + FilePipeInformation); + ok_eq_hex_(Status, STATUS_SUCCESS); + ok_eq_hex_(IoStatusBlock.Status, STATUS_SUCCESS); + ok_eq_ulongptr_(IoStatusBlock.Information, sizeof(PipeInfo)); + ok_eq_ulong_(PipeInfo.ReadMode, ReadMode); + ok_eq_ulong_(PipeInfo.CompletionMode, CompletionMode); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + RtlFillMemory(&PipeLocalInfo, sizeof(PipeLocalInfo), 0x55); + Status = ZwQueryInformationFile(ClientHandle, + &IoStatusBlock, + &PipeLocalInfo, + sizeof(PipeLocalInfo), + FilePipeLocalInformation); + ok_eq_hex_(Status, STATUS_SUCCESS); + ok_eq_hex_(IoStatusBlock.Status, STATUS_SUCCESS); + ok_eq_ulongptr_(IoStatusBlock.Information, sizeof(PipeLocalInfo)); + ok_eq_ulong_(PipeLocalInfo.NamedPipeType, NamedPipeType); + ok_eq_ulong_(PipeLocalInfo.NamedPipeConfiguration, NamedPipeConfiguration); + ok_eq_ulong_(PipeLocalInfo.MaximumInstances, MaximumInstances); + ok_eq_ulong_(PipeLocalInfo.CurrentInstances, CurrentInstances); + ok_eq_ulong_(PipeLocalInfo.InboundQuota, InboundQuota); + ok_eq_ulong_(PipeLocalInfo.ReadDataAvailable, ReadDataAvailable); + ok_eq_ulong_(PipeLocalInfo.OutboundQuota, OutboundQuota); + ok_eq_ulong_(PipeLocalInfo.WriteQuotaAvailable, WriteQuotaAvailable); + ok_eq_ulong_(PipeLocalInfo.NamedPipeState, NamedPipeState); + ok_eq_ulong_(PipeLocalInfo.NamedPipeEnd, (ULONG)FILE_PIPE_CLIENT_END); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + RtlFillMemory(&PipeRemoteInfo, sizeof(PipeRemoteInfo), 0x55); + Status = ZwQueryInformationFile(ClientHandle, + &IoStatusBlock, + &PipeRemoteInfo, + sizeof(PipeRemoteInfo), + FilePipeInformation); + ok_eq_hex_(Status, STATUS_SUCCESS); + ok_eq_hex_(IoStatusBlock.Status, STATUS_SUCCESS); + ok_eq_ulongptr_(IoStatusBlock.Information, RTL_SIZEOF_THROUGH_FIELD(FILE_PIPE_REMOTE_INFORMATION, CollectDataTime)); + ok_eq_ulonglong_(PipeRemoteInfo.CollectDataTime.QuadPart, 0ULL); + ok_eq_ulong_(PipeRemoteInfo.MaximumCollectionCount, 0x55555555UL); +} + +VOID +NpQueryPipe_( + IN HANDLE PipeHandle, + IN NTSTATUS ExpectedStatus, + IN PCSTR FileAndLine) +{ + NTSTATUS Status; + IO_STATUS_BLOCK IoStatusBlock; + FILE_PIPE_INFORMATION PipeInfo; + FILE_PIPE_LOCAL_INFORMATION PipeLocalInfo; + FILE_PIPE_REMOTE_INFORMATION PipeRemoteInfo; + + ASSERT(!NT_SUCCESS(ExpectedStatus)); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + RtlFillMemory(&PipeInfo, sizeof(PipeInfo), 0x55); + Status = ZwQueryInformationFile(PipeHandle, + &IoStatusBlock, + &PipeInfo, + sizeof(PipeInfo), + FilePipeInformation); + ok_eq_hex_(Status, ExpectedStatus); + ok_bool_true(CheckBuffer(&IoStatusBlock, sizeof(IoStatusBlock), 0x55), "CheckBuffer returned"); + ok_bool_true(CheckBuffer(&PipeInfo, sizeof(PipeInfo), 0x55), "CheckBuffer returned"); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + RtlFillMemory(&PipeLocalInfo, sizeof(PipeLocalInfo), 0x55); + Status = ZwQueryInformationFile(PipeHandle, + &IoStatusBlock, + &PipeLocalInfo, + sizeof(PipeLocalInfo), + FilePipeLocalInformation); + ok_eq_hex_(Status, ExpectedStatus); + ok_bool_true(CheckBuffer(&IoStatusBlock, sizeof(IoStatusBlock), 0x55), "CheckBuffer returned"); + ok_bool_true(CheckBuffer(&PipeLocalInfo, sizeof(PipeLocalInfo), 0x55), "CheckBuffer returned"); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + RtlFillMemory(&PipeRemoteInfo, sizeof(PipeRemoteInfo), 0x55); + Status = ZwQueryInformationFile(PipeHandle, + &IoStatusBlock, + &PipeRemoteInfo, + sizeof(PipeRemoteInfo), + FilePipeInformation); + ok_eq_hex_(Status, ExpectedStatus); + ok_bool_true(CheckBuffer(&IoStatusBlock, sizeof(IoStatusBlock), 0x55), "CheckBuffer returned"); + ok_bool_true(CheckBuffer(&PipeRemoteInfo, sizeof(PipeRemoteInfo), 0x55), "CheckBuffer returned"); +} + +static KSTART_ROUTINE PipeWorkerThread; +static +VOID +NTAPI +PipeWorkerThread( + IN PVOID ThreadContext) +{ + PTHREAD_CONTEXT Context = ThreadContext; + PVOID WaitEvents[2] = { &Context->ThreadDoneEvent, + &Context->StartWorkEvent }; + NTSTATUS Status; + + while (TRUE) + { + Status = KeWaitForMultipleObjects(RTL_NUMBER_OF(WaitEvents), + WaitEvents, + WaitAny, + Executive, + KernelMode, + FALSE, + NULL, + NULL); + if (Status == STATUS_WAIT_0) + break; + ASSERT(Status == STATUS_WAIT_1); + + Context->Work(Context); + + KeSetEvent(&Context->WorkCompleteEvent, IO_NO_INCREMENT, TRUE); + } +} + +VOID +StartWorkerThread( + OUT PTHREAD_CONTEXT Context) +{ + KeInitializeEvent(&Context->ThreadDoneEvent, NotificationEvent, FALSE); + KeInitializeEvent(&Context->StartWorkEvent, SynchronizationEvent, FALSE); + KeInitializeEvent(&Context->WorkCompleteEvent, NotificationEvent, TRUE); + + Context->Thread = KmtStartThread(PipeWorkerThread, Context); +} + +VOID +FinishWorkerThread( + IN PTHREAD_CONTEXT Context) +{ + KmtFinishThread(Context->Thread, &Context->ThreadDoneEvent); +} + +BOOLEAN +WaitForWork( + IN PTHREAD_CONTEXT Context, + IN ULONG MilliSeconds) +{ + LARGE_INTEGER Timeout; + NTSTATUS Status; + + Timeout.QuadPart = -10 * 1000 * (LONGLONG)MilliSeconds; + Status = KeWaitForSingleObject(&Context->WorkCompleteEvent, + Executive, + KernelMode, + FALSE, + &Timeout); + ok(Status == STATUS_SUCCESS || Status == STATUS_TIMEOUT, "Wait status %lx\n", Status); + return Status != STATUS_TIMEOUT; +} + +BOOLEAN +TriggerWork( + IN PTHREAD_CONTEXT Context, + IN ULONG MilliSeconds) +{ + NTSTATUS Status; + + Status = KeWaitForSingleObject(&Context->WorkCompleteEvent, + Executive, + KernelMode, + FALSE, + NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + KeResetEvent(&Context->WorkCompleteEvent); + KeSetEvent(&Context->StartWorkEvent, IO_NO_INCREMENT, TRUE); + return WaitForWork(Context, MilliSeconds); +} + +PKTHREAD +KmtStartThread( + IN PKSTART_ROUTINE StartRoutine, + IN PVOID StartContext OPTIONAL) +{ + NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE ThreadHandle; + PVOID ThreadObject = NULL; + + InitializeObjectAttributes(&ObjectAttributes, + NULL, + OBJ_KERNEL_HANDLE, + NULL, + NULL); + ThreadHandle = INVALID_HANDLE_VALUE; + Status = PsCreateSystemThread(&ThreadHandle, + SYNCHRONIZE, + &ObjectAttributes, + NULL, + NULL, + StartRoutine, + StartContext); + ok_eq_hex(Status, STATUS_SUCCESS); + if (!skip(NT_SUCCESS(Status) && ThreadHandle != NULL && ThreadHandle != INVALID_HANDLE_VALUE, "No thread\n")) + { + Status = ObReferenceObjectByHandle(ThreadHandle, + SYNCHRONIZE, + PsThreadType, + KernelMode, + &ThreadObject, + NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + ObCloseHandle(ThreadHandle, KernelMode); + } + return ThreadObject; +} + +VOID +KmtFinishThread( + IN PKTHREAD Thread OPTIONAL, + IN PKEVENT Event OPTIONAL) +{ + NTSTATUS Status; + + if (skip(Thread != NULL, "No thread\n")) + return; + + if (Event) + KeSetEvent(Event, IO_NO_INCREMENT, TRUE); + Status = KeWaitForSingleObject(Thread, + Executive, + KernelMode, + FALSE, + NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + ObDereferenceObject(Thread); +} Propchange: trunk/rostests/kmtests/npfs/NpfsHelpers.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rostests/kmtests/npfs/NpfsReadWrite.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/npfs/NpfsReadWrit…
============================================================================== --- trunk/rostests/kmtests/npfs/NpfsReadWrite.c (added) +++ trunk/rostests/kmtests/npfs/NpfsReadWrite.c [iso-8859-1] Wed Apr 9 18:00:33 2014 @@ -0,0 +1,598 @@ +/* + * PROJECT: ReactOS kernel-mode tests + * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory + * PURPOSE: Kernel-Mode Test Suite NPFS Read/Write test + * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org> + */ + +#include <kmt_test.h> +#include "npfs.h" + +typedef struct _READ_WRITE_TEST_CONTEXT +{ + PCWSTR PipePath; + BOOLEAN ServerSynchronous; + BOOLEAN ClientSynchronous; +} READ_WRITE_TEST_CONTEXT, *PREAD_WRITE_TEST_CONTEXT; + +#define MAX_INSTANCES 5 +#define IN_QUOTA 4096 +#define OUT_QUOTA 4096 + +#define MakeServer(ServerHandle, PipePath, ServerSynchronous) \ + NpCreatePipeEx(ServerHandle, \ + PipePath, \ + BYTE_STREAM, \ + QUEUE, \ + BYTE_STREAM, \ + FILE_SHARE_READ | FILE_SHARE_WRITE, \ + MAX_INSTANCES, \ + IN_QUOTA, \ + OUT_QUOTA, \ + SYNCHRONIZE | GENERIC_READ | GENERIC_WRITE, \ + FILE_OPEN_IF, \ + (ServerSynchronous) ? FILE_SYNCHRONOUS_IO_NONALERT \ + : 0, \ + &DefaultTimeout) + +#define CheckServer(ServerHandle, State) \ + NpCheckServerPipe(ServerHandle, \ + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, \ + MAX_INSTANCES, 1, \ + IN_QUOTA, 0, \ + OUT_QUOTA, OUT_QUOTA, \ + State) + +#define CheckClient(ClientHandle, State) \ + NpCheckClientPipe(ClientHandle, \ + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, \ + MAX_INSTANCES, 1, \ + IN_QUOTA, 0, \ + OUT_QUOTA, OUT_QUOTA, \ + State) + +#define CheckServerQuota(ServerHandle, InQ, OutQ) \ + NpCheckServerPipe(ServerHandle, \ + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, \ + MAX_INSTANCES, 1, \ + IN_QUOTA, InQ, \ + OUT_QUOTA, OUT_QUOTA - (OutQ), \ + FILE_PIPE_CONNECTED_STATE) + +#define CheckClientQuota(ClientHandle, InQ, OutQ) \ + NpCheckClientPipe(ClientHandle, \ + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, \ + MAX_INSTANCES, 1, \ + IN_QUOTA, InQ, \ + OUT_QUOTA, OUT_QUOTA - (OutQ), \ + FILE_PIPE_CONNECTED_STATE) + +#define CheckPipeContext(Context, ExpectedStatus, ExpectedBytes) do \ +{ \ + ok_bool_true(Okay, "CheckPipeContext"); \ + ok_eq_hex((Context)->ReadWrite.Status, ExpectedStatus); \ + ok_eq_ulongptr((Context)->ReadWrite.BytesTransferred, ExpectedBytes); \ +} while (0) + +static +VOID +ConnectPipe( + IN OUT PTHREAD_CONTEXT Context) +{ + HANDLE ClientHandle; + + ClientHandle = NULL; + Context->Connect.Status = NpOpenPipeEx(&ClientHandle, + Context->Connect.PipePath, + SYNCHRONIZE | GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_OPEN, + Context->Connect.ClientSynchronous ? FILE_SYNCHRONOUS_IO_NONALERT + : 0); + Context->Connect.ClientHandle = ClientHandle; +} + +static +VOID +ListenPipe( + IN OUT PTHREAD_CONTEXT Context) +{ + Context->Listen.Status = NpListenPipe(Context->Listen.ServerHandle); +} + +static +VOID +ReadPipe( + IN OUT PTHREAD_CONTEXT Context) +{ + Context->ReadWrite.Status = NpReadPipe(Context->ReadWrite.PipeHandle, + Context->ReadWrite.Buffer, + Context->ReadWrite.BufferSize, + (PULONG_PTR)&Context->ReadWrite.BytesTransferred); +} + +static +VOID +WritePipe( + IN OUT PTHREAD_CONTEXT Context) +{ + Context->ReadWrite.Status = NpWritePipe(Context->ReadWrite.PipeHandle, + Context->ReadWrite.Buffer, + Context->ReadWrite.BufferSize, + (PULONG_PTR)&Context->ReadWrite.BytesTransferred); +} + +static +BOOLEAN +CheckConnectPipe( + IN PTHREAD_CONTEXT Context, + IN PCWSTR PipePath, + IN BOOLEAN ClientSynchronous, + IN ULONG MilliSeconds) +{ + Context->Work = ConnectPipe; + Context->Connect.PipePath = PipePath; + Context->Connect.ClientSynchronous = ClientSynchronous; + return TriggerWork(Context, MilliSeconds); +} + +static +BOOLEAN +CheckListenPipe( + IN PTHREAD_CONTEXT Context, + IN HANDLE ServerHandle, + IN ULONG MilliSeconds) +{ + Context->Work = ListenPipe; + Context->Listen.ServerHandle = ServerHandle; + return TriggerWork(Context, MilliSeconds); +} + +static +BOOLEAN +CheckReadPipe( + IN PTHREAD_CONTEXT Context, + IN HANDLE PipeHandle, + OUT PVOID Buffer, + IN ULONG BufferSize, + IN ULONG MilliSeconds) +{ + Context->Work = ReadPipe; + Context->ReadWrite.PipeHandle = PipeHandle; + Context->ReadWrite.Buffer = Buffer; + Context->ReadWrite.BufferSize = BufferSize; + return TriggerWork(Context, MilliSeconds); +} + +static +BOOLEAN +CheckWritePipe( + IN PTHREAD_CONTEXT Context, + IN HANDLE PipeHandle, + IN const VOID *Buffer, + IN ULONG BufferSize, + IN ULONG MilliSeconds) +{ + Context->Work = WritePipe; + Context->ReadWrite.PipeHandle = PipeHandle; + Context->ReadWrite.Buffer = (PVOID)Buffer; + Context->ReadWrite.BufferSize = BufferSize; + return TriggerWork(Context, MilliSeconds); +} + +static KSTART_ROUTINE TestReadWrite; +static +VOID +NTAPI +TestReadWrite( + IN PVOID Context) +{ + PREAD_WRITE_TEST_CONTEXT TestContext = Context; + PCWSTR PipePath = TestContext->PipePath; + BOOLEAN ServerSynchronous = TestContext->ServerSynchronous; + BOOLEAN ClientSynchronous = TestContext->ClientSynchronous; + NTSTATUS Status; + HANDLE ServerHandle; + LARGE_INTEGER DefaultTimeout; + THREAD_CONTEXT ConnectContext; + THREAD_CONTEXT ListenContext; + THREAD_CONTEXT ClientReadContext; + THREAD_CONTEXT ClientWriteContext; + THREAD_CONTEXT ServerReadContext; + THREAD_CONTEXT ServerWriteContext; + BOOLEAN Okay; + HANDLE ClientHandle; + UCHAR ReadBuffer[128]; + UCHAR WriteBuffer[128]; + + StartWorkerThread(&ConnectContext); + StartWorkerThread(&ListenContext); + StartWorkerThread(&ClientReadContext); + StartWorkerThread(&ClientWriteContext); + StartWorkerThread(&ServerReadContext); + StartWorkerThread(&ServerWriteContext); + + DefaultTimeout.QuadPart = -50 * 1000 * 10; + + /* Server should start out listening */ + Status = MakeServer(&ServerHandle, PipePath, ServerSynchronous); + ok_eq_hex(Status, STATUS_SUCCESS); + CheckServer(ServerHandle, FILE_PIPE_LISTENING_STATE); + + Okay = CheckWritePipe(&ServerWriteContext, ServerHandle, NULL, 0, 100); + ok_bool_true(Okay, "CheckWritePipe returned"); + ok_eq_ulongptr(ServerWriteContext.ReadWrite.BytesTransferred, 0); + ok_eq_hex(ServerWriteContext.ReadWrite.Status, STATUS_PIPE_LISTENING); + + Okay = CheckReadPipe(&ServerReadContext, ServerHandle, NULL, 0, 100); + ok_bool_true(Okay, "CheckReadPipe returned"); + ok_eq_ulongptr(ServerReadContext.ReadWrite.BytesTransferred, 0); + ok_eq_hex(ServerReadContext.ReadWrite.Status, STATUS_PIPE_LISTENING); + + /* Connect a client */ + Okay = CheckConnectPipe(&ConnectContext, PipePath, ClientSynchronous, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_SUCCESS); + ClientHandle = ConnectContext.Connect.ClientHandle; + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /** Server to client, write first, 1 byte */ + WriteBuffer[0] = 'A'; + ReadBuffer[0] = 'X'; + Okay = CheckWritePipe(&ServerWriteContext, ServerHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ServerWriteContext, STATUS_SUCCESS, 1); + CheckServerQuota(ServerHandle, 0, 1); CheckClientQuota(ClientHandle, 1, 0); + Okay = CheckReadPipe(&ClientReadContext, ClientHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ClientReadContext, STATUS_SUCCESS, 1); + ok_eq_uint(ReadBuffer[0], 'A'); + CheckServerQuota(ServerHandle, 0, 0); CheckClientQuota(ClientHandle, 0, 0); + + /** Server to client, read first, 1 byte */ + WriteBuffer[0] = 'B'; + ReadBuffer[0] = 'X'; + Okay = CheckReadPipe(&ClientReadContext, ClientHandle, ReadBuffer, 1, 100); + ok_bool_false(Okay, "CheckReadPipe returned"); + CheckServerQuota(ServerHandle, 0, 1); + Okay = CheckWritePipe(&ServerWriteContext, ServerHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ServerWriteContext, STATUS_SUCCESS, 1); + Okay = WaitForWork(&ClientReadContext, 100); + CheckPipeContext(&ClientReadContext, STATUS_SUCCESS, 1); + ok_eq_uint(ReadBuffer[0], 'B'); + CheckServerQuota(ServerHandle, 0, 0); CheckClientQuota(ClientHandle, 0, 0); + + /** Client to server, write first, 1 byte */ + WriteBuffer[0] = 'C'; + ReadBuffer[0] = 'X'; + Okay = CheckWritePipe(&ClientWriteContext, ClientHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ClientWriteContext, STATUS_SUCCESS, 1); + CheckClientQuota(ClientHandle, 0, 1); CheckServerQuota(ServerHandle, 1, 0); + Okay = CheckReadPipe(&ServerReadContext, ServerHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ServerReadContext, STATUS_SUCCESS, 1); + ok_eq_uint(ReadBuffer[0], 'C'); + CheckClientQuota(ClientHandle, 0, 0); CheckServerQuota(ServerHandle, 0, 0); + + /** Client to server, read first, 1 byte */ + WriteBuffer[0] = 'D'; + ReadBuffer[0] = 'X'; + Okay = CheckReadPipe(&ServerReadContext, ServerHandle, ReadBuffer, 1, 100); + ok_bool_false(Okay, "CheckReadPipe returned"); + CheckClientQuota(ClientHandle, 0, 1); + Okay = CheckWritePipe(&ClientWriteContext, ClientHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ClientWriteContext, STATUS_SUCCESS, 1); + Okay = WaitForWork(&ServerReadContext, 100); + CheckPipeContext(&ServerReadContext, STATUS_SUCCESS, 1); + ok_eq_uint(ReadBuffer[0], 'D'); + CheckClientQuota(ClientHandle, 0, 0); CheckServerQuota(ServerHandle, 0, 0); + + /** Server to client, write 0 bytes */ + Okay = CheckWritePipe(&ServerWriteContext, ServerHandle, (PVOID)1, 0, 100); + CheckPipeContext(&ServerWriteContext, STATUS_SUCCESS, 0); + CheckServerQuota(ServerHandle, 0, 0); CheckClientQuota(ClientHandle, 0, 0); + + /** Client to Server, write 0 bytes */ + Okay = CheckWritePipe(&ClientWriteContext, ClientHandle, (PVOID)1, 0, 100); + CheckPipeContext(&ClientWriteContext, STATUS_SUCCESS, 0); + CheckClientQuota(ClientHandle, 0, 0); CheckServerQuota(ServerHandle, 0, 0); + + /** Server to client, read 0 bytes blocks, write 0 bytes does not unblock, write 1 byte unblocks */ + WriteBuffer[0] = 'E'; + ReadBuffer[0] = 'X'; + Okay = CheckReadPipe(&ClientReadContext, ClientHandle, (PVOID)1, 0, 100); + ok_bool_false(Okay, "CheckReadPipe returned"); + CheckServerQuota(ServerHandle, 0, 0); + Okay = CheckWritePipe(&ServerWriteContext, ServerHandle, (PVOID)1, 0, 100); + CheckPipeContext(&ServerWriteContext, STATUS_SUCCESS, 0); + Okay = WaitForWork(&ClientReadContext, 100); + ok_bool_false(Okay, "WaitForWork returned"); + CheckServerQuota(ServerHandle, 0, 0); + Okay = CheckWritePipe(&ServerWriteContext, ServerHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ServerWriteContext, STATUS_SUCCESS, 1); + Okay = WaitForWork(&ClientReadContext, 100); + CheckPipeContext(&ClientReadContext, STATUS_SUCCESS, 0); + ok_eq_uint(ReadBuffer[0], 'X'); + CheckServerQuota(ServerHandle, 0, 1); CheckClientQuota(ClientHandle, 1, 0); + Okay = CheckReadPipe(&ClientReadContext, ClientHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ClientReadContext, STATUS_SUCCESS, 1); + ok_eq_uint(ReadBuffer[0], 'E'); + CheckServerQuota(ServerHandle, 0, 0); CheckClientQuota(ClientHandle, 0, 0); + + /** Client to server, read 0 bytes blocks, write 0 bytes does not unblock, write 1 byte unblocks */ + WriteBuffer[0] = 'F'; + ReadBuffer[0] = 'X'; + Okay = CheckReadPipe(&ServerReadContext, ServerHandle, (PVOID)1, 0, 100); + ok_bool_false(Okay, "CheckReadPipe returned"); + CheckClientQuota(ClientHandle, 0, 0); + Okay = CheckWritePipe(&ClientWriteContext, ClientHandle, (PVOID)1, 0, 100); + CheckPipeContext(&ClientWriteContext, STATUS_SUCCESS, 0); + Okay = WaitForWork(&ServerReadContext, 100); + ok_bool_false(Okay, "WaitForWork returned"); + CheckClientQuota(ClientHandle, 0, 0); + Okay = CheckWritePipe(&ClientWriteContext, ClientHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ClientWriteContext, STATUS_SUCCESS, 1); + Okay = WaitForWork(&ServerReadContext, 100); + CheckPipeContext(&ServerReadContext, STATUS_SUCCESS, 0); + ok_eq_uint(ReadBuffer[0], 'X'); + CheckClientQuota(ClientHandle, 0, 1); CheckServerQuota(ServerHandle, 1, 0); + Okay = CheckReadPipe(&ServerReadContext, ServerHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ServerReadContext, STATUS_SUCCESS, 1); + ok_eq_uint(ReadBuffer[0], 'F'); + CheckClientQuota(ClientHandle, 0, 0); CheckServerQuota(ServerHandle, 0, 0); + + /** Disconnect server with pending read on client */ + WriteBuffer[0] = 'G'; + ReadBuffer[0] = 'X'; + Okay = CheckReadPipe(&ClientReadContext, ClientHandle, ReadBuffer, 1, 100); + ok_bool_false(Okay, "CheckReadPipe returned"); + CheckServerQuota(ServerHandle, 0, 1); + Status = NpDisconnectPipe(ServerHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + Okay = WaitForWork(&ClientReadContext, 100); + CheckPipeContext(&ClientReadContext, STATUS_PIPE_DISCONNECTED, 0); + ok_eq_uint(ReadBuffer[0], 'X'); + + /* Read from server when disconnected */ + Okay = CheckReadPipe(&ServerReadContext, ServerHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ServerReadContext, STATUS_PIPE_DISCONNECTED, 0); + + /* Write to server when disconnected */ + Okay = CheckWritePipe(&ServerWriteContext, ServerHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ServerWriteContext, STATUS_PIPE_DISCONNECTED, 0); + + /* Read from client when disconnected */ + Okay = CheckReadPipe(&ClientReadContext, ClientHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ClientReadContext, STATUS_PIPE_DISCONNECTED, 0); + + /* Write to client when disconnected */ + Okay = CheckWritePipe(&ClientWriteContext, ClientHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ClientWriteContext, STATUS_PIPE_DISCONNECTED, 0); + Status = ObCloseHandle(ClientHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + + /* Restore the connection */ + Okay = CheckListenPipe(&ListenContext, ServerHandle, 100); + ok_bool_false(Okay, "CheckListenPipe returned"); + Okay = CheckConnectPipe(&ConnectContext, PipePath, ClientSynchronous, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_SUCCESS); + Okay = WaitForWork(&ListenContext, 100); + ok_bool_true(Okay, "WaitForWork returned"); + ok_eq_hex(ListenContext.Listen.Status, STATUS_SUCCESS); + ClientHandle = ConnectContext.Connect.ClientHandle; + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /** Close server with pending read on client */ + WriteBuffer[0] = 'H'; + ReadBuffer[0] = 'X'; + Okay = CheckReadPipe(&ClientReadContext, ClientHandle, ReadBuffer, 1, 100); + ok_bool_false(Okay, "CheckReadPipe returned"); + Status = ObCloseHandle(ServerHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + Okay = WaitForWork(&ClientReadContext, 100); + CheckPipeContext(&ClientReadContext, STATUS_PIPE_BROKEN, 0); + ok_eq_uint(ReadBuffer[0], 'X'); + + /* Read from client when closed */ + Okay = CheckReadPipe(&ClientReadContext, ClientHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ClientReadContext, STATUS_PIPE_BROKEN, 0); + + /* Write to client when closed */ + Okay = CheckWritePipe(&ClientWriteContext, ClientHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ClientWriteContext, STATUS_PIPE_CLOSING, 0); + Status = ObCloseHandle(ClientHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + + /* Restore the connection */ + Status = MakeServer(&ServerHandle, PipePath, ServerSynchronous); + ok_eq_hex(Status, STATUS_SUCCESS); + Okay = CheckConnectPipe(&ConnectContext, PipePath, ClientSynchronous, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_SUCCESS); + ClientHandle = ConnectContext.Connect.ClientHandle; + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /** Close client with pending read on server */ + WriteBuffer[0] = 'I'; + ReadBuffer[0] = 'X'; + Okay = CheckReadPipe(&ServerReadContext, ServerHandle, ReadBuffer, 1, 100); + ok_bool_false(Okay, "CheckReadPipe returned"); + Status = ObCloseHandle(ClientHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + Okay = WaitForWork(&ServerReadContext, 100); + CheckPipeContext(&ServerReadContext, STATUS_PIPE_BROKEN, 0); + ok_eq_uint(ReadBuffer[0], 'X'); + + /* Read from server when closed */ + Okay = CheckReadPipe(&ServerReadContext, ServerHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ServerReadContext, STATUS_PIPE_BROKEN, 0); + + /* Write to server when closed */ + Okay = CheckWritePipe(&ServerWriteContext, ServerHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ServerWriteContext, STATUS_PIPE_CLOSING, 0); + Status = ObCloseHandle(ServerHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + + /* Restore the connection */ + Status = MakeServer(&ServerHandle, PipePath, ServerSynchronous); + ok_eq_hex(Status, STATUS_SUCCESS); + Okay = CheckConnectPipe(&ConnectContext, PipePath, ClientSynchronous, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_SUCCESS); + ClientHandle = ConnectContext.Connect.ClientHandle; + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /** Write to server and disconnect, then read from client */ + WriteBuffer[0] = 'J'; + ReadBuffer[0] = 'X'; + Okay = CheckWritePipe(&ServerWriteContext, ServerHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ServerWriteContext, STATUS_SUCCESS, 1); + CheckServerQuota(ServerHandle, 0, 1); CheckClientQuota(ClientHandle, 1, 0); + Status = NpDisconnectPipe(ServerHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + NpQueryPipe(ClientHandle, STATUS_PIPE_DISCONNECTED); + CheckServer(ServerHandle, FILE_PIPE_DISCONNECTED_STATE); + Okay = CheckReadPipe(&ClientReadContext, ClientHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ClientReadContext, STATUS_PIPE_DISCONNECTED, 0); + ok_eq_uint(ReadBuffer[0], 'X'); + Okay = CheckReadPipe(&ClientReadContext, ClientHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ClientReadContext, STATUS_PIPE_DISCONNECTED, 0); + Status = ObCloseHandle(ClientHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + + /* Restore the connection */ + Okay = CheckListenPipe(&ListenContext, ServerHandle, 100); + ok_bool_false(Okay, "CheckListenPipe returned"); + Okay = CheckConnectPipe(&ConnectContext, PipePath, ClientSynchronous, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_SUCCESS); + Okay = WaitForWork(&ListenContext, 100); + ok_bool_true(Okay, "WaitForWork returned"); + ok_eq_hex(ListenContext.Listen.Status, STATUS_SUCCESS); + ClientHandle = ConnectContext.Connect.ClientHandle; + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /** Write to server and close, then read from client */ + WriteBuffer[0] = 'K'; + ReadBuffer[0] = 'X'; + Okay = CheckWritePipe(&ServerWriteContext, ServerHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ServerWriteContext, STATUS_SUCCESS, 1); + CheckServerQuota(ServerHandle, 0, 1); CheckClientQuota(ClientHandle, 1, 0); + Status = ObCloseHandle(ServerHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + NpCheckClientPipe(ClientHandle, + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, + MAX_INSTANCES, 1, + IN_QUOTA, 1, + OUT_QUOTA, OUT_QUOTA, + FILE_PIPE_CLOSING_STATE); + Okay = CheckReadPipe(&ClientReadContext, ClientHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ClientReadContext, STATUS_SUCCESS, 1); + ok_eq_uint(ReadBuffer[0], 'K'); + Okay = CheckReadPipe(&ClientReadContext, ClientHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ClientReadContext, STATUS_PIPE_BROKEN, 0); + Status = ObCloseHandle(ClientHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + + /* Restore the connection */ + Status = MakeServer(&ServerHandle, PipePath, ServerSynchronous); + ok_eq_hex(Status, STATUS_SUCCESS); + Okay = CheckConnectPipe(&ConnectContext, PipePath, ClientSynchronous, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_SUCCESS); + ClientHandle = ConnectContext.Connect.ClientHandle; + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + + /** Write to client and close, then read from server */ + WriteBuffer[0] = 'L'; + ReadBuffer[0] = 'X'; + Okay = CheckWritePipe(&ClientWriteContext, ClientHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ClientWriteContext, STATUS_SUCCESS, 1); + CheckClientQuota(ClientHandle, 0, 1); CheckServerQuota(ServerHandle, 1, 0); + Status = ObCloseHandle(ClientHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + NpCheckServerPipe(ServerHandle, + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, + MAX_INSTANCES, 1, + IN_QUOTA, 1, + OUT_QUOTA, OUT_QUOTA, + FILE_PIPE_CLOSING_STATE); + Okay = CheckReadPipe(&ServerReadContext, ServerHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ServerReadContext, STATUS_SUCCESS, 1); + ok_eq_uint(ReadBuffer[0], 'L'); + Okay = CheckReadPipe(&ServerReadContext, ServerHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ServerReadContext, STATUS_PIPE_BROKEN, 0); + Status = ObCloseHandle(ServerHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + + /* Restore the connection */ + Status = MakeServer(&ServerHandle, PipePath, ServerSynchronous); + ok_eq_hex(Status, STATUS_SUCCESS); + Okay = CheckConnectPipe(&ConnectContext, PipePath, ClientSynchronous, 100); + ok_bool_true(Okay, "CheckConnectPipe returned"); + ok_eq_hex(ConnectContext.Connect.Status, STATUS_SUCCESS); + ClientHandle = ConnectContext.Connect.ClientHandle; + CheckClient(ClientHandle, FILE_PIPE_CONNECTED_STATE); + CheckServer(ServerHandle, FILE_PIPE_CONNECTED_STATE); + + /** Write to client and disconnect server, then read from server */ + WriteBuffer[0] = 'M'; + ReadBuffer[0] = 'X'; + Okay = CheckWritePipe(&ClientWriteContext, ClientHandle, WriteBuffer, 1, 100); + CheckPipeContext(&ClientWriteContext, STATUS_SUCCESS, 1); + CheckClientQuota(ClientHandle, 0, 1); CheckServerQuota(ServerHandle, 1, 0); + Status = NpDisconnectPipe(ServerHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + NpQueryPipe(ClientHandle, STATUS_PIPE_DISCONNECTED); + CheckServer(ServerHandle, FILE_PIPE_DISCONNECTED_STATE); + Okay = CheckReadPipe(&ServerReadContext, ServerHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ServerReadContext, STATUS_PIPE_DISCONNECTED, 0); + ok_eq_uint(ReadBuffer[0], 'X'); + Okay = CheckReadPipe(&ServerReadContext, ServerHandle, ReadBuffer, 1, 100); + CheckPipeContext(&ServerReadContext, STATUS_PIPE_DISCONNECTED, 0); + Status = ObCloseHandle(ClientHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + + Status = ObCloseHandle(ServerHandle, KernelMode); + ok_eq_hex(Status, STATUS_SUCCESS); + + FinishWorkerThread(&ServerWriteContext); + FinishWorkerThread(&ServerReadContext); + FinishWorkerThread(&ClientWriteContext); + FinishWorkerThread(&ClientReadContext); + FinishWorkerThread(&ListenContext); + FinishWorkerThread(&ConnectContext); +} + +START_TEST(NpfsReadWrite) +{ + PKTHREAD Thread; + READ_WRITE_TEST_CONTEXT TestContext; + + TestContext.PipePath = DEVICE_NAMED_PIPE L"\\KmtestNpfsReadWriteTestPipe"; + + TestContext.ServerSynchronous = TRUE; + TestContext.ClientSynchronous = TRUE; + Thread = KmtStartThread(TestReadWrite, &TestContext); + KmtFinishThread(Thread, NULL); + + TestContext.ServerSynchronous = FALSE; + TestContext.ClientSynchronous = TRUE; + Thread = KmtStartThread(TestReadWrite, &TestContext); + KmtFinishThread(Thread, NULL); + + TestContext.ServerSynchronous = TRUE; + TestContext.ClientSynchronous = FALSE; + Thread = KmtStartThread(TestReadWrite, &TestContext); + KmtFinishThread(Thread, NULL); + + TestContext.ServerSynchronous = FALSE; + TestContext.ClientSynchronous = FALSE; + Thread = KmtStartThread(TestReadWrite, &TestContext); + KmtFinishThread(Thread, NULL); +} Propchange: trunk/rostests/kmtests/npfs/NpfsReadWrite.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rostests/kmtests/npfs/npfs.h URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/npfs/npfs.h?rev=6…
============================================================================== --- trunk/rostests/kmtests/npfs/npfs.h (added) +++ trunk/rostests/kmtests/npfs/npfs.h [iso-8859-1] Wed Apr 9 18:00:33 2014 @@ -0,0 +1,225 @@ +/* + * PROJECT: ReactOS kernel-mode tests + * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory + * PURPOSE: Kernel-Mode Test Suite NPFS helper declarations + * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org> + */ + +#ifndef _KMTEST_NPFS_H_ +#define _KMTEST_NPFS_H_ + +#define DEVICE_NAMED_PIPE L"\\Device\\NamedPipe" + +#define BYTE_STREAM FILE_PIPE_BYTE_STREAM_MODE +C_ASSERT(FILE_PIPE_BYTE_STREAM_MODE == FILE_PIPE_BYTE_STREAM_TYPE); +#define MESSAGE FILE_PIPE_MESSAGE_MODE +C_ASSERT(FILE_PIPE_MESSAGE_MODE == FILE_PIPE_MESSAGE_TYPE); +#define QUEUE FILE_PIPE_QUEUE_OPERATION +#define COMPLETE FILE_PIPE_COMPLETE_OPERATION +#define INBOUND FILE_PIPE_INBOUND +#define OUTBOUND FILE_PIPE_OUTBOUND +#define DUPLEX FILE_PIPE_FULL_DUPLEX + +NTSTATUS +NpCreatePipeEx( + OUT PHANDLE ServerHandle, + IN PCWSTR PipePath, + IN ULONG ReadMode, + IN ULONG CompletionMode, + IN ULONG NamedPipeType, + IN ULONG ShareAccess, + IN ULONG MaximumInstances, + IN ULONG InboundQuota, + IN ULONG OutboundQuota, + IN ACCESS_MASK DesiredAccess, + IN ULONG Disposition, + IN ULONG CreateOptions, + IN PLARGE_INTEGER DefaultTimeout OPTIONAL); + +NTSTATUS +NpCreatePipe( + OUT PHANDLE ServerHandle, + IN PCWSTR PipePath, + IN ULONG ReadMode, + IN ULONG CompletionMode, + IN ULONG NamedPipeType, + IN ULONG NamedPipeConfiguration, + IN ULONG MaximumInstances, + IN ULONG InboundQuota, + IN ULONG OutboundQuota); + +NTSTATUS +NpOpenPipeEx( + OUT PHANDLE ClientHandle, + IN PCWSTR PipePath, + IN ACCESS_MASK DesiredAccess, + IN ULONG ShareAccess, + IN ULONG Disposition, + IN ULONG CreateOptions); + +NTSTATUS +NpOpenPipe( + OUT PHANDLE ClientHandle, + IN PCWSTR PipePath, + IN ULONG NamedPipeConfiguration); + +NTSTATUS +NpControlPipe( + IN HANDLE PipeHandle, + IN ULONG FsControlCode, + IN PVOID InputBuffer, + IN ULONG InputBufferLength); + +#define NpListenPipe(ServerHandle) NpControlPipe(ServerHandle, FSCTL_PIPE_LISTEN, NULL, 0) +#define NpDisconnectPipe(ServerHandle) NpControlPipe(ServerHandle, FSCTL_PIPE_DISCONNECT, NULL, 0) + +NTSTATUS +NpWaitPipe( + IN PCWSTR PipeName, + IN PLARGE_INTEGER Timeout); + +NTSTATUS +NpReadPipe( + IN HANDLE PipeHandle, + OUT PVOID Buffer, + IN ULONG BufferSize, + OUT PULONG_PTR BytesRead); + +NTSTATUS +NpWritePipe( + IN HANDLE PipeHandle, + IN const VOID *Buffer, + IN ULONG BufferSize, + OUT PULONG_PTR BytesWritten); + +#define NpCheckServerPipe(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps) \ + NpCheckServerPipe__(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps, __FILE__, __LINE__) + +#define NpCheckServerPipe__(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps, file, line) \ + NpCheckServerPipe_(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps, file ":" KMT_STRINGIZE(line)) + +VOID +NpCheckServerPipe_( + IN HANDLE ServerHandle, + /* PipeInformation */ + IN ULONG ReadMode, + IN ULONG CompletionMode, + /* PipeLocalInformation */ + IN ULONG NamedPipeType, + IN ULONG NamedPipeConfiguration, + IN ULONG MaximumInstances, + IN ULONG CurrentInstances, + IN ULONG InboundQuota, + IN ULONG ReadDataAvailable, + IN ULONG OutboundQuota, + IN ULONG WriteQuotaAvailable, + IN ULONG NamedPipeState, + /* PipeRemoteInformation */ + /* */ + IN PCSTR FileAndLine); + +#define NpCheckClientPipe(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps) \ + NpCheckClientPipe__(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps, __FILE__, __LINE__) + +#define NpCheckClientPipe__(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps, file, line) \ + NpCheckClientPipe_(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps, file ":" KMT_STRINGIZE(line)) + +VOID +NpCheckClientPipe_( + IN HANDLE ClientHandle, + /* PipeInformation */ + IN ULONG ReadMode, + IN ULONG CompletionMode, + /* PipeLocalInformation */ + IN ULONG NamedPipeType, + IN ULONG NamedPipeConfiguration, + IN ULONG MaximumInstances, + IN ULONG CurrentInstances, + IN ULONG InboundQuota, + IN ULONG ReadDataAvailable, + IN ULONG OutboundQuota, + IN ULONG WriteQuotaAvailable, + IN ULONG NamedPipeState, + /* PipeRemoteInformation */ + /* */ + IN PCSTR FileAndLine); + +#define NpQueryPipe(h, es) \ + NpQueryPipe__(h, es, __FILE__, __LINE__) + +#define NpQueryPipe__(h, es, file, line) \ + NpQueryPipe_(h, es, file ":" KMT_STRINGIZE(line)) + +VOID +NpQueryPipe_( + IN HANDLE Handle, + IN NTSTATUS ExpectedStatus, + IN PCSTR FileAndLine); + + +struct _THREAD_CONTEXT; +typedef VOID (WORK_FUNCTION)(IN OUT struct _THREAD_CONTEXT *); +typedef WORK_FUNCTION *PWORK_FUNCTION; + +typedef struct _THREAD_CONTEXT +{ + volatile PWORK_FUNCTION Work; + volatile union + { + struct + { + PCWSTR PipePath; + BOOLEAN ClientSynchronous; + HANDLE ClientHandle; + NTSTATUS Status; + } Connect; + struct + { + HANDLE ServerHandle; + NTSTATUS Status; + } Listen; + struct + { + HANDLE PipeHandle; + PVOID Buffer; + ULONG BufferSize; + ULONG_PTR BytesTransferred; + NTSTATUS Status; + } ReadWrite; + }; + KEVENT ThreadDoneEvent; + KEVENT StartWorkEvent; + KEVENT WorkCompleteEvent; + PKTHREAD Thread; +} THREAD_CONTEXT, *PTHREAD_CONTEXT; + +VOID +StartWorkerThread( + OUT PTHREAD_CONTEXT Context); + +VOID +FinishWorkerThread( + IN PTHREAD_CONTEXT Context); + +BOOLEAN +WaitForWork( + IN PTHREAD_CONTEXT Context, + IN ULONG MilliSeconds); + +BOOLEAN +TriggerWork( + IN PTHREAD_CONTEXT Context, + IN ULONG MilliSeconds); + + +PKTHREAD +KmtStartThread( + IN PKSTART_ROUTINE StartRoutine, + IN PVOID StartContext OPTIONAL); + +VOID +KmtFinishThread( + IN PKTHREAD Thread OPTIONAL, + IN PKEVENT Event OPTIONAL); + +#endif /* !defined _KMTEST_NPFS_H_ */ Propchange: trunk/rostests/kmtests/npfs/npfs.h ------------------------------------------------------------------------------ svn:eol-style = native
10 years, 8 months
1
0
0
0
[hbelusca] 62694: [CONTROL] - Remove undeeded files. - Fully convert the app to UNICODE. - Code cleanup.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Wed Apr 9 12:29:57 2014 New Revision: 62694 URL:
http://svn.reactos.org/svn/reactos?rev=62694&view=rev
Log: [CONTROL] - Remove undeeded files. - Fully convert the app to UNICODE. - Code cleanup. Removed: trunk/reactos/base/applications/control/control.dsp trunk/reactos/base/applications/control/control.dsw trunk/reactos/base/applications/control/control.h Modified: trunk/reactos/base/applications/control/CMakeLists.txt trunk/reactos/base/applications/control/control.c Modified: trunk/reactos/base/applications/control/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/control/…
============================================================================== --- trunk/reactos/base/applications/control/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/control/CMakeLists.txt [iso-8859-1] Wed Apr 9 12:29:57 2014 @@ -1,5 +1,5 @@ add_executable(control control.c control.rc) set_module_type(control win32gui UNICODE) -add_importlibs(control advapi32 shell32 msvcrt kernel32) +add_importlibs(control advapi32 shell32 user32 msvcrt kernel32) add_cd_file(TARGET control DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/applications/control/control.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/control/…
============================================================================== --- trunk/reactos/base/applications/control/control.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/control/control.c [iso-8859-1] Wed Apr 9 12:29:57 2014 @@ -6,154 +6,182 @@ * Colin Finck (mail(a)colinfinck.de) */ -#include "control.h" +#include <stdio.h> -static const TCHAR szWindowClass[] = _T("DummyControlClass"); +#define WIN32_NO_STATUS -HANDLE hProcessHeap; -HINSTANCE hInst; +#include <windef.h> +#include <winbase.h> +#include <winuser.h> +#include <winreg.h> +#include <shellapi.h> -static -INT -OpenShellFolder(LPTSTR lpFolderCLSID) +#include "resource.h" + +#define MAX_VALUE_NAME 16383 + +/* + * Macro for calling "rundll32.exe" + * According to MSDN, ShellExecute returns a value greater than 32 + * if the operation was successful. + */ +#define RUNDLL(param) \ + ((INT_PTR)ShellExecuteW(NULL, L"open", L"rundll32.exe", (param), NULL, SW_SHOWDEFAULT) > 32) + +VOID +WINAPI +Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow); + +static INT +OpenShellFolder(LPWSTR lpFolderCLSID) { - TCHAR szParameters[MAX_PATH]; + WCHAR szParameters[MAX_PATH]; - /* Open a shell folder using "explorer.exe". - The passed CLSID's are all subfolders of the "Control Panel" shell folder. */ - _tcscpy(szParameters, _T("/n,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}")); - _tcscat(szParameters, lpFolderCLSID); + /* + * Open a shell folder using "explorer.exe". The passed CLSIDs + * are all subfolders of the "Control Panel" shell folder. + */ + wcscpy(szParameters, L"/n,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"); + wcscat(szParameters, lpFolderCLSID); - return (INT_PTR)ShellExecute(NULL, - _T("open"), - _T("explorer.exe"), - szParameters, - NULL, - SW_SHOWDEFAULT) > 32; + return (INT_PTR)ShellExecuteW(NULL, + L"open", + L"explorer.exe", + szParameters, + NULL, + SW_SHOWDEFAULT) > 32; } -static -INT -RunControlPanel(LPTSTR lpCmd) +static INT +RunControlPanel(LPCWSTR lpCmd) { - TCHAR szParameters[MAX_PATH]; + /* + * Old method: + * + WCHAR szParameters[MAX_PATH]; + wcscpy(szParameters, L"shell32.dll,Control_RunDLL "); + wcscat(szParameters, lpCmd); + return RUNDLL(szParameters); + */ - _tcscpy(szParameters, _T("shell32.dll,Control_RunDLL ")); - _tcscat(szParameters, lpCmd); - - return RUNDLL(szParameters); + /* New method: */ + Control_RunDLLW(GetDesktopWindow(), 0, lpCmd, SW_SHOW); + return 1; } -int +INT WINAPI -_tWinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nCmdShow) +wWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPWSTR lpCmdLine, + INT nCmdShow) { HKEY hKey; - hInst = hInstance; - hProcessHeap = GetProcessHeap(); - /* Show the control panel window if no argument or "panel" was passed */ - if(lpCmdLine[0] == 0 || !_tcsicmp(lpCmdLine, _T("panel"))) - return OpenShellFolder(_T("")); + if (*lpCmdLine == 0 || !_wcsicmp(lpCmdLine, L"panel")) + return OpenShellFolder(L""); /* Check one of the built-in control panel handlers */ - if (!_tcsicmp(lpCmdLine, _T("admintools"))) return OpenShellFolder(_T("\\::{D20EA4E1-3957-11d2-A40B-0C5020524153}")); - else if (!_tcsicmp(lpCmdLine, _T("color"))) return RunControlPanel(_T("desk.cpl")); /* TODO: Switch to the "Apperance" tab */ - else if (!_tcsicmp(lpCmdLine, _T("date/time"))) return RunControlPanel(_T("timedate.cpl")); - else if (!_tcsicmp(lpCmdLine, _T("desktop"))) return RunControlPanel(_T("desk.cpl")); - else if (!_tcsicmp(lpCmdLine, _T("folders"))) return RUNDLL(_T("shell32.dll,Options_RunDLL")); - else if (!_tcsicmp(lpCmdLine, _T("fonts"))) return OpenShellFolder(_T("\\::{D20EA4E1-3957-11d2-A40B-0C5020524152}")); - else if (!_tcsicmp(lpCmdLine, _T("infrared"))) return RunControlPanel(_T("irprops.cpl")); - else if (!_tcsicmp(lpCmdLine, _T("international"))) return RunControlPanel(_T("intl.cpl")); - else if (!_tcsicmp(lpCmdLine, _T("keyboard"))) return RunControlPanel(_T("main.cpl @1")); - else if (!_tcsicmp(lpCmdLine, _T("mouse"))) return RunControlPanel(_T("main.cpl @0")); - else if (!_tcsicmp(lpCmdLine, _T("netconnections"))) return OpenShellFolder(_T("\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}")); - else if (!_tcsicmp(lpCmdLine, _T("netware"))) return RunControlPanel(_T("nwc.cpl")); - else if (!_tcsicmp(lpCmdLine, _T("ports"))) return RunControlPanel(_T("sysdm.cpl")); /* TODO: Switch to the "Computer Name" tab */ - else if (!_tcsicmp(lpCmdLine, _T("printers"))) return OpenShellFolder(_T("\\::{2227A280-3AEA-1069-A2DE-08002B30309D}")); - else if (!_tcsicmp(lpCmdLine, _T("scannercamera"))) return OpenShellFolder(_T("\\::{E211B736-43FD-11D1-9EFB-0000F8757FCD}")); - else if (!_tcsicmp(lpCmdLine, _T("schedtasks"))) return OpenShellFolder(_T("\\::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}")); - else if (!_tcsicmp(lpCmdLine, _T("telephony"))) return RunControlPanel(_T("telephon.cpl")); - else if (!_tcsicmp(lpCmdLine, _T("userpasswords"))) return RunControlPanel(_T("nusrmgr.cpl")); /* Graphical User Account Manager */ - else if (!_tcsicmp(lpCmdLine, _T("userpasswords2"))) return RUNDLL(_T("netplwiz.dll,UsersRunDll")); /* Dialog based advanced User Account Manager */ + if (!_wcsicmp(lpCmdLine, L"admintools")) return OpenShellFolder(L"\\::{D20EA4E1-3957-11d2-A40B-0C5020524153}"); + else if (!_wcsicmp(lpCmdLine, L"color")) return RunControlPanel(L"desk.cpl"); /* TODO: Switch to the "Apperance" tab */ + else if (!_wcsicmp(lpCmdLine, L"date/time")) return RunControlPanel(L"timedate.cpl"); + else if (!_wcsicmp(lpCmdLine, L"desktop")) return RunControlPanel(L"desk.cpl"); + else if (!_wcsicmp(lpCmdLine, L"folders")) return RUNDLL(L"shell32.dll,Options_RunDLL"); + else if (!_wcsicmp(lpCmdLine, L"fonts")) return OpenShellFolder(L"\\::{D20EA4E1-3957-11d2-A40B-0C5020524152}"); + else if (!_wcsicmp(lpCmdLine, L"infrared")) return RunControlPanel(L"irprops.cpl"); + else if (!_wcsicmp(lpCmdLine, L"international")) return RunControlPanel(L"intl.cpl"); + else if (!_wcsicmp(lpCmdLine, L"keyboard")) return RunControlPanel(L"main.cpl @1"); + else if (!_wcsicmp(lpCmdLine, L"mouse")) return RunControlPanel(L"main.cpl @0"); + else if (!_wcsicmp(lpCmdLine, L"netconnections")) return OpenShellFolder(L"\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}"); + else if (!_wcsicmp(lpCmdLine, L"netware")) return RunControlPanel(L"nwc.cpl"); + else if (!_wcsicmp(lpCmdLine, L"ports")) return RunControlPanel(L"sysdm.cpl"); /* TODO: Switch to the "Computer Name" tab */ + else if (!_wcsicmp(lpCmdLine, L"printers")) return OpenShellFolder(L"\\::{2227A280-3AEA-1069-A2DE-08002B30309D}"); + else if (!_wcsicmp(lpCmdLine, L"scannercamera")) return OpenShellFolder(L"\\::{E211B736-43FD-11D1-9EFB-0000F8757FCD}"); + else if (!_wcsicmp(lpCmdLine, L"schedtasks")) return OpenShellFolder(L"\\::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}"); + else if (!_wcsicmp(lpCmdLine, L"telephony")) return RunControlPanel(L"telephon.cpl"); + else if (!_wcsicmp(lpCmdLine, L"userpasswords")) return RunControlPanel(L"nusrmgr.cpl"); /* Graphical User Account Manager */ + else if (!_wcsicmp(lpCmdLine, L"userpasswords2")) return RUNDLL(L"netplwiz.dll,UsersRunDll"); /* Dialog based advanced User Account Manager */ /* It is none of them, so look for a handler in the registry */ - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, - _T("Software\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls"), - 0, - KEY_QUERY_VALUE, - &hKey) == ERROR_SUCCESS) + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"Software\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls", + 0, + KEY_QUERY_VALUE, + &hKey) == ERROR_SUCCESS) { DWORD dwIndex; - for(dwIndex = 0; ; ++dwIndex) + for (dwIndex = 0; ; ++dwIndex) { DWORD dwDataSize; DWORD dwValueSize = MAX_VALUE_NAME; - TCHAR szValueName[MAX_VALUE_NAME]; + WCHAR szValueName[MAX_VALUE_NAME]; /* Get the value name and data size */ - if(RegEnumValue(hKey, - dwIndex, - szValueName, - &dwValueSize, - 0, - NULL, - NULL, - &dwDataSize) != ERROR_SUCCESS) + if (RegEnumValueW(hKey, + dwIndex, + szValueName, + &dwValueSize, + 0, + NULL, + NULL, + &dwDataSize) != ERROR_SUCCESS) + { break; + } /* Check if the parameter is the value name */ - if(!_tcsicmp(lpCmdLine, szValueName)) + if (!_wcsicmp(lpCmdLine, szValueName)) { - LPTSTR pszData; - - /* Allocate memory for the data plus two more characters, so we can quote the file name if required */ - pszData = (LPTSTR) HeapAlloc(hProcessHeap, - 0, - dwDataSize + 2 * sizeof(TCHAR)); + /* + * Allocate memory for the data plus two more characters, + * so we can quote the file name if required. + */ + LPWSTR pszData; + pszData = HeapAlloc(GetProcessHeap(), + 0, + dwDataSize + 2 * sizeof(WCHAR)); ++pszData; - /* This value is the one we are looking for, so get the data. It is the path to a .cpl file */ - if(RegQueryValueEx(hKey, - szValueName, - 0, - NULL, - (LPBYTE)pszData, - &dwDataSize) == ERROR_SUCCESS) + /* + * This value is the one we are looking for, so get the data. + * It is the path to a .cpl file. + */ + if (RegQueryValueExW(hKey, + szValueName, + 0, + NULL, + (LPBYTE)pszData, + &dwDataSize) == ERROR_SUCCESS) { INT nReturnValue; /* Quote the file name if required */ - if(*pszData != '\"') + if (*pszData != L'\"') { - *(--pszData) = '\"'; - pszData[dwDataSize / sizeof(TCHAR)] = '\"'; - pszData[(dwDataSize / sizeof(TCHAR)) + 1] = 0; + *(--pszData) = L'\"'; + pszData[dwDataSize / sizeof(WCHAR)] = L'\"'; + pszData[(dwDataSize / sizeof(WCHAR)) + 1] = 0; } nReturnValue = RunControlPanel(pszData); - HeapFree(hProcessHeap, - 0, - pszData); + HeapFree(GetProcessHeap(), 0, pszData); RegCloseKey(hKey); return nReturnValue; } - HeapFree(hProcessHeap, - 0, - pszData); + HeapFree(GetProcessHeap(), 0, pszData); } } RegCloseKey(hKey); } - /* It's none of the known parameters, so interpret the parameter as the file name of a control panel applet */ + /* + * It's none of the known parameters, so interpret the parameter + * as the file name of a control panel applet. + */ return RunControlPanel(lpCmdLine); } Removed: trunk/reactos/base/applications/control/control.dsp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/control/…
============================================================================== --- trunk/reactos/base/applications/control/control.dsp [iso-8859-1] (original) +++ trunk/reactos/base/applications/control/control.dsp (removed) @@ -1,137 +0,0 @@ -# Microsoft Developer Studio Project File - Name="control" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=control - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "control.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "control.mak" CFG="control - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "control - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "control - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "control - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "../../../" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x407 /d "NDEBUG" -# ADD RSC /l 0x407 /d "NDEBUG" /d "MS_COMPILER" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib /nologo /subsystem:windows /machine:I386 -# Begin Custom Build -TargetDir=.\Release -TargetName=control -InputPath=.\Release\control.exe -InputName=control -SOURCE="$(InputPath)" - -"C:\reactos\reactos\$(InputName).EXE" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\$(TargetName).EXE C:\reactos\reactos - -# End Custom Build - -!ELSEIF "$(CFG)" == "control - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "UNICODE" /D "_UNICODE" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x407 /d "_DEBUG" -# ADD RSC /l 0x407 /d "_DEBUG" /d "MS_COMPILER" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# Begin Custom Build -TargetDir=.\Debug -TargetName=control -InputPath=.\Debug\control.exe -InputName=control -SOURCE="$(InputPath)" - -"C:\reactos\reactos\$(InputName).EXE" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\$(TargetName).EXE C:\reactos\reactos - -# End Custom Build - -!ENDIF - -# Begin Target - -# Name "control - Win32 Release" -# Name "control - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\control.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# Begin Source File - -SOURCE=.\config.ico -# End Source File -# Begin Source File - -SOURCE=.\control.rc -# End Source File -# End Group -# End Target -# End Project Removed: trunk/reactos/base/applications/control/control.dsw URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/control/…
============================================================================== --- trunk/reactos/base/applications/control/control.dsw [iso-8859-1] (original) +++ trunk/reactos/base/applications/control/control.dsw (removed) @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "control"=.\control.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - Removed: trunk/reactos/base/applications/control/control.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/control/…
============================================================================== --- trunk/reactos/base/applications/control/control.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/control/control.h (removed) @@ -1,23 +0,0 @@ -/* - * PROJECT: ReactOS System Control Panel - * FILE: base/applications/control/control.h - * PURPOSE: ReactOS System Control Panel - * PROGRAMMERS: Gero Kuehn (reactos.filter(a)gkware.com) - * Colin Finck (mail(a)colinfinck.de) - */ - -#include <tchar.h> -#include <windef.h> -#include <winbase.h> -#include <winuser.h> -#include <winreg.h> -#include <shellapi.h> - -#include "resource.h" - -#define CCH_UINT_MAX 11 -#define MAX_VALUE_NAME 16383 - -/* Macro for calling "rundll32.exe" - According to MSDN, ShellExecute returns a value greater than 32 if the operation was successful. */ -#define RUNDLL(param) ((INT_PTR)ShellExecute(NULL, _T("open"), _T("rundll32.exe"), (param), NULL, SW_SHOWDEFAULT) > 32)
10 years, 8 months
1
0
0
0
[dquintana] 62693: [RSHELL] * Code cleanups and formatting. * Remove the logging wrappers. If I need them again I'll bring them back. * Try to fix a few "glitches" in the hot-tracking.
by dquintana@svn.reactos.org
Author: dquintana Date: Wed Apr 9 11:45:02 2014 New Revision: 62693 URL:
http://svn.reactos.org/svn/reactos?rev=62693&view=rev
Log: [RSHELL] * Code cleanups and formatting. * Remove the logging wrappers. If I need them again I'll bring them back. * Try to fix a few "glitches" in the hot-tracking. Removed: branches/shell-experiments/base/shell/rshell/logging/ branches/shell-experiments/base/shell/rshell/wraplog.cpp branches/shell-experiments/base/shell/rshell/wraplog.h Modified: branches/shell-experiments/base/shell/rshell/CMakeLists.txt branches/shell-experiments/base/shell/rshell/CMenuBand.cpp branches/shell-experiments/base/shell/rshell/CMenuFocusManager.cpp branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp branches/shell-experiments/base/shell/rshell/CStartMenu.cpp Modified: branches/shell-experiments/base/shell/rshell/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
============================================================================== --- branches/shell-experiments/base/shell/rshell/CMakeLists.txt [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/rshell/CMakeLists.txt [iso-8859-1] Wed Apr 9 11:45:02 2014 @@ -16,11 +16,6 @@ CMergedFolder.cpp CStartMenu.cpp misc.cpp - wraplog.cpp - logging/CMenuBandWrap.cpp - logging/CMenuDeskBarWrap.cpp - logging/CMenuSiteWrap.cpp - logging/CStartMenuSiteWrap.cpp ${CMAKE_CURRENT_BINARY_DIR}/rshell.def) add_library(rshell SHARED ${SOURCE}) Modified: branches/shell-experiments/base/shell/rshell/CMenuBand.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
============================================================================== --- branches/shell-experiments/base/shell/rshell/CMenuBand.cpp [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/rshell/CMenuBand.cpp [iso-8859-1] Wed Apr 9 11:45:02 2014 @@ -30,7 +30,7 @@ #undef UNIMPLEMENTED -#define UNIMPLEMENTED DbgPrint("%s is UNIMPLEMENTED!\n", __FUNCTION__) +#define UNIMPLEMENTED TRACE("%s is UNIMPLEMENTED!\n", __FUNCTION__) extern "C" HRESULT WINAPI CMenuBand_Constructor(REFIID riid, LPVOID *ppv) @@ -130,7 +130,7 @@ HWND hwnd, DWORD dwFlags) { - DbgPrint("CMenuBand::SetMenu called, hmenu=%p; hwnd=%p, flags=%x\n", hmenu, hwnd, dwFlags); + TRACE("CMenuBand::SetMenu called, hmenu=%p; hwnd=%p, flags=%x\n", hmenu, hwnd, dwFlags); BOOL created = FALSE; @@ -752,7 +752,7 @@ if (m_hotBar == tb && m_hotItem == id) return S_FALSE; - DbgPrint("Hot item changed from %p %p, to %p %p\n", m_hotBar, m_hotItem, tb, id); + TRACE("Hot item changed from %p %p, to %p %p\n", m_hotBar, m_hotItem, tb, id); _KillPopupTimers(); @@ -769,7 +769,7 @@ HRESULT CMenuBand::_ChangePopupItem(CMenuToolbarBase * tb, INT id) { - DbgPrint("Popup item changed from %p %p, to %p %p\n", m_popupBar, m_popupItem, tb, id); + TRACE("Popup item changed from %p %p, to %p %p\n", m_popupBar, m_popupItem, tb, id); m_popupBar = tb; m_popupItem = id; @@ -818,7 +818,6 @@ { HRESULT hr; - if (m_dwFlags & SMINIT_VERTICAL) { switch (changeType) @@ -839,7 +838,7 @@ else { // In horizontal menubars, left/right are equivalent to vertical's up/down - switch(changeType) + switch (changeType) { case VK_LEFT: hr = _KeyboardItemChange(VK_UP); @@ -878,8 +877,6 @@ return S_OK; return m_subMenuParent->OnSelect(changeType); } - - return S_OK; } HRESULT CMenuBand::_CancelCurrentPopup() @@ -909,11 +906,6 @@ #endif if (FAILED_UNEXPECTEDLY(hr)) return hr; -#if WRAP_MENUSITE - hr = CMenuSite_Wrapper(pBandSite, IID_PPV_ARG(IBandSite, &pBandSite)); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; -#endif #if USE_SYSTEM_MENUDESKBAR hr = CoCreateInstance(CLSID_MenuDeskBar, @@ -925,11 +917,6 @@ #endif if (FAILED_UNEXPECTEDLY(hr)) return hr; -#if WRAP_MENUDESKBAR - hr = CMenuDeskBar_Wrapper(pDeskBar, IID_PPV_ARG(IDeskBar, &pDeskBar)); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; -#endif hr = pDeskBar->SetClient(pBandSite); if (FAILED_UNEXPECTEDLY(hr)) @@ -946,7 +933,7 @@ return hr; m_subMenuChild = popup; - + if (m_subMenuParent) IUnknown_SetSite(popup, m_subMenuParent); else Modified: branches/shell-experiments/base/shell/rshell/CMenuFocusManager.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
============================================================================== --- branches/shell-experiments/base/shell/rshell/CMenuFocusManager.cpp [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/rshell/CMenuFocusManager.cpp [iso-8859-1] Wed Apr 9 11:45:02 2014 @@ -26,8 +26,9 @@ #include "CMenuToolbars.h" #include "CMenuBand.h" -#undef _ASSERT -#define _ASSERT(x) DbgAssert(!!(x), __FILE__, __LINE__, #x) +#if DBG +# undef _ASSERT +# define _ASSERT(x) DbgAssert(!!(x), __FILE__, __LINE__, #x) bool DbgAssert(bool x, const char * filename, int line, const char * expr) { @@ -55,6 +56,10 @@ } return x; } +#else +# undef _ASSERT +# define _ASSERT(x) (!!(x)) +#endif WINE_DEFAULT_DEBUG_CHANNEL(CMenuFocus); @@ -192,10 +197,6 @@ entry.mb->_DisableMouseTrack(bDisable); } } - //else - //{ - // continue; - //} } m_mouseTrackDisabled = lastDisable; } @@ -208,13 +209,13 @@ { ::SetCapture(child); m_captureHwnd = child; - DbgPrint("MouseTrack is now capturing %p\n", child); + TRACE("MouseTrack is now capturing %p\n", child); } else { ::ReleaseCapture(); m_captureHwnd = NULL; - DbgPrint("MouseTrack is now off\n"); + TRACE("MouseTrack is now off\n"); } } @@ -249,7 +250,7 @@ LRESULT CMenuFocusManager::ProcessMouseMove(MSG* msg) { HWND child; - int iHitTestResult; + int iHitTestResult = -1; POINT pt2 = { GET_X_LPARAM(msg->lParam), GET_Y_LPARAM(msg->lParam) }; ClientToScreen(msg->hwnd, &pt2); @@ -271,37 +272,18 @@ StackEntry * entry = NULL; IsTrackedWindow(child, &entry); - if (m_hwndUnderMouse != child) - { - WCHAR cn[1024]; - GetClassName(child, cn, 1023); - DbgPrint("Mouse moved to %p (%S)\n", child, cn); - - if (!entry) - { - if (m_entryUnderMouse) - { - m_entryUnderMouse->mb->_ChangeHotItem(NULL, -1, HICF_MOUSE); - } - if (cCapture == m_captureHwnd) - SetCapture(NULL); - } - - } - + BOOL isTracking = FALSE; if (entry) { ScreenToClient(child, &pt); iHitTestResult = SendMessageW(child, TB_HITTEST, 0, (LPARAM) &pt); - - BOOL isTracking = entry->mb->_IsTracking(); - - if (iHitTestResult >= 0 && - SendMessage(child, WM_USER_ISTRACKEDITEM, iHitTestResult, 0) == S_FALSE) - { - DbgPrint("Hot item tracking detected a change (capture=%p)...\n", m_captureHwnd); + isTracking = entry->mb->_IsTracking(); + + if (SendMessage(child, WM_USER_ISTRACKEDITEM, iHitTestResult, 0) == S_FALSE) + { + TRACE("Hot item tracking detected a change (capture=%p)...\n", m_captureHwnd); DisableMouseTrack(NULL, FALSE); - if (m_current->type == TrackedMenuEntry) + if (isTracking && iHitTestResult>=0 && m_current->type == TrackedMenuEntry) SendMessage(entry->hwnd, WM_CANCELMODE, 0, 0); PostMessage(child, WM_USER_CHANGETRACKEDITEM, iHitTestResult, isTracking); if (m_current->type == TrackedMenuEntry) @@ -309,14 +291,24 @@ } } + if (m_entryUnderMouse != entry) + { + // Mouse moved away from a tracked window + if (m_entryUnderMouse) + { + m_entryUnderMouse->mb->_ChangeHotItem(NULL, -1, HICF_MOUSE); + } + if (cCapture == m_captureHwnd) + SetCapture(NULL); + } + if (m_hwndUnderMouse != child) { if (entry) { + // Mouse moved to a tracked window if (m_current->type == MenuPopupEntry) { - //SetCapture(child); - ScreenToClient(child, &pt2); SendMessage(child, WM_MOUSEMOVE, msg->wParam, MAKELPARAM(pt2.x, pt2.y)); } @@ -446,12 +438,12 @@ { if (m_current->type == TrackedMenuEntry) { - DbgPrint("Entering MSGFILTER hook...\n"); + TRACE("Entering MSGFILTER hook...\n"); m_hMsgFilterHook = SetWindowsHookEx(WH_MSGFILTER, s_MsgFilterHook, NULL, m_threadId); } else { - DbgPrint("Entering GETMESSAGE hook...\n"); + TRACE("Entering GETMESSAGE hook...\n"); m_hGetMsgHook = SetWindowsHookEx(WH_GETMESSAGE, s_GetMsgHook, NULL, m_threadId); } return S_OK; @@ -459,7 +451,7 @@ HRESULT CMenuFocusManager::RemoveHooks() { - DbgPrint("Removing all hooks...\n"); + TRACE("Removing all hooks...\n"); if (m_hMsgFilterHook) UnhookWindowsHookEx(m_hMsgFilterHook); if (m_hGetMsgHook) @@ -538,11 +530,19 @@ // When the mouse moves, it should set itself to the proper band SetCapture(m_current->hwnd); - //// FIXME: Debugging code, probably not right - //POINT pt2; - //GetCursorPos(&pt2); - //ScreenToClient(m_current->hwnd, &pt2); - //SendMessage(m_current->hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(pt2.x, pt2.y)); + if (old && old->type == TrackedMenuEntry) + { + // FIXME: Debugging code, probably not right + POINT pt2; + RECT rc2; + GetCursorPos(&pt2); + ScreenToClient(m_current->hwnd, &pt2); + GetClientRect(m_current->hwnd, &rc2); + if (PtInRect(&rc2, pt2)) + SendMessage(m_current->hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(pt2.x, pt2.y)); + else + SendMessage(m_current->hwnd, WM_MOUSELEAVE, 0, 0); + } } _ASSERT(!m_parent || m_parent->type != TrackedMenuEntry); Modified: branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
============================================================================== --- branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp [iso-8859-1] Wed Apr 9 11:45:02 2014 @@ -105,7 +105,7 @@ case -714: return S_FALSE; default: - DbgPrint("WM_NOTIFY unknown code %d, %d\n", hdr->code, hdr->idFrom); + TRACE("WM_NOTIFY unknown code %d, %d\n", hdr->code, hdr->idFrom); return S_OK; } return S_FALSE; @@ -151,7 +151,7 @@ if (m_disableMouseTrack != bDisable) { m_disableMouseTrack = bDisable; - DbgPrint("DisableMouseTrack %d\n", bDisable); + TRACE("DisableMouseTrack %d\n", bDisable); } return S_OK; } @@ -192,13 +192,13 @@ hdc = cdraw->nmcd.hdc; // The item with an active submenu gets the CHECKED flag. - isHot = m_hotBar == this && (int)cdraw->nmcd.dwItemSpec == m_hotItem; - isPopup = m_popupBar == this && (int)cdraw->nmcd.dwItemSpec == m_popupItem; + isHot = m_hotBar == this && (int) cdraw->nmcd.dwItemSpec == m_hotItem; + isPopup = m_popupBar == this && (int) cdraw->nmcd.dwItemSpec == m_popupItem; if (m_initFlags & SMINIT_VERTICAL) { // Remove HOT and CHECKED flags (will restore HOT if necessary) - cdraw->nmcd.uItemState &= ~(CDIS_HOT|CDIS_CHECKED); + cdraw->nmcd.uItemState &= ~(CDIS_HOT | CDIS_CHECKED); // Decide on the colors if (isHot || (m_hotItem < 0 && isPopup)) @@ -256,8 +256,8 @@ // TODO: Support RTL text modes by drawing a leftwards arrow aligned to the left of the control // "8" is the rightwards dropdown arrow in the Marlett font - WCHAR text[] = L"8"; - + WCHAR text [] = L"8"; + // Configure the font to draw with Marlett, keeping the current background color as-is SelectObject(cdraw->nmcd.hdc, m_marlett); SetBkMode(cdraw->nmcd.hdc, TRANSPARENT); @@ -356,7 +356,7 @@ HRESULT hr = SHGetImageList(shiml, IID_PPV_ARG(IImageList, &piml)); if (FAILED_UNEXPECTEDLY(hr)) { - SendMessageW(m_hwndToolbar, TB_SETIMAGELIST, 0, 0); + SendMessageW(m_hwndToolbar, TB_SETIMAGELIST, 0, 0); } else { @@ -464,7 +464,7 @@ *pMaxSize = m_idealSize; if (pIntegralSize) *pIntegralSize = m_itemSize; - + if (m_hasSizes) return S_OK; @@ -475,7 +475,7 @@ SendMessageW(m_hwndToolbar, TB_AUTOSIZE, 0, 0); SendMessageW(m_hwndToolbar, TB_GETMAXSIZE, 0, reinterpret_cast<LPARAM>(&m_idealSize)); SendMessageW(m_hwndToolbar, TB_GETIDEALSIZE, (m_initFlags & SMINIT_VERTICAL) != 0, reinterpret_cast<LPARAM>(&m_idealSize)); - + // Obtain the button size, to be used as the integral size DWORD size = SendMessageW(m_hwndToolbar, TB_GETBUTTONSIZE, 0, 0); m_itemSize.cx = GET_X_LPARAM(size); @@ -594,14 +594,14 @@ // and mouse tracking is disabled. if (m_disableMouseTrack && dwFlags & HICF_MOUSE) { - DbgPrint("Hot item change prevented by DisableMouseTrack\n"); + TRACE("Hot item change prevented by DisableMouseTrack\n"); return S_OK; } // Notify the toolbar if the hot-tracking left this toolbar if (m_hotBar == this && toolbar != this) { - SendMessage(m_hwndToolbar, TB_SETHOTITEM, (WPARAM)-1, 0); + SendMessage(m_hwndToolbar, TB_SETHOTITEM, (WPARAM) -1, 0); } m_hotBar = toolbar; @@ -620,7 +620,7 @@ SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &elapsed, 0); SetTimer(m_hwndToolbar, TIMERID_HOTTRACK, elapsed, NULL); m_timerEnabled = TRUE; - DbgPrint("SetTimer called with m_hotItem=%d\n", m_hotItem); + TRACE("SetTimer called with m_hotItem=%d\n", m_hotItem); } else if (m_isTrackingPopup) { @@ -676,6 +676,9 @@ if (m_hotBar != this) return S_FALSE; + if (index < 0) + return S_FALSE; + if (!SendMessage(m_hwndToolbar, TB_GETBUTTON, index, reinterpret_cast<LPARAM>(&btn))) return E_FAIL; @@ -691,14 +694,18 @@ HRESULT CMenuToolbarBase::ChangeTrackedItem(INT index, BOOL wasTracking) { TBBUTTON btn; + + if (index < 0) + { + m_isTrackingPopup = FALSE; + return m_menuBand->_ChangeHotItem(NULL, -1, HICF_MOUSE); + } + if (!SendMessage(m_hwndToolbar, TB_GETBUTTON, index, reinterpret_cast<LPARAM>(&btn))) return E_FAIL; - DbgPrint("Changing tracked item to %d...\n", index); m_isTrackingPopup = wasTracking; - m_menuBand->_ChangeHotItem(this, btn.idCommand, HICF_MOUSE); - - return S_OK; + return m_menuBand->_ChangeHotItem(this, btn.idCommand, HICF_MOUSE); } HRESULT CMenuToolbarBase::PopupSubMenu(UINT iItem, UINT index, IShellMenu* childShellMenu) @@ -747,7 +754,7 @@ if (!SendMessage(m_hwndToolbar, TB_GETITEMRECT, index, reinterpret_cast<LPARAM>(&rc))) return E_FAIL; - + POINT a = { rc.left, rc.top }; POINT b = { rc.right, rc.bottom }; @@ -772,6 +779,8 @@ m_menuBand->_ChangePopupItem(NULL, -1); m_isTrackingPopup = FALSE; + m_menuBand->_ChangeHotItem(NULL, -1, 0); + return S_OK; } @@ -790,28 +799,28 @@ if (m_disableMouseTrack) { *theResult = 1; - DbgPrint("Item click prevented by DisableMouseTrack\n"); + TRACE("Item click prevented by DisableMouseTrack\n"); return S_OK; } // If a button is clicked while a submenu was open, cancel the submenu. if (!(m_initFlags & SMINIT_VERTICAL) && m_isTrackingPopup) { - DbgPrint("OnCommand cancelled because it was tracking submenu.\n"); + TRACE("OnCommand cancelled because it was tracking submenu.\n"); return S_FALSE; } - + *theResult = 0; m_menuBand->_KillPopupTimers(); if (PopupItem(wParam) == S_OK) { - DbgPrint("PopupItem returned S_OK\n"); + TRACE("PopupItem returned S_OK\n"); return S_FALSE; } - DbgPrint("Executing...\n"); + TRACE("Executing...\n"); HRESULT hr = m_menuBand->_MenuItemHotTrack(MPOS_EXECUTE); @@ -882,7 +891,7 @@ { if (prev != btn.idCommand) { - DbgPrint("Setting Hot item to %d\n", index); + TRACE("Setting Hot item to %d\n", index); m_menuBand->_ChangeHotItem(this, index, 0); } return S_OK; @@ -901,7 +910,7 @@ if (prev != -1) { - DbgPrint("Setting Hot item to null\n"); + TRACE("Setting Hot item to null\n"); m_menuBand->_ChangeHotItem(NULL, -1, 0); } @@ -1031,7 +1040,7 @@ if (!(m_initFlags & SMINIT_VERTICAL)) { - DbgPrint("PopupItem non-vertical %d %d\n", index, iItem); + TRACE("PopupItem non-vertical %d %d\n", index, iItem); m_menuBand->_ChangeHotItem(this, iItem, 0); } @@ -1096,7 +1105,7 @@ if (!GetMenuItemInfoW(m_hmenu, i, TRUE, &info)) { - DbgPrint("Error obtaining info for menu item at pos=%d\n", i); + TRACE("Error obtaining info for menu item at pos=%d\n", i); continue; } @@ -1185,7 +1194,6 @@ { return ::GetSubMenu(m_hmenu, index) ? S_OK : S_FALSE; } - CMenuSFToolbar::CMenuSFToolbar(CMenuBand * menuBand) : CMenuToolbarBase(menuBand, TRUE), @@ -1350,11 +1358,6 @@ #endif if (FAILED_UNEXPECTEDLY(hr)) return hr; -#if WRAP_MENUBAND - hr = CMenuBand_Wrapper(shellMenu, IID_PPV_ARG(IShellMenu, &shellMenu)); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; -#endif m_menuBand->GetMenuInfo(&psmc, &uId, &uIdAncestor, &flags); Modified: branches/shell-experiments/base/shell/rshell/CStartMenu.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
============================================================================== --- branches/shell-experiments/base/shell/rshell/CStartMenu.cpp [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/rshell/CStartMenu.cpp [iso-8859-1] Wed Apr 9 11:45:02 2014 @@ -158,11 +158,6 @@ #endif if (FAILED_UNEXPECTEDLY(hr)) return hr; -#if WRAP_MENUBAND - hr = CMenuBand_Wrapper(pShellMenu, IID_PPV_ARG(IShellMenu, &pShellMenu)); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; -#endif hr = pShellMenu->Initialize(this, 0, ANCESTORDEFAULT, SMINIT_VERTICAL); @@ -298,51 +293,36 @@ #if USE_SYSTEM_MENUBAND hr = CoCreateInstance(CLSID_MenuBand, - NULL, - CLSCTX_INPROC_SERVER, - IID_PPV_ARG(IShellMenu, &pShellMenu)); + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARG(IShellMenu, &pShellMenu)); #else hr = CMenuBand_Constructor(IID_PPV_ARG(IShellMenu, &pShellMenu)); #endif if (FAILED_UNEXPECTEDLY(hr)) return hr; -#if WRAP_MENUBAND - hr = CMenuBand_Wrapper(pShellMenu, IID_PPV_ARG(IShellMenu, &pShellMenu)); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; -#endif #if USE_SYSTEM_MENUSITE hr = CoCreateInstance(CLSID_MenuBandSite, - NULL, - CLSCTX_INPROC_SERVER, - IID_PPV_ARG(IBandSite, &pBandSite)); + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARG(IBandSite, &pBandSite)); #else hr = CMenuSite_Constructor(IID_PPV_ARG(IBandSite, &pBandSite)); #endif if (FAILED_UNEXPECTEDLY(hr)) return hr; -#if WRAP_MENUSITE - hr = CMenuSite_Wrapper(pBandSite, IID_PPV_ARG(IBandSite, &pBandSite)); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; -#endif #if USE_SYSTEM_MENUDESKBAR hr = CoCreateInstance(CLSID_MenuDeskBar, - NULL, - CLSCTX_INPROC_SERVER, - IID_PPV_ARG(IDeskBar, &pDeskBar)); + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARG(IDeskBar, &pDeskBar)); #else hr = CMenuDeskBar_Constructor(IID_PPV_ARG(IDeskBar, &pDeskBar)); #endif if (FAILED_UNEXPECTEDLY(hr)) return hr; -#if WRAP_MENUDESKBAR - hr = CMenuDeskBar_Wrapper(pDeskBar, IID_PPV_ARG(IDeskBar, &pDeskBar)); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; -#endif CComObject<CShellMenuCallback> *pCallback; hr = CComObject<CShellMenuCallback>::CreateInstance(&pCallback); @@ -351,7 +331,7 @@ pCallback->AddRef(); // CreateInstance returns object with 0 ref count */ pCallback->Initialize(pShellMenu, pBandSite, pDeskBar); - pShellMenu->Initialize(pCallback, (UINT)-1, 0, SMINIT_TOPLEVEL | SMINIT_VERTICAL); + pShellMenu->Initialize(pCallback, (UINT) -1, 0, SMINIT_TOPLEVEL | SMINIT_VERTICAL); if (FAILED_UNEXPECTEDLY(hr)) return hr; Removed: branches/shell-experiments/base/shell/rshell/wraplog.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
============================================================================== --- branches/shell-experiments/base/shell/rshell/wraplog.cpp [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/rshell/wraplog.cpp (removed) @@ -1,159 +0,0 @@ -#include "precomp.h" -#include "wraplog.h" -#include <stdio.h> - -static INT openCount = 0; -static INT callLevel; -static FILE*log; - -static INT nTemps; -static CHAR strTemp[10][256]; - -void WrapLogOpen() -{ - if (openCount == 0) - { - log = fopen("C:\\RShellWrap.log", "w"); - nTemps = 0; - callLevel = 0; - } - openCount++; -} - -void WrapLogClose() -{ - openCount--; - if (openCount == 0) - { - fclose(log); - log = NULL; - } -} - -void __cdecl WrapLogPrint(_Printf_format_string_ const char* msg, ...) -{ - va_list args; - for (int i = 0; i < callLevel; i++) - fputs(" ", log); - va_start(args, msg); - vfprintf(log, msg, args); - va_end(args); - fflush(log); - nTemps = 0; -} - -void __cdecl WrapLogPre(_Printf_format_string_ const char* msg, ...) -{ - va_list args; - for (int i = 0; i < callLevel; i++) - fputs(" ", log); - fputs("pre: ", log); - va_start(args, msg); - vfprintf(log, msg, args); - va_end(args); - fflush(log); - nTemps = 0; -} - -void __cdecl WrapLogPost(_Printf_format_string_ const char* msg, ...) -{ - va_list args; - for (int i = 0; i < callLevel; i++) - fputs(" ", log); - fputs("post: ", log); - va_start(args, msg); - vfprintf(log, msg, args); - va_end(args); - fflush(log); - nTemps = 0; -} - -void __cdecl WrapLogEnter(_Printf_format_string_ const char* msg, ...) -{ - va_list args; - for (int i = 0; i < callLevel; i++) - fputs(" ", log); - fputs("CALL ", log); - va_start(args, msg); - vfprintf(log, msg, args); - va_end(args); - fflush(log); - callLevel++; - nTemps = 0; -} - -void __cdecl WrapLogExit(const char* msg, HRESULT code) -{ - //if (FAILED(code)) - // WrapLogPrint("RETURN %s = %08x\n", msg, code); - //else if (code == S_OK) - // WrapLogPrint("RETURN %s = S_OK\n", msg); - //else if (code == S_FALSE) - // WrapLogPrint("RETURN %s = S_FALSE\n", msg); - //else - // WrapLogPrint("RETURN %s = %d\n", msg, code); - if (FAILED(code)) - WrapLogPrint("RETURN %08x\n", code); - else if (code == S_OK) - WrapLogPrint("RETURN S_OK\n"); - else if (code == S_FALSE) - WrapLogPrint("RETURN S_FALSE\n"); - else - WrapLogPrint("RETURN %d\n", code); - callLevel--; -} - -template <class T> -LPSTR Wrap(const T& value); - -template <> -LPSTR Wrap<GUID>(REFGUID guid) -{ - LPSTR cStr = strTemp[nTemps++]; - StringCchPrintfA(cStr, _countof(strTemp[0]), - "{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}", - guid.Data1, guid.Data2, guid.Data3, - guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], - guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); - return cStr; -} - -template <> -LPSTR Wrap<RECT>(const RECT& rect) -{ - LPSTR cStr = strTemp[nTemps++]; - StringCchPrintfA(cStr, _countof(strTemp[0]), - "{L: %d, T: %d, R: %d, B: %d}", - rect.left, rect.top, rect.right, rect.bottom); - return cStr; -} - -template <> -LPSTR Wrap<OLECMD>(const OLECMD& cmd) -{ - LPSTR cStr = strTemp[nTemps++]; - StringCchPrintfA(cStr, _countof(strTemp[0]), - "{ID: %d, F: %d}", - cmd.cmdID, cmd.cmdf); - return cStr; -} - -template <> -LPSTR Wrap<MSG>(const MSG& msg) -{ - LPSTR cStr = strTemp[nTemps++]; - StringCchPrintfA(cStr, _countof(strTemp[0]), - "{HWND: %d, Code: %d, W: %p, L: %p, T: %d, P.X: %d, P.Y: %d}", - msg.hwnd, msg.message, msg.wParam, msg.lParam, msg.time, msg.pt.x, msg.pt.y); - return cStr; -} - -template <> -LPSTR Wrap<BANDSITEINFO>(const BANDSITEINFO& bsi) -{ - LPSTR cStr = strTemp[nTemps++]; - StringCchPrintfA(cStr, _countof(strTemp[0]), - "{dwMask: %08x, dwState: %08x, dwStyle: %08x}", - bsi.dwMask, bsi.dwState, bsi.dwStyle); - return cStr; -} Removed: branches/shell-experiments/base/shell/rshell/wraplog.h URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
============================================================================== --- branches/shell-experiments/base/shell/rshell/wraplog.h [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/rshell/wraplog.h (removed) @@ -1,11 +0,0 @@ -#pragma once - -void WrapLogOpen(); -void WrapLogClose(); -void __cdecl WrapLogPre(_Printf_format_string_ const char* msg, ...); -void __cdecl WrapLogPost(_Printf_format_string_ const char* msg, ...); -void __cdecl WrapLogEnter(_Printf_format_string_ const char* msg, ...); -void __cdecl WrapLogExit(const char* msg, HRESULT code); - -template <class T> -LPSTR Wrap(const T& value);
10 years, 8 months
1
0
0
0
[jimtabor] 62692: [NtUser|User32] - Start moving system control functions into Win32k. See CORE-7447. - Sync port from wine to update code before move and test.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Wed Apr 9 01:26:19 2014 New Revision: 62692 URL:
http://svn.reactos.org/svn/reactos?rev=62692&view=rev
Log: [NtUser|User32] - Start moving system control functions into Win32k. See CORE-7447. - Sync port from wine to update code before move and test. Modified: trunk/reactos/win32ss/user/ntuser/defwnd.c trunk/reactos/win32ss/user/ntuser/message.c trunk/reactos/win32ss/user/ntuser/window.h trunk/reactos/win32ss/user/user32/windows/defwnd.c Modified: trunk/reactos/win32ss/user/ntuser/defwnd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/defwnd…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/defwnd.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/defwnd.c [iso-8859-1] Wed Apr 9 01:26:19 2014 @@ -135,6 +135,72 @@ LRESULT FASTCALL +DefWndHandleWindowPosChanging(PWND pWnd, WINDOWPOS* Pos) +{ + POINT maxTrack, minTrack; + LONG style = pWnd->style; + + if (Pos->flags & SWP_NOSIZE) return 0; + if ((style & WS_THICKFRAME) || ((style & (WS_POPUP | WS_CHILD)) == 0)) + { + co_WinPosGetMinMaxInfo(pWnd, NULL, NULL, &minTrack, &maxTrack); + Pos->cx = min(Pos->cx, maxTrack.x); + Pos->cy = min(Pos->cy, maxTrack.y); + if (!(style & WS_MINIMIZE)) + { + if (Pos->cx < minTrack.x) Pos->cx = minTrack.x; + if (Pos->cy < minTrack.y) Pos->cy = minTrack.y; + } + } + else + { + Pos->cx = max(Pos->cx, 0); + Pos->cy = max(Pos->cy, 0); + } + return 0; +} + +LRESULT FASTCALL +DefWndHandleWindowPosChanged(PWND pWnd, WINDOWPOS* Pos) +{ + RECT Rect; + LONG style = pWnd->style; + + IntGetClientRect(pWnd, &Rect); + IntMapWindowPoints(pWnd, (style & WS_CHILD ? IntGetParent(pWnd) : NULL), (LPPOINT) &Rect, 2); + + if (! (Pos->flags & SWP_NOCLIENTMOVE)) + { + co_IntSendMessage(UserHMGetHandle(pWnd), WM_MOVE, 0, MAKELONG(Rect.left, Rect.top)); + } + + if (! (Pos->flags & SWP_NOCLIENTSIZE)) + { + WPARAM wp = SIZE_RESTORED; + + if (style & WS_MAXIMIZE) wp = SIZE_MAXIMIZED; + else if (style & WS_MINIMIZE) wp = SIZE_MINIMIZED; + + co_IntSendMessage(UserHMGetHandle(pWnd), WM_SIZE, wp, MAKELONG(Rect.right - Rect.left, Rect.bottom - Rect.top)); + } + return 0; +} + +VOID FASTCALL +UserDrawWindowFrame(HDC hdc, + RECTL *rect, + ULONG width, + ULONG height) +{ + HBRUSH hbrush = NtGdiSelectBrush( hdc, gpsi->hbrGray ); + NtGdiPatBlt( hdc, rect->left, rect->top, rect->right - rect->left - width, height, PATINVERT ); + NtGdiPatBlt( hdc, rect->left, rect->top + height, width, rect->bottom - rect->top - height, PATINVERT ); + NtGdiPatBlt( hdc, rect->left + width, rect->bottom - 1, rect->right - rect->left - width, -height, PATINVERT ); + NtGdiPatBlt( hdc, rect->right - 1, rect->top, -width, rect->bottom - rect->top - height, PATINVERT ); + NtGdiSelectBrush( hdc, hbrush ); +} + +LRESULT FASTCALL DefWndHandleSysCommand(PWND pWnd, WPARAM wParam, LPARAM lParam) { LRESULT lResult = 0; @@ -264,6 +330,7 @@ } case WM_SETREDRAW: + ERR("WM_SETREDRAW\n"); if (wParam) { if (!(Wnd->style & WS_VISIBLE)) @@ -282,6 +349,16 @@ } return 0; + case WM_WINDOWPOSCHANGING: + { + return (DefWndHandleWindowPosChanging(Wnd, (WINDOWPOS*)lParam)); + } + + case WM_WINDOWPOSCHANGED: + { + return (DefWndHandleWindowPosChanged(Wnd, (WINDOWPOS*)lParam)); + } + /* ReactOS only. */ case WM_CBT: { 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] Wed Apr 9 01:26:19 2014 @@ -134,7 +134,7 @@ { WM_SETTINGCHANGE, MMS_SIZE_LPARAMSZ, MMS_FLAG_READ }, { WM_COPYDATA, MMS_SIZE_SPECIAL, MMS_FLAG_READ }, { WM_COPYGLOBALDATA, MMS_SIZE_WPARAM, MMS_FLAG_READ }, - { WM_WINDOWPOSCHANGED, sizeof(WINDOWPOS), MMS_FLAG_READ }, + { WM_WINDOWPOSCHANGED, sizeof(WINDOWPOS), MMS_FLAG_READWRITE }, { WM_WINDOWPOSCHANGING, sizeof(WINDOWPOS), MMS_FLAG_READWRITE }, }; Modified: trunk/reactos/win32ss/user/ntuser/window.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/window…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/window.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/window.h [iso-8859-1] Wed Apr 9 01:26:19 2014 @@ -39,6 +39,7 @@ BOOL FASTCALL IntIsWindow(HWND hWnd); HWND* FASTCALL IntWinListChildren(PWND Window); VOID FASTCALL IntGetClientRect (PWND WindowObject, RECTL *Rect); +INT FASTCALL IntMapWindowPoints(PWND FromWnd, PWND ToWnd, LPPOINT lpPoints, UINT cPoints); BOOL FASTCALL IntIsChildWindow (PWND Parent, PWND Child); VOID FASTCALL IntUnlinkWindow(PWND Wnd); VOID FASTCALL IntLinkHwnd(PWND Wnd, HWND hWndPrev); Modified: trunk/reactos/win32ss/user/user32/windows/defwnd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
============================================================================== --- trunk/reactos/win32ss/user/user32/windows/defwnd.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/defwnd.c [iso-8859-1] Wed Apr 9 01:26:19 2014 @@ -153,7 +153,7 @@ } } - +#if 0 // Moved to Win32k VOID DefWndSetRedraw(HWND hWnd, WPARAM wParam) { @@ -177,7 +177,7 @@ } return; } - +#endif LRESULT DefWndHandleSetCursor(HWND hWnd, WPARAM wParam, LPARAM lParam, ULONG Style) @@ -277,8 +277,11 @@ rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; if (Style & WS_MAXIMIZEBOX) rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; - pt.x = rectWindow.left + (rect.right - rect.left) / 2; - pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2; + //pt.x = rectWindow.left + (rect.right - rect.left) / 2; + //pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2; + pt.x = (rect.right + rect.left) / 2; + pt.y = rect.top + GetSystemMetrics(SM_CYSIZE)/2; + ERR("SC_MOVE\n"); hittest = HTCAPTION; *capturePoint = pt; } @@ -293,9 +296,12 @@ switch(msg.message) { case WM_MOUSEMOVE: + //// Clamp the mouse position to the window rectangle when starting a window resize. + //pt.x = min( max( msg.pt.x, rectWindow.left ), rectWindow.right - 1 ); + //pt.y = min( max( msg.pt.y, rectWindow.top ), rectWindow.bottom - 1 ); + //// Breaks a win test. hittest = DefWndNCHitTest(hWnd, msg.pt); - if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT)) - hittest = 0; + if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT)) hittest = 0; break; case WM_LBUTTONUP: @@ -354,19 +360,8 @@ UserDrawWindowFrame(HDC hdc, const RECT *rect, ULONG width, ULONG height) { - static HBRUSH hDraggingRectBrush = NULL; - HBRUSH hbrush; - - if(!hDraggingRectBrush) - { - static HBITMAP hDraggingPattern = NULL; - const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA}; - - hDraggingPattern = CreateBitmap(8, 8, 1, 1, Pattern); - hDraggingRectBrush = CreatePatternBrush(hDraggingPattern); - } - - hbrush = SelectObject( hdc, hDraggingRectBrush ); + HBRUSH hbrush = SelectObject( hdc, gpsi->hbrGray ); + PatBlt( hdc, rect->left, rect->top, rect->right - rect->left - width, height, PATINVERT ); PatBlt( hdc, rect->left, rect->top + height, width, @@ -410,6 +405,8 @@ BOOL DragFullWindows = FALSE; HWND hWndParent = NULL; PWND Wnd; + WPARAM syscommand = wParam & 0xfff0; + HMONITOR mon = 0; Wnd = ValidateHwnd(hwnd); if (!Wnd) @@ -419,36 +416,32 @@ ExStyle = Wnd->ExStyle; iconic = (Style & WS_MINIMIZE) != 0; + // + // Show window contents while dragging the window, get flag from registry data. + // SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0); pt.x = GET_X_LPARAM(dwPoint); pt.y = GET_Y_LPARAM(dwPoint); capturePoint = pt; - if ((Style & WS_MAXIMIZE) || !IsWindowVisible(hwnd)) - { - return; - } - - thickframe = UserHasThickFrameStyle(Style, ExStyle) && !(Style & WS_MINIMIZE); - if ((wParam & 0xfff0) == SC_MOVE) - { - if (!hittest) - { - hittest = DefWndStartSizeMove(hwnd, Wnd, wParam, &capturePoint); - } - if (!hittest) - { - return; - } - } + TRACE("hwnd %p command %04lx, hittest %d, pos %d,%d\n", + hwnd, syscommand, hittest, pt.x, pt.y); + + if ((Style & WS_MAXIMIZE) || !IsWindowVisible(hwnd)) return; + + thickframe = UserHasThickFrameStyle(Style, ExStyle) && !iconic; + + if (syscommand == SC_MOVE) + { + ERR("SC_MOVE\n"); + if (!hittest) hittest = DefWndStartSizeMove(hwnd, Wnd, wParam, &capturePoint); + if (!hittest) return; + } else /* SC_SIZE */ - { - if (!thickframe) - { - return; - } - if (hittest && ((wParam & 0xfff0) != SC_MOUSEMENU)) + { + if (!thickframe) return; + if (hittest && (syscommand != SC_MOUSEMENU)) { hittest += (HTLEFT - WMSZ_LEFT); } @@ -462,23 +455,24 @@ return; } } - } + } /* Get min/max info */ WinPosGetMinMaxInfo(hwnd, NULL, NULL, &minTrack, &maxTrack); sizingRect = Wnd->rcWindow; + ERR("x %d y %d X %d Y %d\n",pt.x,pt.y,sizingRect.left,sizingRect.top); if (Style & WS_CHILD) - { + { hWndParent = GetParent(hwnd); MapWindowPoints( 0, hWndParent, (LPPOINT)&sizingRect, 2 ); unmodRect = sizingRect; GetClientRect(hWndParent, &mouseRect ); clipRect = mouseRect; MapWindowPoints(hWndParent, HWND_DESKTOP, (LPPOINT)&clipRect, 2); - } + } else - { + { if(!(ExStyle & WS_EX_TOPMOST)) { SystemParametersInfoW(SPI_GETWORKAREA, 0, &clipRect, 0); @@ -489,70 +483,72 @@ SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); clipRect = mouseRect; } + mon = MonitorFromPoint( pt, MONITOR_DEFAULTTONEAREST ); unmodRect = sizingRect; - } + } ClipCursor(&clipRect); origRect = sizingRect; if (ON_LEFT_BORDER(hittest)) - { + { mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x ); mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x ); - } + } else if (ON_RIGHT_BORDER(hittest)) - { + { mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x ); mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x ); - } + } if (ON_TOP_BORDER(hittest)) - { + { mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y ); mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y); - } + } else if (ON_BOTTOM_BORDER(hittest)) - { + { mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y ); mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y ); - } + } if (Style & WS_CHILD) - { + { MapWindowPoints( hWndParent, 0, (LPPOINT)&mouseRect, 2 ); - } - + } + + IntNotifyWinEvent( EVENT_SYSTEM_MOVESIZESTART, hwnd, OBJID_WINDOW, CHILDID_SELF, 0); SendMessageA( hwnd, WM_ENTERSIZEMOVE, 0, 0 ); NtUserxSetGUIThreadHandle(MSQ_STATE_MOVESIZE, hwnd); if (GetCapture() != hwnd) SetCapture( hwnd ); if (Style & WS_CHILD) - { + { /* Retrieve a default cache DC (without using the window style) */ hdc = GetDCEx(hWndParent, 0, DCX_CACHE); DesktopRgn = NULL; - } + } else - { + { hdc = GetDC( 0 ); DesktopRgn = CreateRectRgnIndirect(&clipRect); - } + } SelectObject(hdc, DesktopRgn); if( iconic ) /* create a cursor for dragging */ - { + { HICON hIcon = (HICON)GetClassLongPtrW(hwnd, GCL_HICON); if(!hIcon) hIcon = (HICON)SendMessageW( hwnd, WM_QUERYDRAGICON, 0, 0L); if( hIcon ) hDragCursor = CursorIconToCursor( hIcon, TRUE ); if( !hDragCursor ) iconic = FALSE; - } + } /* invert frame if WIN31_LOOK to indicate mouse click on caption */ if( !iconic && !DragFullWindows) - { + { UserDrawMovingFrame( hdc, &sizingRect, thickframe); - } + } for(;;) - { + { int dx = 0, dy = 0; if (!GetMessageW(&msg, 0, 0, 0)) break; @@ -564,12 +560,12 @@ ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break; if (msg.message == WM_PAINT) - { + { if(!iconic && !DragFullWindows) UserDrawMovingFrame( hdc, &sizingRect, thickframe ); UpdateWindow( msg.hwnd ); if(!iconic && !DragFullWindows) UserDrawMovingFrame( hdc, &sizingRect, thickframe ); continue; - } + } if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE)) { @@ -581,39 +577,56 @@ pt = msg.pt; if (msg.message == WM_KEYDOWN) switch(msg.wParam) - { + { case VK_UP: pt.y -= 8; break; case VK_DOWN: pt.y += 8; break; case VK_LEFT: pt.x -= 8; break; case VK_RIGHT: pt.x += 8; break; - } + } pt.x = max( pt.x, mouseRect.left ); - pt.x = min( pt.x, mouseRect.right ); + pt.x = min( pt.x, mouseRect.right - 1 ); pt.y = max( pt.y, mouseRect.top ); - pt.y = min( pt.y, mouseRect.bottom ); + pt.y = min( pt.y, mouseRect.bottom - 1 ); + + if (!hWndParent) + { + HMONITOR newmon; + MONITORINFO info; + + if ((newmon = MonitorFromPoint( pt, MONITOR_DEFAULTTONULL ))) + mon = newmon; + + info.cbSize = sizeof(info); + if (mon && GetMonitorInfoW( mon, &info )) + { + pt.x = max( pt.x, info.rcWork.left ); + pt.x = min( pt.x, info.rcWork.right - 1 ); + pt.y = max( pt.y, info.rcWork.top ); + pt.y = min( pt.y, info.rcWork.bottom - 1 ); + } + } dx = pt.x - capturePoint.x; dy = pt.y - capturePoint.y; if (dx || dy) - { + { if( !moved ) - { + { moved = TRUE; if( iconic ) /* ok, no system popup tracking */ - { + { hOldCursor = SetCursor(hDragCursor); ShowCursor( TRUE ); - } - } + } + } if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y ); else - { + { RECT newRect = unmodRect; - WPARAM wpSizingHit = 0; if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy ); if (ON_LEFT_BORDER(hittest)) newRect.left += dx; @@ -624,18 +637,26 @@ capturePoint = pt; /* determine the hit location */ - if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT) - wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT); unmodRect = newRect; - SendMessageA( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect ); + if (syscommand == SC_SIZE) + { + WPARAM wpSizingHit = 0; + + if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT) + wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT); + SendMessageW( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect ); + } + else + SendMessageW( hwnd, WM_MOVING, 0, (LPARAM)&newRect ); if (!iconic) { if(!DragFullWindows) UserDrawMovingFrame( hdc, &newRect, thickframe ); - else { - /* To avoid any deadlocks, all the locks on the windows + else + { /* To avoid any deadlocks, all the locks on the windows structures must be suspended before the SetWindowPos */ + //ERR("SWP 1\n"); SetWindowPos( hwnd, 0, newRect.left, newRect.top, newRect.right - newRect.left, newRect.bottom - newRect.top, @@ -643,21 +664,21 @@ } } sizingRect = newRect; - } - } - } + } + } + } ReleaseCapture(); ClipCursor(NULL); if( iconic ) - { + { if( moved ) /* restore cursors, show icon title later on */ - { + { ShowCursor( FALSE ); SetCursor( hOldCursor ); - } + } DestroyCursor( hDragCursor ); - } + } else if(!DragFullWindows) UserDrawMovingFrame( hdc, &sizingRect, thickframe ); @@ -671,6 +692,8 @@ DeleteObject(DesktopRgn); } } + //// This causes the mdi child window to jump up when it is moved. + //if (hWndParent) MapWindowPoints( 0, hWndParent, (POINT *)&sizingRect, 2 ); if (ISITHOOKED(WH_CBT)) { @@ -685,40 +708,45 @@ /* window moved or resized */ if (moved) - { + { /* if the moving/resizing isn't canceled call SetWindowPos * with the new position or the new size of the window */ if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) ) - { + { /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */ - if(!DragFullWindows) + if(!DragFullWindows )//|| iconic) breaks 2 win tests. + { + //ERR("SWP 2\n"); SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top, sizingRect.right - sizingRect.left, sizingRect.bottom - sizingRect.top, ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ); - } - else { /* restore previous size/position */ + } + } + else + { /* restore previous size/position */ if(DragFullWindows) + { + //ERR("SWP 3\n"); SetWindowPos( hwnd, 0, origRect.left, origRect.top, origRect.right - origRect.left, origRect.bottom - origRect.top, ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ); + } } - } + } if( IsWindow(hwnd) ) - if( Style & WS_MINIMIZE ) - { + if( iconic ) + { /* Single click brings up the system menu when iconized */ - if( !moved ) - { + { if( Style & WS_SYSMENU ) - SendMessageA( hwnd, WM_SYSCOMMAND, - SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y)); - } - } + SendMessageA( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y)); + } + } } @@ -858,7 +886,7 @@ return(0); } - +#if 0 // Move to Win32k LRESULT DefWndHandleWindowPosChanging(HWND hWnd, WINDOWPOS* Pos) { @@ -916,6 +944,7 @@ return 0; } +#endif /*********************************************************************** * DefWndControlColor @@ -1165,7 +1194,7 @@ { return (DefWndNCLButtonDblClk(hWnd, wParam, lParam)); } - +/* Moved to Win32k case WM_WINDOWPOSCHANGING: { return (DefWndHandleWindowPosChanging(hWnd, (WINDOWPOS*)lParam)); @@ -1175,7 +1204,7 @@ { return (DefWndHandleWindowPosChanged(hWnd, (WINDOWPOS*)lParam)); } - +*/ case WM_NCRBUTTONDOWN: return NC_HandleNCRButtonDown( hWnd, wParam, lParam ); @@ -1314,7 +1343,7 @@ } return (0); } -/* +/* Moved to Win32k case WM_SYNCPAINT: { HRGN hRgn; @@ -1845,7 +1874,7 @@ break; } -/* Move to win32k !*/ +/* Move to Win32k !*/ case WM_SHOWWINDOW: if (!lParam) break; // Call when it is necessary. case WM_SYNCPAINT: @@ -1853,6 +1882,8 @@ case WM_CLIENTSHUTDOWN: case WM_GETHOTKEY: case WM_SETHOTKEY: + case WM_WINDOWPOSCHANGING: + case WM_WINDOWPOSCHANGED: { LRESULT lResult; NtUserMessageCall( hWnd, Msg, wParam, lParam, (ULONG_PTR)&lResult, FNID_DEFWINDOWPROC, !bUnicode);
10 years, 8 months
1
0
0
0
[tfaber] 62691: [RTL] - Fix apitest crashes in RtlFindClearBits/RtlFindSetBits
by tfaber@svn.reactos.org
Author: tfaber Date: Tue Apr 8 21:04:47 2014 New Revision: 62691 URL:
http://svn.reactos.org/svn/reactos?rev=62691&view=rev
Log: [RTL] - Fix apitest crashes in RtlFindClearBits/RtlFindSetBits Modified: trunk/reactos/lib/rtl/bitmap.c Modified: trunk/reactos/lib/rtl/bitmap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/bitmap.c?rev=62691…
============================================================================== --- trunk/reactos/lib/rtl/bitmap.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/bitmap.c [iso-8859-1] Tue Apr 8 21:04:47 2014 @@ -101,6 +101,11 @@ BITMAP_INDEX Value, BitPos, Length; PBITMAP_BUFFER Buffer, MaxBuffer; + /* If we are already at the end, the length of the run is zero */ + ASSERT(StartingIndex <= BitMapHeader->SizeOfBitMap); + if (StartingIndex >= BitMapHeader->SizeOfBitMap) + return 0; + /* Calculate positions */ Buffer = BitMapHeader->Buffer + StartingIndex / _BITCOUNT; BitPos = StartingIndex & (_BITCOUNT - 1); @@ -149,6 +154,11 @@ { BITMAP_INDEX InvValue, BitPos, Length; PBITMAP_BUFFER Buffer, MaxBuffer; + + /* If we are already at the end, the length of the run is zero */ + ASSERT(StartingIndex <= BitMapHeader->SizeOfBitMap); + if (StartingIndex >= BitMapHeader->SizeOfBitMap) + return 0; /* Calculate positions */ Buffer = BitMapHeader->Buffer + StartingIndex / _BITCOUNT;
10 years, 8 months
1
0
0
0
[tfaber] 62690: [NTDLL_APITEST] - Add two test cases for RtlFindClearBits/RtlFindSetBits that crash on ROS
by tfaber@svn.reactos.org
Author: tfaber Date: Tue Apr 8 20:57:03 2014 New Revision: 62690 URL:
http://svn.reactos.org/svn/reactos?rev=62690&view=rev
Log: [NTDLL_APITEST] - Add two test cases for RtlFindClearBits/RtlFindSetBits that crash on ROS Modified: trunk/rostests/apitests/ntdll/RtlBitmap.c Modified: trunk/rostests/apitests/ntdll/RtlBitmap.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlBitmap.…
============================================================================== --- trunk/rostests/apitests/ntdll/RtlBitmap.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/RtlBitmap.c [iso-8859-1] Tue Apr 8 20:57:03 2014 @@ -409,6 +409,8 @@ ok_int(RtlFindClearBits(&BitMapHeader, 5, 64), 20); ok_int(RtlFindClearBits(&BitMapHeader, 9, 28), 27); ok_int(RtlFindClearBits(&BitMapHeader, 10, 0), -1); + Buffer[1] = 0xFF303F30; + ok_int(RtlFindClearBits(&BitMapHeader, 1, 56), 1); FreeGuarded(Buffer); } @@ -457,6 +459,7 @@ ok_int(RtlFindSetBits(&BitMapHeader, 5, 64), 20); ok_int(RtlFindSetBits(&BitMapHeader, 6, 57), 40); ok_int(RtlFindSetBits(&BitMapHeader, 7, 0), -1); + ok_int(RtlFindSetBits(&BitMapHeader, 1, 62), 1); FreeGuarded(Buffer); }
10 years, 8 months
1
0
0
0
[tfaber] 62689: [NTDLL_APITEST] - Use guarded memory for bitmap buffers in RtlBitmap test - Add a few tests that check for buffer boundaries (which would have spotted the issue fixed in r62591)
by tfaber@svn.reactos.org
Author: tfaber Date: Tue Apr 8 18:35:29 2014 New Revision: 62689 URL:
http://svn.reactos.org/svn/reactos?rev=62689&view=rev
Log: [NTDLL_APITEST] - Use guarded memory for bitmap buffers in RtlBitmap test - Add a few tests that check for buffer boundaries (which would have spotted the issue fixed in r62591) Modified: trunk/rostests/apitests/ntdll/RtlBitmap.c Modified: trunk/rostests/apitests/ntdll/RtlBitmap.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlBitmap.…
============================================================================== --- trunk/rostests/apitests/ntdll/RtlBitmap.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/RtlBitmap.c [iso-8859-1] Tue Apr 8 18:35:29 2014 @@ -2,7 +2,55 @@ #include <apitest.h> #define WIN32_NO_STATUS +#include <ndk/mmfuncs.h> #include <ndk/rtlfuncs.h> + +static +PVOID +AllocateGuarded( + _In_ SIZE_T SizeRequested) +{ + NTSTATUS Status; + SIZE_T Size = PAGE_ROUND_UP(SizeRequested + PAGE_SIZE); + PVOID VirtualMemory = NULL; + PCHAR StartOfBuffer; + + Status = NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory, 0, &Size, MEM_RESERVE, PAGE_NOACCESS); + + if (!NT_SUCCESS(Status)) + return NULL; + + Size -= PAGE_SIZE; + if (Size) + { + Status = NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory, 0, &Size, MEM_COMMIT, PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + Size = 0; + Status = NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); + return NULL; + } + } + + StartOfBuffer = VirtualMemory; + StartOfBuffer += Size - SizeRequested; + + return StartOfBuffer; +} + +static +VOID +FreeGuarded( + _In_ PVOID Pointer) +{ + NTSTATUS Status; + PVOID VirtualMemory = (PVOID)PAGE_ROUND_DOWN((SIZE_T)Pointer); + SIZE_T Size = 0; + + Status = NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); +} void Test_RtlFindMostSignificantBit(void) @@ -65,130 +113,155 @@ Test_RtlClearAllBits(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; - + ULONG *Buffer; + ULONG BufferSize = 2 * sizeof(*Buffer); + + Buffer = AllocateGuarded(BufferSize); RtlInitializeBitMap(&BitMapHeader, Buffer, 19); - memset(Buffer, 0xcc, sizeof(Buffer)); + memset(Buffer, 0xcc, BufferSize); RtlClearAllBits(&BitMapHeader); ok_hex(Buffer[0], 0x00000000); ok_hex(Buffer[1], 0xcccccccc); RtlInitializeBitMap(&BitMapHeader, Buffer, 0); - memset(Buffer, 0xcc, sizeof(Buffer)); + memset(Buffer, 0xcc, BufferSize); RtlClearAllBits(&BitMapHeader); ok_hex(Buffer[0], 0xcccccccc); ok_hex(Buffer[1], 0xcccccccc); + + RtlInitializeBitMap(&BitMapHeader, Buffer, 64); + memset(Buffer, 0xcc, BufferSize); + RtlClearAllBits(&BitMapHeader); + ok_hex(Buffer[0], 0x00000000); + ok_hex(Buffer[1], 0x00000000); + FreeGuarded(Buffer); } void Test_RtlSetAllBits(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; - + ULONG *Buffer; + ULONG BufferSize = 2 * sizeof(*Buffer); + + Buffer = AllocateGuarded(BufferSize); RtlInitializeBitMap(&BitMapHeader, Buffer, 19); - memset(Buffer, 0xcc, sizeof(Buffer)); + memset(Buffer, 0xcc, BufferSize); RtlSetAllBits(&BitMapHeader); ok_hex(Buffer[0], 0xffffffff); ok_hex(Buffer[1], 0xcccccccc); RtlInitializeBitMap(&BitMapHeader, Buffer, 0); - memset(Buffer, 0xcc, sizeof(Buffer)); + memset(Buffer, 0xcc, BufferSize); RtlSetAllBits(&BitMapHeader); ok_hex(Buffer[0], 0xcccccccc); ok_hex(Buffer[1], 0xcccccccc); + + RtlInitializeBitMap(&BitMapHeader, Buffer, 64); + memset(Buffer, 0xcc, BufferSize); + RtlSetAllBits(&BitMapHeader); + ok_hex(Buffer[0], 0xffffffff); + ok_hex(Buffer[1], 0xffffffff); + FreeGuarded(Buffer); } void Test_RtlClearBits(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; - + ULONG *Buffer; + ULONG BufferSize = 2 * sizeof(*Buffer); + + Buffer = AllocateGuarded(BufferSize); RtlInitializeBitMap(&BitMapHeader, Buffer, 19); - memset(Buffer, 0xff, sizeof(Buffer)); + memset(Buffer, 0xff, BufferSize); RtlClearBits(&BitMapHeader, 0, 0); ok_hex(Buffer[0], 0xffffffff); ok_hex(Buffer[1], 0xffffffff); - memset(Buffer, 0xff, sizeof(Buffer)); + memset(Buffer, 0xff, BufferSize); RtlClearBits(&BitMapHeader, 0, 1); ok_hex(Buffer[0], 0xfffffffe); ok_hex(Buffer[1], 0xffffffff); - memset(Buffer, 0xff, sizeof(Buffer)); + memset(Buffer, 0xff, BufferSize); RtlClearBits(&BitMapHeader, 21, 1); ok_hex(Buffer[0], 0xffdfffff); ok_hex(Buffer[1], 0xffffffff); - memset(Buffer, 0xff, sizeof(Buffer)); + memset(Buffer, 0xff, BufferSize); RtlClearBits(&BitMapHeader, 7, 9); ok_hex(Buffer[0], 0xffff007f); ok_hex(Buffer[1], 0xffffffff); - memset(Buffer, 0xff, sizeof(Buffer)); + memset(Buffer, 0xff, BufferSize); RtlClearBits(&BitMapHeader, 13, 22); ok_hex(Buffer[0], 0x00001fff); ok_hex(Buffer[1], 0xfffffff8); - memset(Buffer, 0xcc, sizeof(Buffer)); + memset(Buffer, 0xcc, BufferSize); RtlClearBits(&BitMapHeader, 3, 6); RtlClearBits(&BitMapHeader, 11, 5); RtlClearBits(&BitMapHeader, 21, 7); RtlClearBits(&BitMapHeader, 37, 4); ok_hex(Buffer[0], 0xc00c0404); ok_hex(Buffer[1], 0xcccccc0c); + FreeGuarded(Buffer); } void Test_RtlSetBits(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; - + ULONG *Buffer; + ULONG BufferSize = 2 * sizeof(*Buffer); + + Buffer = AllocateGuarded(BufferSize); RtlInitializeBitMap(&BitMapHeader, Buffer, 19); - memset(Buffer, 0x00, sizeof(Buffer)); + memset(Buffer, 0x00, BufferSize); RtlSetBits(&BitMapHeader, 0, 0); ok_hex(Buffer[0], 0x00000000); ok_hex(Buffer[1], 0x00000000); - memset(Buffer, 0x00, sizeof(Buffer)); + memset(Buffer, 0x00, BufferSize); RtlSetBits(&BitMapHeader, 0, 1); ok_hex(Buffer[0], 0x00000001); ok_hex(Buffer[1], 0x00000000); - memset(Buffer, 0x00, sizeof(Buffer)); + memset(Buffer, 0x00, BufferSize); RtlSetBits(&BitMapHeader, 21, 1); ok_hex(Buffer[0], 0x00200000); ok_hex(Buffer[1], 0x00000000); - memset(Buffer, 0x00, sizeof(Buffer)); + memset(Buffer, 0x00, BufferSize); RtlSetBits(&BitMapHeader, 7, 9); ok_hex(Buffer[0], 0x0000ff80); ok_hex(Buffer[1], 0x00000000); - memset(Buffer, 0x00, sizeof(Buffer)); + memset(Buffer, 0x00, BufferSize); RtlSetBits(&BitMapHeader, 13, 22); ok_hex(Buffer[0], 0xffffe000); ok_hex(Buffer[1], 0x00000007); - memset(Buffer, 0xcc, sizeof(Buffer)); + memset(Buffer, 0xcc, BufferSize); RtlSetBits(&BitMapHeader, 3, 6); RtlSetBits(&BitMapHeader, 11, 5); RtlSetBits(&BitMapHeader, 21, 7); RtlSetBits(&BitMapHeader, 37, 4); ok_hex(Buffer[0], 0xcfecfdfc); ok_hex(Buffer[1], 0xcccccdec); + FreeGuarded(Buffer); } void Test_RtlAreBitsClear(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; - + ULONG *Buffer; + + Buffer = AllocateGuarded(2 * sizeof(*Buffer)); RtlInitializeBitMap(&BitMapHeader, Buffer, 19); Buffer[0] = 0x00ff00ff; Buffer[1] = 0xc0cfc0cf; @@ -204,14 +277,18 @@ ok_hex(RtlAreBitsClear(&BitMapHeader, 24, 7), TRUE); ok_hex(RtlAreBitsClear(&BitMapHeader, 24, 8), FALSE); + RtlInitializeBitMap(&BitMapHeader, Buffer, 64); + ok_hex(RtlAreBitsClear(&BitMapHeader, 60, 4), FALSE); + FreeGuarded(Buffer); } void Test_RtlAreBitsSet(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; - + ULONG *Buffer; + + Buffer = AllocateGuarded(2 * sizeof(*Buffer)); RtlInitializeBitMap(&BitMapHeader, Buffer, 19); Buffer[0] = 0xff00ff00; Buffer[1] = 0x3F303F30; @@ -227,14 +304,18 @@ ok_hex(RtlAreBitsSet(&BitMapHeader, 24, 7), TRUE); ok_hex(RtlAreBitsSet(&BitMapHeader, 24, 8), FALSE); + RtlInitializeBitMap(&BitMapHeader, Buffer, 64); + ok_hex(RtlAreBitsSet(&BitMapHeader, 60, 4), FALSE); + FreeGuarded(Buffer); } void Test_RtlNumberOfSetBits(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; - + ULONG *Buffer; + + Buffer = AllocateGuarded(2 * sizeof(*Buffer)); Buffer[0] = 0xff00ff0f; Buffer[1] = 0x3F303F30; @@ -249,14 +330,19 @@ RtlInitializeBitMap(&BitMapHeader, Buffer, 56); ok_int(RtlNumberOfSetBits(&BitMapHeader), 30); + + RtlInitializeBitMap(&BitMapHeader, Buffer, 64); + ok_int(RtlNumberOfSetBits(&BitMapHeader), 36); + FreeGuarded(Buffer); } void Test_RtlNumberOfClearBits(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; - + ULONG *Buffer; + + Buffer = AllocateGuarded(2 * sizeof(*Buffer)); Buffer[0] = 0xff00fff0; Buffer[1] = 0x3F303F30; @@ -271,14 +357,19 @@ RtlInitializeBitMap(&BitMapHeader, Buffer, 56); ok_int(RtlNumberOfClearBits(&BitMapHeader), 26); + + RtlInitializeBitMap(&BitMapHeader, Buffer, 64); + ok_int(RtlNumberOfClearBits(&BitMapHeader), 28); + FreeGuarded(Buffer); } void Test_RtlFindClearBits(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; - + ULONG *Buffer; + + Buffer = AllocateGuarded(2 * sizeof(*Buffer)); Buffer[0] = 0x060F874D; Buffer[1] = 0x3F303F30; @@ -314,14 +405,20 @@ ok_int(RtlFindClearBits(&BitMapHeader, 4, 32), 11); ok_int(RtlFindClearBits(&BitMapHeader, 5, 32), 20); + RtlInitializeBitMap(&BitMapHeader, Buffer, 64); + ok_int(RtlFindClearBits(&BitMapHeader, 5, 64), 20); + ok_int(RtlFindClearBits(&BitMapHeader, 9, 28), 27); + ok_int(RtlFindClearBits(&BitMapHeader, 10, 0), -1); + FreeGuarded(Buffer); } void Test_RtlFindSetBits(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; - + ULONG *Buffer; + + Buffer = AllocateGuarded(2 * sizeof(*Buffer)); Buffer[0] = 0xF9F078B2; Buffer[1] = 0x3F303F30; @@ -356,14 +453,20 @@ ok_int(RtlFindSetBits(&BitMapHeader, 4, 32), 11); ok_int(RtlFindSetBits(&BitMapHeader, 5, 32), 20); + RtlInitializeBitMap(&BitMapHeader, Buffer, 64); + ok_int(RtlFindSetBits(&BitMapHeader, 5, 64), 20); + ok_int(RtlFindSetBits(&BitMapHeader, 6, 57), 40); + ok_int(RtlFindSetBits(&BitMapHeader, 7, 0), -1); + FreeGuarded(Buffer); } void Test_RtlFindClearBitsAndSet(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; - + ULONG *Buffer; + + Buffer = AllocateGuarded(2 * sizeof(*Buffer)); Buffer[0] = 0x060F874D; Buffer[1] = 0x3F303F30; @@ -401,14 +504,16 @@ ok_hex(Buffer[0], 0x6ff9f4d); ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 2, 12), 13); ok_hex(Buffer[0], 0x6ffff4d); + FreeGuarded(Buffer); } void Test_RtlFindSetBitsAndClear(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; - + ULONG *Buffer; + + Buffer = AllocateGuarded(2 * sizeof(*Buffer)); Buffer[0] = 0xF9F078B2; Buffer[1] = 0x3F303F30; @@ -446,16 +551,17 @@ ok_hex(Buffer[0], 0xf90060b2); ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 2, 12), 13); ok_hex(Buffer[0], 0xf90000b2); - + FreeGuarded(Buffer); } void Test_RtlFindNextForwardRunClear(void) { RTL_BITMAP BitMapHeader; - ULONG Buffer[2]; + ULONG *Buffer; ULONG Index; + Buffer = AllocateGuarded(2 * sizeof(*Buffer)); Buffer[0] = 0xF9F078B2; Buffer[1] = 0x3F303F30; @@ -477,6 +583,7 @@ ok_int(Index, 17); ok_int(RtlFindNextForwardRunClear(&BitMapHeader, 39, &Index), 0); ok_int(Index, 39); + FreeGuarded(Buffer); } void
10 years, 8 months
1
0
0
0
[hbelusca] 62688: [NTVDM] Fix few DPRINTs. The DOS program starting code (common for STANDALONE and OS-integrated modes) can be moved into a helper function later on.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Tue Apr 8 14:57:24 2014 New Revision: 62688 URL:
http://svn.reactos.org/svn/reactos?rev=62688&view=rev
Log: [NTVDM] Fix few DPRINTs. The DOS program starting code (common for STANDALONE and OS-integrated modes) can be moved into a helper function later on. Modified: branches/ntvdm/subsystems/ntvdm/ntvdm.c Modified: branches/ntvdm/subsystems/ntvdm/ntvdm.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/ntvdm.c?…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/ntvdm.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/ntvdm.c [iso-8859-1] Tue Apr 8 14:57:24 2014 @@ -394,9 +394,9 @@ return 0; } - DPRINT1("\n\n\nNTVDM - Starting '%s'...\n\n\n", CommandLine); - #endif + + DPRINT1("\n\n\nNTVDM - Starting...\n\n\n"); /* Initialize the console */ if (!ConsoleInit()) @@ -446,12 +446,14 @@ CommandInfo.Title = Title; CommandInfo.TitleLen = sizeof(Title); + /* Wait for the next available VDM */ if (!GetNextVDMCommand(&CommandInfo)) break; /* Start the process from the command line */ + DPRINT1("Starting '%s'...\n", AppName); if (!DosCreateProcess(AppName, 0)) { - DisplayMessage(L"Could not start program: %S", AppName); + DisplayMessage(L"Could not start '%S'", AppName); goto Cleanup; } @@ -465,28 +467,32 @@ #else /* Start the process from the command line */ + DPRINT1("Starting '%s'...\n", CommandLine); if (!DosCreateProcess(CommandLine, 0)) { - DisplayMessage(L"Could not start program: %S", CommandLine); + DisplayMessage(L"Could not start '%S'", CommandLine); goto Cleanup; } /* Start simulation */ EmulatorSimulate(); -#endif - /* Perform another screen refresh */ VgaRefreshDisplay(); + +#endif Cleanup: BiosCleanup(); EmulatorCleanup(); ConsoleCleanup(); +#ifndef STANDALONE + ExitVDM(FALSE, 0); +#endif + /* Quit the VDM */ DPRINT1("\n\n\nNTVDM - Exiting...\n\n\n"); - ExitVDM(FALSE, 0); return 0; }
10 years, 8 months
1
0
0
0
← Newer
1
...
37
38
39
40
41
42
43
...
50
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Results per page:
10
25
50
100
200