web-dev-qa-db-ja.com

exeファイルの32ビットまたは64ビットをチェックするコマンドラインツールはありますか?

Windowsでは、次のようになります。

is64 abc.exe  
1  

そして

is32 def.exe  
1  

Windowsではabc.exeは64ビットでコンパイルされ、def.exeは32ビットです。

5
kissson

Exeファイルの32ビットまたは64ビットをチェックするコマンドラインツールはありますか?

はい

c:\Program Files (x86)\GnuWin32\bin>file file.exe
file.exe; PE32 executable for MS Windows (console) Intel 80386 32-bit

c:\Program Files (x86)\GnuWin32\bin>cd ..\..\evernote\evernote   
c:\Program Files (x86)\Evernote\Evernote>file evernote.exe
evernote.exe; PE32 executable for MS Windows (GUI) Intel 80386 32-bit

c:\Program Files (x86)\Evernote\Evernote>cd c:\Program Files\Internet Explorer    
c:\Program Files\Internet Explorer>file iexplore.exe
iexplore.exe; PE32+ executable for MS Windows (GUI) Mono/.Net Assembly

PE32形式はPortableExecutable 32ビットの略で、PE32 +はPortableExecutable64ビット形式です。

http://gnuwin32.sourceforge.net/packages/file.htm を参照してください

お気に入り:

is64 abc.exe
1

正確にはそうではありません。

-bオプションを使用してファイル名を出力から除外できます。最初の単語(PE32またはPE32 +)を抽出してPE32 +と比較し、それをìf`ステートメントで使用するには、コマンドラインカンフーが必要です。 。


ウィンドウズ10

Windows 10では、記念日の更新がある場合、 bashシェルを有効にする の場合、bashシェルを開いて、次のようにfileコマンドを使用できます。

rgb@MYPCNAME:/mnt/c$ file install.exe
install.exe: PE32 executable (GUI) Intel 80386, for MS Windows

または

rgb@MYPCNAME:/mnt/c/Program Files/Internet Explorer$ file ieinstal.exe
ieinstal.exe: PE32+ executable (GUI) x86-64, for MS Windows
6
RedGrittyBrick

私はあなたが要求したことを厳密に実行する2つのプログラムを作成しました(エラーなどのエラーメッセージを追加しました)(実際には、動作を完全に正確に変更する定義を持つ1つのプログラムですが、それは問題ではありません。)

あなたは私のDropboxでそれらを見つけることができます ここ 。パッケージにはソースコードが含まれていますが、不要な場合は破棄できます。基本的に、私のバイナリを信頼できない場合にのみ含まれています。

使用例

>is32 C:\Windows\System32\taskmgr.exe
1

>is64 C:\Windows\System32\taskmgr.exe
0

基本的に、プログラムは最初にバイナリをメモリマッピングし、次にPEヘッダーを見つけ、最後にMachineフィールドを要求したアーキテクチャの値と単純に比較することで機能します。本質的に非常に単純なプロセス。

4
user39485
$  file access-client-win32.exe 

access-client-win32.exe: PE32 executable for MS Windows (console) Intel 80386 32-bit


$ file access-client-win64.exe

access-client-win64.exe: PE32+ executable for MS Windows (console) Mono/.Net Assembly

win32.exe -> PE32

win64.exe -> PE32+

ps:PE-> Portable Executable

1
York Tsai