From 2bf494b0e4a31fccc681ce4234832ae36dc5771d Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 29 Jun 2013 13:45:41 +0200 Subject: [PATCH 2/4] Add WINXP <= SP3 support to _dbus_getsid(). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66060 --- dbus/dbus-sysdeps-win.c | 35 ++++++++++++++++++++++++++++++++++- 1 Datei geändert, 34 Zeilen hinzugefügt(+), 1 Zeile entfernt(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 72ccb93..153951a 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -832,6 +832,38 @@ _dbus_pid_for_log (void) } #ifndef DBUS_WINCE + +static BOOL is_winxp_sp3_or_lower() +{ + OSVERSIONINFOEX osvi; + DWORDLONG dwlConditionMask = 0; + int op=VER_LESS_EQUAL; + + // Initialize the OSVERSIONINFOEX structure. + + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + osvi.dwMajorVersion = 5; + osvi.dwMinorVersion = 1; + osvi.wServicePackMajor = 3; + osvi.wServicePackMinor = 0; + + // Initialize the condition mask. + + VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, op ); + VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, op ); + VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMAJOR, op ); + VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMINOR, op ); + + // Perform the test. + + return VerifyVersionInfo( + &osvi, + VER_MAJORVERSION | VER_MINORVERSION | + VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, + dwlConditionMask); +} + /** Gets our SID * @param sid points to sid buffer, need to be freed with LocalFree() * @param process_id the process id for which the sid should be returned @@ -845,7 +877,8 @@ _dbus_getsid(char **sid, dbus_pid_t process_id) DWORD n; PSID psid; int retval = FALSE; - HANDLE process_handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id); + + HANDLE process_handle = OpenProcess(is_winxp_sp3_or_lower() ? PROCESS_QUERY_INFORMATION : PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id); if (!OpenProcessToken (process_handle, TOKEN_QUERY, &process_token)) { -- 1.7.10.4