Created
December 19, 2025 12:44
-
-
Save vanasoft23/fd63db2c628a30caabe8b914dfac973e to your computer and use it in GitHub Desktop.
ImHex AIS decoder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import std.mem; | |
| import std.core; | |
| import std.io; | |
| #include <type/magic.pat> | |
| struct Cmd_SectionLoad { | |
| const str NAME = "Section Load"; | |
| type::Magic<"\x01YSX"> opcode; | |
| u32 addr; | |
| u32 size; | |
| u8 data[size]; | |
| padding[(4-(size%4)) % 4]; | |
| }; | |
| struct Cmd_JumpAndClose { | |
| const str NAME = "Jump And Close"; | |
| type::Magic<"\x06YSX"> opcode; | |
| u32 addr; // entry point of ARM application | |
| }; | |
| struct Cmd_FunctionExecute { | |
| const str NAME = "Function Execute"; | |
| type::Magic<"\x0DYSX"> opcode; | |
| u16 func_idx; | |
| u16 arg_count; | |
| u32 args[arg_count]; | |
| }; | |
| struct Cmd_SequentialReadEnable { | |
| const str NAME = "Sequential Read Enable"; | |
| type::Magic<"\x63YSX"> opcode; | |
| }; | |
| struct Command { | |
| char opcode[4] [[no_unique_address, hidden]]; | |
| match (opcode[0]) { | |
| (0x01): Cmd_SectionLoad cmd [[inline]]; | |
| (0x06): Cmd_JumpAndClose cmd [[inline]]; | |
| (0x0D): Cmd_FunctionExecute cmd [[inline]]; | |
| (0x63): Cmd_SequentialReadEnable cmd [[inline]]; | |
| (_): continue; | |
| } | |
| std::core::set_display_name(this, cmd.NAME); | |
| if (opcode == "\x06YSX") // Jump and Close | |
| break; | |
| }; | |
| #define MAX_COMMANDS 500 | |
| struct AIS { | |
| type::Magic<"TIPA"> magic; | |
| Command commands[MAX_COMMANDS] [[inline]]; | |
| }; | |
| AIS script @ 0x00; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment