Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当使用 .NET 的Process.SessionId属性或 Windows API 调用ProcessIdToSessionId()时,是否可以依赖结果在整个过程的生命周期中是相同的?
Process.SessionId
ProcessIdToSessionId()
即如果我想使用这个值,我只需要确定它是一次吗?
不,这不安全,尤其是当连接从 RDP/remote 更改为物理控制台(反之亦然)或完成快速用户切换 (Windows XP) 时,控制台会话可以更改它的 sessionid。此外,由于 SessionId 是从进程的 PEB 中检索的,因此经常调用此 API 也不会受到伤害。