Solved

Windows XP launch visible program before logon

Posted on 2009-04-10
7
1,477 Views
Last Modified: 2012-05-06
Hello Experts -

I looking for general guidance here as well as whatever other help anyone can supply, I'm going to supply probably more information than you want because I'm not sure what exactly is significant:

I have written two programs in vb.net, a monitoring process which looks for a cookie and an interactive keyboard which the monitoring process launches when it detects the cookie.  The process works fine on XP when the monitoring program is running - for instance, if I drop the monitoring program in startup for all users.

However, the box on which I need to run this setup normally does not logon - it start services which (I'm guessing) launch the interactive programs, which is some sort of program hosting an embedded explorer window.  If I start task manager i can see the logon window process "waiting" as well as other programs under the System User.

I would like to launch the monitoring process as a service as well, and have it display my interactive keyboard in the viewable "instance", or viewport, or whatever that the explorer type program is in... but I can't figure out what that might be since nobody is logged in.  

Am I on the right track trying to do this as a service?  I have written services before but haven't dealt with this type of scenario.  I have been messing around with CreateProcessAsUser but there seems to be the need for a logged on user for this to work?  I have researched this somewhat but am in a little over my head here.

Thanks for any help and your patience with my explanation.  I will supply any particulars that might be useful.
0
Comment
Question by:LawlessOne
  • 4
  • 2
7 Comments
 
LVL 15

Expert Comment

by:oobayly
Comment Utility
As far as I'm aware, the login dialog is the only gui allowed to exist before loging on. The (now mostly unused) Ctrl+Alt+Delete before login was there for exactly that reason: Only windows is allowed to capture Ctrl+Alt+Delete, so by forcing a user to hold that combination of keys meant that if the dialog displaying the prompt was replaced with login dialog, the user could be sure that it was legitimate.

I can't imagine any modern OS allowing user input before authentication.

I'm afraid what you're asking for sounds disturbingly like a keylogger or a fake login dialog.

If you really need to be able to monitor the machine while it's not logged in, then I'd suggest creating something like a webservice that you can poll for the required data.
0
 

Author Comment

by:LawlessOne
Comment Utility
oobayly, For what it is worth, I assure you I'm not trying to do anything like keylogging or a make a fake login dialog.  No keyboard is attached to these boxes and nobody logs into them normally - they are XP boxes that launch services which spawn process on the screen that a user can interact with.

What I'm trying to do is present a virtual keyboard on a touch screen.  To do that I'm popping the keyboard when requested from a monitoring process, which I would normally put in Startup, but Startup programs don't run on this setup normally - there is a process launched that puts some sort of embedded internet explorer type program on screen, like IE in kiosk mode but embedded in some kind of other window.
0
 
LVL 15

Expert Comment

by:oobayly
Comment Utility
That makes it much clearer. I'n a little bit incredulous that the apps are running with a gui while no user has been logged in, but anyhow.
I'm afraid I can't offer any advice as to your question

The only way I can see this settup running is like some of those supermarket self scan kiosks you get. XP is configured to login automatically, and then the app runs full screen, hooking low-level keyboard events so that focus can't be taken from it.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:LawlessOne
Comment Utility
Thanks for trying anyway.

Unfortunately for me it does not do an auto login (and it would cause headaches for me to switch the box to this), because then I would be able to use the startup to run my monitor.  
0
 
LVL 5

Accepted Solution

by:
JMoon5FTM earned 500 total points
Comment Utility
If you're familiar with building service applications, then this shouldn't be too difficult.

This isn't supported by Microsoft, but here's the gist of what you need to do.

NOTE:  I've only tried this on Windows XP.  I'm pretty sure it should work in 2000 as well.  I have no idea whether this needs modifying for Windows Vista.

Your service must be marked as "interactive", and set to run as the LocalSystem user.  This is required in order for Windows to give you permission to do UI stuff from a service.  This can't be set from within Visual Studio using the configuration stuff Microsoft gives you.  In theory you could extend ServiceInstaller to support this, but that's a bunch of extra work I haven't done yet.  So let's go ahead and install it the Microsoft-sanctioned way, and then use RegEdit to tweak the registration:

    Go to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\YourServiceName.
    Ensure that ObjectName is set to "LocalSystem".
    Change Type from 0x10 to 0x110 or from 0x20 to 0x120.

Since we're editing the registry instead of using the API, you will need to restart your computer for these changes to take effect.

Now that your service has permission to do UI... well the road forks depending on whether you're trying to show that UI directly from the service or start it up as a separate application.  Or of course you could do both.

If you're showing UI from the service itself, you need two p-invoke calls.  First, you need OpenDesktop("Winlogon", 0, 0, 0xff).  You can do that one from Main() and store it in a static variable for the lifetime of the EXE.  Then when you go to create a thread to serve as the UI thread for the service, you need to call SetThreadDesktop using the handle you got from OpenDesktop.  Once a thread has called SetThreadDesktop, it can use Forms and such with relative impunity.  Be advised that the pre-logon desktop isn't exactly like a user desktop and some things will have subtle issues - for example, ToolStrip and derived controls won't look very snazzy, and System.Windows.Forms.Timer won't work at all.  (Use System.Timers.Timer instead.)  And as always, you should mark your UI thread with the [STAThread] attribute.

If you're just trying to launch another application and show its UI, you need to call CreateProcess.  In your StartupInfo structure, set lpDesktop to @"WinSta0\Winlogon".  Many programs will work just fine, but once again be advised that the pre-logon desktop isn't exactly like a user desktop and as such some programs may have issues.  For example, I've had a lot of trouble getting media player-type programs to work in this environment.

Let me know where you need additional help.
0
 

Author Comment

by:LawlessOne
Comment Utility
JMoon5FTM, I apologize - for some reason I never saw a notify on your comment as I did on the earlier ones, and I finally just came back to abandon the question.

Your approach is very close to what I have been trying... I'm going to check particulars against what you describe here and I will comment back.

Again my apologies - I appreciate your comment!
0
 

Author Closing Comment

by:LawlessOne
Comment Utility
Good answer, thanks for the help.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now