2012-06-05 131 views
0

我已經搜索,以查找是否有人問及我有沒有看到它。有問題詢問操作系統是64位還是32位。這不是我問的問題。如何判斷應用程序是64位還是32位?

在Windows 64位操作系統上,如何判斷應用程序(程序)是64位還是32位?代碼本身不會說,安裝也不會說。

我有一個64位的機器,但我知道我有一個32位加載並運行的其他程序。所以我的操作系統並不排除我有32位程序。

那麼,我該如何判斷?

+0

的可能的複製 - http://superuser.com/a/103073/137173 –

+0

你想以編程方式檢索此信息來源?如果您的答案是「是」,那麼您要使用哪種語言?如果你回答是否,那麼這個問題不適合在這個網站。 – RRUZ

+0

對於將來的答案搜索者,此Windows資源管理器擴展允許您在不使用外部工具的情況下查看文件管理器內的32/64位體系結構信息:http://sanje2v.wordpress.com/2013/12/10/writing-property-handler - 用於窗口-explorermanta屬性擴展/ – Sanjeev

回答

1

您可以使用工具(如PE Viewer)查看有關EXE文件的信息。

我個人使用Altap Salamander的查看器功能來查看EXE或DLL架構。

enter image description here

它是Intel x86用於32位EXE和AMD64爲64位。

0

您需要分析PE標題。

它是任何Windows可執行文件的標頭。要做到這一點,讀取*.exe作爲二進制,取一個字節,在偏移0x3C0x3DWORD作出這些是開始偏移PE

你有偏差之後,驗證,如果你是對的,的PE開始是PE\0\0PE和兩個NULL符號),就跳過這個指示塊讀取下兩個字節,使另一WORD。它指示目標機器,如果你想檢查64-bit這將是其中之一:

0x8664 - x64 
0xaa64 - ARMv8 in 64-bit mode 
0x0200 - Intel Itanium processor family 

注意你讀兩個字節後,使WORD您可能需要翻轉它們。

而且看看this question with answers

而且還download PE header documentation from Microsoft

0

我敲了在C#控制檯應用程序實用程序來檢查。這是基本的,但可以擴展。

它將信息文本返回到控制檯,但也使用退出代碼來指示類型,以防萬一您希望在批處理文件中使用它。

見下

乾杯

•羅伊

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.IO; 

namespace ExeType 
{ 
    class Program 
    { 
     const int st_error = 99; 
     const int st_unknown = 98; 
     const int st_unidentified = 97; 
     const int st_not_PE_image = 96; 
     const int st_Exec_x86 = 1; 
     const int st_Exec_x64 = 2; 

     const int st_offset = 0x3c; 

     const int st_P = 0x50; 
     const int st_E = 0x45; 

     const int st_ind_x86_1 = 0x4c; 
     const int st_ind_x86_2 = 0x1; 

     const int st_ind_x64_1 = 0x64; 
     const int st_ind_x64_2 = 0x86; 

     static void Main(string[] args) 
     { 
      if (args.Length != 1) 
      { 
       Console.WriteLine("Please specify a file"); 
       Environment.Exit(st_error); 
      } 

      BinaryReader br = new BinaryReader(File.OpenRead(args[0])); 

      byte[] block = br.ReadBytes(0x1000); 

      br.Close(); 

      if (block.Length < st_offset+1) 
      { 
       Console.WriteLine("Unknown"); 
       Environment.Exit(st_unknown); 
      } 

      int offset = (block[st_offset+1] << 8) + block[st_offset]; 

      if (block.Length < offset) 
      { 
       Console.WriteLine("Unknown"); 
       Environment.Exit(st_unknown); 
      } 

      int indicator1 = block[offset]; 
      int indicator2 = block[offset+1]; 

      if (indicator1 != st_P || indicator2 != st_E) 
      { 
       Console.WriteLine("Not a PE format image file"); 
       Environment.Exit(st_not_PE_image); 
      } 

      offset += 4; 
      indicator1 = block[offset]; 
      indicator2 = block[offset + 1]; 

      int retval = st_unidentified; 

      switch (indicator1) 
      { 
       case st_ind_x86_1: 
        if (indicator2 == st_ind_x86_2) 
        { 
         Console.WriteLine("32 bit"); 
         retval = st_Exec_x86; 
        } 
        break; 
       case st_ind_x64_1: 
        if (indicator2 == st_ind_x64_2) 
        { 
         Console.WriteLine("64 bit"); 
         retval = st_Exec_x64; 
        } 
        break; 
       default: 
        Console.WriteLine("Unidentified"); 
        break; 
      } 

      Environment.Exit(retval); 
     } 
    } 
} 
相關問題