Re: CreateDC() problem with printer drivers on Windows Server 200x
- From: LongJohn <LongJohn@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 10 Feb 2009 17:26:02 -0800
Below are the exact steps to reproduce this problem. It seems to come into
play when a 32-bit process, running as a user other than the interactive
user, calls ::CreateDC() for a printer on a 64-bit OS.
You ask why one would run a process in such a way? Simple: for process
isolation and/or least rights security approach (like a web server add-on,
etc).
(1) Build the following program as a 32-bit Windows console EXE called
"prog.exe".
#include <windows.h>
#include <stdio.h>
int main(int argc,char* argv[])
{
HDC hdc=::CreateDC("WINSPOOL","Printer",NULL,NULL);
if (hdc==NULL)
{
printf("Error=%d\n",GetLastError());
}
else
{
printf("All ok\n");
}
return 0;
}
(2) Make a local printer named "Printer" (driver type does not matter).
(3) Make a user (limited user, member of "Users", etc.) called "TestUser".
(4) Execute the program as yourself from a command prompt:
C:\> prog.exe
(5) Execute the program again as the other user:
C:\> runas /user:TestUser prog.exe
Both (4) and (5) work on all 32-bit Windows that we tested.
However, (4) works and (5) fails on Vista Business SP1 x64 (err=1008), and
Server 2003 R3 x64 (err=0). We will try on others once we can install them.
This is not the solution, but it should drive an MS developer directly to
the solution.
LongJohn
.
- References:
- Prev by Date: Re: CreateDC() problem with printer drivers on Windows Server 200x
- Next by Date: Re: CreateDC() problem with printer drivers on Windows Server 200x
- Previous by thread: Re: CreateDC() problem with printer drivers on Windows Server 200x
- Next by thread: Re: CreateDC() problem with printer drivers on Windows Server 200x
- Index(es):
Relevant Pages
|