diff --git a/reactos/subsystems/win32/win32k/misc/rtlstr.c b/reactos/subsystems/win32/win32k/misc/rtlstr.c index 06f8d3eff80..e4ee395c39d 100644 --- a/reactos/subsystems/win32/win32k/misc/rtlstr.c +++ b/reactos/subsystems/win32/win32k/misc/rtlstr.c @@ -3,7 +3,6 @@ * FILE: subsystems/win32/win32k/misc/rtlstr.c * PURPOSE: Large Strings * PROGRAMMER: - * UPDATE HISTORY: * */ @@ -12,11 +11,13 @@ #include /* 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 @@ RtlInitLargeAnsiString(IN OUT PLARGE_ANSI_STRING DestinationString, 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 @@ RtlInitLargeUnicodeString(IN OUT PLARGE_UNICODE_STRING DestinationString, 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); + } } + diff --git a/reactos/subsystems/win32/win32k/objects/dcobjs.c b/reactos/subsystems/win32/win32k/objects/dcobjs.c index 2988c08ceec..1efba17fac9 100644 --- a/reactos/subsystems/win32/win32k/objects/dcobjs.c +++ b/reactos/subsystems/win32/win32k/objects/dcobjs.c @@ -263,7 +263,7 @@ NtGdiSelectBitmap( PDC pdc; PDC_ATTR pdcattr; HBITMAP hbmpOld; - PSURFACE psurfNew; + PSURFACE psurfNew, psurfOld; HRGN hVisRgn; SIZEL sizlBitmap = {1, 1}; HDC hdcOld; @@ -287,17 +287,8 @@ NtGdiSelectBitmap( 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 @@ NtGdiSelectBitmap( } } - /* Select the new surface, release the old */ - DC_vSelectSurface(pdc, psurfNew); + /* Select the new bitmap */ + pdc->dclevel.pSurface = psurfNew; - /* Set the new size */ - pdc->dclevel.sizl = sizlBitmap; + /* Check if there was a bitmap selected before */ + if (psurfOld) + { + /* Get the old bitmap's handle */ + hbmpOld = psurfOld->BaseObject.hHmgr; - /* Release one reference we added */ - SURFACE_ShareUnlockSurface(psurfNew); + /* 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;