Author: tkreuzer
Date: Thu Feb 16 16:05:25 2012
New Revision: 55636
URL:
http://svn.reactos.org/svn/reactos?rev=55636&view=rev
Log:
[WIN32K]
- Modify NtGdiSelectBitmap to correctly handle the case of pdc->dclevel.pSurface == 0
- Small code improvement without functional change for rtlstr functions
Modified:
trunk/reactos/subsystems/win32/win32k/misc/rtlstr.c
trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c
Modified: 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 [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/misc/rtlstr.c [iso-8859-1] Thu Feb 16 16:05:25
2012
@@ -3,7 +3,6 @@
* FILE: subsystems/win32/win32k/misc/rtlstr.c
* PURPOSE: Large Strings
* PROGRAMMER:
- * UPDATE HISTORY:
*
*/
@@ -12,11 +11,13 @@
#include <win32k.h>
/* FUNCTIONS *****************************************************************/
+
VOID
NTAPI
-RtlInitLargeAnsiString(IN OUT PLARGE_ANSI_STRING DestinationString,
- IN PCSZ SourceString,
- IN INT Unknown)
+RtlInitLargeAnsiString(
+ IN OUT PLARGE_ANSI_STRING DestinationString,
+ IN PCSZ SourceString,
+ IN INT Unknown)
{
ULONG DestSize;
@@ -38,9 +39,10 @@
VOID
NTAPI
-RtlInitLargeUnicodeString(IN OUT PLARGE_UNICODE_STRING DestinationString,
- IN PCWSTR SourceString,
- IN INT Unknown)
+RtlInitLargeUnicodeString(
+ IN OUT PLARGE_UNICODE_STRING DestinationString,
+ IN PCWSTR SourceString,
+ IN INT Unknown)
{
ULONG DestSize;
@@ -62,21 +64,29 @@
BOOL
NTAPI
-RtlLargeStringToUnicodeString( PUNICODE_STRING DestinationString,
- PLARGE_STRING SourceString)
+RtlLargeStringToUnicodeString(
+ PUNICODE_STRING DestinationString,
+ PLARGE_STRING SourceString)
{
- ANSI_STRING AnsiString;
+ 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;
+ /* Check parameters */
+ if (!DestinationString || !SourceString) return FALSE;
+
+ /* Check if size if ok */
+ // We can't do this atm and truncate the string instead.
+ //if (SourceString->Length > 0xffff) return FALSE;
+
+ RtlInitUnicodeString(DestinationString, NULL);
+
+ if (SourceString->bAnsi)
+ {
+ RtlInitAnsiString(&AnsiString, (LPSTR)SourceString->Buffer);
+ return NT_SUCCESS(RtlAnsiStringToUnicodeString(DestinationString,
&AnsiString, TRUE));
+ }
+ else
+ {
+ return RtlCreateUnicodeString(DestinationString, SourceString->Buffer);
+ }
}
+
Modified: trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c [iso-8859-1] Thu Feb 16
16:05:25 2012
@@ -263,7 +263,7 @@
PDC pdc;
PDC_ATTR pdcattr;
HBITMAP hbmpOld;
- PSURFACE psurfNew;
+ PSURFACE psurfNew, psurfOld;
HRGN hVisRgn;
SIZEL sizlBitmap = {1, 1};
HDC hdcOld;
@@ -287,17 +287,8 @@
return NULL;
}
- /* Check if there was a bitmap selected before */
- if (pdc->dclevel.pSurface)
- {
- /* Return its handle */
- hbmpOld = pdc->dclevel.pSurface->BaseObject.hHmgr;
- }
- else
- {
- /* Return default bitmap */
- hbmpOld = StockObjects[DEFAULT_BITMAP];
- }
+ /* Save the old bitmap */
+ psurfOld = pdc->dclevel.pSurface;
/* Check if the default bitmap was passed */
if (hbmp == StockObjects[DEFAULT_BITMAP])
@@ -342,14 +333,26 @@
}
}
- /* Select the new surface, release the old */
- DC_vSelectSurface(pdc, psurfNew);
-
- /* Set the new size */
- pdc->dclevel.sizl = sizlBitmap;
-
- /* Release one reference we added */
- SURFACE_ShareUnlockSurface(psurfNew);
+ /* Select the new bitmap */
+ pdc->dclevel.pSurface = psurfNew;
+
+ /* Check if there was a bitmap selected before */
+ if (psurfOld)
+ {
+ /* Get the old bitmap's handle */
+ hbmpOld = psurfOld->BaseObject.hHmgr;
+
+ /* Reset hdc of the old bitmap,it isn't selected anymore */
+ psurfOld->hdc = NULL;
+
+ /* Dereference the old bitmap */
+ SURFACE_ShareUnlockSurface(psurfOld);
+ }
+ else
+ {
+ /* Return default bitmap */
+ hbmpOld = StockObjects[DEFAULT_BITMAP];
+ }
/* Mark the dc brushes invalid */
pdcattr->ulDirty_ |= DIRTY_FILL | DIRTY_LINE;