mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-26 17:19:24 +00:00
ok this is the last one
This commit is contained in:
3 files changed
+13
-9
No files matched your search
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
#include <link.h>
|
#include <link.h>
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// this is every function that i thought would be relevant
|
// this is every function that i thought would be relevant
|
||||||
constexpr std::array remove_symbols{
|
constexpr std::array<const std::string_view, 10> remove_symbols{
|
||||||
"__gxx_personality_v0",
|
"__gxx_personality_v0",
|
||||||
"__cxa_throw",
|
"__cxa_throw",
|
||||||
"__cxa_rethrow",
|
"__cxa_rethrow",
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ struct ElfDynamicState {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// copied from tuliphook source :)
|
// copied from tuliphook source :)
|
||||||
bool set_mprotect(std::uintptr_t address, size_t size, uint32_t protection) {
|
// tuliphook sets WRX perms, but we write to pages with W^X protection
|
||||||
|
bool set_mprotect(std::uintptr_t address, size_t size, int protection) {
|
||||||
auto const page_size = getpagesize();
|
auto const page_size = getpagesize();
|
||||||
auto const page_mask = page_size - 1;
|
auto const page_mask = page_size - 1;
|
||||||
|
|
||||||
@@ -41,12 +42,11 @@ bool set_mprotect(std::uintptr_t address, size_t size, uint32_t protection) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// i copied this function from the android linker
|
// i copied this function from the android linker
|
||||||
std::uint32_t elfhash(const char *_name) {
|
constexpr std::uint32_t elfhash(std::string_view name) {
|
||||||
const auto *name = reinterpret_cast<const unsigned char*>(_name);
|
|
||||||
std::uint32_t h = 0, g;
|
std::uint32_t h = 0, g;
|
||||||
|
|
||||||
while (*name) {
|
for (const auto c : name) {
|
||||||
h = (h << 4) + *name++;
|
h = (h << 4) + static_cast<unsigned char>(c);
|
||||||
g = h & 0xf0000000;
|
g = h & 0xf0000000;
|
||||||
h ^= g;
|
h ^= g;
|
||||||
h ^= g >> 24;
|
h ^= g >> 24;
|
||||||
@@ -55,9 +55,9 @@ std::uint32_t elfhash(const char *_name) {
|
|||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<std::uint8_t, 3> SYMBOL_PATCH_VALUE{":3"};
|
constexpr std::array<const std::uint8_t, 3> SYMBOL_PATCH_VALUE{":3"};
|
||||||
|
|
||||||
bool patch_symbol(std::uint32_t* hash_table, char* str_table, ElfW(Sym)* sym_table, const char* orig_name) {
|
bool patch_symbol(std::uint32_t* hash_table, char* str_table, ElfW(Sym)* sym_table, const std::string_view orig_name) {
|
||||||
auto hash = elfhash(orig_name);
|
auto hash = elfhash(orig_name);
|
||||||
|
|
||||||
auto nbucket = hash_table[0];
|
auto nbucket = hash_table[0];
|
||||||
@@ -69,7 +69,7 @@ bool patch_symbol(std::uint32_t* hash_table, char* str_table, ElfW(Sym)* sym_tab
|
|||||||
auto sym = sym_table + i;
|
auto sym = sym_table + i;
|
||||||
auto sym_name = str_table + sym->st_name;
|
auto sym_name = str_table + sym->st_name;
|
||||||
|
|
||||||
if (strcmp(sym_name, orig_name) == 0) {
|
if (orig_name == sym_name) {
|
||||||
// there's probably no point to checking this, honestly
|
// there's probably no point to checking this, honestly
|
||||||
if (ELF_ST_BIND(sym->st_info) == STB_GLOBAL && ELF_ST_TYPE(sym->st_info) == STT_FUNC) {
|
if (ELF_ST_BIND(sym->st_info) == STB_GLOBAL && ELF_ST_TYPE(sym->st_info) == STT_FUNC) {
|
||||||
// we found it! now go rename the symbol
|
// we found it! now go rename the symbol
|
||||||
|
|||||||
@@ -398,6 +398,9 @@ class ReleaseManager private constructor(
|
|||||||
val geodeName = LaunchUtils.geodeFilename
|
val geodeName = LaunchUtils.geodeFilename
|
||||||
val geodeDirectory = LaunchUtils.getBaseDirectory(applicationContext)
|
val geodeDirectory = LaunchUtils.getBaseDirectory(applicationContext)
|
||||||
|
|
||||||
|
// warning!! while File::createTempFile may look tempting, a certain brand of phones has a messed up implementation of it
|
||||||
|
// so we're making a temp file manually (as long as it doesn't collide with the geode download, it's okay)
|
||||||
|
|
||||||
val alphabet = ('A'..'Z') + ('a'..'z') + ('0'..'9')
|
val alphabet = ('A'..'Z') + ('a'..'z') + ('0'..'9')
|
||||||
val suffix = buildString(8) {
|
val suffix = buildString(8) {
|
||||||
repeat(8) { append(alphabet.random()) }
|
repeat(8) { append(alphabet.random()) }
|
||||||
|
|||||||
Reference in new issue
Block a user