判断exe文件是否经过UPX压缩的方法
有没有办法确定exe文件是否已经用UPX压缩?
除了我发现代码有问题之外,确定 exe 文件是否已压缩的功能非常出色。如果调用函数 IsUPXcompressed 然后尝试运行 upx,upx 无法保存它修改的文件。该功能中存在无法正确共享权限的问题。我已经对此进行了几个小时的测试。如果我不调用该方法,那么 UPX 可以毫无问题地写入文件。你调用它然后尝试运行 UPX 它不会保存文件。尝试写入文件时,UPX 报告 IOException Permission returned 错误。
任何人都可以发现代码中可能导致此问题的错误吗?
谢谢
确定 exe 文件是否已压缩的功能非常好,只是我发现代码有问题。如果调用函数 IsUPXCompressed 然后尝试运行 upx,upx 无法保存它修改的文件。该功能中存在无法正确共享权限的问题。我已经对此进行了几个小时的测试。如果我不调用该方法,那么 UPX 可以毫无问题地写入文件。你调用它然后尝试运行 UPX 它不会保存文件。尝试写入文件时,UPX 报告 IOException Permission returned 错误。
任何人都可以发现代码中可能导致此问题的错误吗?
谢谢
Is there a method to determine if an exe file has been compressed with UPX?
The function to determine if an exe file has been compressed is excellent except I found a problem with the code. If the function IsUPXCompressed is called then you try to run upx, upx can not save the file it modifies. There is something not sharing rights correctly in the function. I have tested this for several hours. If I do not call the method then UPX can write the files with no problem. You you call it then try to run UPX it will not save the file. UPX reports an IOException Permission denied error when trying to write the file.
Can anyone spot something wrong in the code that would cause this problem?
Thank-you
The function to determine if an exe file has been compressed is excellent except I found a problem with the code. If the function IsUPXCompressed is called then you try to run upx, upx can not save the file it modifies. There is something not sharing rights correctly in the function. I have tested this for several hours. If I do not call the method then UPX can write the files with no problem. You you call it then try to run UPX it will not save the file. UPX reports an IOException Permission denied error when trying to write the file.
Can anyone spot something wrong in the code that would cause this problem?
Thank-you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
另一种方法,当使用 UPX 工具打包 exe 时,PE 标头的部分包含名为
UPX0
、UPX1
等的部分,因此如果读取这些部分并比较名称带有字符串UPX
,您可以确定该exe是否是使用UPX加壳程序压缩的。检查此功能
Another Method, when a exe is packed with the UPX tool, the section of the PE header contains sections called
UPX0
,UPX1
, etc. so if read these sections and compare the name with the stringUPX
you can determine if the exe was compressed using the UPX packer.check this function
UPX 本身是这样实现的:
这是 32 位 PE 的实现; 64位PE需要不同的偏移量,
和其他可执行格式必须单独处理。
UPX itself does it like this:
This is the implementation for 32-bit PEs; 64-bit PEs need different offsets,
and other executable formats have to be handled separately.
尝试用upx解压吗?
try to uncompress it with upx?
// 返回 IsUPXCompressed - 针对 Delphi 2010 进行修改
感谢 Rob 的指点。
// Returns IsUPXCompressed - Modified for Delphi 2010
Thanks Rob for the pointers.
部分名称并不总是包含 UPX 单词。它可能包含用户更改的另一个名称。可以肯定的是。 Ypu 必须在整个文件中搜索 UPX copmpressor 签名。
The section names are not included the UPX word always. It mabebe contain another name changed by user. For certain. Ypu must search for UPX copmpressor signature in the whole file.