views:

1188

answers:

12

Whats the easiest way to find out what programming language an application was written in? I would like to know if its vb or c++ or delphi or .net etc from the program exe file.

+6  A: 

Try PEiD

of course if they used a packer, some unpacking will need to be done first :)

John T
PEiD works great!
Unkwntech
+2  A: 

You could try using Depends to see what runtime dependancies it has, which might give some clues.

Paul Dixon
+5  A: 

Start it up and check what run-time DLLs it uses with Process Explorer.

If that doesn't make it immediately obvious, search the web for references to those DLLs.

Most disassemblers (including Olly I think) can easily show you the text contained in an EXE or DLL, and that can also sometimes give a clue. Delphi types are often prefixed with T as in TMyClass.

If it's a small executable with no DLL references and no text you might be SOL. At that point you'd need to look for idioms of particular compilers, and it would be mostly guesswork.

Ed Guiness
+1  A: 
  • Determine Delphi Application
  • Use eda_preview270.exe (from here) or some other spy tool and check the window class names. If they read like TButton or TfrmBlubb, it's a VCL app. If there is an "Afx" in them, it's probably MFC.
Ulrich Gerhardt
+1  A: 

The easiest way is to ask the developer of the program. It does not require any knowledge and utility programs.

HS
I´m guessing if he is looking for a tool to discover this, he doe not have easy access to the developer.
Decio Lira
Seems like a stupid answer, but this is in fact how "hackers" do their work. "Social engineering" it's called... +1
Yar
+1  A: 

Compiled languages (by this I mean no scripting languages, or Java, .NET, etc.) are compiled into CPU assembly instructions, which is essentially a one-way conversion. It is not usually possible to determine which language a program was written in. However, using a dependency walker, you could potentially determine which runtime library the program was loading (if any) and therefore determine which language it used (e.g. MS Visual C++ 9 uses msvcr90.dll).

jgottula
Though you can always link against an older version of the CRT.
jeffamaphone
I guess so. You would know that it was VC++, though.
jgottula
+1  A: 

you can check is that a .net assembly or not by trying to open with ildasm.exe tool

ArsenMkrt
But what bout the different languages in .Net.
rahul
phoenix - no way to determine that. C# and VB.NET are interchangeable once compiled.
Jess
yea, no way to determine that because all .net languages compile the code to the same IL language
ArsenMkrt
I think VB leaves some weird stuff in its IL executables. Stuff that C# and other IL languages don't bother with, because VB is weird.
jgottula
interchangeable but NOT identical. For example VB implements the c# "?" operator as a function call to Iif(). VB includes Microsoft.VisualBasic for a lot of things.
Oplopanax
A: 

In general, you can't.

If you can load it into Reflector, you know it is a managed assembly.

jeffamaphone
A: 

That's a good question. There isn't any general way to tell, but I bet most compilers and libraries leave a mark in the resulting EXE file. If you wanted to spend a lot of time on it, you could gather a bunch of EXEs written in known languages and scan for common strings. I would image you'd find some.

Dependancy Walker, which someone else mentioned would be a good way to look for telltale dependencies, like versions of MSVCRT, etc

Chad Okere
A: 

If I remember correctly PE Explorer Disassembler gives some information about compiler that creates given not .net and java binary, for .net use Reflector or ILDAsm tool

ArsenMkrt
A: 

i'd try running the .exe thru a 'strings' program to get assorted hints.

Scott Evernden
+3  A: 

There is an art to detecting what language a program was written in. It is possible but there are no hard and fast rules. It takes a lot of experience (and it also leads to the question "Why would you want to..." but here are a few ideas on how to go about it.

What you're looking for is a "signature". The signature could be a certain string that is included by the compiler, a reference to an API that is quite common in the programming tool being used, or even a style of programing that is common to the tools being used, visible in the strings contained in the application.

In addition, there are styles to how an application is deployed: various configuration files found in the deployment directory, dlls and assemblies and even images, directories or icons.

Java applications wrapped in a self-launching executable will contain references to java libs, and will likely have certain libraries or files included in the same directory that indicate that it's java.

As indicated in other answers a managed assembly will show certain signs as well: you can open it in Reflector etc. While it is correct that c# and VB are "interchangable" once compiled, it is not true that they are identical. If you use Reflector to disassemble VB code you will quite often see that the assembly references the Microsoft.VisualBasic.dll assembly. You'll be able to tell the difference between Mono applications because they will most likely contain references to the mono assemblies.

Many compilers assemble and link code in certain ways, and leave footprints behind. For example, examining a window executable using "strings: tab in Process Explorer, you'll see a lot of strings. Using these you may be able to determine programming styles, methods called, error or trace methods withint the exe.

An example is that compilers use different mechanisms for localization: Microsoft stores localized strings in XML files or resource files. Other compilers will use a different tactic.

Another example is c++ name mangling. The CodeWarrior compiler uses a different algorithm to mangle the names of the member variables and functions of a call than Visual Studio.

I suppose you could write a book on the subject of accurately determining the lineage of any executable. This subject would probably be called "programming archeology".

Oplopanax