Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CreateProcessAsUser always crashes in debug mode

173 views
Skip to first unread message

Ralf Buschmann

unread,
Aug 2, 2002, 7:07:25 PM8/2/02
to
Hi,

I'm writing an user mode program that uses LogonUser/CreateProcessAsUser
pair to run a program under another account. All the code has been taken
from the "Starting an interactive client process" sample in the PSDK.

The code works just fine when I compile in release mode (using VC++ 6.0
standard edition, SP5), that is, logs on the user and starts the
program. But it always crashes in the CreateProcessAsUser call in debug
mode, access violation in kernel32.dll. I'm testing in W2K and XP, the
caller of the program has all the necessary privileges, but it also
crashes if a privilege is missing.

I'm just curious as to why this is happening. Any ideas?

Thanks!

Ralf.

Ivan Brugiolo [MS]

unread,
Aug 2, 2002, 11:32:16 PM8/2/02
to
Do you use the ansi or unicode version of the API ?
The command line must be a "writable" string in memory.

--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Ralf Buschmann" <busc...@ibherzog.de> wrote in message
news:3d4b103d$0$28141$afc3...@auth.de.news.easynet.net...

Ralf Buschmann

unread,
Aug 3, 2002, 6:13:28 PM8/3/02
to
On Fri, 2 Aug 2002 20:32:16 -0700, "Ivan Brugiolo [MS]"
<ivan...@online.microsoft.com> wrote:

Thanks for your reply!

>Do you use the ansi or unicode version of the API ?

Unicode.

>The command line must be a "writable" string in memory.

Ah, now I see it in the docs:

|The Unicode version of this function, CreateProcessAsUserW,
|will fail if this parameter is a const string.

Well, should read "will crash" then :-). OK, then that is the problem
here. I was passing L"program.exe" for lpCommandLine.

But why it cannot be a const string for the Unicode version? And why
does it crash only in debug mode? Does the API actually modify the
string?

Ralf.

Ivan Brugiolo [MS]

unread,
Aug 5, 2002, 12:13:33 PM8/5/02
to
Basically, it writes a space after the executable name, if params are passed
in a certain way.
The ansi version creates a buffer on the heap, that is writeable by
definition.

--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Ralf Buschmann" <busc...@ibherzog.de> wrote in message

news:3d4c551b$0$28122$afc3...@auth.de.news.easynet.net...

Ralf Buschmann

unread,
Aug 5, 2002, 3:25:26 PM8/5/02
to
On Mon, 5 Aug 2002 09:13:33 -0700, "Ivan Brugiolo [MS]"
<ivan...@online.microsoft.com> wrote:

>Basically, it writes a space after the executable name, if params are passed
>in a certain way.

Are you saying that for the Unicode version, if I pass in an allocated
buffer that contains the null terminated string L"program.exe", it might
overwrite the trailing zero??

Ralf.

0 new messages