获取进程的所有DLLS [英] Get All DLLS For A Process

查看:206
本文介绍了获取进程的所有DLLS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得加载一个指定进程的所有DLL的列表。我目前使用的的.NET Framework 4.0 。我知道,有一个的试图通过Process.Modules属性来访问所有托管DLL时的错误。 (只列出托管DLL)。我需要一种以编程方式检索所有这些DLL

 过程[] = myProcess Process.GetProcessesByName(MyProcess); 
如果(myProcess.Count()0)
{
的foreach(ProcessModule processModule在myProcess [0] .Modules)
//获取信息
$} b $ b

编辑:我感兴趣的是这个过程是不是在当前的AppDomain

$ b $。 b
解决方案

据我所知,有一个bug




不,这不是一个错误。这是在CLR V4故意设计的变化,微软并没有保持一个秘密。 CLR的以前版本作出了努力,就好像它们是托管DLL来模拟加载的程序集。但是,这只是停止决策意识时,他们实施的并排侧进程CLR版本控制功能。这是走了,不会回来了。



这是不完全是一个大问题,让另一个进程中加载​​的程序集的列表深受调试接口的支持。 ICorDebugAppDomain :: EnumerateAssemblies()是门票。好了,不完全是那么容易为Process.Modules使用。使用 MDBG样品,以了解如何使用它。


I would like to get a list of all the dlls loaded for a given Process. I am currently using .NET Framework 4.0. I am aware that there is a bug when trying to access all managed dlls through the Process.Modules property. (Only lists the unmanaged dlls). I need a way to programmatically retrieve all of these dlls.

 Process[] myProcess = Process.GetProcessesByName("MyProcess");
 if(myProcess.Count() > 0) 
 {
      foreach (ProcessModule processModule in myProcess[0].Modules)
      //get information
 }

EDIT: The process I am interested in is not in the current AppDomain.

解决方案

I am aware that there is a bug

No, that's not a bug. It was an intentional design change in CLR v4, Microsoft did not keep that a secret. Previous versions of the CLR made an effort to emulate loaded assemblies as though they were unmanaged DLLs. But that just stopped making sense when they implemented the side-by-side in-process CLR versioning feature. It's gone and won't come back.

This isn't exactly a major problem, getting the list of loaded assemblies in another process is well supported by the debugging interface. ICorDebugAppDomain::EnumerateAssemblies() is the ticket. Well, not exactly as easy to use as Process.Modules. Use the MDbg sample to find out how to use it.

这篇关于获取进程的所有DLLS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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