帮助我理解这种二进制文件格式

发布于 2024-10-08 14:08:03 字数 344 浏览 1 评论 0原文

我正在尝试编写一个小实用程序来生成一个二进制文件,该文件将模仿另一个关闭的应用程序生成的文件。我使用十六进制编辑器来解密格式,因为我一直试图理解格式/编码是什么,以便我可以使用 C++ 或 C# 生成它。

该文件以前四个字节开始:01 00,后跟 FF FE。我的理解是该文件以 SOH 开头,后跟小尾数的字节顺序标记。在这四个字节之后,程序似乎为应用程序 GUI 中的每个字符串字段写入 BSTR。

使用 C#,我生成了一个以 FF FE 开头的 unicode 文件,但我不确定如何首先插入 SOH 字符。

如果有人能够深入了解文件格式或编码以及文件为何以 SOH 字符开头,我将永远感激不已。

先感谢您。

I am attempting to write a small utility to produce a binary file that will mimic the one produced by another closed application. I've used hex editors to decrypt the format by I'm stuck trying to understand what the format/encoding is so that I can produce it using C++ or C#.

The file starts with the first four bytes: 01 00 followed by FF FE. My understanding is that the file begins with SOH followed by the byte order mark for little endian. After these four bytes, the program appears to write BSTR's for each of the string fields from the app's GUI.

Using C#, I have produced a unicode file that starts with FF FE, but I'm not sure how to insert the SOH character first.

I would be forever grateful if someone could offer insight to the file format or encoding and why the file starts with the SOH character.

Thank you in advance.

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

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

发布评论

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

评论(2

街角迷惘 2024-10-15 14:08:03

对二进制文件格式进行逆向工程可能是一项具有挑战性的任务。从表面上看,我不认为这是一种明显的、众所周知的文件格式......但是有成千上万的文件格式,所以谁知道。

除了法律问题之外,我建议您查看以下一些讨论的资源实现这一目标的方法:

Reverse engineering a binary file format can be a challenging task. On the surface, I don't recognize this as an obvious, well-known file format ... but there are thousands out there, so who knows.

Legal issues aside, I would suggest you look at some of the following resources that talk about approaches to such an endeavor:

杀手六號 2024-10-15 14:08:03

如果您在写出前四个字节时遇到困难,这将为您解决。

using (var stream = new FileStream("myfile.bin", FileMode.Create))
{
     using (var binaryWriter = new BinaryWriter(stream))
     {
         binaryWriter.Write((byte)1);
         binaryWriter.Write((byte)0);
         binaryWriter.Write((byte)0xFF);
         binaryWriter.Write((byte)0xFE);
         binaryWriter.Write(Encoding.Unicode.GetBytes("string"));
     }
}

这将输出以下文件

01 00 FF FE 73 00 74 00 72 00 69 00 6e 00 67 00  ....s.t.r.i.n.g.

编辑:添加了 Mark H 关于写出字符串的建议。

If you are just having trouble writing out the first four bytes this will do it for you.

using (var stream = new FileStream("myfile.bin", FileMode.Create))
{
     using (var binaryWriter = new BinaryWriter(stream))
     {
         binaryWriter.Write((byte)1);
         binaryWriter.Write((byte)0);
         binaryWriter.Write((byte)0xFF);
         binaryWriter.Write((byte)0xFE);
         binaryWriter.Write(Encoding.Unicode.GetBytes("string"));
     }
}

This will output the following file

01 00 FF FE 73 00 74 00 72 00 69 00 6e 00 67 00  ....s.t.r.i.n.g.

Edit: Added Mark H's suggestion for writing out a string.

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