How to determine if a particular process is running a WPF application or not?

How to determine if a particular process is running a WPF application or not?

In Snoop, the author uses this code below to test this condition ~

foreach (ProcessModule module in process.Modules)
{
     if (module.ModuleName.Contains("PresentationFramework.dll") ||
        module.ModuleName.Contains("PresentationFramework.ni.dll"))
    {
       isValid = true;
        break;
     }
}
+3
source share
2 answers

Apparently, a 32-bit process cannot list the modules of a 64-bit process. It raises the following Win32Exception:

Only part of the ReadProcessMemory or WriteProcessMemory request has completed

This is probably a limitation of the Process class, should be around it using API methods ...

The same thing works fine if the process is also 64 bit ...

Snoop, 64- , , x64

EDIT: 64-, WPF - 32-, Process.Modules, , PresentationFramework ...

System.Diagnostics.ProcessModule (TheWPFApp.exe)
System.Diagnostics.ProcessModule (ntdll.dll)
System.Diagnostics.ProcessModule (wow64.dll)
System.Diagnostics.ProcessModule (wow64win.dll)
System.Diagnostics.ProcessModule (wow64cpu.dll)
+3

64- Vista, . WPF PresentationFramework.ni.dll ( , ngen'd).

, , ?

+2

Source: https://habr.com/ru/post/1717526/


All Articles