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.

91 lines (90 loc) 3.81 kB
"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; }; Object.defineProperty(exports, "__esModule", { value: true }); exports._Il2CppGC = void 0; const api_1 = require("../api"); const decorators_1 = require("../decorators"); const array_1 = require("./array"); const memory_snapshot_1 = require("./memory-snapshot"); const object_1 = require("./object"); const string_1 = require("./string"); const type_enum_1 = require("./type-enum"); class _Il2CppGC { static collect(generation) { api_1.Api._gcCollect(generation); } static collectALittle() { api_1.Api._gcCollectALittle(); } static disable() { api_1.Api._gcDisable(); } static enable() { api_1.Api._gcEnable(); } static isDisabled() { return api_1.Api._gcIsDisabled(); } static choose(klass) { const isString = klass.type.typeEnum == type_enum_1._Il2CppTypeEnum.STRING; const isArray = klass.type.typeEnum == type_enum_1._Il2CppTypeEnum.SZARRAY; const matches = []; const callback = (objects, size, _) => { for (let i = 0; i < size; i++) { const pointer = objects.add(i * Process.pointerSize).readPointer(); if (isString) matches.push(new string_1._Il2CppString(pointer)); else if (isArray) matches.push(new array_1._Il2CppArray(pointer)); else matches.push(new Object(pointer)); } }; const chooseCallback = new NativeCallback(callback, "void", ["pointer", "int", "pointer"]); const onWorld = new NativeCallback(() => { }, "void", []); const state = api_1.Api._livenessCalculationBegin(klass.handle, 0, chooseCallback, NULL, onWorld, onWorld); api_1.Api._livenessCalculationFromStatics(state); api_1.Api._livenessCalculationEnd(state); return matches; } static choose2(klass) { const isString = klass.type.typeEnum == type_enum_1._Il2CppTypeEnum.STRING; const isArray = klass.type.typeEnum == type_enum_1._Il2CppTypeEnum.SZARRAY; const matches = []; const snapshot = new memory_snapshot_1._Il2CppMemorySnapshot(); const count = snapshot.trackedObjectCount.toNumber(); const start = snapshot.objectsPointer; for (let i = 0; i < count; i++) { const pointer = start.add(i * Process.pointerSize).readPointer(); const object = new object_1._Il2CppObject(pointer); if (object.class.handle.equals(klass.handle)) { if (isString) matches.push(new string_1._Il2CppString(pointer)); else if (isArray) matches.push(new array_1._Il2CppArray(pointer)); else matches.push(object); } } snapshot.free(); return matches; } } __decorate([ decorators_1.since("5.3.5") ], _Il2CppGC, "collectALittle", null); __decorate([ decorators_1.since("5.3.5") ], _Il2CppGC, "disable", null); __decorate([ decorators_1.since("5.3.5") ], _Il2CppGC, "enable", null); __decorate([ decorators_1.since("2018.3.0") ], _Il2CppGC, "isDisabled", null); exports._Il2CppGC = _Il2CppGC;