- Modify NtGdiSelectBitmap to correctly handle the case of pdc->dclevel.pSurface == 0
- Small code improvement without functional change for rtlstr functions

svn path=/trunk/; revision=55636
This commit is contained in:
Timo Kreuzer 2012-02-16 16:05:25 +00:00
parent a49c373b0c
commit 7816af6cb9
2 changed files with 53 additions and 40 deletions

View file

@ -3,7 +3,6 @@
* FILE: subsystems/win32/win32k/misc/rtlstr.c * FILE: subsystems/win32/win32k/misc/rtlstr.c
* PURPOSE: Large Strings * PURPOSE: Large Strings
* PROGRAMMER: * PROGRAMMER:
* UPDATE HISTORY:
* *
*/ */
@ -12,9 +11,11 @@
#include <win32k.h> #include <win32k.h>
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID VOID
NTAPI NTAPI
RtlInitLargeAnsiString(IN OUT PLARGE_ANSI_STRING DestinationString, RtlInitLargeAnsiString(
IN OUT PLARGE_ANSI_STRING DestinationString,
IN PCSZ SourceString, IN PCSZ SourceString,
IN INT Unknown) IN INT Unknown)
{ {
@ -38,7 +39,8 @@ RtlInitLargeAnsiString(IN OUT PLARGE_ANSI_STRING DestinationString,
VOID VOID
NTAPI NTAPI
RtlInitLargeUnicodeString(IN OUT PLARGE_UNICODE_STRING DestinationString, RtlInitLargeUnicodeString(
IN OUT PLARGE_UNICODE_STRING DestinationString,
IN PCWSTR SourceString, IN PCWSTR SourceString,
IN INT Unknown) IN INT Unknown)
{ {
@ -62,21 +64,29 @@ RtlInitLargeUnicodeString(IN OUT PLARGE_UNICODE_STRING DestinationString,
BOOL BOOL
NTAPI NTAPI
RtlLargeStringToUnicodeString( PUNICODE_STRING DestinationString, RtlLargeStringToUnicodeString(
PUNICODE_STRING DestinationString,
PLARGE_STRING SourceString) PLARGE_STRING SourceString)
{ {
ANSI_STRING AnsiString; ANSI_STRING AnsiString;
/* 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); RtlInitUnicodeString(DestinationString, NULL);
if (DestinationString && SourceString && SourceString->bAnsi)
if (SourceString->bAnsi)
{ {
RtlInitAnsiString(&AnsiString, (LPSTR)SourceString->Buffer); RtlInitAnsiString(&AnsiString, (LPSTR)SourceString->Buffer);
return NT_SUCCESS(RtlAnsiStringToUnicodeString(DestinationString, &AnsiString, TRUE)); return NT_SUCCESS(RtlAnsiStringToUnicodeString(DestinationString, &AnsiString, TRUE));
} }
else if (DestinationString && SourceString) else
{ {
return RtlCreateUnicodeString(DestinationString, SourceString->Buffer); return RtlCreateUnicodeString(DestinationString, SourceString->Buffer);
} }
else
return FALSE;
} }

View file

@ -263,7 +263,7 @@ NtGdiSelectBitmap(
PDC pdc; PDC pdc;
PDC_ATTR pdcattr; PDC_ATTR pdcattr;
HBITMAP hbmpOld; HBITMAP hbmpOld;
PSURFACE psurfNew; PSURFACE psurfNew, psurfOld;
HRGN hVisRgn; HRGN hVisRgn;
SIZEL sizlBitmap = {1, 1}; SIZEL sizlBitmap = {1, 1};
HDC hdcOld; HDC hdcOld;
@ -287,17 +287,8 @@ NtGdiSelectBitmap(
return NULL; return NULL;
} }
/* Check if there was a bitmap selected before */ /* Save the old bitmap */
if (pdc->dclevel.pSurface) psurfOld = pdc->dclevel.pSurface;
{
/* Return its handle */
hbmpOld = pdc->dclevel.pSurface->BaseObject.hHmgr;
}
else
{
/* Return default bitmap */
hbmpOld = StockObjects[DEFAULT_BITMAP];
}
/* Check if the default bitmap was passed */ /* Check if the default bitmap was passed */
if (hbmp == StockObjects[DEFAULT_BITMAP]) if (hbmp == StockObjects[DEFAULT_BITMAP])
@ -342,14 +333,26 @@ NtGdiSelectBitmap(
} }
} }
/* Select the new surface, release the old */ /* Select the new bitmap */
DC_vSelectSurface(pdc, psurfNew); pdc->dclevel.pSurface = psurfNew;
/* Set the new size */ /* Check if there was a bitmap selected before */
pdc->dclevel.sizl = sizlBitmap; if (psurfOld)
{
/* Get the old bitmap's handle */
hbmpOld = psurfOld->BaseObject.hHmgr;
/* Release one reference we added */ /* Reset hdc of the old bitmap,it isn't selected anymore */
SURFACE_ShareUnlockSurface(psurfNew); psurfOld->hdc = NULL;
/* Dereference the old bitmap */
SURFACE_ShareUnlockSurface(psurfOld);
}
else
{
/* Return default bitmap */
hbmpOld = StockObjects[DEFAULT_BITMAP];
}
/* Mark the dc brushes invalid */ /* Mark the dc brushes invalid */
pdcattr->ulDirty_ |= DIRTY_FILL | DIRTY_LINE; pdcattr->ulDirty_ |= DIRTY_FILL | DIRTY_LINE;