Re: CreateDC() problem with printer drivers on Windows Server 200x

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
.



Relevant Pages

  • Re: CreateDC() problem with printer drivers on Windows Server 200x
    ... Below are the exact steps to reproduce this problem. ... play when a 32-bit process, running as a user other than the interactive ... Build the following program as a 32-bit Windows console EXE called ... Execute the program as yourself from a command prompt: ...
    (microsoft.public.win32.programmer.gdi)
  • RE: No sound with display
    ... initiating the execute command to play, in is not in fact executing. ... that turns the midi file on and off is titled PlayMidiFile. ... The last sub is ...
    (microsoft.public.excel.programming)
  • Re: Horde Webmail file inclusion proof of concept & patch.
    ... The SQL example in the original post does prevent the themes from appearing but does not execute the file in question. ... I'm a bit behind in reading bugtraq but thought I'd throw this in: We had a similar situation sometime back with Maia Mailguard, and the null byte thing depends on the platform. ... It was reported on a BSD system I think, but our Linux systems would not reproduce it. ...
    (Bugtraq)
  • Re: Possible Bug: name of directory inhibits execution?
    ... you try to execute it that causes the problem (ala the full path to the ... executable which attempts to launch a form). ... we're dealing with paths constructed inside the .NET framework or OS, ... What's the minimal code that anyone could use to reproduce this ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Re: Re: Re: Deceptively OT
    ... I nearly always forget or lose wristwatches sooner or later since I ... habitually take them off to play any one of a number of stringed ... I like the _idea_ of a well-made watch. ... What good is being an executive if you never get to execute anyone? ...
    (alt.usage.english)