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.
107 lines (106 loc) • 3.8 kB
JavaScript
;
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports._Il2CppField = void 0;
const decorator_cache_getter_1 = require("decorator-cache-getter");
const console_1 = require("../../utils/console");
const api_1 = require("../api");
const decorators_1 = require("../decorators");
const native_struct_1 = require("../native-struct");
const utils_1 = require("../utils");
const class_1 = require("./class");
const type_1 = require("./type");
let _Il2CppField = class _Il2CppField extends native_struct_1.NativeStruct {
get class() {
return new class_1._Il2CppClass(api_1.Api._fieldGetClass(this.handle));
}
get isInstance() {
return api_1.Api._fieldIsInstance(this.handle);
}
get isLiteral() {
return api_1.Api._fieldIsLiteral(this.handle);
}
get isThreadStatic() {
return this.offset == -1;
}
get name() {
return api_1.Api._fieldGetName(this.handle);
}
get offset() {
return api_1.Api._fieldGetOffset(this.handle);
}
get type() {
return new type_1._Il2CppType(api_1.Api._fieldGetType(this.handle));
}
get value() {
return utils_1.readFieldValue(this.valueHandle, this.type);
}
set value(value) {
if (this.isThreadStatic || this.isLiteral) {
console_1.raise(`Cannot edit the thread static or literal field "${this.name}".`);
}
utils_1.writeFieldValue(this.valueHandle, value, this.type);
}
get valueHandle() {
let handle;
if (this.isThreadStatic || this.isLiteral) {
handle = Memory.alloc(Process.pointerSize);
api_1.Api._fieldGetStaticValue(this.handle, handle);
}
else {
handle = this.class.staticFieldsData.add(this.offset);
}
return handle;
}
asHeld(handle) {
const type = this.type;
return {
valueHandle: handle,
get value() {
return utils_1.readFieldValue(handle, type);
},
set value(value) {
utils_1.writeFieldValue(handle, value, type);
}
};
}
};
__decorate([
decorator_cache_getter_1.cache
], _Il2CppField.prototype, "class", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppField.prototype, "isInstance", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppField.prototype, "isLiteral", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppField.prototype, "isThreadStatic", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppField.prototype, "name", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppField.prototype, "offset", null);
__decorate([
decorator_cache_getter_1.cache
], _Il2CppField.prototype, "type", null);
__decorate([
decorators_1.shouldBeInstance(false)
], _Il2CppField.prototype, "value", null);
__decorate([
decorators_1.shouldBeInstance(false)
], _Il2CppField.prototype, "valueHandle", null);
__decorate([
decorators_1.shouldBeInstance(true)
], _Il2CppField.prototype, "asHeld", null);
_Il2CppField = __decorate([
decorators_1.nonNullHandle
], _Il2CppField);
exports._Il2CppField = _Il2CppField;