[fpc-pascal] Daemon using TTimer on Windows
R0b0t1
r030t1 at gmail.com
Sun Jul 1 18:44:19 CEST 2018
On Sun, Jul 1, 2018 at 8:06 AM, Marcos Douglas B. Santos <md at delfire.net> wrote:
> On Sat, Jun 30, 2018 at 9:13 PM, R0b0t1 <r030t1 at gmail.com> wrote:
>> Anyway - does TTimer use the WM_TIMER message? That is the type tied
>> to the GUI. Even if you need to use WM_TIMER for some reason you can,
>> as services should be run in "session 0" and should have access to a
>> GUI. The latter is, I think, a compatibility option you can enable.
>
> I didn't understand this "session 0"... is it a something related to
> Lazarus or Windows?
>
It is something related to Windows, and the reason services can not use the GUI.
A session is started for each terminal services instance. A session
contains multiple window stations, each of which contains at least one
desktop, one of which accepts keyboard/mouse input. One terminal
services instance exists by default, and it is the "local session,"
i.e. the one that consumes physical keyboard and mouse input and
outputs to the screen. It used to be that this local session was the
one that ran services in addition to logged in user programs.
This made it easier than it should have been to exploit service
processes, so they made session 0 noninteractive and now the console
logs in to session 1.
One exploit was particularly bad. You can forcibly register WM_TIMER
callbacks for an application and have that callback run in that
processes' thread. As long as services were running in the same
desktop you could trivially run code as SYSTEM.
More information at
https://blogs.technet.microsoft.com/askperf/2007/04/27/application-compatibility-session-0-isolation/
but it is not a lot. There is a better MSDN article I could not find.
Cheers,
R0b0t1
More information about the fpc-pascal
mailing list