如何找到的类型的调试过程中实现给定接口的所有实例过程中、实例、接口、类型

2023-09-03 01:54:58 作者:良人不来

我要寻找一种方式来定位的实现给定接口(在WinDbg的调试是)类型堆当前所有实例。由于接口没有,你可以创建一个接口的实例意识类型,他们显然并不时检查堆出现。即!dumpheap 帮助不大这里。

I am looking for a way to locate all current instances on the heap of types that implement a given interface (during WinDbg debugging that is). As interfaces are not types in the sense that you can create instances of an interface, they obviously do not show up when inspecting the heap. I.e. !dumpheap is of little help here.

不过,!dumpmt -md 在一个给定的MT列出 IFaces 在 IFaceMap 。据我可以告诉这个数字似乎表明,如果该类型实现一个或多个接口,或不。当使用该类型的 -md 标记方法也列。

However, !dumpmt -md on a given MT lists the number of IFaces in IFaceMap. As far as I can tell this number seems to indicate if the type implements one or more interfaces or not. When using the -md flag methods on the type are also listed.

不幸的是,!dumpmd 不会占用一个给定的方法,接口,据我所知道的,所以这不能被用来建立实现的接口。

Unfortunately the !dumpmd doesn't tie a given method to an interface as far as I can tell, so this cannot be used to establish the implemented interfaces.

我认为这些信息是在内存的某个地方,但我不知道去哪里找。任何输入是非常AP preciated。

I assume this information is available somewhere in memory, but I am not sure where to look. Any input is highly appreciated.

推荐答案

几年前,我绝望了这样一些信息。我结束了创建,当你使用一个不起眼的选项,启动应用程序将只会出现一个TreeView。当我点击刷新,它会使用反射通过根类实例的所有属性去旅行。如果它发现一个属性,它是一个集合或持有的其他特性,它会递归调用到它们。最终的结果是,在该点的实例数据的树是可供参阅。

A few years ago, I was desperate for some information like this. I ended up creating a treeview that would only appear when you used an obscure option for starting the app. When I clicked "refresh", it would use reflection to travel through all the properties of the root class instance. If it found a property that was a collection or held other properties, it would recursively call into them. The end result was that a tree of the instance data at that point was available for perusal.

要点这种方法是

确保你只有一个 顶级对象实例,或者你 知道到底有多少,哪些顶级实例 有。 (另外,不要忘了静态值。) 在弄清楚如何使用反射来浏览信息的相关位。 在显示它需要的时候以可读的方式。 Make sure you have only one top-level object instance, or you know exactly how many and which top-level instances there are. (Also, don't forget about static values.) Figure out how to use reflection to look through the relevant bits of information. Display it when needed and in a readable fashion.
 
精彩推荐
图片推荐