获取所有DLLS进程 [英] Get All DLLS For A Process
问题描述
我想获取一个给定进程加载的所有dll的列表。我目前正在使用 .NET Framework 4.0 。我知道有一个。 (仅列出非托管DLL)。我需要一种以编程方式检索所有这些DLL的方法。
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
}
编辑:我感兴趣的过程不在当前的AppDomain中。
The process I am interested in is not in the current AppDomain.
推荐答案
我知道有一个错误
I am aware that there is a bug
不,这不是一个错误。这是CLR v4中的一个有意设计的改变,微软并没有把它保密。以前版本的CLR努力模拟加载的程序集,就像它们是非托管DLL一样。但是,当它们实现并行的进程CLR版本控制功能时,这一切就停止了。它已经走了,不会回来。
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.
这不是一个主要的问题,在另一个进程中获取加载的程序集的列表被调试界面很好的支持。 ICorDebugAppDomain :: EnumerateAssemblies()是机票。那么,不像Process.Modules那么容易使用。使用 MDbg示例了解如何使用它。
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屋!