Author: jimtabor
Date: Sun Jan 4 21:34:10 2009
New Revision: 38574
URL:
http://svn.reactos.org/svn/reactos?rev=38574&view=rev
Log:
- Implement large ansi unicode string support for win32k. I guess some Rtl library
developer should look into adding lib/rtlw32k for Win32k and User32.
- Created DefSetText to processes strings prior to calling NtUserDefSetText.
- Rewrite NtUserDefSetText to support large strings and process them with
RtlLargeStringToUnicodeString.
- On last thing to remove, is the Hook junk in NtUserDefSetText.
Added:
trunk/reactos/subsystems/win32/win32k/misc/rtlstr.c (with props)
Modified:
trunk/reactos/dll/win32/user32/include/user32.h
trunk/reactos/dll/win32/user32/misc/rtlstr.c
trunk/reactos/dll/win32/user32/windows/defwnd.c
trunk/reactos/dll/win32/user32/windows/window.c
trunk/reactos/include/reactos/probe.h
trunk/reactos/include/reactos/win32k/ntuser.h
trunk/reactos/subsystems/win32/win32k/ntuser/window.c
trunk/reactos/subsystems/win32/win32k/win32k.rbuild
Modified: trunk/reactos/dll/win32/user32/include/user32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/u…
==============================================================================
--- trunk/reactos/dll/win32/user32/include/user32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/include/user32.h [iso-8859-1] Sun Jan 4 21:34:10 2009
@@ -119,3 +119,4 @@
PVOID FASTCALL ValidateHandleNoErr(HANDLE handle, UINT uType);
PWINDOW FASTCALL ValidateHwndNoErr(HWND hwnd);
VOID FASTCALL GetConnected(VOID);
+BOOL FASTCALL DefSetText(HWND hWnd, PCWSTR String, BOOL Ansi);
Modified: trunk/reactos/dll/win32/user32/misc/rtlstr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/rtls…
==============================================================================
--- trunk/reactos/dll/win32/user32/misc/rtlstr.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/misc/rtlstr.c [iso-8859-1] Sun Jan 4 21:34:10 2009
@@ -63,3 +63,24 @@
DestinationString->Buffer = (PWSTR)SourceString;
DestinationString->bAnsi = FALSE;
}
+
+BOOL
+NTAPI
+RtlLargeStringToUnicodeString( PUNICODE_STRING DestinationString,
+ PLARGE_STRING SourceString)
+{
+ ANSI_STRING AnsiString;
+
+ RtlInitUnicodeString(DestinationString, NULL);
+ if (DestinationString && SourceString && SourceString->bAnsi)
+ {
+ RtlInitAnsiString(&AnsiString, (LPSTR)SourceString->Buffer);
+ return NT_SUCCESS(RtlAnsiStringToUnicodeString(DestinationString, &AnsiString,
TRUE));
+ }
+ else if (DestinationString && SourceString)
+ {
+ return RtlCreateUnicodeString(DestinationString, SourceString->Buffer);
+ }
+ else
+ return FALSE;
+}
Modified: trunk/reactos/dll/win32/user32/windows/defwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/d…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] Sun Jan 4 21:34:10 2009
@@ -111,6 +111,22 @@
CONST COLORREF *lpaRgbValues)
{
return NtUserSetSysColors(cElements, lpaElements, lpaRgbValues, 0);
+}
+
+BOOL
+FASTCALL
+DefSetText(HWND hWnd, PCWSTR String, BOOL Ansi)
+{
+ LARGE_STRING lsString;
+
+ if ( String )
+ {
+ if ( Ansi )
+ RtlInitLargeAnsiString((PLARGE_ANSI_STRING)&lsString, (PCSZ)String, 0);
+ else
+ RtlInitLargeUnicodeString((PLARGE_UNICODE_STRING)&lsString, String, 0);
+ }
+ return NtUserDefSetText(hWnd, (String ? &lsString : NULL));
}
void
@@ -1853,21 +1869,11 @@
{
case WM_NCCREATE:
{
- ANSI_STRING AnsiString;
- UNICODE_STRING UnicodeString;
LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
/* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
* may have child window IDs instead of window name */
- if(cs->lpszName)
- {
- RtlInitAnsiString(&AnsiString, (LPSTR)cs->lpszName);
- RtlAnsiStringToUnicodeString(&UnicodeString, &AnsiString, TRUE);
- NtUserDefSetText(hWnd, &UnicodeString);
- RtlFreeUnicodeString(&UnicodeString);
- }
- else
- NtUserDefSetText(hWnd, NULL);
+ DefSetText(hWnd, (PCWSTR)cs->lpszName, TRUE);
Result = 1;
break;
@@ -1933,18 +1939,7 @@
case WM_SETTEXT:
{
- ANSI_STRING AnsiString;
- UNICODE_STRING UnicodeString;
-
- if(lParam)
- {
- RtlInitAnsiString(&AnsiString, (LPSTR)lParam);
- RtlAnsiStringToUnicodeString(&UnicodeString, &AnsiString, TRUE);
- NtUserDefSetText(hWnd, &UnicodeString);
- RtlFreeUnicodeString(&UnicodeString);
- }
- else
- NtUserDefSetText(hWnd, NULL);
+ DefSetText(hWnd, (PCWSTR)lParam, TRUE);
if ((GetWindowLongW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION)
{
@@ -2023,15 +2018,11 @@
{
case WM_NCCREATE:
{
- UNICODE_STRING UnicodeString;
LPCREATESTRUCTW cs = (LPCREATESTRUCTW)lParam;
/* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
* may have child window IDs instead of window name */
- if(cs->lpszName)
- RtlInitUnicodeString(&UnicodeString, (LPWSTR)cs->lpszName);
-
- NtUserDefSetText(hWnd, (cs->lpszName ? &UnicodeString : NULL));
+ DefSetText(hWnd, cs->lpszName, FALSE);
Result = 1;
break;
}
@@ -2090,12 +2081,7 @@
case WM_SETTEXT:
{
- UNICODE_STRING UnicodeString;
-
- if(lParam)
- RtlInitUnicodeString(&UnicodeString, (LPWSTR)lParam);
-
- NtUserDefSetText(hWnd, (lParam ? &UnicodeString : NULL));
+ DefSetText(hWnd, (PCWSTR)lParam, FALSE);
if ((GetWindowLongW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION)
{
Modified: trunk/reactos/dll/win32/user32/windows/window.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/w…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] Sun Jan 4 21:34:10 2009
@@ -1657,18 +1657,8 @@
if(ProcessId != GetCurrentProcessId())
{
/* do not send WM_GETTEXT messages to other processes */
- ANSI_STRING AnsiString;
- UNICODE_STRING UnicodeString;
-
- if(lpString)
- {
- RtlInitAnsiString(&AnsiString, (LPSTR)lpString);
- RtlAnsiStringToUnicodeString(&UnicodeString, &AnsiString, TRUE);
- NtUserDefSetText(hWnd, &UnicodeString);
- RtlFreeUnicodeString(&UnicodeString);
- }
- else
- NtUserDefSetText(hWnd, NULL);
+
+ DefSetText(hWnd, (PCWSTR)lpString, TRUE);
if ((GetWindowLongW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION)
{
@@ -1697,12 +1687,8 @@
if(ProcessId != GetCurrentProcessId())
{
/* do not send WM_GETTEXT messages to other processes */
- UNICODE_STRING UnicodeString;
-
- if(lpString)
- RtlInitUnicodeString(&UnicodeString, (LPWSTR)lpString);
-
- NtUserDefSetText(hWnd, (lpString ? &UnicodeString : NULL));
+
+ DefSetText(hWnd, lpString, FALSE);
if ((GetWindowLongW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION)
{
Modified: trunk/reactos/include/reactos/probe.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/probe.h?re…
==============================================================================
--- trunk/reactos/include/reactos/probe.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/probe.h [iso-8859-1] Sun Jan 4 21:34:10 2009
@@ -9,6 +9,10 @@
static const LARGE_INTEGER __emptyLargeInteger = {{0, 0}};
static const ULARGE_INTEGER __emptyULargeInteger = {{0, 0}};
static const IO_STATUS_BLOCK __emptyIoStatusBlock = {{0}, 0};
+
+#if defined(_WIN32K_)
+static const LARGE_STRING __emptyLargeString = {0, 0, 0, NULL};
+#endif
#if defined(_WIN32K_)
/*
@@ -48,7 +52,9 @@
#define ProbeForWriteLargeInteger(Ptr)
ProbeForWriteGenericType(&((PLARGE_INTEGER)Ptr)->QuadPart, LONGLONG)
#define ProbeForWriteUlargeInteger(Ptr)
ProbeForWriteGenericType(&((PULARGE_INTEGER)Ptr)->QuadPart, ULONGLONG)
#define ProbeForWriteUnicodeString(Ptr) ProbeForWriteGenericType((PUNICODE_STRING)Ptr,
UNICODE_STRING)
+#if defined(_WIN32K_)
#define ProbeForWriteLargeString(Ptr) ProbeForWriteGenericType((PLARGE_STRING)Ptr,
LARGE_STRING)
+#endif
#define ProbeForWriteIoStatusBlock(Ptr) ProbeForWriteGenericType((PIO_STATUS_BLOCK)Ptr,
IO_STATUS_BLOCK)
#define ProbeForReadGenericType(Ptr, Type, Default) \
@@ -75,7 +81,9 @@
#define ProbeForReadLargeInteger(Ptr) ProbeForReadGenericType((const LARGE_INTEGER
*)(Ptr), LARGE_INTEGER, __emptyLargeInteger)
#define ProbeForReadUlargeInteger(Ptr) ProbeForReadGenericType((const ULARGE_INTEGER
*)(Ptr), ULARGE_INTEGER, __emptyULargeInteger)
#define ProbeForReadUnicodeString(Ptr) ProbeForReadGenericType((const UNICODE_STRING
*)(Ptr), UNICODE_STRING, __emptyUnicodeString)
+#if defined(_WIN32K_)
#define ProbeForReadLargeString(Ptr) ProbeForReadGenericType((const LARGE_STRING *)(Ptr),
LARGE_STRING, __emptyLargeString)
+#endif
#define ProbeForReadIoStatusBlock(Ptr) ProbeForReadGenericType((const IO_STATUS_BLOCK
*)(Ptr), IO_STATUS_BLOCK, __emptyIoStatusBlock)
#define ProbeAndZeroHandle(Ptr) \
Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntu…
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Sun Jan 4 21:34:10 2009
@@ -33,7 +33,7 @@
VOID NTAPI RtlInitLargeAnsiString(IN OUT PLARGE_ANSI_STRING,IN PCSZ,IN INT);
VOID NTAPI RtlInitLargeUnicodeString(IN OUT PLARGE_UNICODE_STRING,IN PCWSTR,IN INT);
-
+BOOL NTAPI RtlLargeStringToUnicodeString( PUNICODE_STRING, PLARGE_STRING);
/* FIXME: UserHMGetHandle needs to be updated once the new handle manager is implemented
*/
#define UserHMGetHandle(obj) ((obj)->hdr.Handle)
@@ -1176,7 +1176,7 @@
int cy,
UINT Flags);
BOOL NTAPI
-NtUserDefSetText(HWND WindowHandle, PUNICODE_STRING WindowText);
+NtUserDefSetText(HWND WindowHandle, PLARGE_STRING WindowText);
BOOLEAN
NTAPI
Added: trunk/reactos/subsystems/win32/win32k/misc/rtlstr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/mi…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/misc/rtlstr.c (added)
+++ trunk/reactos/subsystems/win32/win32k/misc/rtlstr.c [iso-8859-1] Sun Jan 4 21:34:10
2009
@@ -1,0 +1,82 @@
+/*
+ * PROJECT: ReactOS win32k.sys
+ * FILE: subsystems/win32/win32k/misc/rtlstr.c
+ * PURPOSE: Large Strings
+ * PROGRAMMER:
+ * UPDATE HISTORY:
+ *
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <w32k.h>
+
+/* FUNCTIONS *****************************************************************/
+VOID
+NTAPI
+RtlInitLargeAnsiString(IN OUT PLARGE_ANSI_STRING DestinationString,
+ IN PCSZ SourceString,
+ IN INT Unknown)
+{
+ ULONG DestSize;
+
+ if (SourceString)
+ {
+ DestSize = strlen(SourceString);
+ DestinationString->Length = DestSize;
+ DestinationString->MaximumLength = DestSize + sizeof(CHAR);
+ }
+ else
+ {
+ DestinationString->Length = 0;
+ DestinationString->MaximumLength = 0;
+ }
+
+ DestinationString->Buffer = (PCHAR)SourceString;
+ DestinationString->bAnsi = TRUE;
+}
+
+VOID
+NTAPI
+RtlInitLargeUnicodeString(IN OUT PLARGE_UNICODE_STRING DestinationString,
+ IN PCWSTR SourceString,
+ IN INT Unknown)
+{
+ ULONG DestSize;
+
+ if (SourceString)
+ {
+ DestSize = wcslen(SourceString) * sizeof(WCHAR);
+ DestinationString->Length = DestSize;
+ DestinationString->MaximumLength = DestSize + sizeof(WCHAR);
+ }
+ else
+ {
+ DestinationString->Length = 0;
+ DestinationString->MaximumLength = 0;
+ }
+
+ DestinationString->Buffer = (PWSTR)SourceString;
+ DestinationString->bAnsi = FALSE;
+}
+
+BOOL
+NTAPI
+RtlLargeStringToUnicodeString( PUNICODE_STRING DestinationString,
+ PLARGE_STRING SourceString)
+{
+ ANSI_STRING AnsiString;
+
+ RtlInitUnicodeString(DestinationString, NULL);
+ if (DestinationString && SourceString && SourceString->bAnsi)
+ {
+ RtlInitAnsiString(&AnsiString, (LPSTR)SourceString->Buffer);
+ return NT_SUCCESS(RtlAnsiStringToUnicodeString(DestinationString, &AnsiString,
TRUE));
+ }
+ else if (DestinationString && SourceString)
+ {
+ return RtlCreateUnicodeString(DestinationString, SourceString->Buffer);
+ }
+ else
+ return FALSE;
+}
Propchange: trunk/reactos/subsystems/win32/win32k/misc/rtlstr.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Sun Jan 4 21:34:10
2009
@@ -4531,35 +4531,35 @@
* Status
* @implemented
*/
-
BOOL APIENTRY
-NtUserDefSetText(HWND hWnd, PUNICODE_STRING WindowText)
+NtUserDefSetText(HWND hWnd, PLARGE_STRING WindowText)
{
PWINDOW_OBJECT Window;
PWINDOW Wnd;
- UNICODE_STRING SafeText;
+ LARGE_STRING SafeText;
+ UNICODE_STRING UnicodeString;
BOOL Ret = TRUE;
DPRINT("Enter NtUserDefSetText\n");
- RtlInitUnicodeString(&SafeText, NULL);
if (WindowText != NULL)
{
- _SEH2_TRY
- {
- SafeText = ProbeForReadUnicodeString(WindowText);
- ProbeForRead(SafeText.Buffer, SafeText.Length, sizeof(WCHAR));
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- Ret = FALSE;
- SetLastNtError(_SEH2_GetExceptionCode());
- }
- _SEH2_END;
-
- if (!Ret)
- return FALSE;
- }
+ _SEH2_TRY
+ {
+ SafeText = ProbeForReadLargeString(WindowText);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Ret = FALSE;
+ SetLastNtError(_SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
+
+ if (!Ret)
+ return FALSE;
+ }
+ else
+ return TRUE;
UserEnterExclusive();
@@ -4570,27 +4570,41 @@
}
Wnd = Window->Wnd;
- if (SafeText.Length != 0)
+ // ReactOS uses Unicode and not mixed. Up/Down converting will take time.
+ // Brought to you by: The Wine Project! Dysfunctional Thought Processes!
+ // Now we know what the bAnsi is for.
+ RtlInitUnicodeString(&UnicodeString, NULL);
+ if (SafeText.Buffer)
+ {
+ _SEH2_TRY
+ {
+ if (SafeText.bAnsi)
+ ProbeForRead(SafeText.Buffer, SafeText.Length, sizeof(CHAR));
+ else
+ ProbeForRead(SafeText.Buffer, SafeText.Length, sizeof(WCHAR));
+ Ret = RtlLargeStringToUnicodeString(&UnicodeString, &SafeText);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Ret = FALSE;
+ SetLastNtError(_SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
+ if (!Ret) goto Exit;
+ }
+
+ if (UnicodeString.Length != 0)
{
if (Wnd->WindowName.MaximumLength > 0 &&
- SafeText.Length <= Wnd->WindowName.MaximumLength - sizeof(UNICODE_NULL))
+ UnicodeString.Length <= Wnd->WindowName.MaximumLength -
sizeof(UNICODE_NULL))
{
ASSERT(Wnd->WindowName.Buffer != NULL);
- _SEH2_TRY
- {
- Wnd->WindowName.Length = SafeText.Length;
- Wnd->WindowName.Buffer[SafeText.Length / sizeof(WCHAR)] = L'\0';
- RtlCopyMemory(Wnd->WindowName.Buffer,
- SafeText.Buffer,
- SafeText.Length);
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- Ret = FALSE;
- SetLastNtError(_SEH2_GetExceptionCode());
- }
- _SEH2_END;
+ Wnd->WindowName.Length = UnicodeString.Length;
+ Wnd->WindowName.Buffer[UnicodeString.Length / sizeof(WCHAR)] =
L'\0';
+ RtlCopyMemory(Wnd->WindowName.Buffer,
+ UnicodeString.Buffer,
+ UnicodeString.Length);
}
else
{
@@ -4604,26 +4618,15 @@
}
Wnd->WindowName.Buffer = DesktopHeapAlloc(Wnd->pdesktop,
- SafeText.Length +
sizeof(UNICODE_NULL));
+ UnicodeString.Length +
sizeof(UNICODE_NULL));
if (Wnd->WindowName.Buffer != NULL)
{
- _SEH2_TRY
- {
- Wnd->WindowName.Buffer[SafeText.Length / sizeof(WCHAR)] =
L'\0';
- RtlCopyMemory(Wnd->WindowName.Buffer,
- SafeText.Buffer,
- SafeText.Length);
- Wnd->WindowName.MaximumLength = SafeText.Length +
sizeof(UNICODE_NULL);
- Wnd->WindowName.Length = SafeText.Length;
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- Wnd->WindowName.Buffer = NULL;
- DesktopHeapFree(Wnd->pdesktop, Wnd->WindowName.Buffer);
- Ret = FALSE;
- SetLastNtError(_SEH2_GetExceptionCode());
- }
- _SEH2_END;
+ Wnd->WindowName.Buffer[UnicodeString.Length / sizeof(WCHAR)] =
L'\0';
+ RtlCopyMemory(Wnd->WindowName.Buffer,
+ UnicodeString.Buffer,
+ UnicodeString.Length);
+ Wnd->WindowName.MaximumLength = UnicodeString.Length +
sizeof(UNICODE_NULL);
+ Wnd->WindowName.Length = UnicodeString.Length;
}
else
{
@@ -4649,7 +4652,8 @@
}
Ret = TRUE;
-
+Exit:
+ if (UnicodeString.Buffer) RtlFreeUnicodeString(&UnicodeString);
DPRINT("Leave NtUserDefSetText, ret=%i\n", Ret);
UserLeave();
return Ret;
Modified: trunk/reactos/subsystems/win32/win32k/win32k.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/wi…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/win32k.rbuild [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/win32k.rbuild [iso-8859-1] Sun Jan 4 21:34:10
2009
@@ -84,6 +84,7 @@
<file>driver.c</file>
<file>err.c</file>
<file>math.c</file>
+ <file>rtlstr.c</file>
<file>copy.c</file>
<file>usrheap.c</file>
<if property="ARCH" value="i386">