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
2025
April
March
February
January
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
November 2011
----- 2025 -----
April 2025
March 2025
February 2025
January 2025
----- 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
16 participants
274 discussions
Start a n
N
ew thread
[jimtabor] 54294: [Win32k] - Reposition IntCallWndProc/Ret so it call when sending to client.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Sat Nov 5 06:01:05 2011 New Revision: 54294 URL:
http://svn.reactos.org/svn/reactos?rev=54294&view=rev
Log: [Win32k] - Reposition IntCallWndProc/Ret so it call when sending to client. Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] Sat Nov 5 06:01:05 2011 @@ -1188,7 +1188,6 @@ Win32Thread = PsGetCurrentThreadWin32Thread(); - IntCallWndProc( Window, hWnd, Msg, wParam, lParam); if ( NULL != Win32Thread && Window->head.pti->MessageQueue == Win32Thread->MessageQueue) @@ -1198,6 +1197,8 @@ /* Never send messages to exiting threads */ RETURN( FALSE); } + + IntCallWndProc( Window, hWnd, Msg, wParam, lParam); /* See if this message type is present in the table */ MsgMemoryEntry = FindMsgMemory(Msg); @@ -1268,8 +1269,6 @@ while ((STATUS_TIMEOUT == Status) && (uFlags & SMTO_NOTIMEOUTIFNOTHUNG) && !MsqIsHung(Window->head.pti->MessageQueue)); // FIXME - Set window hung and add to a list. - - IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult); if (STATUS_TIMEOUT == Status) { @@ -1456,8 +1455,6 @@ Result); } } - - if (Window->head.pti->MessageQueue == Win32Thread->MessageQueue) {
13 years, 5 months
1
0
0
0
[jimtabor] 54293: [User32] - Fixed Dialog Ansi and color control brush acquisition. - Added stack protection for message recursion. Due to wine message bug when in dialog initialization. See bug 61...
by jimtabor@svn.reactos.org
Author: jimtabor Date: Sat Nov 5 05:18:57 2011 New Revision: 54293 URL:
http://svn.reactos.org/svn/reactos?rev=54293&view=rev
Log: [User32] - Fixed Dialog Ansi and color control brush acquisition. - Added stack protection for message recursion. Due to wine message bug when in dialog initialization. See bug 6126. - Miscellaneous fixups. Modified: trunk/reactos/dll/win32/user32/windows/dialog.c trunk/reactos/dll/win32/user32/windows/message.c Modified: trunk/reactos/dll/win32/user32/windows/dialog.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/d…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/dialog.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/dialog.c [iso-8859-1] Sat Nov 5 05:18:57 2011 @@ -45,6 +45,7 @@ #define SETDLGINFO(hwnd, info) SetWindowLongPtrW((hwnd), DWLP_ROS_DIALOGINFO, (LONG_PTR)(info)) #define GET_WORD(ptr) (*(WORD *)(ptr)) #define GET_DWORD(ptr) (*(DWORD *)(ptr)) +#define DLG_ISANSI 2 void WINAPI WinPosActivateOtherWindow(HWND hwnd); /* INTERNAL STRUCTS **********************************************************/ @@ -163,11 +164,11 @@ return NULL; } } - else + if (dlgInfo) { if (!(pWindow->state & WNDS_DIALOGWINDOW) || pWindow->fnid != FNID_DIALOG) { - ERR("Wrong window class for Dialog!\n"); + ERR("Wrong window class for Dialog! fnId 0x%x\n", pWindow->fnid); return NULL; } } @@ -264,11 +265,14 @@ /* Windows treats dialog control class ids 0-5 same way as 0x80-0x85 */ if ((id >= 0x80) && (id <= 0x85)) id -= 0x80; if (id <= 5) + { info->className = class_names[id]; + } else { info->className = NULL; /* FIXME: load other classes here? */ + ERR("Unknown built-in class id %04x\n", id ); } p += 2; } @@ -299,6 +303,11 @@ info->windowNameFree = FALSE; p += strlenW( info->windowName ) + 1; } + + TRACE(" %s %s %ld, %d, %d, %d, %d, %08x, %08x, %08x\n", + debugstr_w( info->className ), debugstr_w( info->windowName ), + info->id, info->x, info->y, info->cx, info->cy, + info->style, info->exStyle, info->helpId ); if (GET_WORD(p)) { @@ -339,6 +348,7 @@ info.style &= ~WS_BORDER; info.exStyle |= WS_EX_CLIENTEDGE; } + if (unicode) { hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY, @@ -1147,8 +1157,7 @@ { case WM_ERASEBKGND: { - HBRUSH brush = (HBRUSH)SendMessageW( hwnd, WM_CTLCOLORDLG, wParam, (LPARAM)hwnd ); - if (!brush) brush = (HBRUSH)DefWindowProcW( hwnd, WM_CTLCOLORDLG, wParam, (LPARAM)hwnd ); + HBRUSH brush = GetControlColor( hwnd, hwnd, (HDC)wParam, WM_CTLCOLORDLG); if (brush) { RECT rect; @@ -1247,12 +1256,17 @@ /*********************************************************************** * DEFDLG_Epilog */ -static LRESULT DEFDLG_Epilog(HWND hwnd, UINT msg, BOOL fResult) -{ - - // TODO: where's wine's WM_CTLCOLOR from? +static LRESULT DEFDLG_Epilog(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL fResult, BOOL fAnsi) +{ if ((msg >= WM_CTLCOLORMSGBOX && msg <= WM_CTLCOLORSTATIC) || - msg == WM_CTLCOLOR || msg == WM_COMPAREITEM || + msg == WM_CTLCOLOR) + { + if (fResult) return fResult; + + return fAnsi ? DefWindowProcA(hwnd, msg, wParam, lParam): + DefWindowProcW(hwnd, msg, wParam, lParam); + } + if ( msg == WM_COMPAREITEM || msg == WM_VKEYTOITEM || msg == WM_CHARTOITEM || msg == WM_QUERYDRAGICON || msg == WM_INITDIALOG) return fResult; @@ -1519,7 +1533,7 @@ * Also wine has one more parameter identifying weather it should call * the function with unicode or not */ - return DIALOG_CreateIndirect( hInstance, lpTemplate, hWndParent, lpDialogFunc, lParamInit , !Flags, FALSE ); + return DIALOG_CreateIndirect( hInstance, lpTemplate, hWndParent, lpDialogFunc, lParamInit , Flags == DLG_ISANSI ? FALSE : TRUE, FALSE ); } @@ -1535,7 +1549,7 @@ DLGPROC lpDialogFunc, LPARAM lParamInit) { - return CreateDialogIndirectParamAorW( hInstance, lpTemplate, hWndParent, lpDialogFunc, lParamInit, 2 ); + return CreateDialogIndirectParamAorW( hInstance, lpTemplate, hWndParent, lpDialogFunc, lParamInit, DLG_ISANSI); } @@ -1653,7 +1667,7 @@ return DefWindowProcA( hDlg, Msg, wParam, lParam ); } } - return DEFDLG_Epilog(hDlg, Msg, result); + return DEFDLG_Epilog(hDlg, Msg, wParam, lParam, result, TRUE); } @@ -1713,7 +1727,7 @@ return DefWindowProcW( hDlg, Msg, wParam, lParam ); } } - return DEFDLG_Epilog(hDlg, Msg, result); + return DEFDLG_Epilog(hDlg, Msg, wParam, lParam, result, FALSE); } @@ -1735,7 +1749,7 @@ * Also wine has one more parameter identifying weather it should call * the function with unicode or not */ - HWND hWnd = DIALOG_CreateIndirect( hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam, !Flags, TRUE ); + HWND hWnd = DIALOG_CreateIndirect( hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam, Flags == DLG_ISANSI ? FALSE : TRUE, TRUE ); if (hWnd) return DIALOG_DoDialogBox( hWnd, hWndParent ); return -1; } @@ -1753,7 +1767,7 @@ DLGPROC lpDialogFunc, LPARAM dwInitParam) { - return DialogBoxIndirectParamAorW( hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam, 2); + return DialogBoxIndirectParamAorW( hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam, DLG_ISANSI); } @@ -2063,6 +2077,7 @@ for (i = 0; list[i]; i++) if (GetWindowLongPtrW(list[i], GWLP_ID) == nIDDlgItem) break; ret = list[i]; HeapFree(GetProcessHeap(), 0, list); +// if (!ret) SetLastError(ERROR_CONTROL_ID_NOT_FOUND); return ret; } Modified: trunk/reactos/dll/win32/user32/windows/message.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] Sat Nov 5 05:18:57 2011 @@ -88,6 +88,8 @@ return (message_pointer_flags[message / 32] & SET(message)) != 0; } +#undef SET + /* DDE message exchange * * - Session initialization @@ -1031,6 +1033,48 @@ return TRUE; } +/*********************************************************************** + * map_wparam_AtoW + * + * Convert the wparam of an ASCII message to Unicode. + */ +static WPARAM +map_wparam_AtoW( UINT message, WPARAM wparam ) +{ + switch(message) + { + case WM_CHARTOITEM: + case EM_SETPASSWORDCHAR: + case WM_CHAR: + case WM_DEADCHAR: + case WM_SYSCHAR: + case WM_SYSDEADCHAR: + case WM_MENUCHAR: + { + char ch[2]; + WCHAR wch[2]; + ch[0] = (wparam & 0xff); + ch[1] = (wparam >> 8); + MultiByteToWideChar(CP_ACP, 0, ch, 2, wch, 2); + wparam = MAKEWPARAM(wch[0], wch[1]); + } + break; + case WM_IME_CHAR: + { + char ch[2]; + WCHAR wch; + ch[0] = (wparam >> 8); + ch[1] = (wparam & 0xff); + if (ch[0]) MultiByteToWideChar(CP_ACP, 0, ch, 2, &wch, 1); + else MultiByteToWideChar(CP_ACP, 0, &ch[1], 1, &wch, 1); + wparam = MAKEWPARAM( wch, HIWORD(wparam) ); + } + break; + } + return wparam; +} + + /* * @implemented */ @@ -1064,7 +1108,7 @@ /* - * @unimplemented + * @implemented */ BOOL WINAPI @@ -1083,7 +1127,7 @@ /* - * @unimplemented + * @implemented */ DWORD WINAPI @@ -1131,6 +1175,7 @@ { MSG AnsiMsg; MSG UnicodeMsg; + ULONG_PTR LowLimit; BOOL Hook = FALSE, MsgOverride = FALSE, Dialog; LRESULT Result = 0, PreResult = 0; DWORD Hit = 0, Data = 0; @@ -1139,6 +1184,14 @@ { WARN("IntCallWindowsProcW() called with WndProc = NULL!\n"); return FALSE; + } + + // Safeguard against excessive recursions. + LowLimit = (ULONG_PTR)NtCurrentTeb()->NtTib.StackLimit; + if (((ULONG_PTR)&lParam - LowLimit) < PAGE_SIZE ) + { + ERR("IntCallWindowsProcW() Exceeded Stack!\n"); + return FALSE; } if (pWnd) @@ -1286,6 +1339,7 @@ { MSG AnsiMsg; MSG UnicodeMsg; + ULONG_PTR LowLimit; BOOL Hook = FALSE, MsgOverride = FALSE, Dialog; LRESULT Result = 0, PreResult = 0; DWORD Hit = 0, Data = 0; @@ -1294,6 +1348,13 @@ { WARN("IntCallWindowsProcA() called with WndProc = NULL!\n"); return FALSE; + } + + LowLimit = (ULONG_PTR)NtCurrentTeb()->NtTib.StackLimit; + if (((ULONG_PTR)&lParam - LowLimit) < PAGE_SIZE ) + { + ERR("IntCallWindowsProcA() Exceeded Stack!\n"); + return FALSE; } if (pWnd) @@ -1751,7 +1812,6 @@ return Ret; } - static VOID IntConvertMsgToAnsi(LPMSG lpMsg) { @@ -1793,9 +1853,9 @@ Res = NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); if (-1 == (int) Res) - { + { return Res; - } + } IntConvertMsgToAnsi(lpMsg); @@ -1821,9 +1881,9 @@ Res = NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); if (-1 == (int) Res) - { + { return Res; - } + } return Res; } @@ -1879,9 +1939,11 @@ Res = PeekMessageWorker(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); if (-1 == (int) Res || !Res) - { + { return FALSE; - } + } + + IntConvertMsgToAnsi(lpMsg); return Res; } @@ -1903,9 +1965,9 @@ Res = PeekMessageWorker(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); if (-1 == (int) Res || !Res) - { + { return FALSE; - } + } return Res; } @@ -2062,7 +2124,7 @@ return 0; } - if (Wnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST)) + if (Wnd != HWND_TOPMOST && Wnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST)) { Window = ValidateHwnd(Wnd); @@ -2127,7 +2189,7 @@ return 0; } - if (Wnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST)) + if (Wnd != HWND_TOPMOST && Wnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST)) { Window = ValidateHwnd(Wnd); @@ -2291,7 +2353,8 @@ if (lpdwResult) *lpdwResult = 0; - if (hWnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST)) + //// This is due to message system bug. + if (hWnd != HWND_TOPMOST && hWnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST)) { Window = ValidateHwnd(hWnd); @@ -2306,6 +2369,7 @@ return TRUE; } } + //// SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam); dsm.uFlags = fuFlags; @@ -2366,7 +2430,8 @@ if (lpdwResult) *lpdwResult = 0; - if (hWnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST)) + //// This is due to message system bug. + if (hWnd != HWND_TOPMOST && hWnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST)) { Window = ValidateHwnd(hWnd); @@ -2381,6 +2446,7 @@ return TRUE; } } + //// SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam); dsm.uFlags = fuFlags; @@ -2611,6 +2677,7 @@ PWINDOWPROC_CALLBACK_ARGUMENTS CallbackArgs; MSG KMMsg, UMMsg; PWND pWnd = NULL; + ULONG_PTR LowLimit; PCLIENTINFO pci = GetWin32ClientInfo(); /* Make sure we don't try to access mem beyond what we were given */ @@ -2618,6 +2685,13 @@ { return STATUS_INFO_LENGTH_MISMATCH; } + + LowLimit = (ULONG_PTR)NtCurrentTeb()->NtTib.StackLimit; + if (((ULONG_PTR)&ArgumentLength - LowLimit) < PAGE_SIZE ) + { + ERR("Callback from Win32k Exceeded Stack!\n"); + return STATUS_BAD_STACK; + } CallbackArgs = (PWINDOWPROC_CALLBACK_ARGUMENTS) Arguments; KMMsg.hwnd = CallbackArgs->Wnd; @@ -2914,47 +2988,6 @@ DeleteCriticalSection(&gcsMPH); } -/*********************************************************************** - * map_wparam_AtoW - * - * Convert the wparam of an ASCII message to Unicode. - */ -static WPARAM -map_wparam_AtoW( UINT message, WPARAM wparam ) -{ - switch(message) - { - case WM_CHARTOITEM: - case EM_SETPASSWORDCHAR: - case WM_CHAR: - case WM_DEADCHAR: - case WM_SYSCHAR: - case WM_SYSDEADCHAR: - case WM_MENUCHAR: - { - char ch[2]; - WCHAR wch[2]; - ch[0] = (wparam & 0xff); - ch[1] = (wparam >> 8); - MultiByteToWideChar(CP_ACP, 0, ch, 2, wch, 2); - wparam = MAKEWPARAM(wch[0], wch[1]); - } - break; - case WM_IME_CHAR: - { - char ch[2]; - WCHAR wch; - ch[0] = (wparam >> 8); - ch[1] = (wparam & 0xff); - if (ch[0]) MultiByteToWideChar(CP_ACP, 0, ch, 2, &wch, 1); - else MultiByteToWideChar(CP_ACP, 0, &ch[1], 1, &wch, 1); - wparam = MAKEWPARAM( wch, HIWORD(wparam) ); - } - break; - } - return wparam; -} - /* * @implemented */
13 years, 5 months
1
0
0
0
[ion] 54292: [KERNEL32]: Fix a missing "~" in GlobalReAlloc and LocalReAlloc, which caused a flag never to be removed.
by ion@svn.reactos.org
Author: ion Date: Sat Nov 5 04:53:18 2011 New Revision: 54292 URL:
http://svn.reactos.org/svn/reactos?rev=54292&view=rev
Log: [KERNEL32]: Fix a missing "~" in GlobalReAlloc and LocalReAlloc, which caused a flag never to be removed. Modified: trunk/reactos/dll/win32/kernel32/client/heapmem.c Modified: trunk/reactos/dll/win32/kernel32/client/heapmem.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/heapmem.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/heapmem.c [iso-8859-1] Sat Nov 5 04:53:18 2011 @@ -881,7 +881,7 @@ else { /* Otherwise, remove the flag */ - HandleEntry->Flags &= BASE_HEAP_ENTRY_FLAG_REUSABLE; + HandleEntry->Flags &= ~BASE_HEAP_ENTRY_FLAG_REUSABLE; } } else @@ -1642,7 +1642,7 @@ else { /* Otherwise, remove the flag */ - HandleEntry->Flags &= BASE_HEAP_ENTRY_FLAG_REUSABLE; + HandleEntry->Flags &= ~BASE_HEAP_ENTRY_FLAG_REUSABLE; } } else
13 years, 5 months
1
0
0
0
[ion] 54291: [KERNEL32]: Implement CreateJobSet [KERNEL32]: Acquire SE_INCREASE_WORKING_SET_PRIVILEGE in SetInformationJobObject if needed. [KERNEL32]: Only do conversion of Process Priority Class ...
by ion@svn.reactos.org
Author: ion Date: Sat Nov 5 01:19:52 2011 New Revision: 54291 URL:
http://svn.reactos.org/svn/reactos?rev=54291&view=rev
Log: [KERNEL32]: Implement CreateJobSet [KERNEL32]: Acquire SE_INCREASE_WORKING_SET_PRIVILEGE in SetInformationJobObject if needed. [KERNEL32]: Only do conversion of Process Priority Class in SetInformationJobObject if the limit flags request it. [KERNEL32]: Add missing size checks in QueryInformationJobObject. [KERNEL32]: Use RtlEncode/DecodePointer to protect the top level exception handler pointer, as done on NT 5.2+ [KERNEL32]: Fix IsBadRead/WritePtr to use the correct page size from the CSRSS shared section. [KERNEL32]: Fix IsBad(String)Read/WritePtr loops [KERNEL32]: SetErrorMode now handles SEM_NOALIGNMENTFAULTEXCEPT. [KERNEL32]: Set/GetErrorMode do not set LastError on failure. [KERNEL32]: RaiseException can simply use memcpy instead of copying argument by argument. [KERNEL32]: Minor formatting changes. Modified: trunk/reactos/dll/win32/kernel32/client/appcache.c trunk/reactos/dll/win32/kernel32/client/dllmain.c trunk/reactos/dll/win32/kernel32/client/environ.c trunk/reactos/dll/win32/kernel32/client/except.c trunk/reactos/dll/win32/kernel32/client/job.c trunk/reactos/dll/win32/kernel32/client/proc.c trunk/reactos/dll/win32/kernel32/client/thread.c Modified: trunk/reactos/dll/win32/kernel32/client/appcache.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/appcache.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/appcache.c [iso-8859-1] Sat Nov 5 01:19:52 2011 @@ -12,8 +12,6 @@ #define NDEBUG #include <debug.h> - -/* TYPES **********************************************************************/ /* FUNCTIONS ******************************************************************/ Modified: trunk/reactos/dll/win32/kernel32/client/dllmain.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] Sat Nov 5 01:19:52 2011 @@ -209,6 +209,9 @@ switch (dwReason) { case DLL_PROCESS_ATTACH: + + /* Set no filter intially */ + GlobalTopLevelExceptionFilter = RtlEncodePointer(NULL); /* Don't bother us for each thread */ LdrDisableThreadCalloutsForDll((PVOID)hDll); Modified: trunk/reactos/dll/win32/kernel32/client/environ.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/environ.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/environ.c [iso-8859-1] Sat Nov 5 01:19:52 2011 @@ -11,11 +11,12 @@ * Created 01/11/98 */ +/* INCLUDES *******************************************************************/ + #include <k32.h> #define NDEBUG #include <debug.h> - /* FUNCTIONS ******************************************************************/ Modified: trunk/reactos/dll/win32/kernel32/client/except.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/except.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/except.c [iso-8859-1] Sat Nov 5 01:19:52 2011 @@ -10,13 +10,12 @@ * Created 01/11/98 */ +/* INCLUDES *******************************************************************/ + #include <k32.h> #define NDEBUG #include <debug.h> - -LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter = NULL; -DWORD g_dwLastErrorToBreakOn; /* * Private helper function to lookup the module name from a given address. @@ -69,7 +68,77 @@ #endif } -static LONG +static VOID +PrintStackTrace(struct _EXCEPTION_POINTERS *ExceptionInfo) +{ + PVOID StartAddr; + CHAR szMod[128] = ""; + PEXCEPTION_RECORD ExceptionRecord = ExceptionInfo->ExceptionRecord; + PCONTEXT ContextRecord = ExceptionInfo->ContextRecord; + + /* Print a stack trace. */ + DbgPrint("Unhandled exception\n"); + DbgPrint("ExceptionCode: %8x\n", ExceptionRecord->ExceptionCode); + + if ((NTSTATUS)ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION && + ExceptionRecord->NumberParameters == 2) + { + DbgPrint("Faulting Address: %8x\n", ExceptionRecord->ExceptionInformation[1]); + } + + _dump_context (ContextRecord); + _module_name_from_addr(ExceptionRecord->ExceptionAddress, &StartAddr, szMod, sizeof(szMod)); + DbgPrint("Address:\n %8x+%-8x %s\n", + (PVOID)StartAddr, + (ULONG_PTR)ExceptionRecord->ExceptionAddress - (ULONG_PTR)StartAddr, + szMod); +#ifdef _M_IX86 + DbgPrint("Frames:\n"); + + _SEH2_TRY + { + UINT i; + PULONG Frame = (PULONG)ContextRecord->Ebp; + + for (i = 0; Frame[1] != 0 && Frame[1] != 0xdeadbeef && i < 128; i++) + { + if (IsBadReadPtr((PVOID)Frame[1], 4)) + { + DbgPrint(" %8x%9s %s\n", Frame[1], "<invalid address>"," "); + } + else + { + _module_name_from_addr((const void*)Frame[1], &StartAddr, + szMod, sizeof(szMod)); + DbgPrint(" %8x+%-8x %s\n", + (PVOID)StartAddr, + (ULONG_PTR)Frame[1] - (ULONG_PTR)StartAddr, + szMod); + } + + if (IsBadReadPtr((PVOID)Frame[0], sizeof(*Frame) * 2)) + break; + + Frame = (PULONG)Frame[0]; + } + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + DbgPrint("<error dumping stack trace: 0x%x>\n", _SEH2_GetExceptionCode()); + } + _SEH2_END; +#endif +} + +/* GLOBALS ********************************************************************/ + +LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter; +DWORD g_dwLastErrorToBreakOn; + +/* FUNCTIONS ******************************************************************/ + +LONG +WINAPI BasepCheckForReadOnlyResource(IN PVOID Ptr) { PVOID Data; @@ -91,7 +160,6 @@ /* Attempt to treat it as a resource section. We need to use SEH here because we don't know if it's actually a resource mapping */ - _SEH2_TRY { Data = RtlImageDirectoryEntryToData(mbi.AllocationBase, @@ -126,68 +194,6 @@ return Ret; } -static VOID -PrintStackTrace(struct _EXCEPTION_POINTERS *ExceptionInfo) -{ - PVOID StartAddr; - CHAR szMod[128] = ""; - PEXCEPTION_RECORD ExceptionRecord = ExceptionInfo->ExceptionRecord; - PCONTEXT ContextRecord = ExceptionInfo->ContextRecord; - - /* Print a stack trace. */ - DbgPrint("Unhandled exception\n"); - DbgPrint("ExceptionCode: %8x\n", ExceptionRecord->ExceptionCode); - - if ((NTSTATUS)ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION && - ExceptionRecord->NumberParameters == 2) - { - DbgPrint("Faulting Address: %8x\n", ExceptionRecord->ExceptionInformation[1]); - } - - _dump_context (ContextRecord); - _module_name_from_addr(ExceptionRecord->ExceptionAddress, &StartAddr, szMod, sizeof(szMod)); - DbgPrint("Address:\n %8x+%-8x %s\n", - (PVOID)StartAddr, - (ULONG_PTR)ExceptionRecord->ExceptionAddress - (ULONG_PTR)StartAddr, - szMod); -#ifdef _M_IX86 - DbgPrint("Frames:\n"); - - _SEH2_TRY - { - UINT i; - PULONG Frame = (PULONG)ContextRecord->Ebp; - - for (i = 0; Frame[1] != 0 && Frame[1] != 0xdeadbeef && i < 128; i++) - { - if (IsBadReadPtr((PVOID)Frame[1], 4)) - { - DbgPrint(" %8x%9s %s\n", Frame[1], "<invalid address>"," "); - } - else - { - _module_name_from_addr((const void*)Frame[1], &StartAddr, - szMod, sizeof(szMod)); - DbgPrint(" %8x+%-8x %s\n", - (PVOID)StartAddr, - (ULONG_PTR)Frame[1] - (ULONG_PTR)StartAddr, - szMod); - } - - if (IsBadReadPtr((PVOID)Frame[0], sizeof(*Frame) * 2)) - break; - - Frame = (PULONG)Frame[0]; - } - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - DbgPrint("<error dumping stack trace: 0x%x>\n", _SEH2_GetExceptionCode()); - } - _SEH2_END; -#endif -} - UINT WINAPI GetErrorMode(VOID) @@ -272,9 +278,11 @@ return EXCEPTION_CONTINUE_SEARCH; } - if (GlobalTopLevelExceptionFilter) - { - LONG ret = GlobalTopLevelExceptionFilter(ExceptionInfo); + LPTOP_LEVEL_EXCEPTION_FILTER RealFilter; + RealFilter = RtlDecodePointer(GlobalTopLevelExceptionFilter); + if (RealFilter) + { + LONG ret = RealFilter(ExceptionInfo); if (ret != EXCEPTION_CONTINUE_SEARCH) return ret; } @@ -351,20 +359,14 @@ nNumberOfArguments = EXCEPTION_MAXIMUM_PARAMETERS; } - /* Set the count of parameters */ + /* Set the count of parameters and copy them */ ExceptionRecord.NumberParameters = nNumberOfArguments; - - /* Loop each parameter */ - for (nNumberOfArguments = 0; - (nNumberOfArguments < ExceptionRecord.NumberParameters); - nNumberOfArguments ++) - { - /* Copy the exception information */ - ExceptionRecord.ExceptionInformation[nNumberOfArguments] = - *lpArguments++; - } - } - + RtlCopyMemory(ExceptionRecord.ExceptionInformation, + lpArguments, + nNumberOfArguments * sizeof(ULONG)); + } + + /* Better handling of Delphi Exceptions... a ReactOS Hack */ if (dwExceptionCode == 0xeedface || dwExceptionCode == 0xeedfade) { DPRINT1("Delphi Exception at address: %p\n", ExceptionRecord.ExceptionInformation[0]); @@ -413,12 +415,14 @@ NewMode |= SEM_FAILCRITICALERRORS; } + /* Always keep no alignment faults if they were set */ + NewMode |= (PrevErrMode & SEM_NOALIGNMENTFAULTEXCEPT); + /* Set the new mode */ Status = NtSetInformationProcess(NtCurrentProcess(), ProcessDefaultHardErrorMode, (PVOID)&NewMode, sizeof(NewMode)); - if(!NT_SUCCESS(Status)) BaseSetLastNTError(Status); /* Return the previous mode */ return PrevErrMode; @@ -429,11 +433,14 @@ */ LPTOP_LEVEL_EXCEPTION_FILTER WINAPI -SetUnhandledExceptionFilter( - IN LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) -{ - return InterlockedExchangePointer(&GlobalTopLevelExceptionFilter, - lpTopLevelExceptionFilter); +SetUnhandledExceptionFilter(IN LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) +{ + PVOID EncodedPointer, NewPointer; + + EncodedPointer = RtlEncodePointer(lpTopLevelExceptionFilter); + NewPointer = InterlockedExchangePointer(&GlobalTopLevelExceptionFilter, + EncodedPointer); + return RtlDecodePointer(EncodedPointer); } /* @@ -444,7 +451,7 @@ IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb) { - //ULONG PageSize; + ULONG PageSize; BOOLEAN Result = FALSE; volatile CHAR *Current; PCHAR Last; @@ -454,25 +461,31 @@ if (!lp) return TRUE; /* Get the page size */ - //PageSize = BaseStaticServerData->SysInfo.PageSize; - - /* Calculate the last page */ + PageSize = BaseStaticServerData->SysInfo.PageSize; + + /* Calculate start and end */ + Current = (volatile CHAR*)lp; Last = (PCHAR)((ULONG_PTR)lp + ucb - 1); /* Another quick failure case */ - if ((ULONG_PTR)Last < (ULONG_PTR)lp) return TRUE; + if (Last < Current) return TRUE; /* Enter SEH */ _SEH2_TRY { + /* Do an initial probe */ + *Current; + + /* Align the addresses */ + Current = (volatile CHAR *)ROUND_DOWN(Current, PageSize); + Last = (PCHAR)ROUND_DOWN(Last, PageSize); + /* Probe the entire range */ - Current = (volatile CHAR*)lp; - Last = (PCHAR)(PAGE_ROUND_DOWN(Last)); - do + while (Current != Last) { + Current += PageSize; *Current; - Current = (volatile CHAR*)(PAGE_ROUND_DOWN(Current) + PAGE_SIZE); - } while (Current <= Last); + } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -513,10 +526,10 @@ */ BOOL NTAPI -IsBadWritePtr(LPVOID lp, - UINT_PTR ucb) -{ - //ULONG PageSize; +IsBadWritePtr(IN LPVOID lp, + IN UINT_PTR ucb) +{ + ULONG PageSize; BOOLEAN Result = FALSE; volatile CHAR *Current; PCHAR Last; @@ -526,25 +539,31 @@ if (!lp) return TRUE; /* Get the page size */ - //PageSize = BaseStaticServerData->SysInfo.PageSize; - - /* Calculate the last page */ + PageSize = BaseStaticServerData->SysInfo.PageSize; + + /* Calculate start and end */ + Current = (volatile CHAR*)lp; Last = (PCHAR)((ULONG_PTR)lp + ucb - 1); /* Another quick failure case */ - if ((ULONG_PTR)Last < (ULONG_PTR)lp) return TRUE; + if (Last < Current) return TRUE; /* Enter SEH */ _SEH2_TRY { + /* Do an initial probe */ + *Current = *Current; + + /* Align the addresses */ + Current = (volatile CHAR *)ROUND_DOWN(Current, PageSize); + Last = (PCHAR)ROUND_DOWN(Last, PageSize); + /* Probe the entire range */ - Current = (volatile CHAR*)lp; - Last = (PCHAR)(PAGE_ROUND_DOWN(Last)); - do + while (Current != Last) { + Current += PageSize; *Current = *Current; - Current = (volatile CHAR*)(PAGE_ROUND_DOWN(Current) + PAGE_SIZE); - } while (Current <= Last); + } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -562,8 +581,8 @@ */ BOOL NTAPI -IsBadHugeWritePtr(LPVOID lp, - UINT_PTR ucb) +IsBadHugeWritePtr(IN LPVOID lp, + IN UINT_PTR ucb) { /* Implementation is the same on 32-bit */ return IsBadWritePtr(lp, ucb); @@ -575,7 +594,7 @@ BOOL NTAPI IsBadStringPtrW(IN LPCWSTR lpsz, - UINT_PTR ucchMax) + IN UINT_PTR ucchMax) { BOOLEAN Result = FALSE; volatile WCHAR *Current; @@ -586,20 +605,16 @@ if (!ucchMax) return FALSE; if (!lpsz) return TRUE; - /* Calculate the last page */ + /* Calculate start and end */ + Current = (volatile WCHAR*)lpsz; Last = (PWCHAR)((ULONG_PTR)lpsz + (ucchMax * 2) - 2); /* Enter SEH */ _SEH2_TRY { /* Probe the entire range */ - Current = (volatile WCHAR*)lpsz; - Last = (PWCHAR)(PAGE_ROUND_DOWN(Last)); - do - { - Char = *Current; - Current++; - } while (Char && (Current != Last + 1)); + Char = *Current++; + while ((Char) && (Current != Last)) Char = *Current++; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -618,7 +633,7 @@ BOOL NTAPI IsBadStringPtrA(IN LPCSTR lpsz, - UINT_PTR ucchMax) + IN UINT_PTR ucchMax) { BOOLEAN Result = FALSE; volatile CHAR *Current; @@ -629,20 +644,16 @@ if (!ucchMax) return FALSE; if (!lpsz) return TRUE; - /* Calculate the last page */ + /* Calculate start and end */ + Current = (volatile CHAR*)lpsz; Last = (PCHAR)((ULONG_PTR)lpsz + ucchMax - 1); /* Enter SEH */ _SEH2_TRY { /* Probe the entire range */ - Current = (volatile CHAR*)lpsz; - Last = (PCHAR)(PAGE_ROUND_DOWN(Last)); - do - { - Char = *Current; - Current++; - } while (Char && (Current != Last + 1)); + Char = *Current++; + while ((Char) && (Current != Last)) Char = *Current++; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Modified: trunk/reactos/dll/win32/kernel32/client/job.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/job.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/job.c [iso-8859-1] Sat Nov 5 01:19:52 2011 @@ -9,14 +9,14 @@ * Created 9/23/2004 */ -/* INCLUDES ****************************************************************/ +/* INCLUDES *******************************************************************/ #include <k32.h> #define NDEBUG #include <debug.h> -/* FUNCTIONS ****************************************************************/ +/* FUNCTIONS ******************************************************************/ /* * @implemented @@ -47,9 +47,9 @@ */ HANDLE WINAPI -OpenJobObjectW(DWORD dwDesiredAccess, - BOOL bInheritHandle, - LPCWSTR lpName) +OpenJobObjectW(IN DWORD dwDesiredAccess, + IN BOOL bInheritHandle, + IN LPCWSTR lpName) { /* Open the NT object */ OpenNtObjectFromWin32Api(JobObject, dwDesiredAccess, bInheritHandle, lpName); @@ -61,23 +61,22 @@ */ HANDLE WINAPI -OpenJobObjectA(DWORD dwDesiredAccess, - BOOL bInheritHandle, - LPCSTR lpName) +OpenJobObjectA(IN DWORD dwDesiredAccess, + IN BOOL bInheritHandle, + IN LPCSTR lpName) { /* Call the W(ide) function */ ConvertOpenWin32AnsiObjectApiToUnicodeApi(JobObject, dwDesiredAccess, bInheritHandle, lpName); } - -/* - * @implemented - */ -BOOL -WINAPI -IsProcessInJob(HANDLE ProcessHandle, - HANDLE JobHandle, - PBOOL Result) +/* + * @implemented + */ +BOOL +WINAPI +IsProcessInJob(IN HANDLE ProcessHandle, + IN HANDLE JobHandle, + OUT PBOOL Result) { NTSTATUS Status; @@ -92,14 +91,13 @@ return FALSE; } - -/* - * @implemented - */ -BOOL -WINAPI -AssignProcessToJobObject(HANDLE hJob, - HANDLE hProcess) +/* + * @implemented + */ +BOOL +WINAPI +AssignProcessToJobObject(IN HANDLE hJob, + IN HANDLE hProcess) { NTSTATUS Status; @@ -113,81 +111,198 @@ return TRUE; } - -/* - * @implemented - */ -BOOL -WINAPI -QueryInformationJobObject(HANDLE hJob, - JOBOBJECTINFOCLASS JobObjectInformationClass, - LPVOID lpJobObjectInformation, - DWORD cbJobObjectInformationLength, - LPDWORD lpReturnLength) -{ - NTSTATUS Status; +/* + * @implemented + */ +BOOL +WINAPI +QueryInformationJobObject(IN HANDLE hJob, + IN JOBOBJECTINFOCLASS JobObjectInformationClass, + IN LPVOID lpJobObjectInformation, + IN DWORD cbJobObjectInformationLength, + OUT LPDWORD lpReturnLength) +{ + NTSTATUS Status; + PVOID JobInfo; + JOBOBJECT_EXTENDED_LIMIT_INFORMATION LocalInfo; + ULONG ExpectedSize; + + if (JobObjectInformationClass == JobObjectBasicLimitInformation) + { + ExpectedSize = sizeof(JOBOBJECT_BASIC_LIMIT_INFORMATION); + JobInfo = &LocalInfo; + } + else if (JobObjectInformationClass == JobObjectBasicLimitInformation) + { + ExpectedSize = sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION); + JobInfo = &LocalInfo; + } + else + { + ExpectedSize = cbJobObjectInformationLength; + JobInfo = lpJobObjectInformation; + } + + if (cbJobObjectInformationLength != ExpectedSize) + { + BaseSetLastNTError(STATUS_INFO_LENGTH_MISMATCH); + return FALSE; + } Status = NtQueryInformationJobObject(hJob, JobObjectInformationClass, - lpJobObjectInformation, - cbJobObjectInformationLength, + JobInfo, + ExpectedSize, lpReturnLength); if (NT_SUCCESS(Status)) { - PJOBOBJECT_BASIC_LIMIT_INFORMATION BasicInfo; - - switch (JobObjectInformationClass) + if (JobInfo != &LocalInfo) return TRUE; + + switch (LocalInfo.BasicLimitInformation.PriorityClass) { - case JobObjectBasicLimitInformation: - BasicInfo = (PJOBOBJECT_BASIC_LIMIT_INFORMATION)lpJobObjectInformation; - break; - - case JobObjectExtendedLimitInformation: - BasicInfo = &((PJOBOBJECT_EXTENDED_LIMIT_INFORMATION)lpJobObjectInformation)->BasicLimitInformation; + case PROCESS_PRIORITY_CLASS_IDLE: + LocalInfo.BasicLimitInformation.PriorityClass = + IDLE_PRIORITY_CLASS; + break; + + case PROCESS_PRIORITY_CLASS_BELOW_NORMAL: + LocalInfo.BasicLimitInformation.PriorityClass = + BELOW_NORMAL_PRIORITY_CLASS; + break; + + case PROCESS_PRIORITY_CLASS_NORMAL: + LocalInfo.BasicLimitInformation.PriorityClass = + NORMAL_PRIORITY_CLASS; + break; + + case PROCESS_PRIORITY_CLASS_ABOVE_NORMAL: + LocalInfo.BasicLimitInformation.PriorityClass = + ABOVE_NORMAL_PRIORITY_CLASS; + break; + + case PROCESS_PRIORITY_CLASS_HIGH: + LocalInfo.BasicLimitInformation.PriorityClass = + HIGH_PRIORITY_CLASS; + break; + + case PROCESS_PRIORITY_CLASS_REALTIME: + LocalInfo.BasicLimitInformation.PriorityClass = + REALTIME_PRIORITY_CLASS; break; default: - BasicInfo = NULL; + LocalInfo.BasicLimitInformation.PriorityClass = + NORMAL_PRIORITY_CLASS; break; } - if (BasicInfo != NULL) + RtlCopyMemory(lpJobObjectInformation, &LocalInfo, ExpectedSize); + return TRUE; + } + + BaseSetLastNTError(Status); + return FALSE; +} + +/* + * @implemented + */ +BOOL +WINAPI +SetInformationJobObject(IN HANDLE hJob, + IN JOBOBJECTINFOCLASS JobObjectInformationClass, + IN LPVOID lpJobObjectInformation, + IN DWORD cbJobObjectInformationLength) +{ + NTSTATUS Status; + PVOID JobInfo; + JOBOBJECT_EXTENDED_LIMIT_INFORMATION LocalInfo; + ULONG ExpectedSize; + PVOID State = NULL; + ULONG Privilege = SE_INC_BASE_PRIORITY_PRIVILEGE; + + if (JobObjectInformationClass == JobObjectBasicLimitInformation) + { + ExpectedSize = sizeof(JOBOBJECT_BASIC_LIMIT_INFORMATION); + JobInfo = &LocalInfo; + } + else if (JobObjectInformationClass == JobObjectBasicLimitInformation) + { + ExpectedSize = sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION); + JobInfo = &LocalInfo; + } + else + { + ExpectedSize = cbJobObjectInformationLength; + JobInfo = lpJobObjectInformation; + } + + if (cbJobObjectInformationLength != ExpectedSize) + { + BaseSetLastNTError(STATUS_INFO_LENGTH_MISMATCH); + return FALSE; + } + + if (JobInfo == &LocalInfo) + { + RtlCopyMemory(&LocalInfo, lpJobObjectInformation, ExpectedSize); + + if (LocalInfo.BasicLimitInformation.LimitFlags & + JOB_OBJECT_LIMIT_PRIORITY_CLASS) { - /* we need to convert the process priority classes in the - JOBOBJECT_BASIC_LIMIT_INFORMATION structure the same way as - GetPriorityClass() converts it! */ - switch (BasicInfo->PriorityClass) + switch (LocalInfo.BasicLimitInformation.PriorityClass) { - case PROCESS_PRIORITY_CLASS_IDLE: - BasicInfo->PriorityClass = IDLE_PRIORITY_CLASS; - break; - - case PROCESS_PRIORITY_CLASS_BELOW_NORMAL: - BasicInfo->PriorityClass = BELOW_NORMAL_PRIORITY_CLASS; - break; - - case PROCESS_PRIORITY_CLASS_NORMAL: - BasicInfo->PriorityClass = NORMAL_PRIORITY_CLASS; - break; - - case PROCESS_PRIORITY_CLASS_ABOVE_NORMAL: - BasicInfo->PriorityClass = ABOVE_NORMAL_PRIORITY_CLASS; - break; - - case PROCESS_PRIORITY_CLASS_HIGH: - BasicInfo->PriorityClass = HIGH_PRIORITY_CLASS; - break; - - case PROCESS_PRIORITY_CLASS_REALTIME: - BasicInfo->PriorityClass = REALTIME_PRIORITY_CLASS; + case IDLE_PRIORITY_CLASS: + LocalInfo.BasicLimitInformation.PriorityClass = + PROCESS_PRIORITY_CLASS_IDLE; + break; + + case BELOW_NORMAL_PRIORITY_CLASS: + LocalInfo.BasicLimitInformation.PriorityClass = + PROCESS_PRIORITY_CLASS_BELOW_NORMAL; + break; + + case NORMAL_PRIORITY_CLASS: + LocalInfo.BasicLimitInformation.PriorityClass = + PROCESS_PRIORITY_CLASS_NORMAL; + break; + + case ABOVE_NORMAL_PRIORITY_CLASS: + LocalInfo.BasicLimitInformation.PriorityClass = + PROCESS_PRIORITY_CLASS_ABOVE_NORMAL; + break; + + case HIGH_PRIORITY_CLASS: + LocalInfo.BasicLimitInformation.PriorityClass = + PROCESS_PRIORITY_CLASS_HIGH; + break; + + case REALTIME_PRIORITY_CLASS: + LocalInfo.BasicLimitInformation.PriorityClass = + PROCESS_PRIORITY_CLASS_REALTIME; break; default: - BasicInfo->PriorityClass = NORMAL_PRIORITY_CLASS; + LocalInfo.BasicLimitInformation.PriorityClass = + PROCESS_PRIORITY_CLASS_NORMAL; break; } } + if (LocalInfo.BasicLimitInformation.LimitFlags & + JOB_OBJECT_LIMIT_WORKINGSET) + { + Status = RtlAcquirePrivilege(&Privilege, TRUE, FALSE, &State); + } + } + + Status = NtSetInformationJobObject(hJob, + JobObjectInformationClass, + JobInfo, + ExpectedSize); + if (NT_SUCCESS(Status)) + { + if (State != NULL) RtlReleasePrivilege(State); return TRUE; } @@ -195,112 +310,13 @@ return FALSE; } - -/* - * @implemented - */ -BOOL -WINAPI -SetInformationJobObject(HANDLE hJob, - JOBOBJECTINFOCLASS JobObjectInformationClass, - LPVOID lpJobObjectInformation, - DWORD cbJobObjectInformationLength) -{ - JOBOBJECT_EXTENDED_LIMIT_INFORMATION ExtendedLimitInfo; - PJOBOBJECT_BASIC_LIMIT_INFORMATION BasicInfo; - PVOID ObjectInfo; - NTSTATUS Status; - - switch (JobObjectInformationClass) - { - case JobObjectBasicLimitInformation: - if (cbJobObjectInformationLength != sizeof(JOBOBJECT_BASIC_LIMIT_INFORMATION)) - { - SetLastError(ERROR_BAD_LENGTH); - return FALSE; - } - - ObjectInfo = &ExtendedLimitInfo.BasicLimitInformation; - BasicInfo = (PJOBOBJECT_BASIC_LIMIT_INFORMATION)ObjectInfo; - RtlCopyMemory(ObjectInfo, lpJobObjectInformation, cbJobObjectInformationLength); - break; - - case JobObjectExtendedLimitInformation: - if (cbJobObjectInformationLength != sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION)) - { - SetLastError(ERROR_BAD_LENGTH); - return FALSE; - } - - ObjectInfo = &ExtendedLimitInfo; - BasicInfo = &ExtendedLimitInfo.BasicLimitInformation; - RtlCopyMemory(ObjectInfo, lpJobObjectInformation, cbJobObjectInformationLength); - break; - - default: - ObjectInfo = lpJobObjectInformation; - BasicInfo = NULL; - break; - } - - if (BasicInfo != NULL) - { - /* we need to convert the process priority classes in the - JOBOBJECT_BASIC_LIMIT_INFORMATION structure the same way as - SetPriorityClass() converts it! */ - switch(BasicInfo->PriorityClass) - { - case IDLE_PRIORITY_CLASS: - BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_IDLE; - break; - - case BELOW_NORMAL_PRIORITY_CLASS: - BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL; - break; - - case NORMAL_PRIORITY_CLASS: - BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL; - break; - - case ABOVE_NORMAL_PRIORITY_CLASS: - BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL; - break; - - case HIGH_PRIORITY_CLASS: - BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_HIGH; - break; - - case REALTIME_PRIORITY_CLASS: - BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_REALTIME; - break; - - default: - BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL; - break; - } - } - - Status = NtSetInformationJobObject(hJob, - JobObjectInformationClass, - ObjectInfo, - cbJobObjectInformationLength); - if (!NT_SUCCESS(Status)) - { - BaseSetLastNTError(Status); - return FALSE; - } - - return TRUE; -} - - -/* - * @implemented - */ -BOOL -WINAPI -TerminateJobObject(HANDLE hJob, - UINT uExitCode) +/* + * @implemented + */ +BOOL +WINAPI +TerminateJobObject(IN HANDLE hJob, + IN UINT uExitCode) { NTSTATUS Status; @@ -315,17 +331,24 @@ } /* - * @unimplemented - */ -BOOL -WINAPI -CreateJobSet ( - ULONG NumJob, - PJOB_SET_ARRAY UserJobSet, - ULONG Flags) -{ - STUB; - return 0; + * @implemented + */ +BOOL +WINAPI +CreateJobSet(IN ULONG NumJob, + IN PJOB_SET_ARRAY UserJobSet, + IN ULONG Flags) +{ + NTSTATUS Status; + + Status = NtCreateJobSet(NumJob, UserJobSet, Flags); + if (!NT_SUCCESS(Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + + return TRUE; } /* EOF */ Modified: trunk/reactos/dll/win32/kernel32/client/proc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] Sat Nov 5 01:19:52 2011 @@ -49,12 +49,14 @@ LONG BaseExceptionFilter(EXCEPTION_POINTERS *ExceptionInfo) { LONG ExceptionDisposition = EXCEPTION_EXECUTE_HANDLER; - - if (GlobalTopLevelExceptionFilter != NULL) + LPTOP_LEVEL_EXCEPTION_FILTER RealFilter; + RealFilter = RtlDecodePointer(GlobalTopLevelExceptionFilter); + + if (RealFilter != NULL) { _SEH2_TRY { - ExceptionDisposition = GlobalTopLevelExceptionFilter(ExceptionInfo); + ExceptionDisposition = RealFilter(ExceptionInfo); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -62,7 +64,7 @@ _SEH2_END; } if ((ExceptionDisposition == EXCEPTION_CONTINUE_SEARCH || ExceptionDisposition == EXCEPTION_EXECUTE_HANDLER) && - GlobalTopLevelExceptionFilter != UnhandledExceptionFilter) + RealFilter != UnhandledExceptionFilter) { ExceptionDisposition = UnhandledExceptionFilter(ExceptionInfo); } Modified: trunk/reactos/dll/win32/kernel32/client/thread.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/thread.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/thread.c [iso-8859-1] Sat Nov 5 01:19:52 2011 @@ -29,12 +29,14 @@ LONG BaseThreadExceptionFilter(EXCEPTION_POINTERS * ExceptionInfo) { LONG ExceptionDisposition = EXCEPTION_EXECUTE_HANDLER; - - if (GlobalTopLevelExceptionFilter != NULL) + LPTOP_LEVEL_EXCEPTION_FILTER RealFilter; + RealFilter = RtlDecodePointer(GlobalTopLevelExceptionFilter); + + if (RealFilter != NULL) { _SEH2_TRY { - ExceptionDisposition = GlobalTopLevelExceptionFilter(ExceptionInfo); + ExceptionDisposition = RealFilter(ExceptionInfo); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
13 years, 5 months
1
0
0
0
[tfaber] 54290: [RICHED20_WINETEST] - Sync to Wine 1.3.32
by tfaber@svn.reactos.org
Author: tfaber Date: Fri Nov 4 23:07:16 2011 New Revision: 54290 URL:
http://svn.reactos.org/svn/reactos?rev=54290&view=rev
Log: [RICHED20_WINETEST] - Sync to Wine 1.3.32 Modified: trunk/rostests/winetests/riched20/editor.c trunk/rostests/winetests/riched20/richole.c trunk/rostests/winetests/riched20/testlist.c trunk/rostests/winetests/riched20/txtsrv.c Modified: trunk/rostests/winetests/riched20/editor.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/riched20/editor…
============================================================================== --- trunk/rostests/winetests/riched20/editor.c [iso-8859-1] (original) +++ trunk/rostests/winetests/riched20/editor.c [iso-8859-1] Fri Nov 4 23:07:16 2011 @@ -46,19 +46,30 @@ static HMODULE hmoduleRichEdit; -static int is_win9x = 0; - -static HWND new_window(LPCTSTR lpClassName, DWORD dwStyle, HWND parent) { +static HWND new_window(LPCSTR lpClassName, DWORD dwStyle, HWND parent) { HWND hwnd; - hwnd = CreateWindow(lpClassName, NULL, dwStyle|WS_POPUP|WS_HSCROLL|WS_VSCROLL + hwnd = CreateWindowA(lpClassName, NULL, dwStyle|WS_POPUP|WS_HSCROLL|WS_VSCROLL |WS_VISIBLE, 0, 0, 200, 60, parent, NULL, hmoduleRichEdit, NULL); ok(hwnd != NULL, "class: %s, error: %d\n", lpClassName, (int) GetLastError()); return hwnd; } +static HWND new_windowW(LPCWSTR lpClassName, DWORD dwStyle, HWND parent) { + HWND hwnd; + hwnd = CreateWindowW(lpClassName, NULL, dwStyle|WS_POPUP|WS_HSCROLL|WS_VSCROLL + |WS_VISIBLE, 0, 0, 200, 60, parent, NULL, + hmoduleRichEdit, NULL); + ok(hwnd != NULL, "class: %s, error: %d\n", wine_dbgstr_w(lpClassName), (int) GetLastError()); + return hwnd; +} + static HWND new_richedit(HWND parent) { return new_window(RICHEDIT_CLASS, ES_MULTILINE, parent); +} + +static HWND new_richeditW(HWND parent) { + return new_windowW(RICHEDIT_CLASS20W, ES_MULTILINE, parent); } /* Keeps the window reponsive for the deley_time in seconds. @@ -81,27 +92,6 @@ } } -static void processPendingMessages(void) -{ - MSG msg; - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } -} - -static void pressKeyWithModifier(HWND hwnd, BYTE mod_vk, BYTE vk) -{ - BYTE mod_scan_code = MapVirtualKey(mod_vk, MAPVK_VK_TO_VSC); - BYTE scan_code = MapVirtualKey(vk, MAPVK_VK_TO_VSC); - SetFocus(hwnd); - keybd_event(mod_vk, mod_scan_code, 0, 0); - keybd_event(vk, scan_code, 0, 0); - keybd_event(vk, scan_code, KEYEVENTF_KEYUP, 0); - keybd_event(mod_vk, mod_scan_code, KEYEVENTF_KEYUP, 0); - processPendingMessages(); -} - static void simulate_typing_characters(HWND hwnd, const char* szChars) { int ret; @@ -155,7 +145,7 @@ }; -struct find_s find_tests[] = { +static struct find_s find_tests[] = { /* Find in empty text */ {0, -1, "foo", FR_DOWN, -1}, {0, -1, "foo", 0, -1}, @@ -164,7 +154,7 @@ {5, 20, "foo", FR_DOWN, -1} }; -struct find_s find_tests2[] = { +static struct find_s find_tests2[] = { /* No-result find */ {0, -1, "foo", FR_DOWN | FR_MATCHCASE, -1}, {5, 20, "WINE", FR_DOWN | FR_MATCHCASE, -1}, @@ -386,7 +376,7 @@ * to the MSDN documentation fo EM_GETLINE, which does not state that * a NULL terminating character will be added unless no text is copied. * - * Windows 95, 98 & NT do not append a NULL terminating character, but + * Windows NT does not append a NULL terminating character, but * Windows 2000 and up do append a NULL terminating character if there * is space in the buffer. The test will ignore this difference. */ ok(!strncmp(dest, gl[i].text, expected_bytes_written), @@ -520,11 +510,13 @@ static void test_EM_POSFROMCHAR(void) { HWND hwndRichEdit = new_richedit(NULL); - int i; + int i, expected; LRESULT result; unsigned int height = 0; int xpos = 0; POINTL pt; + LOCALESIGNATURE sig; + BOOL rtl; static const char text[] = "aa\n" "this is a long line of text that should be longer than the " "control's width\n" @@ -534,6 +526,10 @@ "ff\n" "gg\n" "hh\n"; + + rtl = (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_FONTSIGNATURE, + (LPSTR) &sig, sizeof(LOCALESIGNATURE)) && + (sig.lsUsb[3] & 0x08000000) != 0); /* Fill the control to lines to ensure that most of them are offscreen */ for (i = 0; i < 50; i++) @@ -586,7 +582,8 @@ /* Testing position way past end of text */ result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, 55 * 16, 0); ok(HIWORD(result) == 50 * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", HIWORD(result), 50 * height); - ok(LOWORD(result) == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", LOWORD(result)); + expected = (rtl ? 8 : 1); + ok(LOWORD(result) == expected, "EM_POSFROMCHAR reports x=%d, expected %d\n", LOWORD(result), expected); /* Testing that vertical scrolling does, in fact, have an effect on EM_POSFROMCHAR */ SendMessage(hwndRichEdit, EM_SCROLL, SB_LINEDOWN, 0); /* line down */ @@ -608,7 +605,8 @@ /* Testing position way past end of text */ result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, 55 * 16, 0); ok(HIWORD(result) == (50 - 1) * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", HIWORD(result), (50 - 1) * height); - ok(LOWORD(result) == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", LOWORD(result)); + expected = (rtl ? 8 : 1); + ok(LOWORD(result) == expected, "EM_POSFROMCHAR reports x=%d, expected %d\n", LOWORD(result), expected); /* Testing that horizontal scrolling does, in fact, have an effect on EM_POSFROMCHAR */ SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text); @@ -636,7 +634,7 @@ SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pt, SendMessage(hwndRichEdit, WM_GETTEXTLENGTH, 0, 0)); ok(pt.x > xpos, "pt.x = %d\n", pt.x); - xpos = pt.x; + xpos = (rtl ? pt.x + 7 : pt.x); SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pt, SendMessage(hwndRichEdit, WM_GETTEXTLENGTH, 0, 0)+1); ok(pt.x == xpos, "pt.x = %d\n", pt.x); @@ -666,6 +664,12 @@ }; int i; CHARRANGE cr; + LOCALESIGNATURE sig; + BOOL rtl; + + rtl = (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_FONTSIGNATURE, + (LPSTR) &sig, sizeof(LOCALESIGNATURE)) && + (sig.lsUsb[3] & 0x08000000) != 0); /* Invalid flags, CHARFORMAT2 structure blanked out */ memset(&cf2, 0, sizeof(cf2)); @@ -764,8 +768,13 @@ ok(rc == 0, "Text marked as modified, expected not modified!\n"); rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, 0, (LPARAM) &cf2); ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc); - rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); - ok(rc == 0, "Text marked as modified, expected not modified!\n"); + if (! rtl) + { + rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0); + ok(rc == 0, "Text marked as modified, expected not modified!\n"); + } + else + skip("RTL language found\n"); /* wParam==SCF_SELECTION sets modify if nonempty selection */ SendMessage(hwndRichEdit, WM_SETTEXT, 0, 0); @@ -1053,6 +1062,11 @@ CHARRANGE cr; int rc = 0; + /*Attempt to use mutually exclusive modes*/ + rc = SendMessage(hwndRichEdit, EM_SETTEXTMODE, (WPARAM) TM_PLAINTEXT|TM_RICHTEXT, 0); + ok(rc == E_INVALIDARG, + "EM_SETTEXTMODE: using mutually exclusive mode flags - returned: %x\n", rc); + /*Test that EM_SETTEXTMODE fails if text exists within the control*/ /*Insert text into the control*/ @@ -1060,7 +1074,8 @@ /*Attempt to change the control to plain text mode*/ rc = SendMessage(hwndRichEdit, EM_SETTEXTMODE, (WPARAM) TM_PLAINTEXT, 0); - ok(rc != 0, "EM_SETTEXTMODE: changed text mode in control containing text - returned: %d\n", rc); + ok(rc == E_UNEXPECTED, + "EM_SETTEXTMODE: changed text mode in control containing text - returned: %x\n", rc); /*Test that EM_SETTEXTMODE does not allow rich edit text to be pasted. If rich text is pasted, it should have the same formatting as the rest @@ -1526,7 +1541,6 @@ SendMessage(hwndRichEdit, EM_SETOPTIONS, ECOOP_SET, 0); /* testing no readonly by sending 'a' to the control*/ - SetFocus(hwndRichEdit); SendMessage(hwndRichEdit, WM_CHAR, 'a', 0x1E0001); SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok(buffer[0]=='a', @@ -1536,7 +1550,6 @@ /* READONLY - sending 'a' to the control */ SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text); SendMessage(hwndRichEdit, EM_SETOPTIONS, ECOOP_SET, ECO_READONLY); - SetFocus(hwndRichEdit); SendMessage(hwndRichEdit, WM_CHAR, 'a', 0x1E0001); SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok(buffer[0]==text[0], @@ -2440,10 +2453,10 @@ DestroyWindow(hwndRichEdit); } -unsigned int recursionLevel = 0; -unsigned int WM_SIZE_recursionLevel = 0; -BOOL bailedOutOfRecursion = FALSE; -LRESULT (WINAPI *richeditProc)(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +static unsigned int recursionLevel = 0; +static unsigned int WM_SIZE_recursionLevel = 0; +static BOOL bailedOutOfRecursion = FALSE; +static LRESULT (WINAPI *richeditProc)(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); static LRESULT WINAPI RicheditStupidOverrideProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -3336,13 +3349,8 @@ result = lstrcmpW(b, bufW); \ ok(result == 0, "WM_SETTEXT round trip: strcmp = %ld\n", result); - if (is_win9x) - { - skip("Cannot perform unicode tests\n"); - return; - } -hwndRichEdit = CreateWindowW(RICHEDIT_CLASS20W, NULL, - ES_MULTILINE|WS_POPUP|WS_HSCROLL|WS_VSCROLL|WS_VISIBLE, + hwndRichEdit = CreateWindowW(RICHEDIT_CLASS20W, NULL, + ES_MULTILINE|WS_POPUP|WS_HSCROLL|WS_VSCROLL|WS_VISIBLE, 0, 0, 200, 60, NULL, NULL, hmoduleRichEdit, NULL); ok(hwndRichEdit != NULL, "class: RichEdit20W, error: %d\n", (int) GetLastError()); TEST_SETTEXTW(rtftextA, sometextW) /* interpreted as ascii rtf */ @@ -4423,17 +4431,9 @@ r = SendMessage(hwndRichEdit, EM_GETLINECOUNT, 0, 0); ok(r == 2, "EM_GETLINECOUNT returned %d, expected 2\n", r); - /* Win98's riched20 and WinXP's riched20 disagree on what to return from - EM_REPLACESEL. The general rule seems to be that Win98's riched20 - returns the number of characters *inserted* into the control (after - required conversions), but WinXP's riched20 returns the number of - characters interpreted from the original lParam. Wine's builtin riched20 - implements the WinXP behavior. - */ SendMessage(hwndRichEdit, WM_SETTEXT, 0, 0); r = SendMessage(hwndRichEdit, EM_REPLACESEL, 0, (LPARAM) "RichEdit1\r\n"); - ok(11 == r /* WinXP */ || 10 == r /* Win98 */, - "EM_REPLACESEL returned %d, expected 11 or 10\n", r); + ok(r == 11, "EM_REPLACESEL returned %d, expected 11\n", r); /* Test number of lines reported after EM_REPLACESEL */ r = SendMessage(hwndRichEdit, EM_GETLINECOUNT, 0, 0); @@ -4491,8 +4491,7 @@ SendMessage(hwndRichEdit, WM_SETTEXT, 0, 0); r = SendMessage(hwndRichEdit, EM_REPLACESEL, 0, (LPARAM) "\r\r\n"); - ok(3 == r /* WinXP */ || 1 == r /* Win98 */, - "EM_REPLACESEL returned %d, expected 3 or 1\n", r); + ok(r == 3, "EM_REPLACESEL returned %d, expected 3\n", r); r = SendMessage(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); ok(cr.cpMin == 1, "EM_EXGETSEL returned cpMin=%d, expected 1\n", cr.cpMin); @@ -4514,8 +4513,7 @@ SendMessage(hwndRichEdit, WM_SETTEXT, 0, 0); r = SendMessage(hwndRichEdit, EM_REPLACESEL, 0, (LPARAM) "\r\r\r\r\r\n\r\r\r"); - ok(9 == r /* WinXP */ || 7 == r /* Win98 */, - "EM_REPLACESEL returned %d, expected 9 or 7\n", r); + ok(r == 9, "EM_REPLACESEL returned %d, expected 9\n", r); r = SendMessage(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); ok(cr.cpMin == 7, "EM_EXGETSEL returned cpMin=%d, expected 7\n", cr.cpMin); @@ -4537,8 +4535,7 @@ SendMessage(hwndRichEdit, WM_SETTEXT, 0, 0); r = SendMessage(hwndRichEdit, EM_REPLACESEL, 0, (LPARAM) "\r\r\n\r\n"); - ok(5 == r /* WinXP */ || 2 == r /* Win98 */, - "EM_REPLACESEL returned %d, expected 5 or 2\n", r); + ok(r == 5, "EM_REPLACESEL returned %d, expected 5\n", r); r = SendMessage(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); ok(cr.cpMin == 2, "EM_EXGETSEL returned cpMin=%d, expected 2\n", cr.cpMin); @@ -4560,8 +4557,7 @@ SendMessage(hwndRichEdit, WM_SETTEXT, 0, 0); r = SendMessage(hwndRichEdit, EM_REPLACESEL, 0, (LPARAM) "\r\r\n\r\r"); - ok(5 == r /* WinXP */ || 3 == r /* Win98 */, - "EM_REPLACESEL returned %d, expected 5 or 3\n", r); + ok(r == 5, "EM_REPLACESEL returned %d, expected 5\n", r); r = SendMessage(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); ok(cr.cpMin == 3, "EM_EXGETSEL returned cpMin=%d, expected 3\n", cr.cpMin); @@ -4583,8 +4579,7 @@ SendMessage(hwndRichEdit, WM_SETTEXT, 0, 0); r = SendMessage(hwndRichEdit, EM_REPLACESEL, 0, (LPARAM) "\rX\r\n\r\r"); - ok(6 == r /* WinXP */ || 5 == r /* Win98 */, - "EM_REPLACESEL returned %d, expected 6 or 5\n", r); + ok(r == 6, "EM_REPLACESEL returned %d, expected 6\n", r); r = SendMessage(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); ok(cr.cpMin == 5, "EM_EXGETSEL returned cpMin=%d, expected 5\n", cr.cpMin); @@ -4628,8 +4623,7 @@ SendMessage(hwndRichEdit, WM_SETTEXT, 0, 0); r = SendMessage(hwndRichEdit, EM_REPLACESEL, 0, (LPARAM) "\n\n\n\n\r\r\r\r\n"); - ok(9 == r /* WinXP */ || 7 == r /* Win98 */, - "EM_REPLACESEL returned %d, expected 9 or 7\n", r); + ok(r == 9, "EM_REPLACESEL returned %d, expected 9\n", r); r = SendMessage(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); ok(cr.cpMin == 7, "EM_EXGETSEL returned cpMin=%d, expected 7\n", cr.cpMin); @@ -4655,6 +4649,22 @@ SendMessage(hwndRichEdit, WM_SETREDRAW, TRUE, 0); DestroyWindow(hwndRichEdit); +} + +/* Native riched20 inspects the keyboard state (e.g. GetKeyState) + * to test the state of the modifiers (Ctrl/Alt/Shift). + * + * Therefore Ctrl-<key> keystrokes need to be simulated with + * keybd_event or by using SetKeyboardState to set the modifiers + * and SendMessage to simulate the keystrokes. + */ +static LRESULT send_ctrl_key(HWND hwnd, UINT key) +{ + LRESULT result; + hold_key(VK_CONTROL); + result = SendMessage(hwnd, WM_KEYDOWN, key, 1); + release_key(VK_CONTROL); + return result; } static void test_WM_PASTE(void) @@ -4669,34 +4679,19 @@ const char* text3 = "testing paste\r\npaste\r\ntesting paste"; HWND hwndRichEdit = new_richedit(NULL); - /* Native riched20 inspects the keyboard state (e.g. GetKeyState) - * to test the state of the modifiers (Ctrl/Alt/Shift). - * - * Therefore Ctrl-<key> keystrokes need to be simulated with - * keybd_event or by using SetKeyboardState to set the modifiers - * and SendMessage to simulate the keystrokes. - */ - - /* Sent keystrokes with keybd_event */ -#define SEND_CTRL_C(hwnd) pressKeyWithModifier(hwnd, VK_CONTROL, 'C') -#define SEND_CTRL_X(hwnd) pressKeyWithModifier(hwnd, VK_CONTROL, 'X') -#define SEND_CTRL_V(hwnd) pressKeyWithModifier(hwnd, VK_CONTROL, 'V') -#define SEND_CTRL_Z(hwnd) pressKeyWithModifier(hwnd, VK_CONTROL, 'Z') -#define SEND_CTRL_Y(hwnd) pressKeyWithModifier(hwnd, VK_CONTROL, 'Y') - SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text1); SendMessage(hwndRichEdit, EM_SETSEL, 0, 14); - SEND_CTRL_C(hwndRichEdit); /* Copy */ + send_ctrl_key(hwndRichEdit, 'C'); /* Copy */ SendMessage(hwndRichEdit, EM_SETSEL, 14, 14); - SEND_CTRL_V(hwndRichEdit); /* Paste */ + send_ctrl_key(hwndRichEdit, 'V'); /* Paste */ SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); /* Pasted text should be visible at this step */ result = strcmp(text1_step1, buffer); ok(result == 0, "test paste: strcmp = %i, text='%s'\n", result, buffer); - SEND_CTRL_Z(hwndRichEdit); /* Undo */ + send_ctrl_key(hwndRichEdit, 'Z'); /* Undo */ SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); /* Text should be the same as before (except for \r -> \r\n conversion) */ result = strcmp(text1_after, buffer); @@ -4705,37 +4700,31 @@ SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text2); SendMessage(hwndRichEdit, EM_SETSEL, 8, 13); - SEND_CTRL_C(hwndRichEdit); /* Copy */ + send_ctrl_key(hwndRichEdit, 'C'); /* Copy */ SendMessage(hwndRichEdit, EM_SETSEL, 14, 14); - SEND_CTRL_V(hwndRichEdit); /* Paste */ + send_ctrl_key(hwndRichEdit, 'V'); /* Paste */ SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); /* Pasted text should be visible at this step */ result = strcmp(text3, buffer); ok(result == 0, "test paste: strcmp = %i\n", result); - SEND_CTRL_Z(hwndRichEdit); /* Undo */ + send_ctrl_key(hwndRichEdit, 'Z'); /* Undo */ SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); /* Text should be the same as before (except for \r -> \r\n conversion) */ result = strcmp(text2_after, buffer); ok(result == 0, "test paste: strcmp = %i\n", result); - SEND_CTRL_Y(hwndRichEdit); /* Redo */ + send_ctrl_key(hwndRichEdit, 'Y'); /* Redo */ SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); /* Text should revert to post-paste state */ result = strcmp(buffer,text3); ok(result == 0, "test paste: strcmp = %i\n", result); -#undef SEND_CTRL_C -#undef SEND_CTRL_X -#undef SEND_CTRL_V -#undef SEND_CTRL_Z -#undef SEND_CTRL_Y - SendMessage(hwndRichEdit, WM_SETTEXT, 0, 0); /* Send WM_CHAR to simulates Ctrl-V */ SendMessage(hwndRichEdit, WM_CHAR, 22, - (MapVirtualKey('V', MAPVK_VK_TO_VSC) << 16) & 1); + (MapVirtualKey('V', MAPVK_VK_TO_VSC) << 16) | 1); SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); /* Shouldn't paste because pasting is handled by WM_KEYDOWN */ result = strcmp(buffer,""); @@ -4749,7 +4738,7 @@ /* Simulates paste (Ctrl-V) */ hold_key(VK_CONTROL); SendMessage(hwndRichEdit, WM_KEYDOWN, 'V', - (MapVirtualKey('V', MAPVK_VK_TO_VSC) << 16) & 1); + (MapVirtualKey('V', MAPVK_VK_TO_VSC) << 16) | 1); release_key(VK_CONTROL); SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); result = strcmp(buffer,"paste"); @@ -4761,7 +4750,7 @@ /* Simulates copy (Ctrl-C) */ hold_key(VK_CONTROL); SendMessage(hwndRichEdit, WM_KEYDOWN, 'C', - (MapVirtualKey('C', MAPVK_VK_TO_VSC) << 16) & 1); + (MapVirtualKey('C', MAPVK_VK_TO_VSC) << 16) | 1); release_key(VK_CONTROL); SendMessage(hwndRichEdit, WM_SETTEXT, 0, 0); SendMessage(hwndRichEdit, WM_PASTE, 0, 0); @@ -4775,10 +4764,10 @@ /* Simulates select all (Ctrl-A) */ hold_key(VK_CONTROL); SendMessage(hwndRichEdit, WM_KEYDOWN, 'A', - (MapVirtualKey('A', MAPVK_VK_TO_VSC) << 16) & 1); + (MapVirtualKey('A', MAPVK_VK_TO_VSC) << 16) | 1); /* Simulates select cut (Ctrl-X) */ SendMessage(hwndRichEdit, WM_KEYDOWN, 'X', - (MapVirtualKey('X', MAPVK_VK_TO_VSC) << 16) & 1); + (MapVirtualKey('X', MAPVK_VK_TO_VSC) << 16) | 1); release_key(VK_CONTROL); SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); result = strcmp(buffer,""); @@ -4793,14 +4782,14 @@ /* Simulates undo (Ctrl-Z) */ hold_key(VK_CONTROL); SendMessage(hwndRichEdit, WM_KEYDOWN, 'Z', - (MapVirtualKey('Z', MAPVK_VK_TO_VSC) << 16) & 1); + (MapVirtualKey('Z', MAPVK_VK_TO_VSC) << 16) | 1); SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); result = strcmp(buffer,""); ok(result == 0, "test paste: strcmp = %i, actual = '%s'\n", result, buffer); /* Simulates redo (Ctrl-Y) */ SendMessage(hwndRichEdit, WM_KEYDOWN, 'Y', - (MapVirtualKey('Y', MAPVK_VK_TO_VSC) << 16) & 1); + (MapVirtualKey('Y', MAPVK_VK_TO_VSC) << 16) | 1); SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); result = strcmp(buffer,"cut\r\n"); todo_wine ok(result == 0, @@ -4816,6 +4805,7 @@ HDC hdc; HWND hwndRichEdit = new_richedit(NULL); FORMATRANGE fr; + BOOL skip_non_english; static const struct { const char *string; /* The string */ int first; /* First 'pagebreak', 0 for don't care */ @@ -4828,6 +4818,10 @@ {"WINE\r\n\r\nwine\r\nwine", 5, 6} }; + skip_non_english = (PRIMARYLANGID(GetUserDefaultLangID()) != LANG_ENGLISH); + if (skip_non_english) + skip("Skipping some tests on non-English platform\n"); + hdc = GetDC(hwndRichEdit); ok(hdc != NULL, "Could not get HDC\n"); @@ -4889,7 +4883,8 @@ fr.chrg.cpMax = -1; r = SendMessage(hwndRichEdit, EM_FORMATRANGE, TRUE, (LPARAM) &fr); todo_wine { - ok(fr.rc.bottom == (stringsize.cy * tpp_y), "Expected bottom to be %d, got %d\n", (stringsize.cy * tpp_y), fr.rc.bottom); + if (! skip_non_english) + ok(fr.rc.bottom == (stringsize.cy * tpp_y), "Expected bottom to be %d, got %d\n", (stringsize.cy * tpp_y), fr.rc.bottom); } if (fmtstrings[i].first) todo_wine { @@ -4905,7 +4900,7 @@ todo_wine { ok(r == fmtstrings[i].second, "Expected %d, got %d\n", fmtstrings[i].second, r); } - else + else if (! skip_non_english) ok (r < len, "Expected < %d, got %d\n", len, r); /* There is at least on more page, but we don't care */ @@ -5017,20 +5012,29 @@ const char * streamText3 = "RichEdit1"; - struct StringWithLength cookieForStream4; const char * streamText4 = "This text just needs to be long enough to cause run to be split onto " "two separate lines and make sure the null terminating character is " "handled properly.\0"; int length4 = strlen(streamText4) + 1; - cookieForStream4.buffer = (char *)streamText4; - cookieForStream4.length = length4; + struct StringWithLength cookieForStream4 = { + length4, + (char *)streamText4, + }; + + const WCHAR streamText5[] = { 'T', 'e', 's', 't', 'S', 'o', 'm', 'e', 'T', 'e', 'x', 't' }; + int length5 = sizeof(streamText5) / sizeof(WCHAR); + struct StringWithLength cookieForStream5 = { + sizeof(streamText5), + (char *)streamText5, + }; /* Minimal test without \par at the end */ es.dwCookie = (DWORD_PTR)&streamText0; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; - SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + result = SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + ok(result == 12, "got %ld, expected %d\n", result, 12); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == 12, @@ -5044,7 +5048,8 @@ es.dwCookie = (DWORD_PTR)&streamText0a; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; - SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + result = SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + ok(result == 12, "got %ld, expected %d\n", result, 12); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == 12, @@ -5058,7 +5063,8 @@ es.dwCookie = (DWORD_PTR)&streamText0b; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; - SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + result = SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + ok(result == 13, "got %ld, expected %d\n", result, 13); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == 14, @@ -5071,7 +5077,8 @@ es.dwCookie = (DWORD_PTR)&streamText1; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; - SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + result = SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + ok(result == 12, "got %ld, expected %d\n", result, 12); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == 12, @@ -5083,7 +5090,8 @@ es.dwCookie = (DWORD_PTR)&streamText2; es.dwError = 0; - SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + result = SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + ok(result == 0, "got %ld, expected %d\n", result, 0); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == 0, @@ -5094,7 +5102,8 @@ es.dwCookie = (DWORD_PTR)&streamText3; es.dwError = 0; - SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + result = SendMessage(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + ok(result == 0, "got %ld, expected %d\n", result, 0); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == 0, @@ -5106,12 +5115,24 @@ es.dwCookie = (DWORD_PTR)&cookieForStream4; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback2; - SendMessage(hwndRichEdit, EM_STREAMIN, SF_TEXT, (LPARAM)&es); + result = SendMessage(hwndRichEdit, EM_STREAMIN, SF_TEXT, (LPARAM)&es); + ok(result == length4, "got %ld, expected %d\n", result, length4); result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); ok (result == length4, "EM_STREAMIN: Test 4 returned %ld, expected %d\n", result, length4); ok(es.dwError == 0, "EM_STREAMIN: Test 4 set error %d, expected %d\n", es.dwError, 0); + + es.dwCookie = (DWORD_PTR)&cookieForStream5; + es.dwError = 0; + es.pfnCallback = test_EM_STREAMIN_esCallback2; + result = SendMessage(hwndRichEdit, EM_STREAMIN, SF_TEXT | SF_UNICODE, (LPARAM)&es); + ok(result == sizeof(streamText5), "got %ld, expected %u\n", result, (UINT)sizeof(streamText5)); + + result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer); + ok (result == length5, + "EM_STREAMIN: Test 4 returned %ld, expected %d\n", result, length5); + ok(es.dwError == 0, "EM_STREAMIN: Test 5 set error %d, expected %d\n", es.dwError, 0); DestroyWindow(hwndRichEdit); } @@ -5240,17 +5261,8 @@ WPARAM wparam = (wm_get_text == WM_GETTEXT) ? 64 : (WPARAM)>ex; \ assert(wm_get_text == WM_GETTEXT || wm_get_text == EM_GETTEXTEX); \ memset(bufW, 0xAA, sizeof(bufW)); \ - if (is_win9x) \ - { \ - assert(wm_get_text == EM_GETTEXTEX); \ - ret = SendMessageA(hwnd, wm_get_text, wparam, (LPARAM)bufW); \ - ok(ret, "SendMessageA(%02x) error %u\n", wm_get_text, GetLastError()); \ - } \ - else \ - { \ - ret = SendMessageW(hwnd, wm_get_text, wparam, (LPARAM)bufW); \ - ok(ret, "SendMessageW(%02x) error %u\n", wm_get_text, GetLastError()); \ - } \ + ret = SendMessageW(hwnd, wm_get_text, wparam, (LPARAM)bufW); \ + ok(ret, "SendMessageW(%02x) error %u\n", wm_get_text, GetLastError()); \ ret = lstrcmpW(bufW, txt); \ ok(!ret, "%02x: strings do not match: expected[0] %x got[0] %x\n", wm_get_text, txt[0], bufW[0]); \ } while(0) @@ -5270,10 +5282,7 @@ ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); ret = IsWindowUnicode(hwnd); - if (is_win9x) - ok(!ret, "RichEdit20W should NOT be unicode under Win9x\n"); - else - ok(ret, "RichEdit20W should be unicode under NT\n"); + ok(ret, "RichEdit20W should be unicode under NT\n"); /* EM_SETTEXTEX is supported starting from version 3.0 */ em_settextex_supported = is_em_settextex_supported(hwnd); @@ -5299,10 +5308,7 @@ expect_empty(hwnd, WM_GETTEXT); expect_empty(hwnd, EM_GETTEXTEX); - if (is_win9x) - set_textA(hwnd, WM_SETTEXT, textW); - else - set_textA(hwnd, WM_SETTEXT, textA); + set_textA(hwnd, WM_SETTEXT, textA); expect_textA(hwnd, WM_GETTEXT, textA); expect_textA(hwnd, EM_GETTEXTEX, textA); expect_textW(hwnd, EM_GETTEXTEX, textW); @@ -5315,22 +5321,19 @@ expect_textW(hwnd, EM_GETTEXTEX, textW); } - if (!is_win9x) + set_textW(hwnd, WM_SETTEXT, textW); + expect_textW(hwnd, WM_GETTEXT, textW); + expect_textA(hwnd, WM_GETTEXT, textA); + expect_textW(hwnd, EM_GETTEXTEX, textW); + expect_textA(hwnd, EM_GETTEXTEX, textA); + + if (em_settextex_supported) { - set_textW(hwnd, WM_SETTEXT, textW); + set_textW(hwnd, EM_SETTEXTEX, textW); expect_textW(hwnd, WM_GETTEXT, textW); expect_textA(hwnd, WM_GETTEXT, textA); expect_textW(hwnd, EM_GETTEXTEX, textW); expect_textA(hwnd, EM_GETTEXTEX, textA); - - if (em_settextex_supported) - { - set_textW(hwnd, EM_SETTEXTEX, textW); - expect_textW(hwnd, WM_GETTEXT, textW); - expect_textA(hwnd, WM_GETTEXT, textA); - expect_textW(hwnd, EM_GETTEXTEX, textW); - expect_textA(hwnd, EM_GETTEXTEX, textA); - } } DestroyWindow(hwnd); @@ -5354,22 +5357,19 @@ expect_textW(hwnd, EM_GETTEXTEX, textW); } - if (!is_win9x) - { set_textW(hwnd, WM_SETTEXT, textW); expect_textW(hwnd, WM_GETTEXT, textW); expect_textA(hwnd, WM_GETTEXT, textA); expect_textW(hwnd, EM_GETTEXTEX, textW); expect_textA(hwnd, EM_GETTEXTEX, textA); - if (em_settextex_supported) - { - set_textW(hwnd, EM_SETTEXTEX, textW); - expect_textW(hwnd, WM_GETTEXT, textW); - expect_textA(hwnd, WM_GETTEXT, textA); - expect_textW(hwnd, EM_GETTEXTEX, textW); - expect_textA(hwnd, EM_GETTEXTEX, textA); - } + if (em_settextex_supported) + { + set_textW(hwnd, EM_SETTEXTEX, textW); + expect_textW(hwnd, WM_GETTEXT, textW); + expect_textA(hwnd, WM_GETTEXT, textA); + expect_textW(hwnd, EM_GETTEXTEX, textW); + expect_textA(hwnd, EM_GETTEXTEX, textA); } DestroyWindow(hwnd); } @@ -5437,12 +5437,8 @@ char buffer[64] = {0}; /* single line */ - if (!is_win9x) - hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP, - 0, 0, 200, 60, 0, 0, 0, 0); - else - hwnd = CreateWindowExA(0, "RichEdit20A", NULL, WS_POPUP, - 0, 0, 200, 60, 0, 0, 0, 0); + hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP, + 0, 0, 200, 60, 0, 0, 0, 0); ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; @@ -5486,12 +5482,8 @@ DestroyWindow(hwnd); /* multi line */ - if (!is_win9x) - hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP | ES_MULTILINE, - 0, 0, 200, 60, 0, 0, 0, 0); - else - hwnd = CreateWindowExA(0, "RichEdit20A", NULL, WS_POPUP | ES_MULTILINE, - 0, 0, 200, 60, 0, 0, 0, 0); + hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP | ES_MULTILINE, + 0, 0, 200, 60, 0, 0, 0, 0); ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; @@ -5794,12 +5786,8 @@ char buffer[64] = {0}; /* multi-line control inserts CR normally */ - if (!is_win9x) - hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP|ES_MULTILINE, - 0, 0, 200, 60, 0, 0, 0, 0); - else - hwnd = CreateWindowExA(0, "RichEdit20A", NULL, WS_POPUP|ES_MULTILINE, - 0, 0, 200, 60, 0, 0, 0, 0); + hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP|ES_MULTILINE, + 0, 0, 200, 60, 0, 0, 0, 0); ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); result = SendMessage(hwnd, EM_CANUNDO, 0, 0); @@ -5946,9 +5934,6 @@ return 0; } -#define SEND_CTRL_LEFT(hwnd) pressKeyWithModifier(hwnd, VK_CONTROL, VK_LEFT) -#define SEND_CTRL_RIGHT(hwnd) pressKeyWithModifier(hwnd, VK_CONTROL, VK_RIGHT) - static void test_word_movement(void) { HWND hwnd; @@ -5964,25 +5949,25 @@ SendMessage(hwnd, EM_SETSEL, 0, 0); /* |one two three */ - SEND_CTRL_RIGHT(hwnd); + send_ctrl_key(hwnd, VK_RIGHT); /* one |two three */ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); ok(sel_start == sel_end, "Selection should be empty\n"); ok(sel_start == 4, "Cursor is at %d instead of %d\n", sel_start, 4); - SEND_CTRL_RIGHT(hwnd); + send_ctrl_key(hwnd, VK_RIGHT); /* one two |three */ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); ok(sel_start == sel_end, "Selection should be empty\n"); ok(sel_start == 9, "Cursor is at %d instead of %d\n", sel_start, 9); - SEND_CTRL_LEFT(hwnd); + send_ctrl_key(hwnd, VK_LEFT); /* one |two three */ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); ok(sel_start == sel_end, "Selection should be empty\n"); ok(sel_start == 4, "Cursor is at %d instead of %d\n", sel_start, 4); - SEND_CTRL_LEFT(hwnd); + send_ctrl_key(hwnd, VK_LEFT); /* |one two three */ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); ok(sel_start == sel_end, "Selection should be empty\n"); @@ -5990,7 +5975,7 @@ SendMessage(hwnd, EM_SETSEL, 8, 8); /* one two | three */ - SEND_CTRL_RIGHT(hwnd); + send_ctrl_key(hwnd, VK_RIGHT); /* one two |three */ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); ok(sel_start == sel_end, "Selection should be empty\n"); @@ -5998,7 +5983,7 @@ SendMessage(hwnd, EM_SETSEL, 11, 11); /* one two th|ree */ - SEND_CTRL_LEFT(hwnd); + send_ctrl_key(hwnd, VK_LEFT); /* one two |three */ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); ok(sel_start == sel_end, "Selection should be empty\n"); @@ -6009,7 +5994,7 @@ ok (result == TRUE, "Failed to clear the text.\n"); SendMessage(hwnd, EM_SETWORDBREAKPROC, 0, (LPARAM)customWordBreakProc); /* |one twoXthree */ - SEND_CTRL_RIGHT(hwnd); + send_ctrl_key(hwnd, VK_RIGHT); /* one twoX|three */ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); ok(sel_start == sel_end, "Selection should be empty\n"); @@ -6019,11 +6004,6 @@ /* Make sure the behaviour is the same with a unicode richedit window, * and using unicode functions. */ - if (is_win9x) - { - skip("Cannot test with unicode richedit window\n"); - return; - } hwnd = CreateWindowW(RICHEDIT_CLASS20W, NULL, ES_MULTILINE|WS_POPUP|WS_HSCROLL|WS_VSCROLL|WS_VISIBLE, @@ -6034,7 +6014,7 @@ ok (result == TRUE, "Failed to clear the text.\n"); SendMessageW(hwnd, EM_SETWORDBREAKPROC, 0, (LPARAM)customWordBreakProc); /* |one twoXthree */ - SEND_CTRL_RIGHT(hwnd); + send_ctrl_key(hwnd, VK_RIGHT); /* one twoX|three */ SendMessageW(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); ok(sel_start == sel_end, "Selection should be empty\n"); @@ -6056,7 +6036,7 @@ hwnd = new_richedit(NULL); result = SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"one two three four five six seven\reight"); - + ok(result == 1, "Expected 1, got %d\n", result); GetClientRect(hwnd, &rcClient); result = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point); @@ -6074,7 +6054,7 @@ todo_wine ok(result == 33, "expected character index of 33 but got %d\n", result); point.x = 1000; - point.y = 40; + point.y = 36; result = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point); todo_wine ok(result == 39, "expected character index of 39 but got %d\n", result); @@ -6377,6 +6357,49 @@ rc.right = clientRect.right + 15; expected = rc; SendMessageA(hwnd, EM_SETRECT, 1, (LPARAM)&rc); + SendMessageA(hwnd, EM_GETRECT, 0, (LPARAM)&rc); + ok(rc.top == expected.top && rc.left == expected.left && + rc.bottom == expected.bottom && rc.right == expected.right, + "rect a(t=%d, l=%d, b=%d, r=%d) != e(t=%d, l=%d, b=%d, r=%d)\n", + rc.top, rc.left, rc.bottom, rc.right, + expected.top, expected.left, expected.bottom, expected.right); + + /* Reset to default rect and check how the format rect adjusts to window + * resize and how it copes with very small windows */ + SendMessageA(hwnd, EM_SETRECT, 0, (LPARAM)NULL); + + MoveWindow(hwnd, 0, 0, 100, 30, FALSE); + GetClientRect(hwnd, &clientRect); + + expected = clientRect; + expected.left += 1; + expected.right -= 1; + SendMessageA(hwnd, EM_GETRECT, 0, (LPARAM)&rc); + ok(rc.top == expected.top && rc.left == expected.left && + rc.bottom == expected.bottom && rc.right == expected.right, + "rect a(t=%d, l=%d, b=%d, r=%d) != e(t=%d, l=%d, b=%d, r=%d)\n", + rc.top, rc.left, rc.bottom, rc.right, + expected.top, expected.left, expected.bottom, expected.right); + + MoveWindow(hwnd, 0, 0, 0, 30, FALSE); + GetClientRect(hwnd, &clientRect); + + expected = clientRect; + expected.left += 1; + expected.right -= 1; + SendMessageA(hwnd, EM_GETRECT, 0, (LPARAM)&rc); + ok(rc.top == expected.top && rc.left == expected.left && + rc.bottom == expected.bottom && rc.right == expected.right, + "rect a(t=%d, l=%d, b=%d, r=%d) != e(t=%d, l=%d, b=%d, r=%d)\n", + rc.top, rc.left, rc.bottom, rc.right, + expected.top, expected.left, expected.bottom, expected.right); + + MoveWindow(hwnd, 0, 0, 100, 0, FALSE); + GetClientRect(hwnd, &clientRect); + + expected = clientRect; + expected.left += 1; + expected.right -= 1; SendMessageA(hwnd, EM_GETRECT, 0, (LPARAM)&rc); ok(rc.top == expected.top && rc.left == expected.left && rc.bottom == expected.bottom && rc.right == expected.right, @@ -6446,7 +6469,7 @@ msg.message = WM_KEYDOWN; msg.wParam = VK_RETURN; - msg.lParam = MapVirtualKey(VK_RETURN, MAPVK_VK_TO_VSC) | 0x0001; + msg.lParam = (MapVirtualKey(VK_RETURN, MAPVK_VK_TO_VSC) << 16) | 0x0001; msg.pt.x = 0; msg.pt.y = 0; msg.time = GetTickCount(); @@ -6496,7 +6519,7 @@ DestroyWindow(hwnd); msg.wParam = VK_TAB; - msg.lParam = MapVirtualKey(VK_TAB, MAPVK_VK_TO_VSC) | 0x0001; + msg.lParam = (MapVirtualKey(VK_TAB, MAPVK_VK_TO_VSC) << 16) | 0x0001; hwnd = CreateWindowEx(0, RICHEDIT_CLASS, NULL, ES_MULTILINE|WS_POPUP, @@ -6547,7 +6570,7 @@ release_key(VK_CONTROL); msg.wParam = 'a'; - msg.lParam = MapVirtualKey('a', MAPVK_VK_TO_VSC) | 0x0001; + msg.lParam = (MapVirtualKey('a', MAPVK_VK_TO_VSC) << 16) | 0x0001; hwnd = CreateWindowEx(0, RICHEDIT_CLASS, NULL, ES_MULTILINE|WS_POPUP, @@ -7062,14 +7085,100 @@ DestroyWindow(hwParent); } +static void test_EM_FINDWORDBREAK_W(void) +{ + static const struct { + WCHAR c; + BOOL isdelimiter; /* expected result of WB_ISDELIMITER */ + } delimiter_tests[] = { + {0x0a, FALSE}, /* newline */ + {0x0b, FALSE}, /* vertical tab */ + {0x0c, FALSE}, /* form feed */ + {0x0d, FALSE}, /* carriage return */ + {0x20, TRUE}, /* space */ + {0x61, FALSE}, /* capital letter a */ + {0xa0, FALSE}, /* no-break space */ + {0x2000, FALSE}, /* en quad */ + {0x3000, FALSE}, /* Ideographic space */ + {0x1100, FALSE}, /* Hangul Choseong Kiyeok (G sound) Ordinary Letter*/ + {0x11ff, FALSE}, /* Hangul Jongseoung Kiyeok-Hieuh (Hard N sound) Ordinary Letter*/ + {0x115f, FALSE}, /* Hangul Choseong Filler (no sound, used with two letter Hangul words) Ordinary Letter */ + {0xac00, FALSE}, /* Hangul character GA*/ + {0xd7af, FALSE}, /* End of Hangul character chart */ + {0xf020, TRUE}, /* MS private for CP_SYMBOL round trip?, see kb897872 */ + {0xff20, FALSE}, /* fullwidth commercial @ */ + {WCH_EMBEDDING, FALSE}, /* object replacement character*/ + }; + int i; + HWND hwndRichEdit = new_richeditW(NULL); + ok(IsWindowUnicode(hwndRichEdit), "window should be unicode\n"); + for (i = 0; i < sizeof(delimiter_tests)/sizeof(delimiter_tests[0]); i++) + { + WCHAR wbuf[2]; + int result; + + wbuf[0] = delimiter_tests[i].c; + wbuf[1] = 0; + SendMessageW(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)wbuf); + result = SendMessageW(hwndRichEdit, EM_FINDWORDBREAK, WB_ISDELIMITER,0); + if (wbuf[0] == 0x20 || wbuf[0] == 0xf020) + todo_wine + ok(result == delimiter_tests[i].isdelimiter, + "wanted ISDELIMITER_W(0x%x) %d, got %d\n", + delimiter_tests[i].c, delimiter_tests[i].isdelimiter,result); + else + ok(result == delimiter_tests[i].isdelimiter, + "wanted ISDELIMITER_W(0x%x) %d, got %d\n", + delimiter_tests[i].c, delimiter_tests[i].isdelimiter, result); + } + DestroyWindow(hwndRichEdit); +} + +static void test_EM_FINDWORDBREAK_A(void) +{ + static const struct { + WCHAR c; + BOOL isdelimiter; /* expected result of WB_ISDELIMITER */ + } delimiter_tests[] = { + {0x0a, FALSE}, /* newline */ + {0x0b, FALSE}, /* vertical tab */ + {0x0c, FALSE}, /* form feed */ + {0x0d, FALSE}, /* carriage return */ + {0x20, TRUE}, /* space */ + {0x61, FALSE}, /* capital letter a */ + }; + int i; + HWND hwndRichEdit = new_richedit(NULL); + + ok(!IsWindowUnicode(hwndRichEdit), "window should not be unicode\n"); + for (i = 0; i < sizeof(delimiter_tests)/sizeof(delimiter_tests[0]); i++) + { + int result; + char buf[2]; + buf[0] = delimiter_tests[i].c; + buf[1] = 0; + SendMessageW(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)buf); + result = SendMessage(hwndRichEdit, EM_FINDWORDBREAK, WB_ISDELIMITER, 0); + if (buf[0] == 0x20) + todo_wine + ok(result == delimiter_tests[i].isdelimiter, + "wanted ISDELIMITER_A(0x%x) %d, got %d\n", + delimiter_tests[i].c, delimiter_tests[i].isdelimiter,result); + else + ok(result == delimiter_tests[i].isdelimiter, + "wanted ISDELIMITER_A(0x%x) %d, got %d\n", + delimiter_tests[i].c, delimiter_tests[i].isdelimiter, result); + } + DestroyWindow(hwndRichEdit); +} + START_TEST( editor ) { + BOOL ret; /* Must explicitly LoadLibrary(). The test has no references to functions in * RICHED20.DLL, so the linker doesn't actually link to it. */ hmoduleRichEdit = LoadLibrary("RICHED20.DLL"); ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError()); - - is_win9x = GetVersion() & 0x80000000; test_WM_CHAR(); test_EM_FINDTEXT(); @@ -7119,6 +7228,8 @@ test_WM_GETDLGCODE(); test_zoom(); test_dialogmode(); + test_EM_FINDWORDBREAK_W(); + test_EM_FINDWORDBREAK_A(); /* Set the environment variable WINETEST_RICHED20 to keep windows * responsive and open for 30 seconds. This is useful for debugging. @@ -7128,5 +7239,6 @@ } OleFlushClipboard(); - ok(FreeLibrary(hmoduleRichEdit) != 0, "error: %d\n", (int) GetLastError()); -} + ret = FreeLibrary(hmoduleRichEdit); + ok(ret, "error: %d\n", (int) GetLastError()); +} Modified: trunk/rostests/winetests/riched20/richole.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/riched20/richol…
============================================================================== --- trunk/rostests/winetests/riched20/richole.c [iso-8859-1] (original) +++ trunk/rostests/winetests/riched20/richole.c [iso-8859-1] Fri Nov 4 23:07:16 2011 @@ -21,7 +21,7 @@ #define COBJMACROS #include <stdarg.h> -#include <assert.h> + #include <windef.h> #include <winbase.h> #include <wingdi.h> Modified: trunk/rostests/winetests/riched20/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/riched20/testli…
============================================================================== --- trunk/rostests/winetests/riched20/testlist.c [iso-8859-1] (original) +++ trunk/rostests/winetests/riched20/testlist.c [iso-8859-1] Fri Nov 4 23:07:16 2011 @@ -7,11 +7,13 @@ #include "wine/test.h" extern void func_editor(void); +extern void func_richole(void); extern void func_txtsrv(void); const struct test winetest_testlist[] = { - { "editor", func_editor }, - { "txtsrv", func_txtsrv }, + { "editor", func_editor }, + { "richole", func_richole }, + { "txtsrv", func_txtsrv }, { 0, 0 } }; Modified: trunk/rostests/winetests/riched20/txtsrv.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/riched20/txtsrv…
============================================================================== --- trunk/rostests/winetests/riched20/txtsrv.c [iso-8859-1] (original) +++ trunk/rostests/winetests/riched20/txtsrv.c [iso-8859-1] Fri Nov 4 23:07:16 2011 @@ -35,6 +35,24 @@ #include <limits.h> static HMODULE hmoduleRichEdit; +static IID *pIID_ITextServices; +static IID *pIID_ITextHost; +static IID *pIID_ITextHost2; + +static const char *debugstr_guid(REFIID riid) +{ + static char buf[50]; + + if(!riid) + return "(null)"; + + sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", + riid->Data1, riid->Data2, riid->Data3, riid->Data4[0], + riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4], + riid->Data4[5], riid->Data4[6], riid->Data4[7]); + + return buf; +} /* Define C Macros for ITextServices calls. */ @@ -75,17 +93,22 @@ typedef struct ITextHostTestImpl { - ITextHostVtbl *lpVtbl; + ITextHost ITextHost_iface; LONG refCount; } ITextHostTestImpl; + +static inline ITextHostTestImpl *impl_from_ITextHost(ITextHost *iface) +{ + return CONTAINING_RECORD(iface, ITextHostTestImpl, ITextHost_iface); +} static HRESULT WINAPI ITextHostImpl_QueryInterface(ITextHost *iface, REFIID riid, LPVOID *ppvObject) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; - - if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_ITextHost)) { + ITextHostTestImpl *This = impl_from_ITextHost(iface); + + if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, pIID_ITextHost)) { *ppvObject = This; ITextHost_AddRef((ITextHost *)*ppvObject); return S_OK; @@ -96,14 +119,14 @@ static ULONG WINAPI ITextHostImpl_AddRef(ITextHost *iface) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); ULONG refCount = InterlockedIncrement(&This->refCount); return refCount; } static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); ULONG refCount = InterlockedDecrement(&This->refCount); if (!refCount) @@ -117,7 +140,7 @@ static HDC WINAPI ITextHostImpl_TxGetDC(ITextHost *iface) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetDC(%p)\n", This); return NULL; } @@ -125,7 +148,7 @@ static INT WINAPI ITextHostImpl_TxReleaseDC(ITextHost *iface, HDC hdc) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxReleaseDC(%p)\n", This); return 0; } @@ -134,7 +157,7 @@ INT fnBar, BOOL fShow) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxShowScrollBar(%p, fnBar=%d, fShow=%d)\n", This, fnBar, fShow); return FALSE; @@ -144,7 +167,7 @@ INT fuSBFlags, INT fuArrowflags) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxEnableScrollBar(%p, fuSBFlags=%d, fuArrowflags=%d)\n", This, fuSBFlags, fuArrowflags); return FALSE; @@ -156,7 +179,7 @@ INT nMaxPos, BOOL fRedraw) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxSetScrollRange(%p, fnBar=%d, nMinPos=%d, nMaxPos=%d, fRedraw=%d)\n", This, fnBar, nMinPos, nMaxPos, fRedraw); return FALSE; @@ -167,7 +190,7 @@ INT nPos, BOOL fRedraw) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxSetScrollPos(%p, fnBar=%d, nPos=%d, fRedraw=%d)\n", This, fnBar, nPos, fRedraw); return FALSE; @@ -177,14 +200,14 @@ LPCRECT prc, BOOL fMode) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxInvalidateRect(%p, prc=%p, fMode=%d)\n", This, prc, fMode); } static void WINAPI ITextHostImpl_TxViewChange(ITextHost *iface, BOOL fUpdate) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxViewChange(%p, fUpdate=%d)\n", This, fUpdate); } @@ -193,7 +216,7 @@ HBITMAP hbmp, INT xWidth, INT yHeight) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxCreateCaret(%p, nbmp=%p, xWidth=%d, yHeight=%d)\n", This, hbmp, xWidth, yHeight); return FALSE; @@ -201,7 +224,7 @@ static BOOL WINAPI ITextHostImpl_TxShowCaret(ITextHost *iface, BOOL fShow) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxShowCaret(%p, fShow=%d)\n", This, fShow); return FALSE; @@ -210,7 +233,7 @@ static BOOL WINAPI ITextHostImpl_TxSetCaretPos(ITextHost *iface, INT x, INT y) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxSetCaretPos(%p, x=%d, y=%d)\n", This, x, y); return FALSE; } @@ -218,7 +241,7 @@ static BOOL WINAPI ITextHostImpl_TxSetTimer(ITextHost *iface, UINT idTimer, UINT uTimeout) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxSetTimer(%p, idTimer=%u, uTimeout=%u)\n", This, idTimer, uTimeout); return FALSE; @@ -226,7 +249,7 @@ static void WINAPI ITextHostImpl_TxKillTimer(ITextHost *iface, UINT idTimer) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxKillTimer(%p, idTimer=%u)\n", This, idTimer); } @@ -238,20 +261,20 @@ LPRECT lprcUpdate, UINT fuScroll) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxScrollWindowEx(%p, %d, %d, %p, %p, %p, %p, %d)\n", This, dx, dy, lprcScroll, lprcClip, hRgnUpdate, lprcUpdate, fuScroll); } static void WINAPI ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxSetCapture(%p, fCapture=%d)\n", This, fCapture); } static void WINAPI ITextHostImpl_TxSetFocus(ITextHost *iface) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxSetFocus(%p)\n", This); } @@ -259,7 +282,7 @@ HCURSOR hcur, BOOL fText) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxSetCursor(%p, hcur=%p, fText=%d)\n", This, hcur, fText); } @@ -267,7 +290,7 @@ static BOOL WINAPI ITextHostImpl_TxScreenToClient(ITextHost *iface, LPPOINT lppt) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxScreenToClient(%p, lppt=%p)\n", This, lppt); return FALSE; } @@ -275,7 +298,7 @@ static BOOL WINAPI ITextHostImpl_TxClientToScreen(ITextHost *iface, LPPOINT lppt) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxClientToScreen(%p, lppt=%p)\n", This, lppt); return FALSE; } @@ -283,7 +306,7 @@ static HRESULT WINAPI ITextHostImpl_TxActivate(ITextHost *iface, LONG *plOldState) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxActivate(%p, plOldState=%p)\n", This, plOldState); return E_NOTIMPL; } @@ -291,7 +314,7 @@ static HRESULT WINAPI ITextHostImpl_TxDeactivate(ITextHost *iface, LONG lNewState) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxDeactivate(%p, lNewState=%d)\n", This, lNewState); return E_NOTIMPL; } @@ -299,7 +322,7 @@ static HRESULT WINAPI ITextHostImpl_TxGetClientRect(ITextHost *iface, LPRECT prc) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetClientRect(%p, prc=%p)\n", This, prc); return E_NOTIMPL; } @@ -307,7 +330,7 @@ static HRESULT WINAPI ITextHostImpl_TxGetViewInset(ITextHost *iface, LPRECT prc) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetViewInset(%p, prc=%p)\n", This, prc); return E_NOTIMPL; } @@ -315,7 +338,7 @@ static HRESULT WINAPI ITextHostImpl_TxGetCharFormat(ITextHost *iface, const CHARFORMATW **ppCF) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetCharFormat(%p, ppCF=%p)\n", This, ppCF); return E_NOTIMPL; } @@ -323,7 +346,7 @@ static HRESULT WINAPI ITextHostImpl_TxGetParaFormat(ITextHost *iface, const PARAFORMAT **ppPF) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetParaFormat(%p, ppPF=%p)\n", This, ppPF); return E_NOTIMPL; } @@ -331,7 +354,7 @@ static COLORREF WINAPI ITextHostImpl_TxGetSysColor(ITextHost *iface, int nIndex) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetSysColor(%p, nIndex=%d)\n", This, nIndex); return E_NOTIMPL; } @@ -339,7 +362,7 @@ static HRESULT WINAPI ITextHostImpl_TxGetBackStyle(ITextHost *iface, TXTBACKSTYLE *pStyle) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetBackStyle(%p, pStyle=%p)\n", This, pStyle); return E_NOTIMPL; } @@ -347,7 +370,7 @@ static HRESULT WINAPI ITextHostImpl_TxGetMaxLength(ITextHost *iface, DWORD *pLength) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetMaxLength(%p, pLength=%p)\n", This, pLength); return E_NOTIMPL; } @@ -355,7 +378,7 @@ static HRESULT WINAPI ITextHostImpl_TxGetScrollBars(ITextHost *iface, DWORD *pdwScrollBar) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetScrollBars(%p, pdwScrollBar=%p)\n", This, pdwScrollBar); return E_NOTIMPL; @@ -364,7 +387,7 @@ static HRESULT WINAPI ITextHostImpl_TxGetPasswordChar(ITextHost *iface, WCHAR *pch) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetPasswordChar(%p, pch=%p)\n", This, pch); return E_NOTIMPL; } @@ -372,7 +395,7 @@ static HRESULT WINAPI ITextHostImpl_TxGetAcceleratorPos(ITextHost *iface, LONG *pch) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetAcceleratorPos(%p, pch=%p)\n", This, pch); return E_NOTIMPL; } @@ -380,7 +403,7 @@ static HRESULT WINAPI ITextHostImpl_TxGetExtent(ITextHost *iface, LPSIZEL lpExtent) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetExtent(%p, lpExtent=%p)\n", This, lpExtent); return E_NOTIMPL; } @@ -388,7 +411,7 @@ static HRESULT WINAPI ITextHostImpl_OnTxCharFormatChange(ITextHost *iface, const CHARFORMATW *pcf) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to OnTxCharFormatChange(%p, pcf=%p)\n", This, pcf); return E_NOTIMPL; } @@ -396,7 +419,7 @@ static HRESULT WINAPI ITextHostImpl_OnTxParaFormatChange(ITextHost *iface, const PARAFORMAT *ppf) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to OnTxParaFormatChange(%p, ppf=%p)\n", This, ppf); return E_NOTIMPL; } @@ -407,7 +430,7 @@ DWORD dwMask, DWORD *pdwBits) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetPropertyBits(%p, dwMask=0x%08x, pdwBits=%p)\n", This, dwMask, pdwBits); *pdwBits = 0; @@ -417,31 +440,31 @@ static HRESULT WINAPI ITextHostImpl_TxNotify(ITextHost *iface, DWORD iNotify, void *pv) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxNotify(%p, iNotify=%d, pv=%p)\n", This, iNotify, pv); return E_NOTIMPL; } static HIMC WINAPI ITextHostImpl_TxImmGetContext(ITextHost *iface) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxImmGetContext(%p)\n", This); return 0; } static void WINAPI ITextHostImpl_TxImmReleaseContext(ITextHost *iface, HIMC himc) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxImmReleaseContext(%p, himc=%p)\n", This, himc); } /* This function must set the variable pointed to by *lSelBarWidth. - Otherwise an uninitalized value will be used to calculate + Otherwise an uninitialized value will be used to calculate positions and sizes even if E_NOTIMPL is returned. */ static HRESULT WINAPI ITextHostImpl_TxGetSelectionBarWidth(ITextHost *iface, LONG *lSelBarWidth) { - ITextHostTestImpl *This = (ITextHostTestImpl *)iface; + ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetSelectionBarWidth(%p, lSelBarWidth=%p)\n", This, lSelBarWidth); *lSelBarWidth = 0; @@ -604,24 +627,24 @@ skip("Insufficient memory to create ITextHost interface\n"); return FALSE; } - dummyTextHost->lpVtbl = &itextHostVtbl; + dummyTextHost->ITextHost_iface.lpVtbl = &itextHostVtbl; dummyTextHost->refCount = 1; /* MSDN states that an IUnknown object is returned by CreateTextServices which is then queried to obtain a ITextServices object. */ pCreateTextServices = (void*)GetProcAddress(hmoduleRichEdit, "CreateTextServices"); - result = (*pCreateTextServices)(NULL,(ITextHost*)dummyTextHost, &init); - ok(result == S_OK, "Did not return OK when created. Returned %x\n", result); + result = (*pCreateTextServices)(NULL, &dummyTextHost->ITextHost_iface, &init); + ok(result == S_OK, "Did not return S_OK when created (result = %x)\n", result); if (result != S_OK) { CoTaskMemFree(dummyTextHost); skip("CreateTextServices failed.\n"); return FALSE; } - result = IUnknown_QueryInterface(init, &IID_ITextServices, + result = IUnknown_QueryInterface(init, pIID_ITextServices, (void **)&txtserv); - ok((result == S_OK) && (txtserv != NULL), "Querying interface failed\n"); + ok((result == S_OK) && (txtserv != NULL), "Querying interface failed (result = %x, txtserv = %p)\n", result, txtserv); IUnknown_Release(init); if (!((result == S_OK) && (txtserv != NULL))) { CoTaskMemFree(dummyTextHost); @@ -632,6 +655,12 @@ return TRUE; } +static void free_texthost(void) +{ + IUnknown_Release(txtserv); + CoTaskMemFree(dummyTextHost); +} + static void test_TxGetText(void) { HRESULT hres; @@ -641,10 +670,9 @@ return; hres = ITextServices_TxGetText(txtserv, &rettext); - ok(hres == S_OK, "ITextServices_TxGetText failed\n"); - - IUnknown_Release(txtserv); - CoTaskMemFree(dummyTextHost); + ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres); + + free_texthost(); } static void test_TxSetText(void) @@ -657,19 +685,18 @@ return; hres = ITextServices_TxSetText(txtserv, settext); - ok(hres == S_OK, "ITextServices_TxSetText failed\n"); + ok(hres == S_OK, "ITextServices_TxSetText failed (result = %x)\n", hres); hres = ITextServices_TxGetText(txtserv, &rettext); - ok(hres == S_OK, "ITextServices_TxGetText failed\n"); + ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres); ok(SysStringLen(rettext) == 4, - "String returned of wrong length\n"); + "String returned of wrong length (expected 4, got %d)\n", SysStringLen(rettext)); ok(memcmp(rettext,settext,SysStringByteLen(rettext)) == 0, "String returned differs\n"); SysFreeString(rettext); - IUnknown_Release(txtserv); - CoTaskMemFree(dummyTextHost); + free_texthost(); } static void test_TxGetNaturalSize(void) { @@ -708,9 +735,7 @@ ret = GetCharWidth32(hdcDraw,'A','Z',charwidth_caps_text); if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { win_skip("GetCharWidth32 is not available\n"); - RestoreDC(hdcDraw,1); - ReleaseDC(NULL,hdcDraw); - return; + goto cleanup; } /* Make measurements in MM_TEXT */ @@ -718,13 +743,20 @@ xdim = 0; ydim = 0; result = ITextServices_TxSetText(txtserv, oneA); - ok(result == S_OK, "ITextServices_TxSetText failed\n"); - + ok(result == S_OK, "ITextServices_TxSetText failed (result = %x)\n", result); + if (result != S_OK) { + skip("Could not set text\n"); + goto cleanup; + } + + SetLastError(0xdeadbeef); result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, hdcDraw, NULL, NULL, TXTNS_FITTOCONTENT, &psizelExtent, &xdim, &ydim); - todo_wine ok(result == S_OK, "TxGetNaturalSize failed\n"); + todo_wine ok(result == S_OK || broken(result == E_FAIL), /* WINXP Arabic Language */ + "TxGetNaturalSize gave unexpected return value (result = %x)\n", result); + if (result == S_OK) { todo_wine ok(ydim == tmInfo_text.tmHeight, "Height calculated incorrectly (expected %d, got %d)\n", tmInfo_text.tmHeight, ydim); @@ -732,12 +764,14 @@ todo_wine ok(xdim >= charwidth_caps_text[0] && xdim <= charwidth_caps_text[0] + 1, "Width calculated incorrectly (expected %d {+1}, got %d)\n", charwidth_caps_text[0], xdim); - + } else + skip("TxGetNaturalSize measurements not performed (xdim = %d, ydim = %d, result = %x, error = %x)\n", + xdim, ydim, result, GetLastError()); + +cleanup: RestoreDC(hdcDraw,1); ReleaseDC(NULL,hdcDraw); - - IUnknown_Release(txtserv); - CoTaskMemFree(dummyTextHost); + free_texthost(); } static void test_TxDraw(void) @@ -757,13 +791,27 @@ result = ITextServices_TxDraw(txtserv, dwAspect, 0, pvAspect, ptd, tmphdc, hicTargetDev, &client, NULL, NULL, NULL, 0, 0); - ok(result == S_OK, "TxDraw failed\n"); - } - - IUnknown_Release(txtserv); - CoTaskMemFree(dummyTextHost); - -} + ok(result == S_OK, "TxDraw failed (result = %x)\n", result); + } + + free_texthost(); + +} + +DEFINE_GUID(expected_iid_itextservices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5); +DEFINE_GUID(expected_iid_itexthost, 0x13e670f4,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1); +DEFINE_GUID(expected_iid_itexthost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1); + +static void test_IIDs(void) +{ + ok(IsEqualIID(pIID_ITextServices, &expected_iid_itextservices), + "unexpected value for IID_ITextServices: %s\n", debugstr_guid(pIID_ITextServices)); + ok(IsEqualIID(pIID_ITextHost, &expected_iid_itexthost), + "unexpected value for IID_ITextHost: %s\n", debugstr_guid(pIID_ITextHost)); + ok(IsEqualIID(pIID_ITextHost2, &expected_iid_itexthost2), + "unexpected value for IID_ITextHost2: %s\n", debugstr_guid(pIID_ITextHost2)); +} + START_TEST( txtsrv ) { @@ -774,10 +822,14 @@ hmoduleRichEdit = LoadLibrary("RICHED20.DLL"); ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError()); + pIID_ITextServices = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextServices"); + pIID_ITextHost = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextHost"); + pIID_ITextHost2 = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextHost2"); + test_IIDs(); + if (init_texthost()) { - IUnknown_Release(txtserv); - CoTaskMemFree(dummyTextHost); + free_texthost(); test_TxGetText(); test_TxSetText();
13 years, 5 months
1
0
0
0
[jimtabor] 54289: - Fix build.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Fri Nov 4 13:21:13 2011 New Revision: 54289 URL:
http://svn.reactos.org/svn/reactos?rev=54289&view=rev
Log: - Fix build. Modified: trunk/reactos/subsystems/win32/win32k/pch.h Modified: trunk/reactos/subsystems/win32/win32k/pch.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/pc…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/pch.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/pch.h [iso-8859-1] Fri Nov 4 13:21:13 2011 @@ -58,6 +58,7 @@ #define NT_BUILD_ENVIRONMENT #include <winddi.h> #include <winuser.h> +#include <windowsx.h> #include <prntfont.h> #include <dde.h> #include <wincon.h>
13 years, 5 months
1
0
0
0
[jimtabor] 54288: [Win32k|User32] - Move control color support to Win32k.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Fri Nov 4 13:16:48 2011 New Revision: 54288 URL:
http://svn.reactos.org/svn/reactos?rev=54288&view=rev
Log: [Win32k|User32] - Move control color support to Win32k. Modified: trunk/reactos/dll/win32/user32/controls/button.c trunk/reactos/dll/win32/user32/controls/listbox.c trunk/reactos/dll/win32/user32/include/ntwrapper.h trunk/reactos/dll/win32/user32/include/user32p.h trunk/reactos/dll/win32/user32/misc/misc.c trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c trunk/reactos/subsystems/win32/win32k/ntuser/misc.c trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c Modified: trunk/reactos/dll/win32/user32/controls/button.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/…
============================================================================== --- trunk/reactos/dll/win32/user32/controls/button.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/controls/button.c [iso-8859-1] Fri Nov 4 13:16:48 2011 @@ -335,10 +335,7 @@ HBRUSH hBrush; HWND parent = GetParent(hWnd); if (!parent) parent = hWnd; - hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hdc, (LPARAM)hWnd); - if (!hBrush) /* did the app forget to call defwindowproc ? */ - hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN, - (WPARAM)hdc, (LPARAM)hWnd); + hBrush = GetControlColor( parent, hWnd, hdc, WM_CTLCOLORBTN); GetClientRect(hWnd, &rc); FillRect(hdc, &rc, hBrush); } @@ -885,7 +882,7 @@ if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); parent = GetParent(hwnd); if (!parent) parent = hwnd; - SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd ); + GetControlColor( parent, hwnd, hDC, WM_CTLCOLORBTN); setup_clipping( hwnd, hDC ); #ifdef __REACTOS__ @@ -1175,10 +1172,7 @@ parent = GetParent(hwnd); if (!parent) parent = hwnd; - hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd); - if (!hBrush) /* did the app forget to call defwindowproc ? */ - hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN, - (WPARAM)hDC, (LPARAM)hwnd); + hBrush = GetControlColor( parent, hwnd, hDC, WM_CTLCOLORBTN); FillRect( hDC, &rc, hBrush ); if ((action == ODA_FOCUS) || @@ -1219,7 +1213,7 @@ if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont ); parent = GetParent(hwnd); if (!parent) parent = hwnd; - SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd ); + GetControlColor( parent, hwnd, hDC, WM_CTLCOLORBTN); setup_clipping( hwnd, hDC ); Modified: trunk/reactos/dll/win32/user32/controls/listbox.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/…
============================================================================== --- trunk/reactos/dll/win32/user32/controls/listbox.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/controls/listbox.c [iso-8859-1] Fri Nov 4 13:16:48 2011 @@ -660,8 +660,7 @@ if (LISTBOX_GetItemRect( descr, index, &rect ) != 1) return; if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE ))) return; if (descr->font) oldFont = SelectObject( hdc, descr->font ); - hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX, - (WPARAM)hdc, (LPARAM)descr->self ); + hbrush = GetControlColor( descr->owner, descr->self, hdc, WM_CTLCOLORLISTBOX); if (hbrush) oldBrush = SelectObject( hdc, hbrush ); if (!IsWindowEnabled(descr->self)) SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) ); @@ -1032,8 +1031,7 @@ } if (descr->font) oldFont = SelectObject( hdc, descr->font ); - hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX, - (WPARAM)hdc, (LPARAM)descr->self ); + hbrush = GetControlColor( descr->owner, descr->self, hdc, WM_CTLCOLORLISTBOX); if (hbrush) oldBrush = SelectObject( hdc, hbrush ); if (!IsWindowEnabled(descr->self)) SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) ); @@ -3162,8 +3160,7 @@ if ((IS_OWNERDRAW(descr)) && !(descr->style & LBS_DISPLAYCHANGED)) { RECT rect; - HBRUSH hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX, - wParam, (LPARAM)descr->self ); + HBRUSH hbrush = GetControlColor( descr->owner, descr->self, (HDC)wParam, WM_CTLCOLORLISTBOX); TRACE("hbrush = %p\n", hbrush); if(!hbrush) hbrush = GetSysColorBrush(COLOR_WINDOW); Modified: trunk/reactos/dll/win32/user32/include/ntwrapper.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/n…
============================================================================== --- trunk/reactos/dll/win32/user32/include/ntwrapper.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/include/ntwrapper.h [iso-8859-1] Fri Nov 4 13:16:48 2011 @@ -240,6 +240,16 @@ return NtUserGetClipCursor(lpRect); } +EXTINLINE HBRUSH WINAPI GetControlBrush(HWND hwnd, HDC hdc, UINT ctlType) +{ + return NtUserGetControlBrush(hwnd, hdc, ctlType); +} + +EXTINLINE HBRUSH WINAPI GetControlColor(HWND hwndParent, HWND hwnd, HDC hdc, UINT CtlMsg) +{ + return NtUserGetControlColor(hwndParent, hwnd, hdc, CtlMsg); +} + EXTINLINE BOOL WINAPI GetCursorInfo(PCURSORINFO pci) { Modified: trunk/reactos/dll/win32/user32/include/user32p.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/u…
============================================================================== --- trunk/reactos/dll/win32/user32/include/user32p.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/include/user32p.h [iso-8859-1] Fri Nov 4 13:16:48 2011 @@ -100,7 +100,5 @@ HWND* WIN_ListChildren (HWND hWndparent); VOID DeleteFrameBrushes(VOID); BOOL WINAPI GdiValidateHandle(HGDIOBJ); -HBRUSH FASTCALL GetControlColor(HWND,HWND,HDC,UINT); -HBRUSH FASTCALL GetControlBrush(HWND,HDC,UINT); /* EOF */ Modified: trunk/reactos/dll/win32/user32/misc/misc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/misc…
============================================================================== --- trunk/reactos/dll/win32/user32/misc/misc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/misc/misc.c [iso-8859-1] Fri Nov 4 13:16:48 2011 @@ -481,45 +481,6 @@ return ValidateHwnd(hwnd); } -HBRUSH -FASTCALL -GetControlColor( - HWND hwndParent, - HWND hwnd, - HDC hdc, - UINT CtlMsg) -{ - PWND pwnd; - HBRUSH hBrush; - - if (!hwndParent) hwndParent = hwnd; - - pwnd = ValidateHwnd(hwndParent); - if (pwnd && !TestWindowProcess(pwnd)) - { - return (HBRUSH)DefWindowProcW( hwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)hwnd); - } - - hBrush = (HBRUSH)SendMessageW( hwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)hwnd); - - if (!hBrush || !GdiValidateHandle(hBrush)) - { - hBrush = (HBRUSH)DefWindowProcW( hwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)hwnd); - } - return hBrush; -} - -HBRUSH -FASTCALL -GetControlBrush( - HWND hwnd, - HDC hdc, - UINT ctlType) -{ - HWND hwndParent = GetParent(hwnd); - return GetControlColor( hwndParent, hwnd, hdc, ctlType); -} - /* * @implemented */ Modified: trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c [iso-8859-1] Fri Nov 4 13:16:48 2011 @@ -94,6 +94,43 @@ return lResult; } +HBRUSH FASTCALL +DefWndControlColor(HDC hDC, UINT ctlType) +{ + if (ctlType == CTLCOLOR_SCROLLBAR) + { + HBRUSH hb = IntGetSysColorBrush(COLOR_SCROLLBAR); + COLORREF bk = IntGetSysColor(COLOR_3DHILIGHT); + IntGdiSetTextColor(hDC, IntGetSysColor(COLOR_3DFACE)); + IntGdiSetBkColor(hDC, bk); + + /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT + * we better use 0x55aa bitmap brush to make scrollbar's background + * look different from the window background. + */ + if ( bk == IntGetSysColor(COLOR_WINDOW)) + return gpsi->hbrGray; + + NtGdiUnrealizeObject( hb ); + return hb; + } + + IntGdiSetTextColor(hDC, IntGetSysColor(COLOR_WINDOWTEXT)); + + if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX)) + { + IntGdiSetBkColor(hDC, IntGetSysColor(COLOR_WINDOW)); + } + else + { + IntGdiSetBkColor(hDC, IntGetSysColor(COLOR_3DFACE)); + return IntGetSysColorBrush(COLOR_3DFACE); + } + + return IntGetSysColorBrush(COLOR_WINDOW); +} + + LRESULT FASTCALL DefWndHandleSysCommand(PWND pWnd, WPARAM wParam, LPARAM lParam) { @@ -168,10 +205,30 @@ case WM_CLIENTSHUTDOWN: return IntClientShutdown(Wnd, wParam, lParam); + case WM_CTLCOLORMSGBOX: + case WM_CTLCOLOREDIT: + case WM_CTLCOLORLISTBOX: + case WM_CTLCOLORBTN: + case WM_CTLCOLORDLG: + case WM_CTLCOLORSTATIC: + case WM_CTLCOLORSCROLLBAR: + return (LRESULT) DefWndControlColor((HDC)wParam, Msg - WM_CTLCOLORMSGBOX); + + case WM_CTLCOLOR: + return (LRESULT) DefWndControlColor((HDC)wParam, HIWORD(lParam)); + case WM_GETHOTKEY: return DefWndGetHotKey(UserHMGetHandle(Wnd)); case WM_SETHOTKEY: return DefWndSetHotKey(Wnd, wParam); + + case WM_NCHITTEST: + { + POINT Point; + Point.x = GET_X_LPARAM(lParam); + Point.y = GET_Y_LPARAM(lParam); + return GetNCHitEx(Wnd, Point); + } /* ReactOS only. */ case WM_CBT: Modified: trunk/reactos/subsystems/win32/win32k/ntuser/misc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/misc.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/misc.c [iso-8859-1] Fri Nov 4 13:16:48 2011 @@ -53,6 +53,90 @@ } TRACE("Language ID = %x\n",Ret); return (SHORT) Ret; +} + +HBRUSH +FASTCALL +GetControlColor( + PWND pwndParent, + PWND pwnd, + HDC hdc, + UINT CtlMsg) +{ + HBRUSH hBrush; + + if (!pwndParent) pwndParent = pwnd; + + if ( pwndParent->head.pti->ppi != PsGetCurrentProcessWin32Process()) + { + return (HBRUSH)IntDefWindowProc( pwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd), FALSE); + } + + hBrush = (HBRUSH)co_IntSendMessage( UserHMGetHandle(pwndParent), CtlMsg, (WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd)); + + if (!hBrush || !GreIsHandleValid(hBrush)) + { + hBrush = (HBRUSH)IntDefWindowProc( pwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd), FALSE); + } + return hBrush; +} + +HBRUSH +FASTCALL +GetControlBrush( + PWND pwnd, + HDC hdc, + UINT ctlType) +{ + PWND pwndParent = IntGetParent(pwnd); + return GetControlColor( pwndParent, pwnd, hdc, ctlType); +} + +HBRUSH +APIENTRY +NtUserGetControlBrush( + HWND hwnd, + HDC hdc, + UINT ctlType) +{ + PWND pwnd; + HBRUSH hBrush = NULL; + + UserEnterExclusive(); + if ( (pwnd = UserGetWindowObject(hwnd)) && + ((ctlType - WM_CTLCOLORMSGBOX) < CTLCOLOR_MAX) && + hdc ) + { + hBrush = GetControlBrush(pwnd, hdc, ctlType); + } + UserLeave(); + return hBrush; +} + +/* + * Called from PaintRect, works almost like wine PaintRect16 but returns hBrush. + */ +HBRUSH +APIENTRY +NtUserGetControlColor( + HWND hwndParent, + HWND hwnd, + HDC hdc, + UINT CtlMsg) // Wine PaintRect: WM_CTLCOLORMSGBOX + hbrush +{ + PWND pwnd, pwndParent = NULL; + HBRUSH hBrush = NULL; + + UserEnterExclusive(); + if ( (pwnd = UserGetWindowObject(hwnd)) && + ((CtlMsg - WM_CTLCOLORMSGBOX) < CTLCOLOR_MAX) && + hdc ) + { + if (hwndParent) pwndParent = UserGetWindowObject(hwndParent); + hBrush = GetControlColor( pwndParent, pwnd, hdc, CtlMsg); + } + UserLeave(); + return hBrush; } /* Modified: trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c [iso-8859-1] Fri Nov 4 13:16:48 2011 @@ -202,35 +202,6 @@ LPWSTR pszItemText, UINT cchItemText, BOOL Ansi) -{ - STUB - - return 0; -} - -HBRUSH -APIENTRY -NtUserGetControlBrush( - HWND hwnd, - HDC hdc, - UINT ctlType) -{ - STUB - - return 0; -} - - -/* - * Called from PaintRect, works almost like wine PaintRect16 but returns hBrush. - */ -HBRUSH -APIENTRY -NtUserGetControlColor( - HWND hwndParent, - HWND hwnd, - HDC hdc, - UINT CtlMsg) // Wine PaintRect: WM_CTLCOLORMSGBOX + hbrush { STUB
13 years, 5 months
1
0
0
0
[khornicek] 54287: [KERNEL32] Fix a copypasta. See issue #6635 for more details.
by khornicek@svn.reactos.org
Author: khornicek Date: Thu Nov 3 13:48:23 2011 New Revision: 54287 URL:
http://svn.reactos.org/svn/reactos?rev=54287&view=rev
Log: [KERNEL32] Fix a copypasta. See issue #6635 for more details. Modified: trunk/reactos/dll/win32/kernel32/client/utils.c Modified: trunk/reactos/dll/win32/kernel32/client/utils.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/utils.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/utils.c [iso-8859-1] Thu Nov 3 13:48:23 2011 @@ -205,7 +205,7 @@ else { /* Convert it */ - Status = Basep8BitStringToUnicodeString(UnicodeString, &AnsiString, FALSE); + Status = Basep8BitStringToUnicodeString(UnicodeString, &AnsiString, TRUE); } if (NT_SUCCESS(Status)) return TRUE;
13 years, 5 months
1
0
0
0
[ion] 54286: [KERNEL32]: BaseNamedObjectDirectory should work on demand, instead of on startup. Also, support cases when the thread is doing impersonation, to make sure it uses its real session ID ...
by ion@svn.reactos.org
Author: ion Date: Thu Nov 3 07:00:48 2011 New Revision: 54286 URL:
http://svn.reactos.org/svn/reactos?rev=54286&view=rev
Log: [KERNEL32]: BaseNamedObjectDirectory should work on demand, instead of on startup. Also, support cases when the thread is doing impersonation, to make sure it uses its real session ID and security access. Also, support cases when the BNO directory is not available, and use the BNO\Restricted directory instead (we should have our CSRSS create it). Modified: trunk/reactos/dll/win32/kernel32/client/dllmain.c trunk/reactos/dll/win32/kernel32/client/file/filemap.c trunk/reactos/dll/win32/kernel32/client/resntfy.c trunk/reactos/dll/win32/kernel32/client/utils.c trunk/reactos/dll/win32/kernel32/include/base_x.h trunk/reactos/dll/win32/kernel32/include/kernel32.h Modified: trunk/reactos/dll/win32/kernel32/client/dllmain.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] Thu Nov 3 07:00:48 2011 @@ -31,7 +31,6 @@ HANDLE BaseNamedObjectDirectory; HMODULE hCurrentModule = NULL; HMODULE kernel32_handle = NULL; -HANDLE hBaseDir = NULL; PPEB Peb; ULONG SessionId; BOOL ConsoleInitialized = FALSE; @@ -288,15 +287,6 @@ /* Initialize command line */ InitCommandLines(); - /* Open object base directory */ - Status = BaseGetNamedObjectDirectory(); - hBaseDir = BaseNamedObjectDirectory; - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to open object base directory (Status %lx)\n", Status); - return FALSE; - } - /* Initialize the DLL critical section */ RtlInitializeCriticalSection(&BaseDllDirectoryLock); Modified: trunk/reactos/dll/win32/kernel32/client/file/filemap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/file/filemap.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/file/filemap.c [iso-8859-1] Thu Nov 3 07:00:48 2011 @@ -312,7 +312,7 @@ InitializeObjectAttributes(&ObjectAttributes, &UnicodeName, (bInheritHandle ? OBJ_INHERIT : 0), - hBaseDir, + BaseGetNamedObjectDirectory(), NULL); /* Convert COPY to READ */ Modified: trunk/reactos/dll/win32/kernel32/client/resntfy.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/resntfy.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/resntfy.c [iso-8859-1] Thu Nov 3 07:00:48 2011 @@ -41,7 +41,7 @@ InitializeObjectAttributes(&ObjectAttributes, &EventName, 0, - hBaseDir, + BaseGetNamedObjectDirectory(), NULL); Status = NtOpenEvent(&hEvent, Modified: trunk/reactos/dll/win32/kernel32/client/utils.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/utils.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/utils.c [iso-8859-1] Thu Nov 3 07:00:48 2011 @@ -22,15 +22,46 @@ /* GLOBALS ********************************************************************/ PRTL_CONVERT_STRING Basep8BitStringToUnicodeString; +UNICODE_STRING Restricted = RTL_CONSTANT_STRING(L"Restricted"); /* FUNCTIONS ******************************************************************/ -NTSTATUS +HANDLE WINAPI BaseGetNamedObjectDirectory(VOID) { OBJECT_ATTRIBUTES ObjectAttributes; NTSTATUS Status; + HANDLE DirHandle, BnoHandle, Token, NewToken; + + if (BaseNamedObjectDirectory) return BaseNamedObjectDirectory; + + if (NtCurrentTeb()->IsImpersonating) + { + Status = NtOpenThreadToken(NtCurrentThread(), + TOKEN_IMPERSONATE, + TRUE, + &Token); + if (!NT_SUCCESS(Status)) return BaseNamedObjectDirectory; + + NewToken = NULL; + Status = NtSetInformationThread(NtCurrentThread(), + ThreadImpersonationToken, + &NewToken, + sizeof(HANDLE)); + if (!NT_SUCCESS (Status)) + { + NtClose(Token); + return BaseNamedObjectDirectory; + } + } + else + { + Token = NULL; + } + + RtlAcquirePebLock(); + if (BaseNamedObjectDirectory) goto Quickie; InitializeObjectAttributes(&ObjectAttributes, &BaseStaticServerData->NamedObjectDirectory, @@ -38,14 +69,54 @@ NULL, NULL); - Status = NtOpenDirectoryObject(&BaseNamedObjectDirectory, - DIRECTORY_ALL_ACCESS & - ~(DELETE | WRITE_DAC | WRITE_OWNER), + Status = NtOpenDirectoryObject(&BnoHandle, + DIRECTORY_QUERY | + DIRECTORY_TRAVERSE | + DIRECTORY_CREATE_OBJECT | + DIRECTORY_CREATE_SUBDIRECTORY, &ObjectAttributes); - if (!NT_SUCCESS(Status)) return Status; - - DPRINT("Opened BNO: %lx\n", BaseNamedObjectDirectory); - return Status; + if (!NT_SUCCESS(Status)) + { + Status = NtOpenDirectoryObject(&DirHandle, + DIRECTORY_TRAVERSE, + &ObjectAttributes); + + if (NT_SUCCESS(Status)) + { + InitializeObjectAttributes(&ObjectAttributes, + (PUNICODE_STRING)&Restricted, + OBJ_CASE_INSENSITIVE, + DirHandle, + NULL); + + Status = NtOpenDirectoryObject(&BnoHandle, + DIRECTORY_QUERY | + DIRECTORY_TRAVERSE | + DIRECTORY_CREATE_OBJECT | + DIRECTORY_CREATE_SUBDIRECTORY, + &ObjectAttributes); + NtClose(DirHandle); + + } + } + + if (NT_SUCCESS(Status)) BaseNamedObjectDirectory = BnoHandle; + +Quickie: + + RtlReleasePebLock(); + + if (Token) + { + NtSetInformationThread(NtCurrentThread(), + ThreadImpersonationToken, + &Token, + sizeof(Token)); + + NtClose(Token); + } + + return BaseNamedObjectDirectory; } VOID @@ -224,7 +295,7 @@ if (ObjectName) { Attributes |= OBJ_OPENIF; - RootDirectory = hBaseDir; + RootDirectory = BaseGetNamedObjectDirectory(); } else { @@ -282,10 +353,10 @@ { StackReserve = ROUND_UP(StackCommit, 1024 * 1024); } - + StackCommit = ROUND_UP(StackCommit, PageSize); StackReserve = ROUND_UP(StackReserve, AllocationGranularity); - + GuaranteedStackCommit = NtCurrentTeb()->GuaranteedStackBytes; if ((GuaranteedStackCommit) && (StackCommit < GuaranteedStackCommit)) { @@ -299,7 +370,7 @@ StackCommit = ROUND_UP(StackCommit, PageSize); StackReserve = ROUND_UP(StackReserve, AllocationGranularity); - + /* ROS Hack until we support guard page stack expansion */ StackCommit = StackReserve; @@ -337,7 +408,7 @@ { UseGuard = FALSE; } - + /* Allocate memory for the stack */ Status = ZwAllocateVirtualMemory(hProcess, (PVOID*)&Stack, Modified: trunk/reactos/dll/win32/kernel32/include/base_x.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
============================================================================== --- trunk/reactos/dll/win32/kernel32/include/base_x.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/include/base_x.h [iso-8859-1] Thu Nov 3 07:00:48 2011 @@ -100,7 +100,7 @@ POBJECT_ATTRIBUTES ObjectAttributes = &LocalAttributes; #define CreateNtObjectFromWin32ApiBody(ntobj, sec, name, access, ...) \ if (name) RtlInitUnicodeString(&ObjectName, name); \ - ObjectAttributes = BaseFormatObjectAttributes(&LocalAttributes, \ + ObjectAttributes = BaseFormatObjectAttributes(&LocalAttributes, \ sec, \ name ? &ObjectName : NULL); \ Status = NtCreate##ntobj(&Handle, access, ObjectAttributes, ##__VA_ARGS__); @@ -113,7 +113,7 @@ SetLastError(ERROR_SUCCESS); \ return Handle; \ } \ - BaseSetLastNTError(Status); \ + BaseSetLastNTError(Status); \ return NULL; \ } @@ -138,19 +138,19 @@ CreateNtObjectFromWin32ApiPrologue \ if (!name) \ { \ - BaseSetLastNTError(STATUS_INVALID_PARAMETER); \ + BaseSetLastNTError(STATUS_INVALID_PARAMETER); \ return NULL; \ } \ RtlInitUnicodeString(&ObjectName, name); \ InitializeObjectAttributes(ObjectAttributes, \ &ObjectName, \ inh ? OBJ_INHERIT : 0, \ - hBaseDir, \ + BaseGetNamedObjectDirectory(), \ NULL); \ Status = NtOpen##ntobj(&Handle, acc, ObjectAttributes); \ if (!NT_SUCCESS(Status)) \ { \ - BaseSetLastNTError(Status); \ + BaseSetLastNTError(Status); \ return NULL; \ } \ return Handle; \ Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
============================================================================== --- trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] Thu Nov 3 07:00:48 2011 @@ -109,7 +109,6 @@ /* GLOBAL VARIABLES **********************************************************/ extern BOOL bIsFileApiAnsi; -extern HANDLE hBaseDir; extern HMODULE hCurrentModule; extern RTL_CRITICAL_SECTION BaseDllDirectoryLock; @@ -243,7 +242,7 @@ extern PRTL_CONVERT_STRING Basep8BitStringToUnicodeString; extern HANDLE BaseNamedObjectDirectory; -NTSTATUS +HANDLE WINAPI BaseGetNamedObjectDirectory(VOID);
13 years, 5 months
1
0
0
0
[ion] 54285: [KERNEL32]: Fix multiple issues in BaseCreateStack: - StackLimit was set incorrectly. - Code was not using BaseStaticServerdata, but querying NT instead. - Fix memory leak in failure c...
by ion@svn.reactos.org
Author: ion Date: Thu Nov 3 06:46:22 2011 New Revision: 54285 URL:
http://svn.reactos.org/svn/reactos?rev=54285&view=rev
Log: [KERNEL32]: Fix multiple issues in BaseCreateStack: - StackLimit was set incorrectly. - Code was not using BaseStaticServerdata, but querying NT instead. - Fix memory leak in failure case. - StackCommit and StackReserved values were not aligned correctly. - Windows Server 2003+ feature of "Guaranteed Stack Commit Size" was not respected. - Some math was screwy. - Failure to get NT headers was not handled. Modified: trunk/reactos/dll/win32/kernel32/client/fiber.c trunk/reactos/dll/win32/kernel32/client/proc.c trunk/reactos/dll/win32/kernel32/client/thread.c trunk/reactos/dll/win32/kernel32/client/utils.c trunk/reactos/dll/win32/kernel32/include/kernel32.h Modified: trunk/reactos/dll/win32/kernel32/client/fiber.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/fiber.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/fiber.c [iso-8859-1] Thu Nov 3 06:46:22 2011 @@ -201,7 +201,7 @@ } /* Create the stack for the fiber */ - Status = BasepCreateStack(NtCurrentProcess(), + Status = BaseCreateStack(NtCurrentProcess(), dwStackCommitSize, dwStackReserveSize, &InitialTeb); Modified: trunk/reactos/dll/win32/kernel32/client/proc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] Thu Nov 3 06:46:22 2011 @@ -187,7 +187,7 @@ DPRINT("BasepCreateFirstThread. hProcess: %lx\n", ProcessHandle); /* Create the Thread's Stack */ - BasepCreateStack(ProcessHandle, + BaseCreateStack(ProcessHandle, SectionImageInfo->MaximumStackSize, SectionImageInfo->CommittedStackSize, &InitialTeb); Modified: trunk/reactos/dll/win32/kernel32/client/thread.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/thread.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/thread.c [iso-8859-1] Thu Nov 3 06:46:22 2011 @@ -137,7 +137,7 @@ ClientId.UniqueProcess = hProcess; /* Create the Stack */ - Status = BasepCreateStack(hProcess, + Status = BaseCreateStack(hProcess, dwStackSize, dwCreationFlags & STACK_SIZE_PARAM_IS_A_RESERVATION ? dwStackSize : 0, Modified: trunk/reactos/dll/win32/kernel32/client/utils.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/utils.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/utils.c [iso-8859-1] Thu Nov 3 06:46:22 2011 @@ -247,60 +247,64 @@ */ NTSTATUS WINAPI -BasepCreateStack(HANDLE hProcess, +BaseCreateStack(HANDLE hProcess, SIZE_T StackReserve, SIZE_T StackCommit, PINITIAL_TEB InitialTeb) { NTSTATUS Status; - SYSTEM_BASIC_INFORMATION SystemBasicInfo; PIMAGE_NT_HEADERS Headers; - ULONG_PTR Stack = 0; - BOOLEAN UseGuard = FALSE; - - DPRINT("BasepCreateStack (hProcess: %lx, Max: %lx, Current: %lx)\n", + ULONG_PTR Stack; + BOOLEAN UseGuard; + ULONG PageSize, Dummy, AllocationGranularity; + SIZE_T StackReserveHeader, StackCommitHeader, GuardPageSize, GuaranteedStackCommit; + DPRINT("BaseCreateStack (hProcess: %lx, Max: %lx, Current: %lx)\n", hProcess, StackReserve, StackCommit); - /* Get some memory information */ - Status = NtQuerySystemInformation(SystemBasicInformation, - &SystemBasicInfo, - sizeof(SYSTEM_BASIC_INFORMATION), - NULL); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failure to query system info\n"); - return Status; - } - - /* Use the Image Settings if we are dealing with the current Process */ - if (hProcess == NtCurrentProcess()) - { - /* Get the Image Headers */ - Headers = RtlImageNtHeader(NtCurrentPeb()->ImageBaseAddress); - - /* If we didn't get the parameters, find them ourselves */ - StackReserve = (StackReserve) ? - StackReserve : Headers->OptionalHeader.SizeOfStackReserve; - StackCommit = (StackCommit) ? - StackCommit : Headers->OptionalHeader.SizeOfStackCommit; - } - else - { - /* Use the System Settings if needed */ - StackReserve = (StackReserve) ? StackReserve : - SystemBasicInfo.AllocationGranularity; - StackCommit = (StackCommit) ? StackCommit : SystemBasicInfo.PageSize; - } - - /* Align everything to Page Size */ - StackReserve = ROUND_UP(StackReserve, SystemBasicInfo.AllocationGranularity); - StackCommit = ROUND_UP(StackCommit, SystemBasicInfo.PageSize); - #if 1 // FIXME: Remove once Guard Page support is here + /* Read page size */ + PageSize = BaseStaticServerData->SysInfo.PageSize; + AllocationGranularity = BaseStaticServerData->SysInfo.AllocationGranularity; + + /* Get the Image Headers */ + Headers = RtlImageNtHeader(NtCurrentPeb()->ImageBaseAddress); + if (!Headers) return STATUS_INVALID_IMAGE_FORMAT; + + StackCommitHeader = Headers->OptionalHeader.SizeOfStackCommit; + StackReserveHeader = Headers->OptionalHeader.SizeOfStackReserve; + + if (!StackReserve) StackReserve = StackReserveHeader; + + if (!StackCommit) + { + StackCommit = StackCommitHeader; + } + else if (StackCommit >= StackReserve) + { + StackReserve = ROUND_UP(StackCommit, 1024 * 1024); + } + + StackCommit = ROUND_UP(StackCommit, PageSize); + StackReserve = ROUND_UP(StackReserve, AllocationGranularity); + + GuaranteedStackCommit = NtCurrentTeb()->GuaranteedStackBytes; + if ((GuaranteedStackCommit) && (StackCommit < GuaranteedStackCommit)) + { + StackCommit = GuaranteedStackCommit; + } + + if (StackCommit >= StackReserve) + { + StackReserve = ROUND_UP(StackCommit, 1024 * 1024); + } + + StackCommit = ROUND_UP(StackCommit, PageSize); + StackReserve = ROUND_UP(StackReserve, AllocationGranularity); + + /* ROS Hack until we support guard page stack expansion */ StackCommit = StackReserve; - #endif - DPRINT("StackReserve: %lx, StackCommit: %lx\n", StackReserve, StackCommit); /* Reserve memory for the stack */ + Stack = 0; Status = ZwAllocateVirtualMemory(hProcess, (PVOID*)&Stack, 0, @@ -309,7 +313,7 @@ PAGE_READWRITE); if (!NT_SUCCESS(Status)) { - DPRINT1("Failure to reserve stack\n"); + DPRINT1("Failure to reserve stack: %lx\n", Status); return Status; } @@ -325,11 +329,15 @@ /* Check if we will need a guard page */ if (StackReserve > StackCommit) { - Stack -= SystemBasicInfo.PageSize; - StackCommit += SystemBasicInfo.PageSize; + Stack -= PageSize; + StackCommit += PageSize; UseGuard = TRUE; } - + else + { + UseGuard = FALSE; + } + /* Allocate memory for the stack */ Status = ZwAllocateVirtualMemory(hProcess, (PVOID*)&Stack, @@ -340,6 +348,8 @@ if (!NT_SUCCESS(Status)) { DPRINT1("Failure to allocate stack\n"); + GuardPageSize = 0; + ZwFreeVirtualMemory(hProcess, (PVOID*)&Stack, &GuardPageSize, MEM_RELEASE); return Status; } @@ -349,10 +359,8 @@ /* Create a guard page */ if (UseGuard) { - SIZE_T GuardPageSize = SystemBasicInfo.PageSize; - ULONG Dummy; - - /* Attempt maximum space possible */ + /* Set the guard page */ + GuardPageSize = PAGE_SIZE; Status = ZwProtectVirtualMemory(hProcess, (PVOID*)&Stack, &GuardPageSize, @@ -360,12 +368,13 @@ &Dummy); if (!NT_SUCCESS(Status)) { - DPRINT1("Failure to create guard page\n"); + DPRINT1("Failure to set guard page\n"); return Status; } /* Update the Stack Limit keeping in mind the Guard Page */ - InitialTeb->StackLimit = (PVOID)((ULONG_PTR)InitialTeb->StackLimit - GuardPageSize); + InitialTeb->StackLimit = (PVOID)((ULONG_PTR)InitialTeb->StackLimit + + GuardPageSize); } /* We are done! */ Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
============================================================================== --- trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] Thu Nov 3 06:46:22 2011 @@ -173,7 +173,7 @@ NTSTATUS WINAPI -BasepCreateStack(HANDLE hProcess, +BaseCreateStack(HANDLE hProcess, SIZE_T StackReserve, SIZE_T StackCommit, PINITIAL_TEB InitialTeb);
13 years, 5 months
1
0
0
0
← Newer
1
...
24
25
26
27
28
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
Results per page:
10
25
50
100
200