#include "patch.h" namespace patch { type identify(const file& patch) { byte head[16]; size_t len = patch.read(arrayview(head)); if (len>=5 && !memcmp(head, "PATCH", 5)) return t_ips; if (len>=4 && !memcmp(head, "UPS1", 4)) return t_ups; if (len>=4 && !memcmp(head, "BPS1", 4)) return t_bps; return t_unknown; } type identify_ext(cstring path) { if (path.endswith(".ips")) return t_ips; if (path.endswith(".ups")) return t_ups; if (path.endswith(".bps")) return t_bps; return t_unknown; } bool memstream::bpsnum(size_t* out) { //similar to uleb128, but bpsnum adds another 1<::lslov(next^0x80, shift, &tmp)) return false; if (safeint::addov(ret, tmp, &ret)) return false; if (next&0x80) break; shift+=7; } *out = ret; return true; } }