X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: sourceware.org X-ASG-Debug-ID: 1233954739-4f4200010000-w5GHUG X-Barracuda-URL: http://10.10.100.8:8000/cgi-bin/mark.cgi Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-ASG-Orig-Subj: w32api 3.13-1 Incorrect #define of WTS_CURRENT_SESSION in wtsapi32.h Subject: w32api 3.13-1 Incorrect #define of WTS_CURRENT_SESSION in wtsapi32.h Date: Fri, 6 Feb 2009 16:12:26 -0500 Message-ID: From: "Linton Miller" To: X-Barracuda-Connect: UNKNOWN[10.10.100.232] X-Barracuda-Start-Time: 1233954740 X-Barracuda-Virus-Scanned: by Barracuda Spam Firewall at trivininc.com X-Barracuda-Spam-Score: -1002.00 X-Barracuda-Spam-Status: No, SCORE=-1002.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1000.0 Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Note-from-DJ: This may be spam 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=3DE6E1C3DF-A74F- 4207-8586-711EBE331CDC&displaylang=3Den), the definition is=20 /* * 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=3D0x0501 -o test-wts test-wts.c -lwtsapi32 */ #include #include #include 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 !=3D 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/