mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-14 17:33:25 +00:00
[mod][bin] Fill replacement string with zeroes.
This commit is contained in:
parent
3096e42954
commit
1b3ad96fc1
1 changed files with 5 additions and 2 deletions
|
|
@ -178,9 +178,12 @@ struct bin_patcher {
|
||||||
}
|
}
|
||||||
v ^= value;
|
v ^= value;
|
||||||
}
|
}
|
||||||
static void replace_bin_in_file_raw(const path &fn, const std::string &from, const std::string &to) {
|
static void replace_bin_in_file_raw(const path &fn, const std::string &from, std::string to) {
|
||||||
|
if (to.size() > from.size()) {
|
||||||
|
throw std::runtime_error{"replacement string is larger than original"};
|
||||||
|
}
|
||||||
if (from.size() != to.size()) {
|
if (from.size() != to.size()) {
|
||||||
throw std::runtime_error{"mismatched size"};
|
to.resize(from.size(), '\0');
|
||||||
}
|
}
|
||||||
primitives::templates2::mmap_file<uint8_t> f{fn, primitives::templates2::mmap_file<uint8_t>::rw{}};
|
primitives::templates2::mmap_file<uint8_t> f{fn, primitives::templates2::mmap_file<uint8_t>::rw{}};
|
||||||
while (auto p = memmem(f.p, f.sz, from)) {
|
while (auto p = memmem(f.p, f.sz, from)) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue