forked from PretendoNetwork/Inkay
chore: Run code formatter across project
this is the CLion formatter since I haven't set up clang-format for Inkay yet
This commit is contained in:
parent
b02db3f20b
commit
695a077ebd
9 changed files with 71 additions and 72 deletions
|
|
@ -23,13 +23,14 @@
|
|||
#include <coreinit/memorymap.h>
|
||||
#include <algorithm>
|
||||
|
||||
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) {
|
||||
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) {
|
||||
for (uint32_t addr = start; addr < start + size - original_val_sz; addr++) {
|
||||
int ret = memcmp(original_val, (void*)addr, original_val_sz);
|
||||
int ret = memcmp(original_val, (void *) addr, original_val_sz);
|
||||
if (ret == 0) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("found str @%08x: %s", addr, (const char*)addr);
|
||||
KernelCopyData(OSEffectiveToPhysical(addr), OSEffectiveToPhysical((uint32_t)new_val), new_val_sz);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("new str @%08x: %s", addr, (const char*)addr);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("found str @%08x: %s", addr, (const char *) addr);
|
||||
KernelCopyData(OSEffectiveToPhysical(addr), OSEffectiveToPhysical((uint32_t) new_val), new_val_sz);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("new str @%08x: %s", addr, (const char *) addr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -39,24 +40,24 @@ bool replace(uint32_t start, uint32_t size, const char* original_val, size_t ori
|
|||
|
||||
void replaceBulk(uint32_t start, uint32_t size, std::span<const replacement> replacements) {
|
||||
// work out the biggest input replacement
|
||||
auto max_sz = std::max_element(replacements.begin(), replacements.end(), [](auto& a, auto& b) {
|
||||
auto max_sz = std::max_element(replacements.begin(), replacements.end(), [](auto &a, auto &b) {
|
||||
return a.orig.size_bytes() < b.orig.size_bytes();
|
||||
})->orig.size_bytes();
|
||||
|
||||
int counts[replacements.size()];
|
||||
for (auto& c : counts) {
|
||||
for (auto &c: counts) {
|
||||
c = 0;
|
||||
}
|
||||
|
||||
for (uint32_t addr = start; addr < start + size - max_sz; addr++) {
|
||||
for (int i = 0; i < (int)replacements.size(); i++) {
|
||||
const auto& replacement = replacements[i];
|
||||
for (int i = 0; i < (int) replacements.size(); i++) {
|
||||
const auto &replacement = replacements[i];
|
||||
|
||||
int ret = memcmp((void*)addr, replacement.orig.data(), replacement.orig.size_bytes());
|
||||
int ret = memcmp((void *) addr, replacement.orig.data(), replacement.orig.size_bytes());
|
||||
if (ret == 0) {
|
||||
KernelCopyData(
|
||||
OSEffectiveToPhysical(addr),
|
||||
OSEffectiveToPhysical((uint32_t)replacement.repl.data()),
|
||||
OSEffectiveToPhysical((uint32_t) replacement.repl.data()),
|
||||
replacement.repl.size_bytes()
|
||||
);
|
||||
counts[i]++;
|
||||
|
|
@ -64,7 +65,7 @@ void replaceBulk(uint32_t start, uint32_t size, std::span<const replacement> rep
|
|||
}
|
||||
}
|
||||
}
|
||||
for (auto c : counts) {
|
||||
for (auto c: counts) {
|
||||
DEBUG_FUNCTION_LINE("replaced %d times", c);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
#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);
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include <optional>
|
||||
|
||||
nn::swkbd::LanguageType get_system_language() {
|
||||
static std::optional<nn::swkbd::LanguageType> cached_language{};
|
||||
static std::optional <nn::swkbd::LanguageType> cached_language{};
|
||||
if (cached_language) return *cached_language;
|
||||
|
||||
UCHandle handle = UCOpen();
|
||||
|
|
|
|||
Loading…
Reference in a new issue