如何获取任意进程的 SID/会话? [英] How do I get the SID / session of an arbitrary process?

查看:33
本文介绍了如何获取任意进程的 SID/会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个程序来枚举进程,我想找出指定进程在其下运行的 SID/用户 ID 和会话(即我一个 PID/句柄要处理,我想要 SID 和它在其下运行的会话).有什么线索吗?

I'm writing a program to enumerate through processes, and I want to find out the SID/user ID and session of which the specified process is running under (i.e. i have a PID/handle to process, I want the SID and session it's running under). Any clues?

推荐答案

对于 SID,调用 OpenProcess 获取句柄,然后将句柄传递给 GetSecurityInfo().

For the SID, call OpenProcess to get the handle, then pass the handle to GetSecurityInfo().

对于会话 ID,使用 ProcessIdToSessionId().

For the session id, use ProcessIdToSessionId().

这篇关于如何获取任意进程的 SID/会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆