How to enum 32bit process's modules from a 64bit application

时光怂恿深爱的人放手 提交于 2019-12-08 05:38:45

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/7485271/how-to-enum-32bit-processs-modules-from-a-64bit-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!