Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "../include/main.hpp"
- FILE* fp;
- #define PATH "/sdcard/Android/data/com.beatgames.beatsaber/files/logdump.txt"
- #define RUN_METHOD0(outp, inp, name) \
- do { \
- if (!il2cpp_utils::RunMethod(outp, inp, name)) { \
- log(CRITICAL, "Failed to run method!"); \
- std::abort(); \
- } \
- } while(0);
- #define RUN_METHOD1(outp, inp, name, arg1) \
- do { \
- if (!il2cpp_utils::RunMethod(outp, inp, name, arg1)) { \
- log(CRITICAL, "Failed to run method!"); \
- std::abort(); \
- } \
- } while(0);
- void write_info(std::string str) {
- fwrite(str.data(), str.length() + 1, 1, fp);
- }
- void DumpParents(std::string prefix, Il2CppObject* parentTransform) {
- // Get children
- int childCount;
- RUN_METHOD0(&childCount, parentTransform, "get_childCount");
- Il2CppString* parentName;
- RUN_METHOD0(&parentName, parentTransform, "get_name");
- write_info(prefix + to_utf8(csstrtostr(parentName)) + " Children: " + std::to_string(childCount));
- Il2CppObject* child;
- for (int i = 0; i < childCount; i++) {
- RUN_METHOD1(&child, parentTransform, "GetChild", i);
- if (child) {
- DumpParents(prefix + "-", child);
- }
- }
- }
- // Iterates over all GameObjects in the scene, dumps information about them to file
- void DumpAll() {
- fp = fopen(PATH, "w");
- Il2CppArray* arr;
- static auto typeObject = il2cpp_utils::GetSystemType("UnityEngine", "GameObject");
- RUN_METHOD1(&arr, il2cpp_utils::GetClassFromName("UnityEngine", "Resources"), "FindObjectsOfTypeAll", typeObject);
- Il2CppObject* transform;
- for (il2cpp_array_size_t i = 0; i < arr->bounds->length; i++) {
- auto go = il2cpp_array_get(arr, Il2CppObject*, 0);
- if (go != nullptr) {
- RUN_METHOD0(&transform, go, "get_transform");
- if (transform != nullptr) {
- RUN_METHOD0(&transform, transform, "get_parent");
- if (transform != nullptr) {
- DumpParents("", transform);
- }
- } else {
- Il2CppString* goName;
- RUN_METHOD0(&goName, go, "get_name");
- write_info(to_utf8(csstrtostr(goName)) + " has no transform!");
- }
- } else {
- write_info("GameObject is null!");
- }
- }
- fclose(fp);
- }
Add Comment
Please, Sign In to add comment