Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know if a ".exe" process was written with C++ or C#? [duplicate]

Tags:

c++

c#

exe

Possible Duplicate:
How do I tell if a win32 application uses the .NET runtime

There is a way to manually recognize if a specific ".exe" process was written with C++(unmanaged code) or with C#(managed code)?

like image 443
Diogo Avatar asked Dec 08 '11 15:12

Diogo


1 Answers

If you're trying to determine if a process is a .NET process, I can suggest a solution inspired from Dave Van den Eynde's answer in this topic: How do I tell if a win32 application uses the .NET runtime

"An application is a .NET executable if it requires mscoree.dll to run.".

Given that, you check the process' modules to see if mscoree is listed.

        foreach (var process in Process.GetProcesses())
        {
            if (process.Modules.OfType<ProcessModule>().Any(m => m.ModuleName.Equals("mscoree.dll", StringComparison.OrdinalIgnoreCase)))
            {
                Console.WriteLine("{0} is a .NET process", process.ProcessName);
            }
        }
like image 190
Kevin Gosse Avatar answered Sep 29 '22 13:09

Kevin Gosse