mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-28 15:57:02 -05:00
patterns: Added Nintendo Switch NRO format pattern (#22)
* add intel_hex format (#15) * pattern: Added Nintendo Switch NACP file format pattern (#21) * patterns: Added Nintendo Switch NRO format pattern Co-authored-by: Matt Farstad <matthewwilliamfarstad@gmail.com>
This commit is contained in:
@@ -20,6 +20,7 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed
|
||||
| AFE2 | | `patterns/afe2.hexpat` | Nintendo Switch Atmosphère CFW Fatal Error log |
|
||||
| AR | `application/x-archive` | `patterns/ar.hexpat` | Static library archive files |
|
||||
| NACP | | `patterns/nacp.hexpat` | Nintendo Switch NACP files |
|
||||
| NRO | | `patterns/nro.hexpat` | Nintendo Switch NRO files |
|
||||
| Java Class | `application/x-java-applet` | `patterns/java_class.hexpat` | Java Class files |
|
||||
|
||||
### Pattern Libraries
|
||||
|
||||
70
patterns/nro.hexpat
Normal file
70
patterns/nro.hexpat
Normal file
@@ -0,0 +1,70 @@
|
||||
struct MOD0 {
|
||||
char magic[4];
|
||||
u32 dynamic_offset [[name(".dynamic offset")]];
|
||||
u32 bss_start_offset [[name(".bss start offset")]];
|
||||
u32 bss_end_offset [[name(".bss end offset")]];
|
||||
u32 eh_frane_hdr_start_offset [[name(".eh_frame_hdr start offset")]];
|
||||
u32 eh_frane_hdr_end_offset [[name(".eh_frame_hdr end offset")]];
|
||||
u32 runtime_generated_module_object_offset;
|
||||
};
|
||||
|
||||
struct Start {
|
||||
padding[4];
|
||||
MOD0 *mod0 : u32;
|
||||
char hb_magic[8];
|
||||
};
|
||||
|
||||
struct SegmentHeader {
|
||||
u32 offset;
|
||||
u32 size;
|
||||
};
|
||||
|
||||
struct Header {
|
||||
char magic[4];
|
||||
u32 version;
|
||||
u32 file_size;
|
||||
u32 flags;
|
||||
SegmentHeader segment_header_1[3];
|
||||
u32 bss_size;
|
||||
padding[4];
|
||||
u8 module_id[0x20];
|
||||
u32 dso_handle_offset;
|
||||
padding[4];
|
||||
SegmentHeader segment_header_2[3];
|
||||
};
|
||||
|
||||
struct AssetSection {
|
||||
u8 *asset_offset : u64 [[pointer_base("asset_ptr")]];
|
||||
u64 size;
|
||||
};
|
||||
|
||||
struct AssetHeader {
|
||||
if (is_homebrew()) {
|
||||
char magic[4];
|
||||
u32 version;
|
||||
AssetSection icon;
|
||||
AssetSection nacp;
|
||||
AssetSection romfs;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
fn asset_ptr(u128 offset) {
|
||||
return header.file_size;
|
||||
};
|
||||
|
||||
fn is_homebrew() {
|
||||
return start.hb_magic == "HOMEBREW";
|
||||
};
|
||||
|
||||
|
||||
Start start @ 0x00;
|
||||
Header header @ $;
|
||||
std::assert(header.magic == "NRO0", "Invalid NRO File!");
|
||||
|
||||
AssetHeader assets @ header.file_size;
|
||||
|
||||
fn main() {
|
||||
if (is_homebrew())
|
||||
std::print("This is a Homebrew NRO!");
|
||||
};
|
||||
Reference in New Issue
Block a user