C++使用文件格式
几天前,我问如何对文件格式进行逆向工程。虽然这并没有真正解决问题,但有人给了我文件格式。 (单击此处)谢谢 Xadet。
我对这一切还很陌生,我想知道我应该从这里去哪里。我猜我必须在 C++ 中使用 inline-asm 才能使用这种格式,但我不知道如何使用它实际打开文件,或将数据插入其中。
那么问题是,如何使用文件格式来获取或插入数据?而且文件格式看起来像asm,但我不想以纯ASM开始编程。我以前见过人们用 C++ 编程 asm,这就是为什么我认为这将是一个不错的选择
任何帮助将不胜感激。
A couple of days ago, I asked how you could reverse engineer a file format. While that didn't really work out, someone gave me the file format. (Click Here) Thank you Xadet.
I'm still quite new to all this, and I was wondering where I should go from here. I am guessing I will have to use inline-asm in C++ to use this format, but I wouldn't know how to actually open the file using this, or insert data into it.
So the question would be, how do I use the file format to get or insert data? And the file format looks like asm, but I don't want to start programming in pure ASM. I've seen people programming asm in C++ before, that's why I think it would be a good choice
Any help would be greatly apreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
文件格式描述看起来不像asm,它看起来像伪代码。
The file format description doesn't look like asm, it looks like pseudocode.
我假设您不希望 C++ 程序在启动时读取该文件格式文档,然后在此基础上解析实际的数据文件。相反,您只想要一个专门用于读取该文件格式的当前版本的 C++ 程序? (这更简单并且运行速度更快)。您不需要使用 ASM。您需要做的是计算出与格式文件中使用的名称等效的 C++ 类型。例如,我认为 Microsoft 语言中使用 DWORD 来指代特定大小的整数 - 可能是 32 或 64 位。跟踪这些内容,然后创建具有等效成员的 C++ 结构。
例如:
HTH、
托尼
I assume you don't want to have a C++ program that reads that file format document when it starts, then parses the actual data file on that basis. Instead, you just want a C++ program dedicated to reading the current version of that file format? (This is much simpler and will run faster). You don't need to use ASM. What you do need to do is work out the C++ types that are equivalent to the names used in the format file. For example, I think DWORD is used in Microsoft languages to refer to an integer of a specific size - maybe 32 or 64 bits. Track that stuff down, then create C++ structs with equivalent members.
For example:
HTH,
Tony
它是一种用于定义数据格式的脚本语言,类似于 XDR。
您只需为其编写一个解析器(不要尝试在运行时使用该脚本)。编写一些函数,例如
get_WORD_BE()
或get_DWORD_LE()
等,这样您就不会依赖于字节序。是的,如果您想使用 Tony 的方法,请添加一些
#pragma pack(1)
。It's a kind of scripting language for defining data format, something similar to XDR.
You just have to write a parser for it (don't try to use the script in the runtime). Write some functions like
get_WORD_BE()
orget_DWORD_LE()
, etc so that you don't depend on endiannes.Yes, and if you want to use Tony's approach, add some
#pragma pack(1)
.