patterns: Added support for GNU MO files (#383)

This commit is contained in:
David Schneider
2025-05-10 13:49:02 +02:00
committed by GitHub
parent bcaeef31d7
commit 7ad9cd4f41
3 changed files with 38 additions and 0 deletions

View File

@@ -105,6 +105,7 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
| MBR & GPT | | [`patterns/partition_table.hexpat`](patterns/partition_table.hexpat) | Partition tables with primary focus on GPT |
| MIDI | `audio/midi` | [`patterns/midi.hexpat`](patterns/midi.hexpat) | MIDI header, event fields provided |
| MiniDump | `application/x-dmp` | [`patterns/minidump.hexpat`](patterns/minidump.hexpat) | Windows MiniDump files |
| MO | | [`patterns/mo.hexpat`](patterns/mo.hexpat) | GNU Machine Object (MO) files containing translations for gettext |
| mp4 | `video/mp4` | [`patterns/mp4.hexpat`](patterns/mp4.hexpat) | MPEG-4 Part 14 digital multimedia container format |
| msgpack | `application/x-msgpack` | [`patterns/msgpack.hexpat`](patterns/msgpack.hexpat) | MessagePack binary serialization format |
| MSSCMP | | [`patterns/msscmp.hexpat`](patterns/msscmp.hexpat) | Miles Sound System Compressed Archive |

37
patterns/mo.hexpat Normal file
View File

@@ -0,0 +1,37 @@
#pragma author dvob
#pragma description GNU Machine Object (MO) files containing translations for gettext
// https://www.gnu.org/software/gettext/manual/html_node/MO-Files.html
import std.core;
import std.io;
struct strPtr {
u32 length;
u32 offset;
char string[length] @ offset;
};
struct file {
be u32 magic;
if ( magic == 0x950412de )
std::core::set_endian(std::mem::Endian::Big);
else if ( magic == 0xde120495)
std::core::set_endian(std::mem::Endian::Little);
else
std::error("Invalid MO Magic!");
u16 majorVersion;
u16 minorVersion;
u32 count;
u32 msgIdOffset;
u32 msgStrOffset;
u32 hashSize;
u32 hashOffset;
u32 hashTable[hashSize] @ hashOffset;
strPtr msgIDTable[count] @ msgIdOffset;
strPtr msgStrTable[count] @ msgStrOffset;
};
file moFile @ 0x0;

Binary file not shown.