Skip to content

Instantly share code, notes, and snippets.

@mochaaP
Last active May 16, 2024 20:00
Show Gist options
  • Save mochaaP/b89b4618ff9116a56e5a304d81a4937d to your computer and use it in GitHub Desktop.
Save mochaaP/b89b4618ff9116a56e5a304d81a4937d to your computer and use it in GitHub Desktop.
simple imhex pattern for diablo2oo2's universal patcher's rsrc
#include <std/io.pat>
namespace dup2 {
u32 offset @ 0x16;
u32 count @ 0x1E;
fn read_pat(auto pat) {
str hex_pat = "";
for (auto i = 0, i < pat.size, i = i + 1) {
if (!pat.Mask[i])
hex_pat += std::format("{:02x}", pat.Pattern[i]);
else
hex_pat += "??";
hex_pat += " ";
}
return hex_pat;
};
struct patch_pattern<auto Size> {
char Pattern[Size];
bool Mask[Size];
u32 size = Size;
} [[format_read("dup2::read_pat")]];
struct patch_info {
u32 PatternSize;
s32 PatchNumber;
patch_pattern<PatternSize> Search;
patch_pattern<PatternSize> Patch;
std::print("== Patch ==\nMatch = {}:\n- {}\n+ {}", PatchNumber, Search, Patch);
};
patch_info PatchInfo[count + 1] @ offset;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment