UNPKG

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.

66 lines (65 loc) 2.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.nonNullHandle = exports.checkOutOfBounds = exports.nonNullMethodPointer = exports.since = exports.shouldBeInstance = void 0; const console_1 = require("../utils/console"); const variables_1 = require("./variables"); function shouldBeInstance(shouldBeInstance) { return function (_, __, descriptor) { const fn = descriptor.value ?? descriptor.get ?? descriptor.set; const key = descriptor.value ? "value" : descriptor.get ? "get" : "set"; descriptor[key] = function (...args) { if (this.isInstance != shouldBeInstance) { console_1.raise(`${this.constructor.name} ("${this.name}") is ${shouldBeInstance ? "" : "not "}static.`); } return fn.apply(this, args); }; }; } exports.shouldBeInstance = shouldBeInstance; function since(version) { return function (_, propertyKey, descriptor) { const fn = descriptor.value ?? descriptor.get ?? descriptor.set; const key = descriptor.value ? "value" : descriptor.get ? "get" : "set"; descriptor[key] = function (...args) { if (variables_1.unityVersion.isBelow(version)) { console_1.raise(`${this.constructor.name}.${propertyKey.toString()} is available from version ${version} onwards.`); } return fn.apply(this, args); }; }; } exports.since = since; function nonNullMethodPointer(_, propertyKey, descriptor) { const fn = descriptor.value ?? descriptor.get ?? descriptor.set; const key = descriptor.value ? "value" : descriptor.get ? "get" : "set"; descriptor[key] = function (...args) { if (this.actualPointer.isNull()) { console_1.raise(`Can't ${propertyKey.toString()} method ${this.name} from ${this.class.type.name}: pointer is NULL.`); } return fn.apply(this, args); }; } exports.nonNullMethodPointer = nonNullMethodPointer; function checkOutOfBounds(_, __, descriptor) { const fn = descriptor.value; descriptor.value = function (...args) { const index = args[0]; if (index < 0 || index >= this.length) { console_1.raise(`${this.constructor.name} element index '${index}' out of bounds (length: ${this.length}).`); } return fn.apply(this, args); }; } exports.checkOutOfBounds = checkOutOfBounds; function nonNullHandle(Class) { return new Proxy(Class, { construct(Class, args) { const constructed = new Class(...args); if (constructed.handle.isNull()) { console_1.raise(`Handle for "${Class.name}" cannot be NULL.`); } return constructed; } }); } exports.nonNullHandle = nonNullHandle;