首页 > 解决方案 > 检查 PE 是 32 位还是 64 位

问题描述

我试图弄清楚,如果上传的 EXE 或 DLL 文件是 32 位或 64 位文件。这专门针对基于 Windows 的 EXE/DLL 文件。有人有什么建议吗?

标签: phpwindowsportable-executable

解决方案


当我使用 Python 时,我已经用 python 2.7 尝试过这个。如果我对 PE 文件格式不熟悉,请检查并确认解决方案是否有任何更改。用于此的 Python 代码是::

#Program to check PE file is 32 or 64 bit
import os
import win32file
import ctypes, hashlib

#Take File as input
resultPathFile = raw_input('Enter the path location of given file')
if os.path.isfile(resultPathFile) == True:
    print("File is present at this path"+"\n"+resultPathFile+"\n")
    #File check 32 or 64
    try:
        peFileCheck = win32file.GetBinaryType(resultPathFile)
        if peFileCheck == 6:
            print("The Given file is :"+"\t"+"64 bit x64")
        elif peFileCheck == 0:
            print("The Given file is :"+"\t"+"32 bit x86")
        else:
            print("other format file")
    except:
        print("Other file format")

else:
    print("File is absent at given Path")

推荐阅读