frida-il2cpp-bridge-my
Version:
(my:Support IOS)Frida module to dump, manipulate and hijack any IL2CPP application at runtime with a high level of abstraction.
247 lines (246 loc) • 9.13 kB
JavaScript
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var _Il2CppClass_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports._Il2CppClass = void 0;
const decorator_cache_getter_1 = require("decorator-cache-getter");
const accessor_1 = require("../../utils/accessor");
const api_1 = require("../api");
const decorators_1 = require("../decorators");
const native_struct_1 = require("../native-struct");
const utils_1 = require("../utils");
const field_1 = require("./field");
const generic_class_1 = require("./generic-class");
const image_1 = require("./image");
const method_1 = require("./method");
const type_1 = require("./type");
const type_enum_1 = require("./type-enum");
let _Il2CppClass = _Il2CppClass_1 = class _Il2CppClass extends native_struct_1.NativeStruct {
get arrayClass() {
return new _Il2CppClass_1(api_1.Api._classGetArrayClass(this.handle, 1));
}
get arrayElementSize() {
return api_1.Api._classGetArrayElementSize(this.handle);
}
get assemblyName() {
return api_1.Api._classGetAssemblyName(this.handle);
}
get declaringClass() {
return utils_1.getOrNull(api_1.Api._classGetDeclaringType(this.handle), _Il2CppClass_1);
}
get elementClass() {
return utils_1.getOrNull(api_1.Api._classGetElementClass(this.handle), _Il2CppClass_1);
}
get fieldCount() {
return api_1.Api._classGetFieldCount(this.handle);
}
get fields() {
const iterator = Memory.alloc(Process.pointerSize);
const accessor = new accessor_1.Accessor();
let handle;
let field;
while (!(handle = api_1.Api._classGetFields(this.handle, iterator)).isNull()) {
field = new field_1._Il2CppField(handle);
accessor[field.name] = field;
}
return accessor;
}
get genericClass() {
return utils_1.getOrNull(api_1.Api._classGetGenericClass(this.handle), generic_class_1._Il2CppGenericClass);
}
get hasStaticConstructor() {
return api_1.Api._classHasStaticConstructor(this.handle);
}
get image() {
return new image_1._Il2CppImage(api_1.Api._classGetImage(this.handle));
}
get instanceSize() {
return api_1.Api._classGetInstanceSize(this.handle);
}
get isEnum() {
return api_1.Api._classIsEnum(this.handle);
}
get isInterface() {
return api_1.Api._classIsInterface(this.handle);
}
get isStaticConstructorFinished() {
return api_1.Api._classIsStaticConstructorFinished(this.handle);
}
get isStruct() {
return api_1.Api._classIsStruct(this.handle) && !this.isEnum;
}
get interfaceCount() {
return api_1.Api._classGetInterfaceCount(this.handle);
}
get interfaces() {
const iterator = Memory.alloc(Process.pointerSize);
const accessor = new accessor_1.Accessor();
let handle;
let klass;
while (!(handle = api_1.Api._classGetInterfaces(this.handle, iterator)).isNull()) {
klass = new _Il2CppClass_1(handle);
accessor[klass.type.name] = klass;
}
return accessor;
}
get methodCount() {
return api_1.Api._classGetMethodCount(this.handle);
}
get methods() {
const iterator = Memory.alloc(Process.pointerSize);
const accessor = new accessor_1.Accessor(true);
let handle;
let method;
while (!(handle = api_1.Api._classGetMethods(this.handle, iterator)).isNull()) {
method = new method_1._Il2CppMethod(handle);
accessor[method.name] = method;
}
return accessor;
}
get name() {
return api_1.Api._classGetName(this.handle);
}
get namespace() {
return api_1.Api._classGetNamespace(this.handle);
}
get parent() {
return utils_1.getOrNull(api_1.Api._classGetParent(this.handle), _Il2CppClass_1);
}
get staticFieldsData() {
return api_1.Api._classGetStaticFieldData(this.handle);
}
get type() {
return new type_1._Il2CppType(api_1.Api._classGetType(this.handle));
}
ensureInitialized() {
api_1.Api._classInit(this.handle);
}
trace() {
for (const method of this.methods)
method.trace();
}
toString() {
const spacer = "\n ";
let text = "// " + this.image.name + "\n";
text += this.isEnum ? "enum" : this.isStruct ? "struct" : this.isInterface ? "interface" : "class";
text += " " + this.type.name;
if (this.parent != null || this.interfaceCount > 0)
text += " : ";
if (this.parent != null) {
text += this.parent.type.name;
if (this.interfaceCount > 0)
text += ", ";
}
if (this.interfaceCount > 0)
text += Object.keys(this.interfaces).join(", ");
text += "\n{";
for (const field of this.fields) {
text += spacer + (this.isEnum && field.name != "value__" ? "" : field.type.name + " ") + field.name;
if (field.isLiteral) {
text += " = ";
if (field.type.typeEnum == type_enum_1._Il2CppTypeEnum.STRING)
text += '"';
text += field.value;
if (field.type.typeEnum == type_enum_1._Il2CppTypeEnum.STRING)
text += '"';
}
text += this.isEnum && field.name != "value__" ? "," : "; // 0x" + field.offset.toString(16);
}
if (this.fieldCount + this.methodCount > 0)
text += "\n";
for (const method of this.methods) {
text += spacer;
if (!method.isInstance)
text += "static ";
text += method.returnType.name + " " + method.name + "(";
for (const parameter of method.parameters) {
if (parameter.position > 0)
text += ", ";
text += parameter.type.name + " " + parameter.name;
}
text += ");";
if (!method.actualPointer.isNull())
text += " // " + method.relativePointerAsString + ";";
}
text += "\n}\n\n";
return text;
}
};
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "arrayClass", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "arrayElementSize", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "assemblyName", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "declaringClass", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "elementClass", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "fieldCount", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "fields", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "genericClass", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "hasStaticConstructor", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "image", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "instanceSize", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "isEnum", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "isInterface", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "isStruct", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "interfaceCount", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "interfaces", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "methodCount", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "methods", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "name", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "namespace", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "parent", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "staticFieldsData", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppClass.prototype, "type", null);
_Il2CppClass = _Il2CppClass_1 = __decorate([
decorators_1.nonNullHandle
], _Il2CppClass);
exports._Il2CppClass = _Il2CppClass;