保持.exe时间戳不变 [英] Keep .exe timestamp from changing

查看:194
本文介绍了保持.exe时间戳不变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道一种方法来防止可执行文件的时间戳发生变化?我试图为.exe生成一致的哈希码,但我认为时间戳可能会阻止这种情况发生。每次重新编译代码(VS C ++)时,FastSum生成不同的校验和。

Does anybody know of a way to prevent the timestamp of an executable from changing? I'm trying to generate a consistent hash code for the .exe but I think the timestamp may be preventing that from happening. Each time I recompile the code (VS C++) the FastSum generates a different checksum.

谢谢!

推荐答案

根据你有什么校验和,你可以剥离COFF标题(时间戳存在的地方)或可选标题。在后一种情况下,您只需保存节表和节数据(可执行文件的二进制内容)。如果确保您的源代码未更改,并且编译和链接标志未更改,则段数据应保持不变。如果要在校验和中包含版本号或代码大小,则必须包含可选标题。

Depending on what you have to checksum, you can either strip off the COFF header (where the timestamp resides) or the Optional Header. In the latter case, you just only save the section table and section data (the binary content of the executable). If you make sure your source code is not changed and compile and link flags are not changed, the section data should remain the same. If you want to include version numbers or size of code in the checksum, you must include the Optional Header.

要查找可选标题的开始,请按照以下步骤操作: / p>

To find the start of Optional Header, follow the procedure:


  1. 从0x3c读取4字节的签名基址。

  2. 转到签名偏移。 >
  3. 偏移20个字节。这是可选标头的开始。

  4. 如果是32位exe文件,则应该为0x10b,如果是64位,则应该为0x20b。



    要查找节表的开头,请按照以下步骤操作:

To find the start of section table, follow the procedure:



  1. 转到签名偏移。

  2. 偏移16个字节。

  3. 2字节

  4. 转到可选标题

  5. 偏移可选标题大小字节。

  6. 这里应该是一个段落名称(例如.text,.data等)。

  1. Read 4-byte signature base address from 0x3c.
  2. Goto the signature offset.
  3. offset 16 bytes.
  4. Read 2-byte Optional Header size here.
  5. Goto the Optional Header.
  6. Offset Optional Header size bytes. This is the start of the section table.
  7. You should expect a section name here (like ".text", ".data", etc).

有关PE& COFF格式,请下载: Microsoft PE和COFF规格

For complete specification of PE & COFF format, download this: Microsoft PE and COFF Specification.

这篇关于保持.exe时间戳不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆