|
Re: WTSSendMessage fail with error Access Denied "kalpesh" <kalpeshgedia@gmail.com> wrote ...
> callFun( WTS_CURRENT_SERVER_HANDLE,
> WTS_CURRENT_SESSION,
> (LPWSTR)L"Thunder Driver",
> function return with "Error : Access Denied";;
> WTSSendmesage function fail
> and return with error "ACCESS DENIED".
Hi Kalpesh,
I'm not sure if this is the full answer to your problem, but ... in your
code snippet, you are sending the Message to WTS_CURRENT_SESSION. Is this
what you really want to do? (actually, I'm pretty sure it's *not* what you
want to do). This will send the message to the current session. In the
context of the spooler service on Vista, that's going to be Session 0 -
exactly what you're trying to avoid!!
I suspect you'd need to list the current user sessions on the machine; eg,
by a call to WTSEnumerateSessions(). Then select one or more of these user
sessions to send the message to. Typically logged-in users will start from
session 1, but this isn't enforced by teh system - the logged-in user could
potentially be in be in session 7, 16 or 42. And if several users are logged
in at one (even on a desktop PC, there may be multiple "fast user switching"
sessions), you 'll need to decide which sessions (and which logged-in users)
you want to send your message to.
The user context of the process which is sending the message also needs the
Terminal Server "Message" permission, to send messages to another user's
session - otherwise, it would be vulnerable to shatter attacks. See
WTSSendMessage() in MSDN fo rdetails.
Hope it helps,
Andrew |