每次重新编译后exe校验和都不同

发布于 2024-11-03 05:07:59 字数 227 浏览 4 评论 0原文

所以我试图弄清楚如何让我的 exe 在重新编译时具有相同的哈希代码/校验和。我正在使用 FastSum 生成校验和。目前,没有进行任何代码更改,我只是在 VS 中重建项目,并且校验和结果有所不同。代码是用c++编写的。

我不熟悉以这种方式使用哈希码和/或校验和,但我做了一些研究并阅读了一些关于需要一致的 GUID 的内容。但我不知道这将如何与校验和生成程序联系起来......

好吧,我就这样吧,提前致谢。

So I'm trying to figure out how to get my exe to have the same hash code/checksum when it's recompiled. I'm using FastSum to generate the checksum. Currently, no code changes are made, I'm just rebuilding the project in VS and the checksum comes out different. The code is written in c++.

I'm not familiar with using hash codes and/or checksums in this manner, but I did some research and read something about needing a consistent GUID. But I have no idea how that would tie into the checksum generation program...

Well, I'll leave it at that, thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

羁绊已千年 2024-11-10 05:07:59

你检查过前任之间的差异吗?我怀疑编译器/链接器正在将日期或时间插入二进制文件中,因此每个二进制文件将彼此不同。或者情况可能更糟,有时编译器/链接器在自己的系统内存中构建静态表,然后将其复制到二进制文件中,假设您有 9 个字节的内容,出于对齐原因,编译器选择在二进制文件中使用 12 个字节,我见过编译器/链接器获取该计算机系统内存中的 3 个字节并将其复制到文件中。理想情况下,您希望工具将用于此类操作的内存清零,以便获得可重复的结果。

基本上在文件之间进行二进制比较,然后您应该找出它们不匹配的原因。

Have you examined the differences between the exes? I suspect the compiler/linker is inserting the date or time into the binary and as a result each binary will be different from another. Or it could be worse, sometimes compilers/linkers build static tables in their own system memory then copy that into the binary, say you have 9 bytes of something and for alignment reasons the compiler chooses to use 12 bytes in the binary, I have seen compilers/linkers take whatever 3 bytes are in system memory of that computer and copy that into the file. Ideally you would want the tools to zero out memory they are using for such a thing so you get repeatable results.

Basically do a binary diff between the files you should then find out why they dont match.

小瓶盖 2024-11-10 05:07:59

据我所知,EXE 格式包含一个构建时间戳,因此 exe 的哈希值(包括该时间戳)在每次重新编译时都会发生变化。

From what I recall, the EXE format includes a build timestamp so a hash of the exe, including that timestamp, would change on each recompile.

独享拥抱 2024-11-10 05:07:59

这是托管二进制文件吗?托管二进制文件有一个 GUID 部分,该部分在每次构建时都会发生变化,您无法阻止这种情况发生。

您可以通过运行“link /dump /all [文件名]”或“link /dump /disasm [文件名]”来更好地查看二进制文件中的更改。 /all 选项将向您显示所有十六进制值以及它们的 ascii 等效值,而 /disasm 选项将反汇编代码并以汇编形式向您显示,这可以更容易阅读,但可能会忽略一些可能存在的细微差异导致哈希值改变。

Is this a managed binary? Managed binaries have a GUID section that changes from build to build and there's not much you can do to stop that.

You can get a better look at the changes in your binary by running "link /dump /all [filename]" or "link /dump /disasm [filename]". The /all option will show you all the hex values as well as their ascii equivalent, while the /disasm option will disassemble the code and show it to you in assembly, which can be easier to read but might ignore some trivial differences which might have caused the hash to change.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文