Terminal Services / CreateProcessAsUser() / MFC = CRASH


G

Guest

Hi,

I have an app that has been working for several years that I am now trying
to modify for Terminal Services compatibility.

It has a service running as LocalSystem on W2000Server, that logs on as a
windows user
using LogonUser() (default provider, interactive logon) and then creates a
process using the obtained security token. The process launched is an MFC
application from MSVC++ 6.0.

Now, for TS compatibility, I have modified the code to find the active TS
sessions and before calling CreateProcessAsUser() I now insert a
SetTokenInformation() to change the Session ID parameter from 0 to the proper
session ID of a TS session.

There are now two problems:

1) The process dies "right out of the gate" with a Visual C++ Runtime Error
(abnormal program termination) -- but at least this error window is displayed
on the proper TS terminal display. To test, I have tried with the same code
to launch other (non-MFC) applications with success and even an MFC console
application with no GUI (created my MSVC wizard) with success. Trying a
degenerate case of a dialog based MFC EXE from MSVC wizard, it crashes the
same way as above unless I remove the DoModal() call for the main dialog!

2) Even with the apps that launch and run properly, I can only get it to
work wit the Administrator account. I have code to add the user to the DACL
of the winstation and desktop but the original code used
GetProcessWindowStation() and GetThreadDesktop() since everything was local.
Anyone know a good procedure to get the WinStation and Desktop of the TS
session so I can add my user the their DACLs before calling
CreateProcessAsUser()?

Many thanks for any insight.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top