Sign in to follow this  
fathom88

PostMessage Inside a Service???

Recommended Posts

I created a service which uses Visual C++'s PostMessage() to send a key press to a window. The service works fine when a user is logged in. However, the service does not work when no one is logged in. The moment someone "logs in" the service does its job and sends a key press message to the window and closes it. The service was ment to close down application generated warning dialogs. Is this a permission issue? Thanks.

Share this post


Link to post
Share on other sites
It's very likely that the service hasn't even been started yet, depending on the service start type.

I'm pretty sure the OS will only let you start up driver services before login, and for that you need ring 0 access.

Out of curiosity, why do you need to be running before login?

Share this post


Link to post
Share on other sites
I'm pretty sure the the service is started because I log when the service starts inside the application event viewer. The service starts at boot up. The service needs to always run because the user can telnet in and start certain apps. The apps that the PC run , run by themselves. Hence the need for my service. To minimize user interface my service closes dialog boxes and restarts any auto apps.

Share this post


Link to post
Share on other sites
I'm pretty sure the the service is started because I log when the service starts inside the application event viewer. The service starts at boot up. The service needs to always run because the user can telnet in and start certain apps. The apps that the PC run , run by themselves. Hence the need for my service. To minimize user interface my service closes dialog boxes and restarts any auto apps.

Share this post


Link to post
Share on other sites
The problem is is that before login, there's no desktops for the service to interact with. You can't interact with the login screen at all, without jumping through some SERIOUS non-trivial hoops.

Share this post


Link to post
Share on other sites
I think an important question is what you are trying to accomplish.

When the Service Manager executes a service it is *not* executed within the same Window Station as an interactive process.

The Interactive Services portion of the Platform SDK discusses this quite thoroughly and the section on Window Stations includes sample code on how to access the active Window Station (WinSta0) and the (generally speaking) 3 default desktops (Screen Saver, Winlogon, and Default) created when Windows authenticates an interactive session.

Your service is likely operating within its own Window Station and/or desktop depending on how you have written it, or which framework you are using.

If you show a specific sample of code perhaps a more useful answer could be provided.

[Edited for clarity :P]

Share this post


Link to post
Share on other sites
Quote:
Original post by fathom88
I see your point. My problem is need to get that contents of pop up windows messages during the login screen. Is there a lower level that I can catch it??? Thanks.


You are aware that some of us (me included) are kind of suspicious about the intentions of this software? How much like creating a zombie computer attempt it looks?

Share this post


Link to post
Share on other sites
Quote:
Original post by MichaelT
Quote:
Original post by fathom88
I see your point. My problem is need to get that contents of pop up windows messages during the login screen. Is there a lower level that I can catch it??? Thanks.


You are aware that some of us (me included) are kind of suspicious about the intentions of this software? How much like creating a zombie computer attempt it looks?


If that is the approach he is taking it is woe-fully inadequate, especially for those of us who are running completely custom SSPIs and GINA authentication modules ;)

Share this post


Link to post
Share on other sites
The service and program must load under a profile in order to send keys like that.


A program like office uses registry keys to contain preferences. However the user profile is not load, the program fails to load.

If you start the service as a user, then use CreateProcess with the correct security descriptor settings you should be able to do this. It is completely unsupported by MS tho...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this