Is it 32 or 64 bit?

Windows specific forum
Randy Walker
Addict
Addict
Posts: 989
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Is it 32 or 64 bit?

Post by Randy Walker »

Any way to look at a file to know if it is a 64 or 32 bit app?

And while we're at it -- are all apps compiled using 64 bit PB automatically 64 bit?

Antbody?
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 989
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Is it 32 or 64 bit?

Post by Randy Walker »

Randy Walker wrote: Mon Aug 12, 2024 7:34 am Any way to look at a file to know if it is a 64 or 32 bit app?

Antbody?
I found an answer on the web to part one above:

"The easiest way, without installing another program or running the file, is just to right click on the file, choose Properties, and then go the the Compatibility tab. If there are no greyed out options and Windows XP and 9x modes are offered, it's 32-bit. If there are greyed out options and Vista is the earliest mode offered, it's 64-bit. No need to start the application at all."

No telling if that is bullet proof, but seems to work.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
BarryG
Addict
Addict
Posts: 4122
Joined: Thu Apr 18, 2019 8:17 am

Re: Is it 32 or 64 bit?

Post by BarryG »

Randy Walker wrote: Mon Aug 12, 2024 7:34 amare all apps compiled using 64 bit PB automatically 64 bit?
Yes. For your other question: I don't know.
User avatar
Demivec
Addict
Addict
Posts: 4259
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Is it 32 or 64 bit?

Post by Demivec »

Randy Walker wrote: Mon Aug 12, 2024 7:34 am And while we're at it -- are all apps compiled using 64 bit PB automatically 64 bit?
If compiled by a 64 bit compiler a program is 64 bit.
If compiled by a 32 bit compiler a program is 32 bit.
This is true whether or not the c compilers are used for the compilation.

It should be noted that you can also arrange for a 32 bit compiler to be used in a 64 bit version of the PureBasic IDE.
Bitblazer
Enthusiast
Enthusiast
Posts: 761
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Is it 32 or 64 bit?

Post by Bitblazer »

For PE executables, check the Machine Types of the header
Last edited by Bitblazer on Mon Aug 12, 2024 4:44 pm, edited 2 times in total.
User avatar
NicTheQuick
Addict
Addict
Posts: 1503
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Is it 32 or 64 bit?

Post by NicTheQuick »

On Linux just use the `file` tool:

Code: Select all

~$ file /usr/bin/ls
/usr/bin/ls: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=36b86f957a1be53733633d184c3a3354f3fc7b12, for GNU/Linux 3.2.0, stripped
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Is it 32 or 64 bit?

Post by RASHAD »

Hi Randy
You can use Detect It Easy v3.09 and get more information
Egypt my love
Bitblazer
Enthusiast
Enthusiast
Posts: 761
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Is it 32 or 64 bit?

Post by Bitblazer »

There are several free tools for windows to detect and display PE structures. For example my current favorite hex editor ImHex.
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Is it 32 or 64 bit?

Post by skywalk »

Code: Select all

Procedure.i SL_IsApp64Bit(fnpath_dll_exe$)
  ; Mijikai, https://www.purebasic.fr/english/viewtopic.php?p=530113#p530113
  Protected.i ri, ri2
  ri = ReadFile(#PB_Any, fnpath_dll_exe$)
  If ri
    Protected.i pos
    Protected IDH.IMAGE_DOS_HEADER
    Protected INH.IMAGE_NT_HEADERS
    If IsFile(ri)
      pos = Loc(ri)
      FileSeek(ri, #Null, #PB_Absolute)
      If ReadData(ri, @IDH, SizeOf(IMAGE_DOS_HEADER)) = SizeOf(IMAGE_DOS_HEADER)
        If IDH\e_magic = $5A4D
          If (IDH\e_lfanew - 8) < Lof(ri)
            FileSeek(ri, IDH\e_lfanew, #PB_Absolute)
            If ReadData(ri, @INH, SizeOf(IMAGE_NT_HEADERS)) = SizeOf(IMAGE_NT_HEADERS)
              If INH\Signature = $4550
                Select (INH\FileHeader\Machine & $FFFF) ; Helles Code
                Case $014C
                  ri2 = 0 ;32
                Case $8664
                  ri2 = 1 ;64
                EndSelect
              EndIf
            EndIf
          EndIf
        EndIf
      EndIf
      FileSeek(ri, pos, #PB_Absolute)
    EndIf
    CloseFile(ri)
  EndIf
  ProcedureReturn ri2
EndProcedure
Debug SL_IsApp64Bit("C:\PureBasic-x86\Compilers\Scintilla.dll")
Debug SL_IsApp64Bit("C:\PureBasic-x64\Compilers\Scintilla.dll")
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Randy Walker
Addict
Addict
Posts: 989
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Is it 32 or 64 bit?

Post by Randy Walker »

Bitblazer wrote: Mon Aug 12, 2024 12:57 pm There are several free tools for windows to detect and display PE structures. For example my current favorite hex editor ImHex.
Thank you BitBlazer, I've been using freewsare "WinVI" which has been great for a portable plain hex editor.
https://www.winvi.de/en/
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 989
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Is it 32 or 64 bit?

Post by Randy Walker »

skywalk wrote: Mon Aug 12, 2024 3:15 pm

Code: Select all

Procedure.i SL_IsApp64Bit(fnpath_dll_exe$)
Thanks for that skywalk!! Some very cool code.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Post Reply