Solved

Identify .Exe is 32 bit or 64 bit

Posted on 2006-06-14
8
620 Views
Last Modified: 2013-11-20
Hi,
     
      Any API or function which would say that a .exe file is either 64bit or 32 bit.
      I don't want to load the .exe in to the memory and then find out 32 or 64 bit.

Thanks in Advance,
Ramesh.
0
Comment
Question by:ramesh_hyd_ap
  • 2
  • 2
8 Comments
 
LVL 11

Accepted Solution

by:
DeepuAbrahamK earned 25 total points
Comment Utility
I don't know any API but this might work:

1.Open .exe file in using fopen
2.Search for string "This program must be run under Win32" or "Win32"./Search for string "This program must be run under Win64 or "Win64".
3.Close file.

Best Regards,
DeepuAbrahamK
0
 
LVL 1

Author Comment

by:ramesh_hyd_ap
Comment Utility
Hi,
     I think there should be a more better approach because if in the future if Microsoft changes these strings, my validation will fail.

Thanks,
Ramesh.
0
 
LVL 2

Expert Comment

by:karfi
Comment Utility
maybe this works:

check "magic" field in the PE header, and if its value is 0x020b, the file is a 64bit executable.
0
 
LVL 1

Author Comment

by:ramesh_hyd_ap
Comment Utility
Hi karfi,
 
I don't much about PE header, can u please be more detail.

Thanks,
Ramesh.
0
 
LVL 2

Assisted Solution

by:karfi
karfi earned 25 total points
Comment Utility
Hi!

you can read more here (for example):

http://en.wikibooks.org/wiki/Reverse_Engineering/PE#MS-DOS_header

some explanation for the page:

The offset of the PE exe header is in the DOS header in the beginning of the .exe file.
(e_lfanew in the DOS_Header structure, 0x00000080 is tipical, sometimes it is 0x000000e0 but can be any value (maybe aligned to 4 or 16? bytes)).

After you get PE offset (from the beginning of the file), you can read a COFF header(you can skip this) and a PE Optional header.

The field "magic" I mentioned is called "signature" on the wiki page. (It is the first member of the PEOptHeader struct)

BR,
mate
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now