从进程 ID 获取 Winstation 名称
我试图获取一个单独进程仅使用其进程 ID 打开的 winstation 的名称(例如“winsta0”)。 我在 MSDN 上找不到执行此操作的任何内容。 他们似乎只有 GetProcessWindowStation() ,它只适用于您自己的进程。
有任何想法吗?
更新: 也许这是谜题的一部分...
BOOL ProcessIdToSessionId( __in DWORD dwProcessId, __out DWORD *pSessionId );
I am trying to get the name of the winstation (for example "winsta0") that a separate process has opened using only its Process ID. I can't find anything that does this on MSDN. They only seem to have GetProcessWindowStation() which only works for your own process.
Any ideas?
UPDATE:
Maybe this is part of the puzzle...
BOOL ProcessIdToSessionId(
__in DWORD dwProcessId,
__out DWORD *pSessionId
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能需要使用 EnumWindowStations()、EnumDesktops()、EnumDesktopWindows() 和 GetWindowThreadProcessId() 来查看所有正在运行的窗口,直到找到与所需进程 ID 匹配的窗口。
You will probably have to use EnumWindowStations(), EnumDesktops(), EnumDesktopWindows(), and GetWindowThreadProcessId() to look at all running windows until you find one that matches the desired process ID.
好吧,我查看了 API 函数,但遇到了和你一样的死胡同。 只要目标进程创建一个或多个顶级窗口,雷米的建议就应该有效。 我还想到了以下疯狂的想法:
注入的代码将调用GetProcessWindowStation(),然后使用 IPC 机制将其发送回您的进程。 获取后,使用VirtualFreeEx()恢复目标进程的原始地址空间。 在其他用户的进程上使用此功能会出现一些其他问题,但如果您以管理员身份运行,它应该仍然可以工作。
Well, I had a look at the API functions but hit the same dead end as you. Remy's suggestion should work as long as the target process creates one or more top-level windows. The following, crazy idea also occured to me:
The injected code would call GetProcessWindowStation() and then use an IPC mechanism to send it back to your process. After you get it, use VirtualFreeEx() to restore the target process's orginal address space. There are some additional issues using this on another user's process, but it should still work if you run as administrator.