如何从64位应用程序枚举32位进程的模块 [英] How to enum 32bit process's modules from a 64bit application

查看:910
本文介绍了如何从64位应用程序枚举32位进程的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有代码:

  foreach(Process.GetProcesses()中的var进程){
if process.ProcessName.ToLowerInvariant()。StartsWith(iexplore)){

foreach(ProcessModule module in process.Modules){
string descr = module.FileVersionInfo.FileDescription;
MessageBox.Show(module.FileName);
}
}
}

我的应用设置为任何CPU配置,所以它应该作为64位进程在我的Win7 x64上运行。我试图枚举iexplore.exe的模块(32位版本)。我的问题是如何从64位应用程序枚举32位应用程序的模块?它只返回WoW dll。

解决方案

我的应用程序中有同样的问题,虽然我认为你倒退了可能会对您的问题发表评论。)



实际上,如果您自己的进程是64位进程,则无法在64位Windows上枚举32位进程的模块。 p>

您只能看到以下模块(这是32位进程中唯一的64位模块):




  • 主模块(即可执行文件)

  • NtDll.dll

  • Wow64.dll

  • Wow64cpu.dll

  • Wow64win.dll



最有可能是由于事实上, Process.Modules 使用 EnumProcessModules 内部的Win32 API,在使用32/64位时有限制。 MSDN建议(对于本机应用程序)使用 EnumProcessModulesEx ,您也可以P / Invoke。



看起来像其他人也发现了这个问题。 / p>

I have the code:

        foreach (var process in Process.GetProcesses()) {
            if (process.ProcessName.ToLowerInvariant().StartsWith("iexplore")) {

                foreach (ProcessModule module in process.Modules) {
                    string descr = module.FileVersionInfo.FileDescription;
                    MessageBox.Show(module.FileName);
                }
            }
        }

My app is set on "Any CPU" configuration, so it should run as 64bit process on my Win7 x64. I tried to enumerate iexplore.exe's modules (the 32bit version). My question is how to enum the modules of 32bit apps from 64bit app? It returns only the WoW dlls.

解决方案

I have the same problem in my application, although I think you got it backwards (see may comment to your question).

Actually, it is not possible to enumerate the modules of 32bit process on 64bit Windows, if your own process is a 64bit process.

You'll only see the following modules (which are the only 64bit modules in the 32 bit process):

  • The main module (i.e. the executable)
  • NtDll.dll
  • Wow64.dll
  • Wow64cpu.dll
  • Wow64win.dll

Which is most likely due to the fact that Process.Modules uses the EnumProcessModules Win32 API internally, which has limitations when working with 32/64 bit. MSDN suggests (for native applications) to use EnumProcessModulesEx, which you could P/Invoke as well.

It looks like others have discovered this issue as well.

这篇关于如何从64位应用程序枚举32位进程的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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