diff --git a/loader/include/Geode/utils/addresser.hpp b/loader/include/Geode/utils/addresser.hpp index bf4ac936..42ecd82a 100644 --- a/loader/include/Geode/utils/addresser.hpp +++ b/loader/include/Geode/utils/addresser.hpp @@ -4,13 +4,14 @@ * Adapted from https://gist.github.com/altalk23/29b97969e9f0624f783b673f6c1cd279 */ +#include "../utils/casts.hpp" #include "casts.hpp" #include +#include #include #include #include -#include "../utils/casts.hpp" namespace geode::addresser { @@ -71,16 +72,23 @@ namespace geode::addresser { ) { using geode::cast::reference_cast; - // Create a random memory block with the size of T - // Assign a pointer to that block and cast it to type T* - uint8_t dum[sizeof(T)] {}; - auto ptr = reinterpret_cast(dum); - // Now you have a object of T that actually isn't an object of T and is just a random - // memory But C++ doesn't know that of course So now you can copy an object that wasn't - // there in the first place - // ((oh also get the offsets of the virtual tables)) - auto ins = new T(*ptr); - // this is how the first human was made + // exceptions, can't be bothered to have a proper fix because there is None + T* ins; + if constexpr (std::is_same_v) { + ins = cocos2d::CCSet::create(); + } + else { + // Create a random memory block with the size of T + // Assign a pointer to that block and cast it to type T* + uint8_t dum[sizeof(T)]{}; + auto ptr = reinterpret_cast(dum); + // Now you have a object of T that actually isn't an object of T and is just a + // random memory But C++ doesn't know that of course So now you can copy an object + // that wasn't there in the first place + // ((oh also get the offsets of the virtual tables)) + ins = new T(*ptr); + // this is how the first human was made + } auto index = indexOf(func); auto thunk = thunkOf(func); @@ -93,8 +101,7 @@ namespace geode::addresser { // ); // [[this + thunk] + offset] is the f we want - auto address = - *(intptr_t*)(*(intptr_t*)(reference_cast(ins) + thunk) + index); + auto address = *(intptr_t*)(*(intptr_t*)(reference_cast(ins) + thunk) + index); #ifdef GEODE_IS_WINDOWS // check if first instruction is a jmp, i.e. if the func is a thunk @@ -116,8 +123,7 @@ namespace geode::addresser { template static intptr_t addressOfVirtual( R (T::*func)(Ps...) const, - typename std::enable_if_t && !std::is_abstract_v>* = - 0 + typename std::enable_if_t && !std::is_abstract_v>* = 0 ) { return addressOfVirtual(reinterpret_cast(func)); } @@ -199,7 +205,7 @@ namespace geode::addresser { template inline F thunkAdjust(T func, F self) { - // do NOT delete the line below. + // do NOT delete the line below. // doing so breaks thunk adjusting on windows. // why? bruh idk auto _ = *geode::cast::template union_cast(&func); @@ -208,7 +214,7 @@ namespace geode::addresser { template inline F rthunkAdjust(T func, F self) { - // do NOT delete the line below. + // do NOT delete the line below. // doing so breaks thunk adjusting on windows. // why? bruh idk auto _ = *geode::cast::template union_cast(&func);