Skip to content

Commit 7ad9cd4

Browse files
authored
patterns: Added support for GNU MO files (#383)
1 parent bcaeef3 commit 7ad9cd4

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

README.md

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

patterns/mo.hexpat

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#pragma author dvob
2+
#pragma description GNU Machine Object (MO) files containing translations for gettext
3+
4+
// https://www.gnu.org/software/gettext/manual/html_node/MO-Files.html
5+
6+
import std.core;
7+
import std.io;
8+
9+
struct strPtr {
10+
u32 length;
11+
u32 offset;
12+
char string[length] @ offset;
13+
};
14+
15+
struct file {
16+
be u32 magic;
17+
if ( magic == 0x950412de )
18+
std::core::set_endian(std::mem::Endian::Big);
19+
else if ( magic == 0xde120495)
20+
std::core::set_endian(std::mem::Endian::Little);
21+
else
22+
std::error("Invalid MO Magic!");
23+
24+
u16 majorVersion;
25+
u16 minorVersion;
26+
u32 count;
27+
u32 msgIdOffset;
28+
u32 msgStrOffset;
29+
u32 hashSize;
30+
u32 hashOffset;
31+
32+
u32 hashTable[hashSize] @ hashOffset;
33+
strPtr msgIDTable[count] @ msgIdOffset;
34+
strPtr msgStrTable[count] @ msgStrOffset;
35+
};
36+
37+
file moFile @ 0x0;

tests/patterns/test_data/mo.hexpat.mo

182 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)