php - 检查 PE 是 32 位还是 64 位
问题描述
我试图弄清楚,如果上传的 EXE 或 DLL 文件是 32 位或 64 位文件。这专门针对基于 Windows 的 EXE/DLL 文件。有人有什么建议吗?
解决方案
当我使用 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")
推荐阅读
- python - Python - 从选择中插入 - 使用光标的 Fom Pandas
- javascript - React:如何将“存储”传递给连接的组件?
- arduino - 如何使中断仅在 ISR 中运行而不运行主代码
- c# - C# - API - 更新字段的问题 - PUT 方法 - 复杂的哈希
- swift - 在 Realm 数据中保存和使用数据,Swift
- reactjs - FlatList 渲染数组的顺序错误
- javascript - 为什么浏览器允许设置一些没有 CORS 的标头,但不允许设置其他标头?试图避免预检
- php - 如何在wordpress中解码奇怪的HTML实体,如'?
- r - R对列表中具有不同维度的矩阵求和并返回一个矩阵
- google-app-engine - 如果自动扩缩功能无法创建新实例,App Engine 请求会发生什么情况?