Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista General Discussion > WTSSendMessage fail with error Access Denied

Reply
Thread Tools Display Modes

WTSSendMessage fail with error Access Denied

 
 
kalpesh
Guest
Posts: n/a

 
      06-22-2007
i describe my Issue that i am developing virtual printer driver DLL
which is run by
spooler service of operation system, means my driver is run under
spooler service.

Now i need to show one MessageBox from my this DLL in Window vista
but
vista not support any user interface from service thats why i use
this
WTSSendMessage function but this function give me error "ACCESS
DENIED"...


//Code i used


#define WTS_CURRENT_SERVER ((HANDLE)NULL)
#define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL)
#define WTS_CURRENT_SERVER_NAME (NULL)


#define WTS_CURRENT_SESSION ((DWORD)-1)


//defination of WTSSendmessage Function pointer
typedef BOOL (*funPtr) ( HANDLE,
DWORD,
LPWSTR,
DWORD, LPWSTR, DWORD, DWORD, DWORD, DWORD*,
BOOL);


funPtr callFun;
HMODULE hModule = LoadLibrary(L"Wtsapi32.dll");
if(hModule)
{
callFun = (funPtr) GetProcAddress(hModule, "WTSSendMessageW");
if(callFun) {
DWORD result;
BOOL ret =
callFun( WTS_CURRENT_SERVER_HANDLE,


WTS_CURRENT_SESSION,


(LPWSTR)L"Thunder Driver",
38,
MB_OK,
FALSE,
&result,
0);


if(!ret) {
Print_Error();
}


}//end getproc
}//end loadlibrary


function return with "Error : Access Denied";;
WTSSendmesage function fail
and return with error "ACCESS DENIED".


This function failed is happening on Window vista only,
One more thing is this same code is running successfully On Window XP
means i think that
there is some problem arise due to Vista securtiy...


So please help me ....
Thanks in Advance....

 
Reply With Quote
 
 
 
 
Andrew McLaren
Guest
Posts: n/a

 
      06-23-2007
"kalpesh" <> 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

 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WTSSendMessage return access denied! girishsripathy@gmail.com Windows Vista Security 0 08-06-2007 08:59 PM
WTSSendMessage fail with error Access Denied kalpesh Windows Vista Security 2 06-27-2007 04:43 PM
Access is denied-system error 5 no_spam_paquette@uwo.ca Windows Vista Networking 3 06-21-2007 06:53 PM
Access Denied Error with Scan and Fax Gary Crim Windows Vista Printing / Faxing / Scanning 3 05-24-2007 01:31 AM
getdrivelayout: create file fail! Access Denied (ERROR) Please he Brent J. Windows Vista General Discussion 3 04-04-2007 05:04 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59