二进制数据库对齐或打包

发布于 2024-07-06 16:45:49 字数 59 浏览 3 评论 0原文

有没有办法通过十六进制编辑器或其他方式查看二进制文件中的数据是否对齐或打包,特别是对于 HPUX 系统?

Is there a way to see, via hex editor or otherwise, if data in a binary file is aligned or packed, specifically for an HPUX system?

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

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

发布评论

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

评论(1

庆幸我还是我 2024-07-13 16:45:49

如果您知道要查找的内容并且可以在十六进制转储中识别它,那么您可以对数据是否对齐或打包做出明智的估计。 但从很多方面来说,你的问题是无法回答的。 数据从哪里来? 为什么你不能询问那个人(大概是驱动程序的人)它是如何创建的?

如果您问“我可以使用什么工具来查看数据”,那么您可以考虑:

  • od(八进制转储 - 可能也带有 -c 选项)
  • hd(十六进制转储 - 并不总是可用,并且 HP 上似乎不存在-UX)
  • sed l(这是一个小写的 ell - 它意味着列出数据;除非大部分数据是纯文本,否则这不是一个好的选择)

或者您可以在 Perl 中执行此操作。 很久以前(1987 年左右),我编写了一个程序 odx(十六进制八进制转储 - 奇怪),我继续使用它 - 它给了我一个十六进制转储,每行 16 个字节,加上可打印字符的图像。 这个例子不是很令人兴奋(odx 自行运行 - 在 Sun Sparc 上):

Black JL: odx odx | sed 10q
0x0000: 7F 45 4C 46 01 02 01 00 00 00 00 00 00 00 00 00   .ELF............
0x0010: 00 02 00 12 00 00 00 01 00 01 0D 84 00 00 00 34   ...............4
0x0020: 00 00 77 9C 00 00 01 00 00 34 00 20 00 05 00 28   ..w......4. ...(
0x0030: 00 24 00 23 00 00 00 06 00 00 00 34 00 01 00 34   .$.#.......4...4
0x0040: 00 00 00 00 00 00 00 A0 00 00 00 A0 00 00 00 05   ................
0x0050: 00 00 00 00 00 00 00 03 00 00 00 D4 00 00 00 00   ................
0x0060: 00 00 00 00 00 00 00 11 00 00 00 00 00 00 00 04   ................
0x0070: 00 00 00 00 00 00 00 01 00 00 00 00 00 01 00 00   ................
0x0080: 00 00 00 00 00 00 22 86 00 00 22 86 00 00 00 05   ......"...".....
0x0090: 00 01 00 00 00 00 00 01 00 00 22 88 00 02 22 88   .........."...".
Black JL:

If you know what you are looking for and can recognize it in a hex dump, then you can make informed estimates about whether the data is aligned or not, or packed. But in many ways, your question is unanswerable. Where did the data come from? Why can't you ask the person (driving a program, presumably) how it was created?

If you are asking 'what tools could I use to view the data', then you can consider:

  • od (octal dump - probably with the -c option too)
  • hd (hex dump - not always available, and seems to be absent on HP-UX)
  • sed l (that's a lower-case ell - it means list the data; not a good option unless the majority of the data is plain text)

Or you could do it in Perl. Once upon a long time ago (1987 or so), I wrote a program odx (octal dump in hex - weird) that I continue to use - it gives me a hex dump, 16 bytes per line, plus an image of the printable characters. This example isn't very exciting (odx run on itself - on a Sun Sparc):

Black JL: odx odx | sed 10q
0x0000: 7F 45 4C 46 01 02 01 00 00 00 00 00 00 00 00 00   .ELF............
0x0010: 00 02 00 12 00 00 00 01 00 01 0D 84 00 00 00 34   ...............4
0x0020: 00 00 77 9C 00 00 01 00 00 34 00 20 00 05 00 28   ..w......4. ...(
0x0030: 00 24 00 23 00 00 00 06 00 00 00 34 00 01 00 34   .$.#.......4...4
0x0040: 00 00 00 00 00 00 00 A0 00 00 00 A0 00 00 00 05   ................
0x0050: 00 00 00 00 00 00 00 03 00 00 00 D4 00 00 00 00   ................
0x0060: 00 00 00 00 00 00 00 11 00 00 00 00 00 00 00 04   ................
0x0070: 00 00 00 00 00 00 00 01 00 00 00 00 00 01 00 00   ................
0x0080: 00 00 00 00 00 00 22 86 00 00 22 86 00 00 00 05   ......"...".....
0x0090: 00 01 00 00 00 00 00 01 00 00 22 88 00 02 22 88   .........."...".
Black JL:
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文