用于编译/反编译二进制数据文件的通用实用程序或库? [英] General purpose utility or library for compiling/decompiling binary data files?

查看:314
本文介绍了用于编译/反编译二进制数据文件的通用实用程序或库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有各种二进制文件格式,我需要转储到某种文本格式,编辑然后重新编译(可能是二进制格式略有不同的版本)。当然,我可以在C / C ++中写一堆实用程序代码来做这种事情,也许可以利用一个库来处理事物(XML或JSON或其他)的文本端,但这是一个任务模式,在我的工作,似乎在我看来,可能已经存在某种通用工具这种工作。

I have various binary file formats which I need to dump to some kind of text format, edit and then recompile (possibly to a slightly different version of the binary format). Of course I could write a bunch of utility code in C/C++ to do this kind of thing, and maybe leverage a library for the text side of things (XML or JSON or whatever), but this is a task pattern that keeps cropping up in my work and it seems to me that there probably ought to exist already some kind of general purpose tool for this kind of job.

显然,需要一些方式描述二进制文件格式 - 一个模式或某些 - 这将需要支持所有明显的数据类型(字符串,各种大小,bools等的int,浮动也很好),以及类似计数字段,长度字段,填充/对齐等,以处理在数据文件中找到的所有典型的东西。因为二进制文件可能具有与我们运行的平台不同的字节序,所以它也是有用的。

Obviously there would need to be some way of describing the binary file formats - a schema or some such - this would need to support all the obvious data types (strings, ints of various sizes, bools, etc, floats would be nice too), and things like count fields, length fields, padding/alignment, etc, to handle all the typical stuff that you find in a data file. It would also be useful to have endianness support, as the binary file may have a different endianness than the platform we're running on.

我会很惊讶if像这样的东西已经不存在了,但是我没有运气到目前为止通过谷歌(你怎么甚至描述这样的实用程序或库简洁?)。在经典Mac OS的时代,我回忆起的是苹果的资源编译器/反编译器实用程序。这些语法使用类似C的语法,在头文件中使用资源模板定义来描述各种二进制资源的格式,并且可以在类似C语言的源语法和二进制资源之间编译/反编译。

I'd be very surprised if something like this doesn't exist already, but I have had no luck so far via Google (how do you even describe such a utility or library succinctly ?). The closest thing to this I ever remember seeing was Apple's resource compiler/decompiler utilities back in the days of "Classic" Mac OS. These used a C-like syntax, with resource template definitions in header files to describe the formats of the various binary resources, and you could compiled/decompile between this C-like source syntax and the binary resources.

推荐答案

BinX ,二进制XML描述语言以及相应的库似乎符合您的目的。

BinX, the Binary XML Description Language, plus the corresponding library, seem to fit your purpose.

也有兴趣的可能是第24章实用:解析二进制文件 Practical Common Lisp 书,其中演示了如何在 150行中编写用于解析(二进制)MP3文件中的ID3标签的库的Lisp代码。 *

Also of interest might be Chapter 24. Practical: Parsing Binary Files of the Practical Common Lisp book, which demonstrates how to write a library for parsing ID3 tags in (binary) MP3 files in 150 lines of Lisp code. *

*现在,我可能不会使用Lisp,而是使用更现代的功能语言,例如 Clojure 。请参阅在Clojure中读取二进制数据一个例子。

* nowadays, i probably wouldn't use Lisp, but a more modern functional language like Clojure. see Reading binary data in Clojure for an example.

PS 二进制数据库二进制数据文件库是Google的好关键字。

P.S. binary data library or binary data file library are good keywords for Google.

这篇关于用于编译/反编译二进制数据文件的通用实用程序或库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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