diff options
author | Ralf Habacker <ralf.habacker@freenet.de> | 2015-02-10 16:21:34 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2015-02-11 11:57:49 +0000 |
commit | 4a3943972798989f433c30394d3349d10c0d0827 (patch) | |
tree | 6e041d75f16a7f3294be9ddb6a02db37f78fe8f8 | |
parent | 87d40ec9508e75fbc6076e3e3b3ad7bedf6909bf (diff) | |
download | dbus-4a3943972798989f433c30394d3349d10c0d0827.tar.gz |
Minor optimization in _dbus_getsid().
MSDN recommands to use GetCurrentProcess() for current process.
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54445
-rw-r--r-- | dbus/dbus-sysdeps-win.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 526db8e8..50258151 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,13 @@ _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; + if (process_id == 0) + process_handle = GetCurrentProcess(); + else if (is_winxp_sp3_or_lower()) + process_handle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, process_id); + else + process_handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id); if (!OpenProcessToken (process_handle, TOKEN_QUERY, &process_token)) { |