* w32api 3.13-1 Incorrect #define of WTS_CURRENT_SESSION in wtsapi32.h
@ 2009-02-06 21:12 Linton Miller
2009-02-07 4:37 ` Chris Sutcliffe
0 siblings, 1 reply; 2+ messages in thread
From: Linton Miller @ 2009-02-06 21:12 UTC (permalink / raw)
To: cygwin
In w32api, the definition of WTS_CURRENT_SESSION in wtsapi32.h is
#define WTS_CURRENT_SESSION 0
However, from the Microsoft Windows SDK for Windows Server 2008 and .NET
Framework 3.5
(http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-
4207-8586-711EBE331CDC&displaylang=en), the definition is
/*
* Specifies the current session (SessionId)
*/
#define WTS_CURRENT_SESSION ((DWORD)-1)
This results in the wrong session being referenced when used in WTS API
calls such as WTSQuerySessionInformation. The following small example
demonstrates the problem: when I run this over an RDP connection to my
Windows box (logged in as an admin user), it prints
Is a remote connection: 0
which is obviously incorrect. If the "WTS_CURRENT_SESSION" is changed to
"-1", then the expected result
Is a remote connection: 1
is returned.
/* Compile with gcc -Wall -DWINVER=0x0501 -o test-wts test-wts.c
-lwtsapi32 */
#include <windows.h>
#include <wtsapi32.h>
#include <stdio.h>
int main(void) {
USHORT *clnProto;
DWORD size;
if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE,
WTS_CURRENT_SESSION, WTSClientProtocolType, (LPTSTR *)&clnProto, &size))
{
printf("Is a remote connection: %d\n", (*clnProto != 0));
WTSFreeMemory(clnProto);
}
return 0;
}
Linton
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: w32api 3.13-1 Incorrect #define of WTS_CURRENT_SESSION in wtsapi32.h
2009-02-06 21:12 w32api 3.13-1 Incorrect #define of WTS_CURRENT_SESSION in wtsapi32.h Linton Miller
@ 2009-02-07 4:37 ` Chris Sutcliffe
0 siblings, 0 replies; 2+ messages in thread
From: Chris Sutcliffe @ 2009-02-07 4:37 UTC (permalink / raw)
To: cygwin
Thank you for the heads up! I've applied your fix to CVS.
> However, from the Microsoft Windows SDK for Windows Server 2008 and .NET
> Framework 3.5
> (http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-
> 4207-8586-711EBE331CDC&displaylang=en), the definition is
On a side note, I'm not sure what your source was for this patch, but
generally it's not a good idea to extract the values directly from
Microsoft headers, since it may violate license agreements, etc.
Cheers!
Chris
--
Chris Sutcliffe
http://emergedesktop.org
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-02-07 4:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-06 21:12 w32api 3.13-1 Incorrect #define of WTS_CURRENT_SESSION in wtsapi32.h Linton Miller
2009-02-07 4:37 ` Chris Sutcliffe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).