Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2



Thanks Paul. I was aware of these limitations but they don't seem to apply in
my case. There's no UI or interaction requirement for this service. It
manipulates bitmaps and I don't think GDI funtions are limited to interactive
sessions (at least they ones we use don't fail in session 0). The process
does create a device context (HDC). The ICM functions it uses are:

OpenColorProfile
IsColorProfileValid
CreateColorTransform
CloseColorProfile
TranslateBitmapBits

All code returns from the Win API are checked and they all succeed. The
oddity is that in session 0, TranslateBitmapBits expects the bitmap as BGRA
instead of RGBA. For no obvious reason.

CK

"Paul Baker [MVP, Windows Desktop Experie" wrote:

I have found that in a non-interactive session on Windows XP, I can use
user32 and gdi32 functions and expect them to work as usual. However, no
user can ever see or interact with the session.

Are you aware that Session 0 on Windows Vista or Windows Server 2008 is
subject to Session 0 Isolation?
http://msdn.microsoft.com/en-us/library/bb756986.aspx

I would imagine that GDI functions require a desktop to be associated with
the current thread to work properly. And creating a desktop requires a
window station to be associated with the current process. This article would
suggest that window stations *can* be used in Session 0, and therefore
probably, desktops. But *are* they, by default?

Launching an interactive process from Windows Service in Windows Vista and
later:
http://blogs.msdn.com/winsdk/archive/2009/07/14/launching-an-interactive-process-from-windows-service-in-windows-vista-and-later.aspx

You could see what GetThreadDesktop and GetProcessWindowStation return. If
you don't have both a desktop and window station, this could be the
underlying cause. And if this is the case, you might be able to create one,
but I don't recommend it. Rather, I'd avoid doing any UI stuff in a service.
Even if the user cannot see or interact with the session, you don't want to
be loading video drivers, GDI, etc. if you don't need to.

Also, make sure you are checking the result and error codes of any functions
that you are calling. It may indicate in more detail what is going on. For
example, ERROR_ACCESS_DENIED would probably indicate a Session 0 Isolation
or related security feature whereas ERROR_INVALID_PARAMETER would probably
indicate that you made a mistake. Sometimes the only reason a newer OS
reports an error when an older one did not is that it got stricter in
validating input, and that's not the OS's problem. You don'yt explain what
you mean by "incorrect" results. It might help to dig into that a bit
deeper.

Paul

"CK" <ck@xxxxxxxxxxxxx> wrote in message
news:6F176514-566E-44A5-8483-02160CE21AC6@xxxxxxxxxxxxxxxx
Our application has both desktop and services components. In a shared
piece
of code we're using TranslateBitmapBits() to do translate bitmap colors in
order to do CMYK proofing on screen. The destination profile is an sRGB
profile and the target profile is a U.S. SWOP Proofer profile.

Under Vista/Windows Server 2008 x64, when our code runs from the desktop
application is produces correct results. When it runs from the service
application, it produces incorrect results. The code works fine under
Windows
Server 2003 and XP.

The code is calling TranslateBitmapBits using BM_xRGBQUADS for the
BMFORMAT.
While experimenting with the settings, we discovered that if we called
TranslateBitmapBits using BM_xBGRQUADS for the BMFORMAT, then the service
application produced the desired results. Of course this broke the desktop
application. Also, BM_xBGRQUADS does not work under Windows Server 2003
and
XP where it's expecting BM_xRGBQUADS.

The net result is if we add a check in our code that a) we're running as a
service and b) we're running under Windows Vista/2008, and use
BM_xBGRQUADS
instead of BM_xRGBQUADS, we have a workaround.

But this seems like a bug in the latest OSs.




.



Relevant Pages

  • Re: Windows Service - Fast User Switching - Find Active Desktop Problem
    ... >> I am writing a Windows Service, which is allowed to interact with the ... > AFAIK services are always run in the console terminal session, ... > simple by adding a UI client program in the Run key of HKLM or HKCU, ...
    (microsoft.public.platformsdk.security)
  • Re: Windows Service - Fast User Switching - Find Active Desktop Problem
    ... It needs to post advice windows on the desktop of whoever ... so that the active user can interact with it. ... > advice window it still appears on my session, ... simple by adding a UI client program in the Run key of HKLM or HKCU, ...
    (microsoft.public.platformsdk.security)
  • Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2
    ... Are there any performance considerations around session 0's use of the ... oddity is that in session 0, TranslateBitmapBits expects the bitmap as ... Are you aware that Session 0 on Windows Vista or Windows Server 2008 is ... Even if the user cannot see or interact with the session, ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2
    ... Because calling GetObject now with DIBSECTION ... When tsddd.dll is the display driver bound to the session, ... oddity is that in session 0, TranslateBitmapBits expects the bitmap as ... Are you aware that Session 0 on Windows Vista or Windows Server 2008 ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2008
    ... I have found that in a non-interactive session on Windows XP, ... profile and the target profile is a U.S. SWOP Proofer profile. ... The code is calling TranslateBitmapBits using BM_xRGBQUADS for the ...
    (microsoft.public.win32.programmer.gdi)

Loading