mirror of
https://github.com/PretendoNetwork/Inkay.git
synced 2026-08-18 11:37:02 +02:00
35 lines
1.4 KiB
C++
35 lines
1.4 KiB
C++
/* Copyright 2023 Pretendo Network contributors <pretendo.network>
|
|
Copyright 2023 Ash Logan <ash@heyquark.com>
|
|
Copyright 2019 Maschell
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
|
granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
|
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <cstddef>
|
|
#include <span>
|
|
|
|
bool replace(uint32_t start, uint32_t size, const char *original_val, size_t original_val_sz, const char *new_val,
|
|
size_t new_val_sz);
|
|
|
|
struct replacement {
|
|
std::span<const uint8_t> orig;
|
|
std::span<const uint8_t> repl;
|
|
};
|
|
|
|
void replaceBulk(uint32_t start, uint32_t size, std::span<const replacement> replacements);
|
|
|
|
template <typename U>
|
|
requires std::integral<U>
|
|
bool replace_unsigned(U *addr, U original_value, U new_value);
|
|
|
|
bool replace_instruction(uint32_t *inst, uint32_t original_value, uint32_t new_value);
|