间谍是如何做到的?构建其进程列表?
TL;DR - Spy++ 工具如何真正构建其进程列表?
阶段
我们有一个 MFC 桌面应用程序(在 Windows XP 上运行),该应用程序处于挂起状态,不再对任何用户输入做出反应。然而,当通过 alt-tab 切换到它时,它会被重绘。 (它确实收到 WM_SETFOCUS
、WM_ACTIVATE
等。它显然没有收到任何鼠标或键盘消息。)
由于应用程序处于某种不确定状态,我们拉出了一些进程转储,但到目前为止这些没有什么帮助。输入:
Spy++
我们使用 Spy++ 来查找我上面提供的信息该应用程序似乎正在处理的窗口消息。我们通过打开 Windows 视图 并选择我们的应用程序窗口,并在消息属性中选择
同一进程的 Windows
和 Messages to查看
:全选
。
但是我们首先尝试通过打开 Spy++ 的进程视图 Spy++ 和我们的应用程序未在此进程中显示列表。在另一台运行正常的PC上进行交叉检查,该进程也正常显示在Spy++的进程列表中。
是否可以从进程未显示在 Spy++ 的进程视图中,但应用程序的主窗口显示在 Windows 视图中的事实中推断出有关行为不当的应用程序的任何信息。 为什么主窗口可见的进程不会显示在 Spy++ 的进程视图中?
该进程列在任务管理器和 Visual Studio 2005 的附加进程窗口中。因此,这些工具显然使用列出进程的方法与 Spy++ 不同...?
该应用程序当前挂起的系统是Windows XP SP2 系统,我们使用了Visual Studio 2005 附带的Spy++ 实用程序。
该行为偶尔会重复发生,但仅在该应用程序运行几天后才会发生!
TL;DR - How does the Spy++ tool really construct its process list?
Stage
We have an MFC desktop application (running on Windows XP) that is hanging in that it doesn't react to any user input anymore. It is redrawn when switching to it via alt-tab however. (It does receive WM_SETFOCUS
, WM_ACTIVATE
, etc. It apparently does not receive any mouse or keyboard messages.)
Since the app is hanging in some limbo, we pulled a few process dumps, but these were of little help so far. Enter:
Spy++
We used Spy++ to find the information I gave above about the window messages this application seems to be processing. We did this by Opening the Windows View and selecting our application Window and in the Messages properties selected
Windows of same process
and Messages to View
: Select All
.
However we first tried to view all messages of this process by opening the Processes View of Spy++ and our application is not shown in this process list. Cross checking on another PC where the app is running normally, the process is also normally shown in the processes list of Spy++.
Can anything about the misbehaving app be inferred from the fact that the process is not shown in Spy++'s Process View, but the main window of the app is shown in the Windows View. Why would a process with a main window that is visible not be shown in Spy++'s Processes View?
The process is listed in Task Manager and in the Attach Process Window of Visual Studio 2005. So these tools apparently use a different method to list processes than Spy++ ... ?
The system where the app is currently hanging is a Windows XP SP2 system and we've used the Spy++ Utility that comes with Visual Studio 2005.
The behavior does recur occasionally, but only after the App has been running for several days!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
运行 Vista 或更高版本?您的进程可能会被提升,而 Spy++ 则不会。较新版本的 Spy++ 需要提升。因此,尝试显式提升 Spy++ 并看看是否有帮助。
Running Vista or later? Your process is probably elevated and Spy++ is not. Newer versions of Spy++ require elevation. So, try elevating Spy++ explicitly and see if that helps.
是的,当然可以由此推断出一些事情。不要太认真地对待我在这种情况下所说的任何事情,我必须去看看代码。但我相信 Spy 会查看 EnumProcesses API。 (http://msdn.microsoft.com/en-us/library/ms682629.aspx)
所以,如果您的进程没有显示在那里......嗯。
但是,运行的系统和不运行的系统有什么不同呢?
Yes, of course things can be inferred from this. Don't take anything I say too seriously in this context, I'd have to go look at the code. But I believe that Spy goes off and looks at the EnumProcesses API. (http://msdn.microsoft.com/en-us/library/ms682629.aspx)
So, if your process isn't showing up there... hrm.
But, what is different between the system where it's working and the one where it's not?
Spy++ 需要禁用注册表中的以下两个值 (0) 才能完全显示进程/线程列表:
试图找出它拒绝显示它们的原因正变得疯狂。这是某种糟糕的笑话 - 这个调试器需要本身有一个调试器才能使其工作! WinDBG 不会显示任何有意义的信息,MS 甚至不在其符号服务器上提供符号文件 pfft。
无论如何,也许它不会显示禁用性能计数器的进程,因为我认为,这可以单独设置,至少对于服务而言,例如:
所以它基本上始终是“性能”子项的值。所有这些东西都没有记录,它使用 advapi32.dll 函数,如“PerfRegQueryValue”和“PerfRegQueryInfoKey”...不要问我。
Spy++ requires the following two values in the registry to be disabled (0) to display the processes/threads list AT ALL:
Was going insane trying to find out why it refused to display them. It's some kind of bad joke - this debugger requires itself a debugger to get it working! Not that WinDBG would display any meaningful info, MS doesn't even provide a symbol file on their symbol server, pfft.
Anyway, maybe it doesn't display processes that have their performance counters disabled, because I think, this can be set on individual basis, at least for services, like:
So it's basically always a value of the "Performance" subkey. All this stuff is undocumented, it makes use of advapi32.dll functions like "PerfRegQueryValue" and "PerfRegQueryInfoKey"... don't ask me.