From 6b91dd6aadb496e7fccdc30fb9445313cc14a256 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 10 Feb 2015 16:21:34 +0100 Subject: [PATCH 2/3] Minor optimization in _dbus_getsid(). MSDN recommands to use GetCurrentProcess() for current process. --- dbus/dbus-sysdeps-win.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 526db8e..bc02f42 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -981,7 +981,7 @@ static BOOL is_winxp_sp3_or_lower() /** 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 + * @param process_id the process id for which the sid should be returned (use 0 for current process) * @returns process sid */ dbus_bool_t @@ -993,7 +993,8 @@ _dbus_getsid(char **sid, dbus_pid_t process_id) PSID psid; int retval = FALSE; - HANDLE process_handle = OpenProcess(is_winxp_sp3_or_lower() ? PROCESS_QUERY_INFORMATION : PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id); + HANDLE process_handle = process_id == 0 ? GetCurrentProcess() + : 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.8.4.5