added il2cpp dump, changed sdk generator

workingdir/cra0-upated
xerox 4 years ago
parent 1049f10a92
commit 5b0da954a1

Binary file not shown.

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

@ -1,77 +0,0 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"Dll2Sdk/1.0.0": {
"dependencies": {
"CommandLineParser": "2.7.82",
"dnlib": "3.3.2"
},
"runtime": {
"Dll2Sdk.dll": {}
}
},
"CommandLineParser/2.7.82": {
"runtime": {
"lib/netstandard2.0/CommandLine.dll": {
"assemblyVersion": "2.7.82.0",
"fileVersion": "2.7.82.0"
}
}
},
"dnlib/3.3.2": {
"dependencies": {
"System.Reflection.Emit": "4.7.0",
"System.Reflection.Emit.Lightweight": "4.7.0"
},
"runtime": {
"lib/netstandard2.0/dnlib.dll": {
"assemblyVersion": "3.3.2.0",
"fileVersion": "3.3.2.0"
}
}
},
"System.Reflection.Emit/4.7.0": {},
"System.Reflection.Emit.Lightweight/4.7.0": {}
}
},
"libraries": {
"Dll2Sdk/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"CommandLineParser/2.7.82": {
"type": "package",
"serviceable": true,
"sha512": "sha512-JnjxBu4++EDnYtDzHskiPrPJ9hAna8amu8qlQx8J+2oZnPddDnkR/0FFtQMDz0Cs0YF2lbyW3OmYfRmIrLNY0A==",
"path": "commandlineparser/2.7.82",
"hashPath": "commandlineparser.2.7.82.nupkg.sha512"
},
"dnlib/3.3.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-16p2zxL0d0FJ7POvunZ+9cn3mREmQD1rDm+1C1eIMDBRAuEGLCSWdIobrUNYP//DcfMRYHbpgB8Gh2BYjEkS2Q==",
"path": "dnlib/3.3.2",
"hashPath": "dnlib.3.3.2.nupkg.sha512"
},
"System.Reflection.Emit/4.7.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-VR4kk8XLKebQ4MZuKuIni/7oh+QGFmZW3qORd1GvBq/8026OpW501SzT/oypwiQl4TvT8ErnReh/NzY9u+C6wQ==",
"path": "system.reflection.emit/4.7.0",
"hashPath": "system.reflection.emit.4.7.0.nupkg.sha512"
},
"System.Reflection.Emit.Lightweight/4.7.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-a4OLB4IITxAXJeV74MDx49Oq2+PsF6Sml54XAFv+2RyWwtDBcabzoxiiJRhdhx+gaohLh4hEGCLQyBozXoQPqA==",
"path": "system.reflection.emit.lightweight/4.7.0",
"hashPath": "system.reflection.emit.lightweight.4.7.0.nupkg.sha512"
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1,8 +0,0 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\xerox\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\xerox\\.nuget\\packages"
]
}
}

@ -1,9 +0,0 @@
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.1.0"
}
}
}

Binary file not shown.

Binary file not shown.

@ -74,9 +74,11 @@ public:
return *(T*)((uintptr_t)StaticClass()->static_fields + 0x50); return *(T*)((uintptr_t)StaticClass()->static_fields + 0x50);
} }
template <typename T = uintptr_t> static T get_Game() { template <typename T = uintptr_t> static T get_Game()
return ((T (*)(void *))(Il2CppBase() + 0x36E708C))(0); {
return ((T(*)(void))(Il2CppBase() + 0x36E708C))();
} }
template <typename T = uintptr_t> static T get_MatchGame() { template <typename T = uintptr_t> static T get_MatchGame() {
return ((T (*)(void *))(Il2CppBase() + 0x36F611C))(0); return ((T (*)(void *))(Il2CppBase() + 0x36F611C))(0);
} }

@ -10,62 +10,48 @@
#define IL2CPP_LOGW(...) __android_log_print(ANDROID_LOG_WARN,IL2CPP__TAG,__VA_ARGS__) #define IL2CPP_LOGW(...) __android_log_print(ANDROID_LOG_WARN,IL2CPP__TAG,__VA_ARGS__)
#define IL2CPP_LOGE(...) __android_log_print(ANDROID_LOG_ERROR,IL2CPP__TAG,__VA_ARGS__) #define IL2CPP_LOGE(...) __android_log_print(ANDROID_LOG_ERROR,IL2CPP__TAG,__VA_ARGS__)
// ========================================================================================================================================== // // ========================================================================================================================================== //
map<string, size_t> m_cacheFields; std::map<std::string, std::size_t> m_cacheFields;
map<string, void *> m_cacheMethods; std::map<std::string, void*> m_cacheMethods;
map<string, void *> m_cacheClasses; std::map<std::string, void*> m_cacheClasses;
// ========================================================================================================================================== // // ========================================================================================================================================== //
namespace { namespace
{
const void *(*il2cpp_assembly_get_image)(const void *assembly); const void *(*il2cpp_assembly_get_image)(const void *assembly);
void *(*il2cpp_domain_get)(); void *(*il2cpp_domain_get)();
void **(*il2cpp_domain_get_assemblies)(const void *domain, size_t *size); void **(*il2cpp_domain_get_assemblies)(const void *domain, size_t *size);
const char *(*il2cpp_image_get_name)(void *image); const char *(*il2cpp_image_get_name)(void *image);
void *(*il2cpp_class_from_name)(const void *image, const char *namespaze, const char *name); void *(*il2cpp_class_from_name)(const void *image, const char *namespaze, const char *name);
void *(*il2cpp_class_get_field_from_name)(void *klass, const char *name); void *(*il2cpp_class_get_field_from_name)(void *klass, const char *name);
void *(*il2cpp_class_get_method_from_name)(void *klass, const char *name, int argsCount); void *(*il2cpp_class_get_method_from_name)(void *klass, const char *name, int argsCount);
size_t (*il2cpp_field_get_offset)(void *field); size_t (*il2cpp_field_get_offset)(void *field);
void (*il2cpp_field_static_get_value)(void *field, void *value); void (*il2cpp_field_static_get_value)(void *field, void *value);
void (*il2cpp_field_static_set_value)(void *field, void *value); void (*il2cpp_field_static_set_value)(void *field, void *value);
void *(*il2cpp_array_new)(void *elementTypeInfo, size_t length); void *(*il2cpp_array_new)(void *elementTypeInfo, size_t length);
char *(*il2cpp_type_get_name)(void *type); char *(*il2cpp_type_get_name)(void *type);
void* (*il2cpp_method_get_param)(void *method, uint32_t index); void* (*il2cpp_method_get_param)(void *method, uint32_t index);
void* (*il2cpp_class_get_methods)(void *klass, void* *iter); void* (*il2cpp_class_get_methods)(void *klass, void* *iter);
const char* (*il2cpp_method_get_name)(void *method); const char* (*il2cpp_method_get_name)(void *method);
const char *(*il2cpp_class_get_name)(void *klass); const char *(*il2cpp_class_get_name)(void *klass);
void *(*il2cpp_class_get_nested_types)(void *, void **); void *(*il2cpp_class_get_nested_types)(void *, void **);
void *(*il2cpp_object_new)(void *); void *(*il2cpp_object_new)(void *);
Il2CppString *(*il2cpp_string_new)(const char *); Il2CppString *(*il2cpp_string_new)(const char *);
Il2CppString *(*il2cpp_string_new_utf16)(const wchar_t *, size_t len); Il2CppString *(*il2cpp_string_new_utf16)(const wchar_t *, size_t len);
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
vector<string> split_string(string str, string token) { std::vector<std::string> split_string(std::string str, std::string token)
vector<string> result; {
while (str.size()) { std::vector<std::string> result;
int index = str.find(token); while (str.size())
if (index != string::npos) { {
const auto index = str.find(token);
if (index != std::string::npos)
{
result.push_back(str.substr(0, index)); result.push_back(str.substr(0, index));
str = str.substr(index + token.size()); str = str.substr(index + token.size());
if (str.size() == 0) if (!str.size())
result.push_back(str); result.push_back(str);
} else { } else
{
result.push_back(str); result.push_back(str);
str = ""; str = "";
} }
@ -74,63 +60,34 @@ vector<string> split_string(string str, string token) {
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
int not_found_export = 0; int not_found_export = 0;
void *get_export_function(const char *lib, const char *name) void *get_export_function(const char *lib, const char *name)
{ {
void *handle = dlopen(lib, 4); return dlsym(dlopen(lib, RTLD_NOLOAD), name);
if(handle) {
void *fn = dlsym(handle, name);
if (fn) {
return fn;
}
}
not_found_export++;
return 0;
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
#define GAME_LIB_ENGINE "libil2cpp.so" #define GAME_LIB_ENGINE "libil2cpp.so"
uintptr_t lib_addr = 0; std::uintptr_t Il2CppBase()
{
uintptr_t Il2CppBase(){ return reinterpret_cast<std::uintptr_t>(dlopen(GAME_LIB_ENGINE, RTLD_NOLOAD));
if(lib_addr)
{
return lib_addr;
}
char line[512];
FILE *f = fopen("/proc/self/maps", "r");
if (!f)
return 0;
while (fgets(line, sizeof line, f)) {
uintptr_t base;
char tmp[64];
sscanf(line, "%" PRIXPTR "-%*" PRIXPTR " %*s %*s %*s %*s %s", &base, tmp);
if (strstr(tmp, GAME_LIB_ENGINE)) {
fclose(f);
lib_addr = base;
return base;
}
}
fclose(f);
return 0;
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
typedef unsigned short UTF16; typedef unsigned short UTF16;
typedef wchar_t UTF32; typedef wchar_t UTF32;
typedef char UTF8; typedef char UTF8;
int is_surrogate(UTF16 uc) { int is_surrogate(UTF16 uc)
{
return (uc - 0xd800u) < 2048u; return (uc - 0xd800u) < 2048u;
} }
int is_high_surrogate(UTF16 uc) { int is_high_surrogate(UTF16 uc)
{
return (uc & 0xfffffc00) == 0xd800; return (uc & 0xfffffc00) == 0xd800;
} }
int is_low_surrogate(UTF16 uc) { int is_low_surrogate(UTF16 uc)
{
return (uc & 0xfffffc00) == 0xdc00; return (uc & 0xfffffc00) == 0xdc00;
} }
@ -138,172 +95,192 @@ UTF32 surrogate_to_utf32(UTF16 high, UTF16 low) {
return (high << 10) + low - 0x35fdc00; return (high << 10) + low - 0x35fdc00;
} }
const char* utf16_to_utf8(const UTF16* source, size_t len) { const char* utf16_to_utf8(const wchar_t* source, std::size_t len)
{
std::u16string s(source, source + len); std::u16string s(source, source + len);
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
return convert.to_bytes(s).c_str(); return convert.to_bytes(s).c_str();
} }
const wchar_t* utf16_to_utf32(const UTF16* source, size_t len) { const wchar_t* utf16_to_utf32(const wchar_t* source, std::size_t len)
UTF32* output = new UTF32[len + 1]; {
auto output = new wchar_t[len + 1];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++)
const UTF16 uc = source[i]; {
if (!is_surrogate(uc)) { const auto uc = source[i];
if (!is_surrogate(uc))
output[i] = uc; output[i] = uc;
} else
else {
if (is_high_surrogate(uc) && is_low_surrogate(source[i])) if (is_high_surrogate(uc) && is_low_surrogate(source[i]))
output[i] = surrogate_to_utf32(uc, source[i]); output[i] = surrogate_to_utf32(uc, source[i]);
else else
output[i] = L'?'; output[i] = L'?';
}
} }
output[len] = L'\0'; output[len] = L'\0';
return output; return output;
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
const char* Il2CppString::CString() { const char* Il2CppString::CString()
{
return utf16_to_utf8(&this->start_char, this->length); return utf16_to_utf8(&this->start_char, this->length);
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
const wchar_t* Il2CppString::WCString() { const wchar_t* Il2CppString::WCString()
{
return utf16_to_utf32(&this->start_char, this->length); return utf16_to_utf32(&this->start_char, this->length);
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
int Il2Cpp::Attach(const char *libname) { bool Il2Cpp::Attach(const char *libname)
if(!libname) return -1; {
if (!libname)
il2cpp_assembly_get_image = (const void *(*)(const void *)) get_export_function(libname, "il2cpp_assembly_get_image"); return false;
il2cpp_domain_get = (void *(*)()) get_export_function(libname, "il2cpp_domain_get");
il2cpp_domain_get_assemblies = (void **(*)(const void* , size_t*)) get_export_function(libname, "il2cpp_domain_get_assemblies"); if(!(il2cpp_assembly_get_image = (const void *(*)(const void *)) get_export_function(libname, "il2cpp_assembly_get_image")))
return false;
il2cpp_image_get_name = (const char *(*)(void *)) get_export_function(libname, "il2cpp_image_get_name"); if (!(il2cpp_domain_get = (void* (*)()) get_export_function(libname, "il2cpp_domain_get")))
return false;
il2cpp_class_from_name = (void* (*)(const void*, const char*, const char *)) get_export_function(libname, "il2cpp_class_from_name"); if (!(il2cpp_domain_get_assemblies = (void** (*)(const void*, size_t*)) get_export_function(libname, "il2cpp_domain_get_assemblies")))
return false;
il2cpp_class_get_field_from_name = (void* (*)(void*, const char *)) get_export_function(libname, "il2cpp_class_get_field_from_name");; if (!(il2cpp_image_get_name = (const char* (*)(void*)) get_export_function(libname, "il2cpp_image_get_name")))
return false;
il2cpp_class_get_method_from_name = (void* (*)(void *, const char*, int)) get_export_function(libname, "il2cpp_class_get_method_from_name");; if (!(il2cpp_class_from_name = (void* (*)(const void*, const char*, const char*)) get_export_function(libname, "il2cpp_class_from_name")))
return false;
il2cpp_field_get_offset = (size_t (*)(void *)) get_export_function(libname, "il2cpp_field_get_offset");; if (!(il2cpp_class_get_field_from_name = (void* (*)(void*, const char*)) get_export_function(libname, "il2cpp_class_get_field_from_name")))
return false;
il2cpp_field_static_get_value = (void (*)(void*, void *)) get_export_function(libname, "il2cpp_field_static_get_value");; if (!(il2cpp_class_get_method_from_name = (void* (*)(void*, const char*, int)) get_export_function(libname, "il2cpp_class_get_method_from_name")))
return false;
il2cpp_field_static_set_value = (void (*)(void*, void *)) get_export_function(libname, "il2cpp_field_static_set_value");; if (!(il2cpp_field_get_offset = (size_t (*)(void *)) get_export_function(libname, "il2cpp_field_get_offset")))
return false;
il2cpp_array_new = (void *(*)(void*, size_t)) get_export_function(libname, "il2cpp_array_new");; if (!(il2cpp_field_static_get_value = (void (*)(void*, void*)) get_export_function(libname, "il2cpp_field_static_get_value")))
return false;
il2cpp_type_get_name = (char *(*)(void *)) get_export_function(libname, "il2cpp_type_get_name");; if (!(il2cpp_field_static_set_value = (void (*)(void*, void*)) get_export_function(libname, "il2cpp_field_static_set_value")))
return false;
il2cpp_method_get_param = (void *(*)(void *, uint32_t)) get_export_function(libname, "il2cpp_method_get_param");; if (!(il2cpp_array_new = (void* (*)(void*, size_t)) get_export_function(libname, "il2cpp_array_new")))
return false;
il2cpp_class_get_methods = (void *(*)(void *, void **)) get_export_function(libname, "il2cpp_class_get_methods");; if (!(il2cpp_type_get_name = (char* (*)(void*)) get_export_function(libname, "il2cpp_type_get_name")))
return false;
il2cpp_method_get_name = (const char *(*)(void *)) get_export_function(libname, "il2cpp_method_get_name");; if (!(il2cpp_method_get_param = (void* (*)(void*, uint32_t)) get_export_function(libname, "il2cpp_method_get_param")))
return false;
il2cpp_class_get_name = (const char *(*)(void *)) get_export_function(libname, "il2cpp_class_get_name"); if (!(il2cpp_class_get_methods = (void* (*)(void*, void**)) get_export_function(libname, "il2cpp_class_get_methods")))
return false;
il2cpp_class_get_nested_types = (void *(*)(void *, void **)) get_export_function(libname, "il2cpp_class_get_nested_types"); if (!(il2cpp_method_get_name = (const char* (*)(void*)) get_export_function(libname, "il2cpp_method_get_name")))
return false;
il2cpp_object_new = (void *(*)(void *)) get_export_function(libname, "il2cpp_object_new"); if (!(il2cpp_class_get_name = (const char* (*)(void*)) get_export_function(libname, "il2cpp_class_get_name")))
return false;
il2cpp_string_new = (Il2CppString *(*)(const char *)) get_export_function(libname, "il2cpp_string_new"); if (!(il2cpp_class_get_nested_types = reinterpret_cast<decltype(il2cpp_class_get_nested_types)>(get_export_function(libname, "il2cpp_class_get_nested_types"))))
return false;
il2cpp_string_new_utf16 = (Il2CppString *(*)(const wchar_t *, size_t)) get_export_function(libname, "il2cpp_string_new_utf16"); if (!(il2cpp_object_new = (void* (*)(void*)) get_export_function(libname, "il2cpp_object_new")))
return false;
if(not_found_export) if (!(il2cpp_string_new = (Il2CppString * (*)(const char*)) get_export_function(libname, "il2cpp_string_new")))
{ return false;
return -1;
}
return 0;
if (!(il2cpp_string_new_utf16 = (Il2CppString * (*)(const wchar_t*, size_t)) get_export_function(libname, "il2cpp_string_new_utf16")))
return false;
return true;
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
void *Il2Cpp::GetImage(const char *image) { void* Il2Cpp::GetImage(const char *image)
size_t size; {
std::size_t size;
void **assemblies = il2cpp_domain_get_assemblies(il2cpp_domain_get(), &size); void **assemblies = il2cpp_domain_get_assemblies(il2cpp_domain_get(), &size);
for(int i = 0; i < size; ++i) for(int i = 0; i < size; ++i)
{ {
void *img = (void *)il2cpp_assembly_get_image(assemblies[i]); void *img = (void *)il2cpp_assembly_get_image(assemblies[i]);
const char *img_name = il2cpp_image_get_name(img); const char *img_name = il2cpp_image_get_name(img);
if(!strcmp(img_name, image))
if(strcmp(img_name, image) == 0)
{
return img; return img;
}
} }
return 0; return nullptr;
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
void Il2Cpp::GetStaticFieldValue(const char *image, const char *namespaze, const char *clazz, const char *name, void *output) { void Il2Cpp::GetStaticFieldValue(const char *image, const char *namespaze, const char *clazz, const char *name, void *output)
{
void *img = GetImage(image); void *img = GetImage(image);
if(!img) { if(!img)
{
IL2CPP_LOGI("Can't find image %s!", image); IL2CPP_LOGI("Can't find image %s!", image);
return; return;
} }
void *klass = GetClass(image, namespaze, clazz); void *klass = GetClass(image, namespaze, clazz);
if(!klass) { if(!klass)
{
IL2CPP_LOGI("Can't find class %s for field %s!", clazz, name); IL2CPP_LOGI("Can't find class %s for field %s!", clazz, name);
return; return;
} }
void *field = il2cpp_class_get_field_from_name(klass, name); void *field = il2cpp_class_get_field_from_name(klass, name);
if(!field) { if(!field)
{
IL2CPP_LOGI("Can't find field %s in class %s!", name, clazz); IL2CPP_LOGI("Can't find field %s in class %s!", name, clazz);
return; return;
} }
il2cpp_field_static_get_value(field, output); il2cpp_field_static_get_value(field, output);
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
void Il2Cpp::SetStaticFieldValue(const char *image, const char *namespaze, const char *clazz, const char *name, void* value) { void Il2Cpp::SetStaticFieldValue(const char *image, const char *namespaze, const char *clazz, const char *name, void* value)
{
void *img = GetImage(image); void *img = GetImage(image);
if(!img) { if(!img)
{
IL2CPP_LOGI("Can't find image %s!", image); IL2CPP_LOGI("Can't find image %s!", image);
return; return;
} }
void *klass = GetClass(image, namespaze, clazz); void *klass = GetClass(image, namespaze, clazz);
if(!klass) { if(!klass)
{
IL2CPP_LOGI("Can't find class %s for field %s!", clazz, name); IL2CPP_LOGI("Can't find class %s for field %s!", clazz, name);
return; return;
} }
void *field = il2cpp_class_get_field_from_name(klass, name); void *field = il2cpp_class_get_field_from_name(klass, name);
if(!field) { if(!field)
{
IL2CPP_LOGI("Can't find field %s in class %s!", name, clazz); IL2CPP_LOGI("Can't find field %s in class %s!", name, clazz);
return; return;
} }
il2cpp_field_static_set_value(field, value); il2cpp_field_static_set_value(field, value);
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
void *Il2Cpp::GetClass(const char *image, const char *namespaze, const char *clazz) { void* Il2Cpp::GetClass(const char *image, const char *namespaze, const char *clazz)
string _sig = image; {
std::string _sig = image;
_sig += namespaze; _sig += namespaze;
_sig += clazz; _sig += clazz;
if(m_cacheClasses.count(_sig) > 0) if(m_cacheClasses.count(_sig))
{
return m_cacheClasses[_sig]; return m_cacheClasses[_sig];
}
void *img = GetImage(image); void *img = GetImage(image);
if(!img) { if(!img)
{
IL2CPP_LOGI("Can't find image %s!", image); IL2CPP_LOGI("Can't find image %s!", image);
return 0; return nullptr;
} }
vector<string> classes = split_string(clazz, "."); std::vector<std::string> classes = split_string(clazz, ".");
void *klass = il2cpp_class_from_name(img, namespaze, classes[0].c_str()); void *klass = il2cpp_class_from_name(img, namespaze, classes[0].c_str());
if(!klass) { if(!klass)
{
IL2CPP_LOGI("Can't find class %s!", clazz); IL2CPP_LOGI("Can't find class %s!", clazz);
return 0; return nullptr;
} }
if(classes.size() > 1) if(classes.size() > 1)
@ -313,17 +290,13 @@ void *Il2Cpp::GetClass(const char *image, const char *namespaze, const char *cla
while(nest) while(nest)
{ {
const char *name = il2cpp_class_get_name(nest); const char *name = il2cpp_class_get_name(nest);
if(strcmp(name, classes[1].c_str()) == 0) if(!strcmp(name, classes[1].c_str()))
{
return nest; return nest;
}
nest = il2cpp_class_get_nested_types(klass, &iter); nest = il2cpp_class_get_nested_types(klass, &iter);
} }
IL2CPP_LOGI("Can't find subclass %s in class %s!", classes[1].c_str(), classes[0].c_str()); IL2CPP_LOGI("Can't find subclass %s in class %s!", classes[1].c_str(), classes[0].c_str());
return 0; return nullptr;
} }
return klass; return klass;
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
@ -351,11 +324,11 @@ void *Il2Cpp::NewClassObject(const char *image, const char *namespaze, const cha
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
void *Il2Cpp::GetMethodOffset(const char *image, const char *namespaze, const char *clazz, const char *name, int argsCount) { void *Il2Cpp::GetMethodOffset(const char *image, const char *namespaze, const char *clazz, const char *name, int argsCount) {
string _sig = image; std::string _sig = image;
_sig += namespaze; _sig += namespaze;
_sig += clazz; _sig += clazz;
_sig += name; _sig += name;
_sig += to_string(argsCount); _sig += std::to_string(argsCount);
if(m_cacheMethods.count(_sig) > 0) if(m_cacheMethods.count(_sig) > 0)
{ {
@ -386,14 +359,14 @@ void *Il2Cpp::GetMethodOffset(const char *image, const char *namespaze, const ch
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
void *Il2Cpp::GetMethodOffset(const char *image, const char *namespaze, const char *clazz, const char *name, char** args, int argsCount) { void *Il2Cpp::GetMethodOffset(const char *image, const char *namespaze, const char *clazz, const char *name, char** args, int argsCount) {
string _sig = image; std::string _sig = image;
_sig += namespaze; _sig += namespaze;
_sig += clazz; _sig += clazz;
_sig += name; _sig += name;
for (int i = 0; i < argsCount; i++) { for (int i = 0; i < argsCount; i++) {
_sig += args[i]; _sig += args[i];
} }
_sig += to_string(argsCount); _sig += std::to_string(argsCount);
if(m_cacheMethods.count(_sig) > 0) if(m_cacheMethods.count(_sig) > 0)
{ {
@ -453,7 +426,7 @@ goto skip;
} }
// ========================================================================================================================================== // // ========================================================================================================================================== //
uintptr_t Il2Cpp::GetFieldOffset(const char *image, const char *namespaze, const char *clazz, const char *name) { uintptr_t Il2Cpp::GetFieldOffset(const char *image, const char *namespaze, const char *clazz, const char *name) {
string _sig = image; std::string _sig = image;
_sig += namespaze; _sig += namespaze;
_sig += clazz; _sig += clazz;
_sig += name; _sig += name;

@ -2,7 +2,6 @@
// Created by aimar on 12/28/2019. // Created by aimar on 12/28/2019.
// //
#pragma once #pragma once
#include <stdio.h> #include <stdio.h>
#include <android/log.h> #include <android/log.h>
#include <dlfcn.h> #include <dlfcn.h>
@ -13,42 +12,22 @@
#include <inttypes.h> #include <inttypes.h>
#include <codecvt> #include <codecvt>
#include <locale> #include <locale>
using namespace std;
#ifndef IL2CPP_H
#define IL2CPP_H
#include "Il2CppType.h" #include "Il2CppType.h"
namespace Il2Cpp { namespace Il2Cpp
int Attach(const char *libname = "libil2cpp.so"); {
bool Attach(const char *libname = "libil2cpp.so");
void *GetImage(const char *image); void *GetImage(const char *image);
void *GetClass(const char *image, const char *namespaze, const char *clazz); void *GetClass(const char *image, const char *namespaze, const char *clazz);
void *CreateArray(const char *image, const char *namespaze, const char *clazz, size_t length); void *CreateArray(const char *image, const char *namespaze, const char *clazz, size_t length);
void *GetMethodOffset(const char *image, const char *namespaze, const char *clazz, const char *name, int argsCount = 0); void *GetMethodOffset(const char *image, const char *namespaze, const char *clazz, const char *name, int argsCount = 0);
void *GetMethodOffset(const char *image, const char *namespaze, const char *clazz, const char *name, char **args, int argsCount = 0); void *GetMethodOffset(const char *image, const char *namespaze, const char *clazz, const char *name, char **args, int argsCount = 0);
std::uintptr_t GetFieldOffset(const char *image, const char *namespaze, const char *clazz, const char *name);
uintptr_t GetFieldOffset(const char *image, const char *namespaze, const char *clazz, const char *name);
void GetStaticFieldValue(const char *image, const char *namespaze, const char *clazz, const char *name, void *output); void GetStaticFieldValue(const char *image, const char *namespaze, const char *clazz, const char *name, void *output);
void SetStaticFieldValue(const char *image, const char *namespaze, const char *clazz, const char *name, void *value); void SetStaticFieldValue(const char *image, const char *namespaze, const char *clazz, const char *name, void *value);
void *NewClassObject(const char *image, const char *namespaze, const char *clazz); void *NewClassObject(const char *image, const char *namespaze, const char *clazz);
Il2CppString *CreateString(const char *s); Il2CppString *CreateString(const char *s);
Il2CppString *CreateString(const wchar_t *s, size_t len); Il2CppString *CreateString(const wchar_t *s, size_t len);
bool IsAssembliesLoaded(); bool IsAssembliesLoaded();
}; };
std::uintptr_t Il2CppBase();
uintptr_t Il2CppBase();
#endif //ML_IL2CPP_H

@ -2,6 +2,8 @@
// Created by aimar on 7/14/2020. // Created by aimar on 7/14/2020.
// //
#include <math.h>
#ifndef CODM_IL2CPPTYPE_H #ifndef CODM_IL2CPPTYPE_H
#define CODM_IL2CPPTYPE_H #define CODM_IL2CPPTYPE_H
@ -101,20 +103,40 @@ template<typename T> struct Il2CppArray {
} }
}; };
struct Il2CppString { struct Il2CppString
{
Il2CppClass* klass; Il2CppClass* klass;
void* monitor; void* monitor;
int32_t length; int32_t length;
uint16_t start_char; wchar_t start_char;
static Il2CppString* newString(const wchar_t* string)
{
const auto result =
reinterpret_cast<Il2CppString*>(
malloc(sizeof(Il2CppString) + (std::wcslen(string) * sizeof(wchar_t))));
memcpy(&result->start_char, string, std::wcslen(string) * sizeof(wchar_t));
return result;
}
int getLength() { static Il2CppString* newString(const char* string)
{
const auto result =
reinterpret_cast<Il2CppString*>(
malloc(sizeof(Il2CppString) + (std::strlen(string))));
memcpy(&result->start_char, string, std::strlen(string));
return result;
}
std::uint32_t getLength()
{
return length; return length;
} }
char *getChars() { char* getChars()
{
return (char *)&start_char; return (char *)&start_char;
} }
const char* CString(); const char* CString();
const wchar_t* WCString(); const wchar_t* WCString();
}; };

@ -14,14 +14,12 @@ namespace ligma
ligma::utils::on_image_load("libxlua.so", [&](const std::uintptr_t module_base) ligma::utils::on_image_load("libxlua.so", [&](const std::uintptr_t module_base)
{ {
LOGI("libxlua.so base = %p", module_base); LOGI("libxlua.so base = %p", module_base);
// install lua hooks when libxlua.so gets loaded...
ligma::hook::make_hook( ligma::hook::make_hook(
dlsym(reinterpret_cast<void*>(module_base), "luaL_loadbufferx"), dlsym(reinterpret_cast<void*>(module_base), "luaL_loadbufferx"),
reinterpret_cast<void*>(&load_bufferx_hook) reinterpret_cast<void*>(&load_bufferx_hook)
); );
}); });
// these hooks can be registered at anytime.
fopen_ptr = dlsym(dlopen("libc.so", RTLD_NOLOAD), "fopen"); fopen_ptr = dlsym(dlopen("libc.so", RTLD_NOLOAD), "fopen");
dlopen_ptr = dlsym(dlopen("libdl.so", RTLD_NOLOAD), "dlopen"); dlopen_ptr = dlsym(dlopen("libdl.so", RTLD_NOLOAD), "dlopen");
system_prop_get = dlsym(dlopen("libc.so", RTLD_NOLOAD), "__system_property_get"); system_prop_get = dlsym(dlopen("libc.so", RTLD_NOLOAD), "__system_property_get");
@ -80,8 +78,8 @@ namespace ligma
{ {
if (strstr(filename, file_key.c_str())) if (strstr(filename, file_key.c_str()))
{ {
callback(reinterpret_cast<std::uintptr_t>(result));
ligma::utils::get_callbacks()->erase(file_key); ligma::utils::get_callbacks()->erase(file_key);
callback(reinterpret_cast<std::uintptr_t>(result));
break; break;
} }
} }

@ -37,6 +37,7 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="bypass\bypass.cpp" /> <ClCompile Include="bypass\bypass.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="SDK\Il2Cpp\Il2Cpp.cpp" />
<ClCompile Include="utils\utils.cpp" /> <ClCompile Include="utils\utils.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -44,6 +45,8 @@
<ClInclude Include="hooks\got_hook.h" /> <ClInclude Include="hooks\got_hook.h" />
<ClInclude Include="hooks\shithook.h" /> <ClInclude Include="hooks\shithook.h" />
<ClInclude Include="ligma.h" /> <ClInclude Include="ligma.h" />
<ClInclude Include="SDK\Il2Cpp\Il2Cpp.h" />
<ClInclude Include="SDK\Il2Cpp\Il2CppType.h" />
<ClInclude Include="utils\utils.h" /> <ClInclude Include="utils\utils.h" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
@ -125,10 +128,10 @@
<ImportGroup Label="PropertySheets" /> <ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>$(IncludePath)</IncludePath> <IncludePath>C:\Users\interesting\Desktop\codm\ligma-cheat\ligma-cheat\SDK;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(IncludePath)</IncludePath> <IncludePath>C:\Users\interesting\Desktop\codm\ligma-cheat\ligma-cheat\SDK;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<IncludePath>$(IncludePath)</IncludePath> <IncludePath>$(IncludePath)</IncludePath>
@ -143,10 +146,10 @@
<IncludePath>$(IncludePath)</IncludePath> <IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<IncludePath>$(IncludePath)</IncludePath> <IncludePath>C:\Users\interesting\Desktop\codm\ligma-cheat\ligma-cheat\SDK;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<IncludePath>$(IncludePath)</IncludePath> <IncludePath>C:\Users\interesting\Desktop\codm\ligma-cheat\ligma-cheat\SDK;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>

@ -33,6 +33,7 @@
<ClCompile Include="utils\utils.cpp"> <ClCompile Include="utils\utils.cpp">
<Filter>source\utils</Filter> <Filter>source\utils</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="SDK\Il2Cpp\Il2Cpp.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="bypass\bypass.h"> <ClInclude Include="bypass\bypass.h">
@ -50,5 +51,7 @@
<ClInclude Include="ligma.h"> <ClInclude Include="ligma.h">
<Filter>headers</Filter> <Filter>headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="SDK\Il2Cpp\Il2Cpp.h" />
<ClInclude Include="SDK\Il2Cpp\Il2CppType.h" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ShowAllFiles>false</ShowAllFiles> <ShowAllFiles>true</ShowAllFiles>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

@ -1,10 +1,30 @@
#include <thread>
#include "bypass/bypass.h" #include "bypass/bypass.h"
#include "SDK/Il2Cpp/Il2Cpp.h"
#include "SDK/Assembly-CSharp.dll/GameEngine.h"
#include "SDK/Assembly-CSharp.dll/GameBase.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/Component.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/Transform.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/Screen.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/Camera.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/Physics.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/RaycastHit.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/Object.h"
// just an example that this never gets called, ever
int get_localplayer_hook()
{
LOGI("=========== get local player called!!!! ===========");
return NULL;
}
__attribute__((constructor)) __attribute__((constructor))
void init() void init()
{ {
ligma::bypass::init([](const std::uintptr_t il2cpp_base) ligma::bypass::init([&](const std::uintptr_t il2cpp_base)
{ {
LOGI("il2cpp base address = %p", il2cpp_base); LOGI("il2cpp base address = %p", il2cpp_base);
ligma::hook::make_hook(reinterpret_cast<void*>(il2cpp_base + 0x36F2600), reinterpret_cast<void*>(&get_localplayer_hook));
}); });
} }
Loading…
Cancel
Save