Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2
- From: CK <ck@xxxxxxxxxxxxx>
- Date: Thu, 16 Jul 2009 14:08:01 -0700
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.
- Follow-Ups:
- Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2
- From: Ivan Brugiolo [MSFT]
- Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2
- From: "Jialiang Ge [MSFT]"
- Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2
- References:
- Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2008
- From: CK
- Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2008
- From: Paul Baker [MVP, Windows Desktop Experience]
- Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2008
- Prev by Date: Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2008
- Next by Date: Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2
- Previous by thread: Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2008
- Next by thread: Re: Session 0 bug in TranslateBitmapBits on Vista/Windows Server 2
- Index(es):
Relevant Pages
|
Loading