PostMessage Inside a Service???

Started by
8 comments, last by afterburn 19 years, 6 months ago
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.
Advertisement
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?
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.
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.
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.
daerid@gmail.com
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.
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]
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?

No no no no! :)
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 ;)
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...
--What are you nutz?I have nothing to say to your unevolved little brain. The more I say gives you more weapons to ask stupid questions.

This topic is closed to new replies.

Advertisement