1

I'm looking for a solution to determine whether a given executable is 64-bit or 32-bit.

The executable being tested may be .NET based or not.

I've seen multiple different techniques, not sure in what one differs from the other.

Techniques i've seen listed:

What is the most robust way of doing it ?

Community
  • 1
  • 1
lysergic-acid
  • 19,570
  • 21
  • 109
  • 218

1 Answers1

1

There are two ways I know of:
1. If you need to check it in run-time: use IsWow64Process. http://msdn.microsoft.com/en-us/library/windows/desktop/ms684139(v=vs.85).aspx?ppud=4
if it is a x86 process - it will return true, otherwise - false.
2. If you need to check it not in run-time, just inspect the EXE PE format.
if the NT Header -> Optional header->Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC it's a x64 exe/dll.

Idov
  • 5,006
  • 17
  • 69
  • 106