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

前端 未结 1 1099
北恋
北恋 2021-01-16 15:20

I have the code:

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


        
相关标签:
1条回答
  • 2021-01-16 15:54

    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.

    0 讨论(0)
提交回复
热议问题