diff --git a/README.md b/README.md index 2bcea97..cb6cfa1 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed | BMP | `image/bmp` | `patterns/bmp.hexpat` | OS2/Windows Bitmap files | | ELF | `application/x-executable`, `application/x-sharedlib` | `patterns/elf.hexpat` | ELF header in elf binaries | | PE | `application/x-dosexec` | `patterns/pe.hexpat` | PE header, COFF header, Standard COFF fields and Windows Specific fields | +| Intel HEX | `text/plain` | `patterns/intel_hex.hexpat` | [Intel hexadecimal object file format definition]("https://en.wikipedia.org/wiki/Intel_HEX") | | MIDI | `audio/midi` | `patterns/midi.hexpat` | MIDI header, event fields provided | | WAV | `audio/wav` | `patterns/wav.hexpat` | RIFF header, WAVE header, PCM header | | ZIP | `application/zip` | `patterns/zip.hexpat` | End of Central Directory Header, Central Directory File Headers | diff --git a/patterns/intel_hex.hexpat b/patterns/intel_hex.hexpat new file mode 100644 index 0000000..75a34fb --- /dev/null +++ b/patterns/intel_hex.hexpat @@ -0,0 +1,52 @@ +/* If you have no delimiters between data records then remove + * the null_bytes field in the data_packet struct. + * Set the array at the bottom to the highest index + 1 in the Pattern Data view + * NOTE: these were ascii hex values for me, so use the calculator tool to convert + * values +*/ +#pragma MIME text/plain +#pragma endian big + +enum FileType: u16 { + Data = 0x3030, + EOF = 0x3031, + Extended_Segment_Address = 0x3032, + Start_Segment_Address = 0x3033, + Extended_Linear_Address = 0x3034, + Start_Linear_Address = 0x3035 +}; + +struct Bytes { + u8 HOB [[color("00FF6699")]]; + u8 LOB [[color("00FF6699")]]; +}; + +struct data_packet { + char start_code [[color("00EFECCA")]]; + Bytes byte_count [[color("00A9CBB7")]]; + u32 address [[color("00F7FF58")]]; + FileType recordType [[color("00FF934F")]]; + + // both not A + if (byte_count.HOB < 65 && byte_count.LOB < 65) { + u16 data[((byte_count.HOB - 48) * 16) + + (byte_count.LOB - 48)] [[color("0095B46A")]]; + // HOB is A but LOB is not + } else if (byte_count.HOB >= 65 && byte_count.LOB < 65) { + u16 data[((byte_count.HOB - 55) * 16) + + (byte_count.LOB - 48)] [[color("0095B46A")]]; + // LOB is A but HOB is not + } else if (byte_count.HOB < 65 && byte_count.LOB >= 65) { + u16 data[((byte_count.HOB - 48) * 16) + + (byte_count.LOB - 55)] [[color("0095B46A")]]; + // both are A + } else { + u16 data[((byte_count.HOB - 55) * 16) + + (byte_count.LOB - 55)] [[color("0095B46A")]]; + } + + u16 checksum [[color("0045F0DF")]]; + u16 null_bytes [[color("005E565A")]]; +}; + +data_packet data[1418] @ 0x00; \ No newline at end of file