2011-11-17 10:29:58 +0000 2011-11-17 10:29:58 +0000
341
341
Advertisement

Windowsでバイナリが32ビットか64ビットかを確認する方法

Advertisement

Windowsでバイナリが32ビットか64ビットかを確認する簡単な方法はありますか?32ビットマシンにプログラムを移動して、壮大な失敗を経験する前に確認する必要があります。

Advertisement
Advertisement

回答 (20)

377
377
377
2015-03-13 17:08:57 +0000

Richard’s answer ](https://superuser.com/a/358459/341852)からヘッダーの値を調べた結果、速くて簡単で、テキストエディタを使うだけの解決策を思いつきました。Windowsのデフォルトのnotepad.exeでも動作します。テキストエディタで実行ファイルを開きます。Windows は実行ファイルのコンテキストメニューに Open... オプションを表示していないので、ドラッグアンドドロップするか、エディタの Open with... ダイアログを使う必要があるかもしれません。最初にPEが発生した後、最初に印刷可能な文字を確認します。この部分は、少なくともいくつかの空白で囲まれている可能性が高いので(たくさんあるかもしれません)、視覚的に簡単にできます。

ここでは、以下のようになっています:

32ビット:

PE L

64ビット:

PE d†

警告の言葉:大きなファイルでデフォルトのメモ帳を使用すると、非常に遅くなることがあります。私の場合は、12メガバイトのファイルを表示するために約30秒かかりました。

その他の情報:

HEX-Editor を使用している場合、PE Signature のオフセットはオフセット 0x3C にあります。署名は PE0x86640x014c (文字 “P” と “E” の後に 2 つのヌルバイトが続く) で、その後にリトルエンディアンの 2 バイトのマシンタイプが続きます。

関連する値は、64 ビットの実行ファイルの場合は 64 86、32 ビットの場合は 4c 01 です (エンディアンを調整するとそれぞれ &007 と &007 になりますが、まともな 16 進数のエディタであれば、16 進数の値を検索するときに自動的にエンディアンを処理します)。もっと多くの可能な値がありますが、おそらくこれらの値に遭遇することはないでしょうし、Windows PC上でそのような実行ファイルを実行することもできません。

マシンタイプの完全なリストと.exeの仕様の残りの部分は、 Microsoft PE and COFF Specification Machine Typesセクションを参照してください。

129
129
129
2011-11-17 12:14:43 +0000

SDKツールdumpbin.exeオプションでこの情報を含む/headersは、これらの2つを比較してください(私は重要な情報のために太字を追加しました)

PS [64] E:\ #4\> dumpbin /headers C:\Windows\system32\cmd.exe Microsoft (R) COFF/PE Dumper Version 10.00.40219.01 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file C:\Windows\system32\cmd.exe PE signature found File Type: EXECUTABLE IMAGE FILE HEADER VALUES **8664 machine (x64)** 6 number of sections 4CE798E5 time date stamp Sat Nov 20 09:46:13 2010 0 file pointer to symbol table 0 number of symbols F0 size of optional header 22 characteristics Executable Application can handle large (\>2GB) addresses [...]
PS [64] E:\ #5\> dumpbin /headers C:\Windows\syswow64\cmd.exe Microsoft (R) COFF/PE Dumper Version 10.00.40219.01 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file C:\Windows\syswow64\cmd.exe PE signature found File Type: EXECUTABLE IMAGE FILE HEADER VALUES **14C machine (x86)** 4 number of sections 4CE78E2B time date stamp Sat Nov 20 09:00:27 2010 0 file pointer to symbol table 0 number of symbols E0 size of optional header 102 characteristics Executable 32 bit word machine [...]
50
Advertisement
50
50
2014-09-06 15:02:25 +0000
Advertisement

Windows SDKやVisual Studio全体を持っていない、または必要ない場合は、 sigcheck.exe from SysInternals :

sigcheck.exe C:\Windows\Notepad.exe

Output:

Sigcheck v2.1 - File version and signature viewer
Copyright (C) 2004-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

c:\windows\notepad.exe:
    Verified: Signed
    Signing date: 8:59 AM 8/22/2013
    Publisher: Microsoft Windows
    Description: Notepad
    Product: Microsoft« Windows« Operating System
    Prod version: 6.3.9600.16384
    File version: 6.3.9600.16384 (winblue_rtm.130821-1623)
    MachineType: 64-bit
```を使用することができます。
46
46
46
2014-01-17 02:08:47 +0000

私が確認できるのは、fileユーティリティ(例:cygwinから)で32-bitと64-bitの実行ファイルを区別してくれることです。以下のように表示されます:

32.exe: PE32 executable (GUI) Intel 80386, for MS Windows
64.exe: PE32+ executable (console) x86-64, for MS Windows

ご覧のように、どちらがどちらであるかは一目瞭然です。さらに、コンソール実行ファイルとGUI実行ファイルを区別します。

33
Advertisement
33
33
2011-11-17 10:39:49 +0000
Advertisement

簡単な方法は、それを実行して(あなたがそれを信頼していると仮定して)、タスクマネージャのプロセスタブを見てみることです。32bitプロセスはプロセス名の最後に “32 "と表示されます。それがあなたのコンピュータ上で実行する気がないものであれば、 EXE Explorer を試すことができます。32ビットか64ビットかを含む実行ファイルの情報がたくさん表示されます。

28
28
28
2015-10-04 10:56:52 +0000

多くの人が優秀な 7-zip をインストールしていて、PATHに7-Zipフォルダを追加しています。7-zipは、MSIファイルやPE実行ファイルなど、ZIPやRAR以外のファイル形式を理解しています。問題の PE ファイル (Exe または DLL) 上でコマンドライン 7z.exe を使用するだけです:

7z l some.exe | more
7z l some.exe | findstr CPU

出力は以下のような行を含み、CPU 行は x86 または x64 のどちらかを読み取ることになります。

21
Advertisement
21
21
2011-11-17 13:36:05 +0000
Advertisement

64ビット版の プロセスエクスプローラ を見ればわかります。実行ファイルを実行して、プロセスのプロパティウィンドウを開くだけです。メインタブに「Image:32 Bit」または「Image:64 Bit」という項目があります。

17
17
17
2015-01-05 16:53:58 +0000

最も簡単な方法(データが機密でない場合)

バイナリーが32ビットか64ビットかを調べるには、Virustotal File detailが最も簡単な方法だと思います。

14
Advertisement
14
14
2012-09-27 07:08:26 +0000
Advertisement

実行ファイルを実行してからプロセスエクスプローラや類似のツールでチェックする方法には、いくつかの明らかな欠点があります:

  1. プロセスを実行しなければならない
  2. 2. 短命なプロセス (echo hello world タイプのようなもの) の場合、プロセスエクスプローラは新しいプロセスが開始されたことさえ登録しないかもしれません。

もう一つの方法は cygwin の file コマンドを使うことです。しかし、Windowsではテストしていません。Linuxでは問題なく動作します。

Usage: file program_under_test.exe

EDIT: file.exeをWindowsで試してみました。)

13
13
13
2015-03-19 12:09:30 +0000

ここに Powershell ソリューションがあります。Powershellを開いて、関数を貼り付けて(Enterキーを2回押してプロンプトに戻るようにしてください)、関数の下にある私の例のようにそれを使用してください:

function Test-is64Bit {
    param($FilePath=“$env:windir\notepad.exe”)

    [int32]$MACHINE_OFFSET = 4
    [int32]$PE_POINTER_OFFSET = 60

    [byte[]]$data = New-Object -TypeName System.Byte[] -ArgumentList 4096
    $stream = New-Object -TypeName System.IO.FileStream -ArgumentList ($FilePath, 'Open', 'Read')
    $stream.Read($data, 0, 4096) | Out-Null

    [int32]$PE_HEADER_ADDR = [System.BitConverter]::ToInt32($data, $PE_POINTER_OFFSET)
    [int32]$machineUint = [System.BitConverter]::ToUInt16($data, $PE_HEADER_ADDR + $MACHINE_OFFSET)
    $stream.Close()

    $result = "" | select FilePath, FileType, Is64Bit
    $result.FilePath = $FilePath
    $result.Is64Bit = $false

    switch ($machineUint) 
    {
        0 { $result.FileType = 'Native' }
        0x014c { $result.FileType = 'x86' }
        0x0200 { $result.FileType = 'Itanium' }
        0x8664 { $result.FileType = 'x64'; $result.is64Bit = $true; }
    }

    $result
}

ここに出力例があります:

D:\> Test-is64bit

FilePath FileType Is64Bit
-------- -------- -------
C:\Windows\notepad.exe x64 True

D:\> Test-is64bit 'C:\Program Files (x86)\Mozilla Firefox\firefox.exe'

FilePath FileType Is64Bit
-------- -------- -------
C:\Program Files (x86)\Mozilla Firefox\firefox.exe x86 False
9
9
9
2015-10-07 15:32:36 +0000

32 ビットとマークされた実行ファイルであっても、例えば、32 ビットまたは 64 ビットとして実行できる .NET 実行ファイルであれば、64 ビットとして実行することができます。詳細については、 https://stackoverflow.com/questions/3782191/how-do-i-determine-if-a-net-application-is-32-or-64-bit を参照してください。これには、CORFLAGS ユーティリティを使用して .NET アプリケーションの実行方法を決定することができるという回答があります。 EXE 出力**

32 ビット実行ファイルの場合:

Version : v2.0.50727
CLR Header: 2.5
PE : PE32
CorFlags : 0x3
ILONLY : 1
32BITREQ : 1
32BITPREF : 0
Signed : 0

64 ビット実行ファイルの場合:

Version : v2.0.50727
CLR Header: 2.5
PE : PE32+
CorFlags : 0x1
ILONLY : 1
32BITREQ : 0
32BITPREF : 0
Signed : 0

32 ビットまたは 64 ビットとして実行でき、可能な場合は 64 ビットとして実行される実行ファイルの場合:

Version : v2.0.50727
CLR Header: 2.5
PE : PE32
CorFlags : 0x1
ILONLY : 1
32BITREQ : 0
32BITPREF : 0
Signed : 0

32 ビットまたは 64 ビットとして実行でき、64 ビット プロセスにロードされない限り 32 ビットとして実行される実行ファイルの場合:

Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 0x20003
ILONLY : 1
32BITREQ : 0
32BITPREF : 1
Signed : 0
6
6
6
2016-06-14 00:19:11 +0000

私の2セントは、 dependency walker をダウンロードして、実行ファイルの中で何のアーキテクチャが使われているかを確認することです。

使い方:

アプリをダウンロードして起動し、アイコンをクリックして開く → *.exeファイルを探す → 選択して、反射スキャンをした後、下の方に、1つの列に “アーキテクチャ "の詳細が入っているデータが表示されます。 exeファイルを探す→選択すると、反射スキャン後の下の方に、アーキテクチャの詳細(x86, x64)が書かれたグリッドが表示されます。

5
5
5
2015-05-06 08:51:55 +0000

Windows 7 の場合は、Windows エクスプローラで実行ファイルを右クリックし、プロパティを選択します。プロパティウィンドウで互換性タブを選択します。互換性モードのセクションでWindows XPが表示されている場合、これは32ビットの実行ファイルです。Windows Vistaの場合は64ビットです。

5
5
5
2015-01-05 13:54:17 +0000

また、 mingw の msys バンドル の中から file ツールを使うこともできます。これは unix コマンドと同じように動作します。GNUwin32](http://gnuwin32.sourceforge.net/packages/file.htm)の`file`ツールも同様に動作します。

5
5
5
2016-01-16 11:20:03 +0000

32/64ビットテストをコンテキストメニューに追加する方法

exetest.regという名前のテキストファイルを作成して、このコードを含むものを作成します:

Windows Registry Editor Version 5.00

; What will appear in the contextual menu when right-clicking on a .exe file
[HKEY_CLASSES_ROOT\exefile\shell\command32_64]
@="32/64 bit test"

; What to do with it
; here, %1 is the file given as argument of the script
[HKEY_CLASSES_ROOT\exefile\shell\command32_64\command]
@="\"c:\temp\x86TestStart.bat\" \"%1\""
c:\temp\x86or64.vbs %1

x86TestStart.batという名前のテキストファイルを作成して、このコードを含むものを作成して、C:\temp に保存します。 reg**という名前のテキストファイルを作成し、このコードを含んでいます:

rem Reading binary file in VBScript: http://stackoverflow.com/questions/21249440/modify-first-two-bytes-of-a-file-using-vbscript
rem Info on executables: https://dmoj.ca/problem/exe

rem x86/64 signature is located dinamycally; its position is addressed
rem from bytes in 0x3C-0x3D position.

rem Possible signatures;
rem "PE..L" (hex code: 50.45.00.00.4C) = 32 bit
rem "PE..d†" (hex code: 50.45.00.00.64.86) = 64 bit

' ------------------------------------
' Source code by Jumpkack 2015
' ------------------------------------

' Read all arguments from command line:
Set args = Wscript.Arguments

' Store first argument (full path to file)
FileName = args(0)

' Find address of executable signature:
FirstChars = readBinary(FileName)
FirstChars = FirstChars
Addr1 = asc(mid(FirstChars,61,1))
Addr2 = asc(mid(FirstChars,62,1))
AddrFinal = Addr2*256 + Addr1 + 1

' Check signature:
if ucase(hex(asc(mid(FirstChars,AddrFinal+4,2)))) = "4C" then Wscript.Echo Filename & " is a 32 bit executable."
if ucase(hex(asc(mid(FirstChars,AddrFinal+4,2)))) = "64" then Wscript.Echo Filename & " is a 64 bit executable."

Function readBinary(path)
    Dim a, fso, file, i, ts
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.getFile(path)
    If isNull(file) Then
        wscript.echo "File not found: " & path
        Exit Function
    End If
    Set ts = file.OpenAsTextStream()
    'a = makeArray(file.size)
    a=""
    i = 0
    While (Not ts.atEndOfStream) and (i<60000)
       'a(i) = ts.read(1)
       a = a + ts.read(1)
       i = i + 1
    Wend
    ts.close
    readBinary = a
 End Function

x86or64.vbsという名前のテキストファイルを作成し、コードのちょうどこの行を含み、C:\temp:

[HKEY_CLASSES_ROOT\exefile\shell\command32_64\command]

`c:\temp\x86TestStart.bat# 32/64ビットテストをコンテキストメニューに追加する方法

exetest.regという名前のテキストファイルを作成して、このコードを含むものを作成します:

Windows Registry Editor Version 5.00

; What will appear in the contextual menu when right-clicking on a .exe file
[HKEY_CLASSES_ROOT\exefile\shell\command32_64]
@="32/64 bit test"

; What to do with it
; here, %1 is the file given as argument of the script
[HKEY_CLASSES_ROOT\exefile\shell\command32_64\command]
@="\"c:\temp\x86TestStart.bat\" \"%1\""
c:\temp\x86or64.vbs %1

x86TestStart.batという名前のテキストファイルを作成して、このコードを含むものを作成して、C:\temp に保存します。 reg**という名前のテキストファイルを作成し、このコードを含んでいます:

rem Reading binary file in VBScript: http://stackoverflow.com/questions/21249440/modify-first-two-bytes-of-a-file-using-vbscript
rem Info on executables: https://dmoj.ca/problem/exe

rem x86/64 signature is located dinamycally; its position is addressed
rem from bytes in 0x3C-0x3D position.

rem Possible signatures;
rem "PE..L" (hex code: 50.45.00.00.4C) = 32 bit
rem "PE..d†" (hex code: 50.45.00.00.64.86) = 64 bit

' ------------------------------------
' Source code by Jumpkack 2015
' ------------------------------------

' Read all arguments from command line:
Set args = Wscript.Arguments

' Store first argument (full path to file)
FileName = args(0)

' Find address of executable signature:
FirstChars = readBinary(FileName)
FirstChars = FirstChars
Addr1 = asc(mid(FirstChars,61,1))
Addr2 = asc(mid(FirstChars,62,1))
AddrFinal = Addr2*256 + Addr1 + 1

' Check signature:
if ucase(hex(asc(mid(FirstChars,AddrFinal+4,2)))) = "4C" then Wscript.Echo Filename & " is a 32 bit executable."
if ucase(hex(asc(mid(FirstChars,AddrFinal+4,2)))) = "64" then Wscript.Echo Filename & " is a 64 bit executable."

Function readBinary(path)
    Dim a, fso, file, i, ts
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.getFile(path)
    If isNull(file) Then
        wscript.echo "File not found: " & path
        Exit Function
    End If
    Set ts = file.OpenAsTextStream()
    'a = makeArray(file.size)
    a=""
    i = 0
    While (Not ts.atEndOfStream) and (i<60000)
       'a(i) = ts.read(1)
       a = a + ts.read(1)
       i = i + 1
    Wend
    ts.close
    readBinary = a
 End Function

x86or64.vbsという名前のテキストファイルを作成し、コードのちょうどこの行を含み、C:\temp:

[HKEY_CLASSES_ROOT\exefile\shell\command32_64\command]

という名前のテキストファイルを作成し、このコードを含み、C:\temp:

&001

ダブルクリックして下さい exetest.regファイル: 新しいキーは窓のレジストリに加えられます: &001

&001

ダブルクリックして下さい。 reg ファイル: 新しいキーは窓のレジストリで加えられます:

&001

それは実行可能ファイルの右クリックにコンテキストメニューの「32/64 ビットテスト」として現われます。

この項目をクリックすると、バッチファイル x86or64.vbs が起動し、VBscript ファイル &007 が起動し、exe の署名を読み込んで結果を表示します。

2
2
2
2017-10-10 00:41:35 +0000

しかし、 WSL file コマンドは大きく動作します。

2
2
2
2017-02-01 22:27:17 +0000

言及されているのを見たことがありません。CFF Explorer by NTCore というPEビューアプログラムがありますが、これで情報を得ることができます。これは、ポータブルでダウンロードして実行することもできますが、必要に応じてインストールすることもできます。Nt Headers -> File Header -> “Features "欄の "Click here "をクリックします。例えば、下の画像のように32bit版のメモ帳++をインストールしています。それ以外の場合は64bitです。

1
1
1
2017-09-28 07:37:39 +0000

私の2つのセント: C++開発者として、依存性ウォーカー http://www.dependencywalker.com/ ) は非常に有益で、64/32ビットを表示するだけでなく、関係するすべてのDllを表示します:

すべてのファイル名の左側に64が表示されます…

0
0
0
2019-08-02 22:55:25 +0000

windows 10のタスクマネージャーのプラットフォーム欄

Windows 7にはプラットフォーム欄がありません。Windows 7のタスクマネージャーにはプラットフォームの列がないので、Windows 7のタスクマネージャーには表示されません。Windows 10では、[詳細]タブで、右クリックして列のヘッダーをクリックし、[列を選択]します。そして、「プラットフォーム」にチェックを入れます。

0
0
0
2015-03-19 11:39:51 +0000
  • アプリケーションを実行する
  • タスクマネージャを開く
  • 右クリックしてダンプファイルを作成する
  • パスをメモする
  • パスに移動し、Visual Studioで.DMPダンプを開く
  • そこにすべての詳細を取得する
  • プロセスアーキテクチャを確認します。
Advertisement

関連する質問

3
19
10
28
6
Advertisement