Created
June 30, 2025 15:49
-
-
Save EastArctica/a0d86311114568b1c35a294581377b61 to your computer and use it in GitHub Desktop.
ImHex pattern for the racelogic can data file format v1 and v1a
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
#pragma author East_Arctica | |
#pragma description Racelogic Can Data File | |
#pragma magic [ 52 61 63 65 6C 6F 67 69 63 20 43 61 6E 20 44 61 74 61 20 46 69 6C 65 20 56 31 61 0d 0a ] @ 0x00 | |
#pragma magic [ 52 61 63 65 6C 6F 67 69 63 20 43 61 6E 20 44 61 74 61 20 46 69 6C 65 20 56 31 0d 0a ] @ 0x00 | |
#pragma endian big | |
import std.mem; | |
import hex.dec; | |
import hex.core; | |
import std.io; | |
import std.string; | |
struct ZlibStr { | |
u16 len; | |
u8 data[len]; | |
} [[format("format_zlib_str")]]; | |
struct ChArray<auto N> { | |
char array[N]; | |
}; | |
fn format_zlib_str(ref ZlibStr entry) { | |
std::mem::Section dec = std::mem::create_section("dec"); | |
hex::dec::zlib_decompress(entry.data, dec, 15); | |
char data[std::mem::get_section_size(dec)] @ 0x00 in dec; | |
// This just makes it show as an actual string in imhex | |
// idk https://discord.com/channels/789833418631675954/789840633414025246/1232124715661787206 | |
ChArray<std::mem::get_section_size(dec)> string; | |
for (u128 j = 0, j < std::mem::get_section_size(dec), j += 1) { | |
string.array[j] = data[j]; | |
} | |
return string.array; | |
}; | |
struct RacelogicCanDataV1a { | |
char header[while (std::mem::read_unsigned($, 2) != 0x0A0D)]; | |
padding[2]; | |
char serial_str[while (std::mem::read_unsigned($, 2) != 0x0A0D)]; | |
padding[2]; | |
ZlibStr serial; | |
u16 total_entries; | |
ZlibStr entries[total_entries]; | |
}; | |
RacelogicCanDataV1a data @ 0x0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment