Advertisement
emieylea

GuardianTales

Mar 1st, 2023
1,387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 170.50 KB | Source Code | 0 0
  1. (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. (function (setImmediate){(function (){
  3. "use strict";
  4. Object.defineProperty(exports, "__esModule", { value: true });
  5. require("frida-il2cpp-bridge");
  6. const main_1 = require("./main");
  7. setImmediate(main_1.start);
  8. }).call(this)}).call(this,require("timers").setImmediate)
  9.  
  10. },{"./main":2,"frida-il2cpp-bridge":31,"timers":37}],2:[function(require,module,exports){
  11. "use strict";
  12. Object.defineProperty(exports, "__esModule", { value: true });
  13. exports.start = void 0;
  14. function start() {
  15.     var lea_multidamage = false;
  16.     var lea_damage = 10;
  17.     var lea_multidefence = false;
  18.     var lea_defence = 10;
  19.     var lea_dash = false;
  20.     if (typeof common != 'undefined') {
  21.         common.modmenu('Guardian Tales', [
  22.             {
  23.                 'id': '9001',
  24.                 'type': 'webview',
  25.                 'data': '<center><p style="color: white;line-height: 18px;"><b>BaALッ</b></p></center>',
  26.             },
  27.             {
  28.                 'id': 'multidamage',
  29.                 'type': 'switch',
  30.                 'title': 'Multiply Damage',
  31.                 'enable': lea_multidamage
  32.             },
  33.             {
  34.                 'id': 'damage',
  35.                 'type': 'input',
  36.                 'title': 'Damage',
  37.                 'val': lea_damage
  38.             },
  39.             {
  40.                 'id': 'multidefence',
  41.                 'type': 'switch',
  42.                 'title': 'Multiply Defence',
  43.                 'enable': lea_multidefence
  44.             },
  45.             {
  46.                 'id': 'defence',
  47.                 'type': 'input',
  48.                 'title': 'Multiple Defence',
  49.                 'val': lea_defence
  50.             },
  51.             {
  52.                 'id': 'fastdash',
  53.                 'type': 'switch',
  54.                 'title': 'Fast Dash',
  55.                 'enable': lea_dash
  56.             }
  57.         ], function (data) {
  58.             switch (data.id) {
  59.                 case 'multidamage':
  60.                     lea_multidamage = data.val;
  61.                     break;
  62.                 case 'damage':
  63.                     lea_damage = parseInt(data.val);
  64.                     break;
  65.                 case 'multidefence':
  66.                     lea_multidefence = data.val;
  67.                     break;
  68.                 case 'defence':
  69.                     lea_defence = parseInt(data.val);
  70.                     break;
  71.                 case 'fastdash':
  72.                     lea_dash = data.val;
  73.                     break;
  74.                 default:
  75.                     common.toast("Nothing Happen");
  76.             }
  77.         });
  78.     }
  79.     Il2Cpp.perform(() => {
  80.         console.log(Il2Cpp.unityVersion);
  81.         var lib = Il2Cpp.Domain.assembly("Assembly-CSharp").image;
  82.         let lib2 = Il2Cpp.Domain.assembly("Scripts").image;
  83.  
  84.        
  85.  
  86.         lib2.class("Oak.DamageCalculator").method("GetDamage").implementation = function(damage, target, elementalType, damageType, targetOptionModifier, damageModifier, useHighestBoost, ignoreImmunePer){
  87.             var entity = target.method("get_EntityGroup").invoke();
  88.             if(entity == "Player0"){
  89.                 if(lea_multidefence == true){
  90.                     damage = damage / lea_defence;
  91.                 }
  92.             }else if(entity != "Player0"){
  93.                 if(lea_multidamage == true){
  94.                     damage = damage * lea_damage;
  95.                 }
  96.             }
  97.             return this.method("GetDamage").invoke(damage, target, elementalType, damageType, targetOptionModifier, damageModifier, useHighestBoost, ignoreImmunePer);
  98.         }
  99.  
  100.        
  101.  
  102.         lib2.class("Oak.CharacterStatsBehaviour").method("get_DashSpeed").implementation = function(){
  103.             let entity2 = this.field("character").value;
  104.             var entity = entity2.method("get_EntityGroup").invoke();
  105.             if(entity == "Player0"){
  106.                 if(lea_dash == true){
  107.                     return 20;
  108.                 }
  109.             }
  110.             return this.method("get_DashSpeed").invoke();
  111.         }
  112.  
  113.         lib2.class("Oak.CharacterStatsBehaviour").method("get_SoftDashSpeed").implementation = function(){
  114.             let entity2 = this.field("character").value;
  115.             var entity = entity2.method("get_EntityGroup").invoke();
  116.             if(entity == "Player0"){
  117.                 if(lea_dash == true){
  118.                     return 20;
  119.                 }
  120.             }
  121.             return this.method("get_SoftDashSpeed").invoke();
  122.         }
  123.         lib2.class("Oak.CharacterStatsBehaviour").method("get_KnockBackDefense").implementation = function(){
  124.             let entity2 = this.field("character").value;
  125.             var entity = entity2.method("get_EntityGroup").invoke();
  126.             if(entity == "Player0"){
  127.                 if(lea_multidefence == true){
  128.                     return 9999;
  129.                 }
  130.             }
  131.             return this.method("get_KnockBackDefense").invoke();
  132.         }
  133.         lib2.class("Oak.CharacterStatsBehaviour").method("get_StunDefense").implementation = function(){
  134.             let entity2 = this.field("character").value;
  135.             var entity = entity2.method("get_EntityGroup").invoke();
  136.             if(entity == "Player0"){
  137.                 if(lea_multidefence == true){
  138.                     return 9999;
  139.                 }
  140.             }
  141.             return this.method("get_StunDefense").invoke();
  142.         }
  143.  
  144.         var target1 = lib2.class('Oak.DamageCalculator').method('GetDamage');
  145.         //Il2Cpp.trace().methods(target1).and().attach("detailed");
  146.  
  147.     });
  148. }
  149. exports.start = start;
  150. },{}],3:[function(require,module,exports){
  151. "use strict";
  152. Object.defineProperty(exports, "__esModule", { value: true });
  153. ;
  154. function cache(target, name, descriptor) {
  155.     var getter = descriptor.get;
  156.     if (!getter)
  157.         throw new TypeError("Getter property descriptor expected");
  158.     descriptor.get = function () {
  159.         var value = getter.call(this);
  160.         Object.defineProperty(this, name, {
  161.             configurable: descriptor.configurable,
  162.             enumerable: descriptor.enumerable,
  163.             writable: false,
  164.             value: value
  165.         });
  166.         return value;
  167.     };
  168. }
  169. exports.cache = cache;
  170.  
  171. },{}],4:[function(require,module,exports){
  172. "use strict";
  173. exports.__esModule = true;
  174. exports.distance = exports.closest = void 0;
  175. var peq = new Uint32Array(0x10000);
  176. var myers_32 = function (a, b) {
  177.     var n = a.length;
  178.     var m = b.length;
  179.     var lst = 1 << (n - 1);
  180.     var pv = -1;
  181.     var mv = 0;
  182.     var sc = n;
  183.     var i = n;
  184.     while (i--) {
  185.         peq[a.charCodeAt(i)] |= 1 << i;
  186.     }
  187.     for (i = 0; i < m; i++) {
  188.         var eq = peq[b.charCodeAt(i)];
  189.         var xv = eq | mv;
  190.         eq |= ((eq & pv) + pv) ^ pv;
  191.         mv |= ~(eq | pv);
  192.         pv &= eq;
  193.         if (mv & lst) {
  194.             sc++;
  195.         }
  196.         if (pv & lst) {
  197.             sc--;
  198.         }
  199.         mv = (mv << 1) | 1;
  200.         pv = (pv << 1) | ~(xv | mv);
  201.         mv &= xv;
  202.     }
  203.     i = n;
  204.     while (i--) {
  205.         peq[a.charCodeAt(i)] = 0;
  206.     }
  207.     return sc;
  208. };
  209. var myers_x = function (b, a) {
  210.     var n = a.length;
  211.     var m = b.length;
  212.     var mhc = [];
  213.     var phc = [];
  214.     var hsize = Math.ceil(n / 32);
  215.     var vsize = Math.ceil(m / 32);
  216.     for (var i = 0; i < hsize; i++) {
  217.         phc[i] = -1;
  218.         mhc[i] = 0;
  219.     }
  220.     var j = 0;
  221.     for (; j < vsize - 1; j++) {
  222.         var mv_1 = 0;
  223.         var pv_1 = -1;
  224.         var start_1 = j * 32;
  225.         var vlen_1 = Math.min(32, m) + start_1;
  226.         for (var k = start_1; k < vlen_1; k++) {
  227.             peq[b.charCodeAt(k)] |= 1 << k;
  228.         }
  229.         for (var i = 0; i < n; i++) {
  230.             var eq = peq[a.charCodeAt(i)];
  231.             var pb = (phc[(i / 32) | 0] >>> i) & 1;
  232.             var mb = (mhc[(i / 32) | 0] >>> i) & 1;
  233.             var xv = eq | mv_1;
  234.             var xh = ((((eq | mb) & pv_1) + pv_1) ^ pv_1) | eq | mb;
  235.             var ph = mv_1 | ~(xh | pv_1);
  236.             var mh = pv_1 & xh;
  237.             if ((ph >>> 31) ^ pb) {
  238.                 phc[(i / 32) | 0] ^= 1 << i;
  239.             }
  240.             if ((mh >>> 31) ^ mb) {
  241.                 mhc[(i / 32) | 0] ^= 1 << i;
  242.             }
  243.             ph = (ph << 1) | pb;
  244.             mh = (mh << 1) | mb;
  245.             pv_1 = mh | ~(xv | ph);
  246.             mv_1 = ph & xv;
  247.         }
  248.         for (var k = start_1; k < vlen_1; k++) {
  249.             peq[b.charCodeAt(k)] = 0;
  250.         }
  251.     }
  252.     var mv = 0;
  253.     var pv = -1;
  254.     var start = j * 32;
  255.     var vlen = Math.min(32, m - start) + start;
  256.     for (var k = start; k < vlen; k++) {
  257.         peq[b.charCodeAt(k)] |= 1 << k;
  258.     }
  259.     var score = m;
  260.     for (var i = 0; i < n; i++) {
  261.         var eq = peq[a.charCodeAt(i)];
  262.         var pb = (phc[(i / 32) | 0] >>> i) & 1;
  263.         var mb = (mhc[(i / 32) | 0] >>> i) & 1;
  264.         var xv = eq | mv;
  265.         var xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb;
  266.         var ph = mv | ~(xh | pv);
  267.         var mh = pv & xh;
  268.         score += (ph >>> (m - 1)) & 1;
  269.         score -= (mh >>> (m - 1)) & 1;
  270.         if ((ph >>> 31) ^ pb) {
  271.             phc[(i / 32) | 0] ^= 1 << i;
  272.         }
  273.         if ((mh >>> 31) ^ mb) {
  274.             mhc[(i / 32) | 0] ^= 1 << i;
  275.         }
  276.         ph = (ph << 1) | pb;
  277.         mh = (mh << 1) | mb;
  278.         pv = mh | ~(xv | ph);
  279.         mv = ph & xv;
  280.     }
  281.     for (var k = start; k < vlen; k++) {
  282.         peq[b.charCodeAt(k)] = 0;
  283.     }
  284.     return score;
  285. };
  286. var distance = function (a, b) {
  287.     if (a.length < b.length) {
  288.         var tmp = b;
  289.         b = a;
  290.         a = tmp;
  291.     }
  292.     if (b.length === 0) {
  293.         return a.length;
  294.     }
  295.     if (a.length <= 32) {
  296.         return myers_32(a, b);
  297.     }
  298.     return myers_x(a, b);
  299. };
  300. exports.distance = distance;
  301. var closest = function (str, arr) {
  302.     var min_distance = Infinity;
  303.     var min_index = 0;
  304.     for (var i = 0; i < arr.length; i++) {
  305.         var dist = distance(str, arr[i]);
  306.         if (dist < min_distance) {
  307.             min_distance = dist;
  308.             min_index = i;
  309.         }
  310.     }
  311.     return arr[min_index];
  312. };
  313. exports.closest = closest;
  314.  
  315. },{}],5:[function(require,module,exports){
  316. "use strict";
  317. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  318.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  319.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  320.     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;
  321.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  322. };
  323. var __importDefault = (this && this.__importDefault) || function (mod) {
  324.     return (mod && mod.__esModule) ? mod : { "default": mod };
  325. };
  326. Object.defineProperty(exports, "__esModule", { value: true });
  327. const decorator_cache_getter_1 = require("decorator-cache-getter");
  328. const versioning_1 = __importDefault(require("versioning"));
  329. const console_1 = require("../utils/console");
  330. class Il2CppApi {
  331.     constructor() { }
  332.     static get _alloc() {
  333.         return this.r("il2cpp_alloc", "pointer", ["size_t"]);
  334.     }
  335.     static get _arrayGetElements() {
  336.         return this.r("il2cpp_array_get_elements", "pointer", ["pointer"]);
  337.     }
  338.     static get _arrayGetLength() {
  339.         return this.r("il2cpp_array_length", "uint32", ["pointer"]);
  340.     }
  341.     static get _arrayNew() {
  342.         return this.r("il2cpp_array_new", "pointer", ["pointer", "uint32"]);
  343.     }
  344.     static get _assemblyGetImage() {
  345.         return this.r("il2cpp_assembly_get_image", "pointer", ["pointer"]);
  346.     }
  347.     static get _classForEach() {
  348.         return this.r("il2cpp_class_for_each", "void", ["pointer", "pointer"]);
  349.     }
  350.     static get _classFromName() {
  351.         return this.r("il2cpp_class_from_name", "pointer", ["pointer", "pointer", "pointer"]);
  352.     }
  353.     static get _classFromSystemType() {
  354.         return this.r("il2cpp_class_from_system_type", "pointer", ["pointer"]);
  355.     }
  356.     static get _classFromType() {
  357.         return this.r("il2cpp_class_from_type", "pointer", ["pointer"]);
  358.     }
  359.     static get _classGetActualInstanceSize() {
  360.         return this.r("il2cpp_class_get_actual_instance_size", "int32", ["pointer"]);
  361.     }
  362.     static get _classGetArrayClass() {
  363.         return this.r("il2cpp_array_class_get", "pointer", ["pointer", "uint32"]);
  364.     }
  365.     static get _classGetArrayElementSize() {
  366.         return this.r("il2cpp_class_array_element_size", "int", ["pointer"]);
  367.     }
  368.     static get _classGetAssemblyName() {
  369.         return this.r("il2cpp_class_get_assemblyname", "pointer", ["pointer"]);
  370.     }
  371.     static get _classGetBaseType() {
  372.         return this.r("il2cpp_class_enum_basetype", "pointer", ["pointer"]);
  373.     }
  374.     static get _classGetDeclaringType() {
  375.         return this.r("il2cpp_class_get_declaring_type", "pointer", ["pointer"]);
  376.     }
  377.     static get _classGetElementClass() {
  378.         return this.r("il2cpp_class_get_element_class", "pointer", ["pointer"]);
  379.     }
  380.     static get _classGetFieldFromName() {
  381.         return this.r("il2cpp_class_get_field_from_name", "pointer", ["pointer", "pointer"]);
  382.     }
  383.     static get _classGetFields() {
  384.         return this.r("il2cpp_class_get_fields", "pointer", ["pointer", "pointer"]);
  385.     }
  386.     static get _classGetFlags() {
  387.         return this.r("il2cpp_class_get_flags", "int", ["pointer"]);
  388.     }
  389.     static get _classGetImage() {
  390.         return this.r("il2cpp_class_get_image", "pointer", ["pointer"]);
  391.     }
  392.     static get _classGetInstanceSize() {
  393.         return this.r("il2cpp_class_instance_size", "int32", ["pointer"]);
  394.     }
  395.     static get _classGetInterfaces() {
  396.         return this.r("il2cpp_class_get_interfaces", "pointer", ["pointer", "pointer"]);
  397.     }
  398.     static get _classGetMethodFromName() {
  399.         return this.r("il2cpp_class_get_method_from_name", "pointer", ["pointer", "pointer", "int"]);
  400.     }
  401.     static get _classGetMethods() {
  402.         return this.r("il2cpp_class_get_methods", "pointer", ["pointer", "pointer"]);
  403.     }
  404.     static get _classGetName() {
  405.         return this.r("il2cpp_class_get_name", "pointer", ["pointer"]);
  406.     }
  407.     static get _classGetNamespace() {
  408.         return this.r("il2cpp_class_get_namespace", "pointer", ["pointer"]);
  409.     }
  410.     static get _classGetNestedClasses() {
  411.         return this.r("il2cpp_class_get_nested_types", "pointer", ["pointer", "pointer"]);
  412.     }
  413.     static get _classGetParent() {
  414.         return this.r("il2cpp_class_get_parent", "pointer", ["pointer"]);
  415.     }
  416.     static get _classGetRank() {
  417.         return this.r("il2cpp_class_get_rank", "int", ["pointer"]);
  418.     }
  419.     static get _classGetStaticFieldData() {
  420.         return this.r("il2cpp_class_get_static_field_data", "pointer", ["pointer"]);
  421.     }
  422.     static get _classGetValueSize() {
  423.         return this.r("il2cpp_class_value_size", "int32", ["pointer", "pointer"]);
  424.     }
  425.     static get _classGetType() {
  426.         return this.r("il2cpp_class_get_type", "pointer", ["pointer"]);
  427.     }
  428.     static get _classHasReferences() {
  429.         return this.r("il2cpp_class_has_references", "bool", ["pointer"]);
  430.     }
  431.     static get _classInit() {
  432.         return this.r("il2cpp_runtime_class_init", "void", ["pointer"]);
  433.     }
  434.     static get _classIsAbstract() {
  435.         return this.r("il2cpp_class_is_abstract", "bool", ["pointer"]);
  436.     }
  437.     static get _classIsAssignableFrom() {
  438.         return this.r("il2cpp_class_is_assignable_from", "bool", ["pointer", "pointer"]);
  439.     }
  440.     static get _classIsBlittable() {
  441.         return this.r("il2cpp_class_is_blittable", "bool", ["pointer"]);
  442.     }
  443.     static get _classIsEnum() {
  444.         return this.r("il2cpp_class_is_enum", "bool", ["pointer"]);
  445.     }
  446.     static get _classIsGeneric() {
  447.         return this.r("il2cpp_class_is_generic", "bool", ["pointer"]);
  448.     }
  449.     static get _classIsInflated() {
  450.         return this.r("il2cpp_class_is_inflated", "bool", ["pointer"]);
  451.     }
  452.     static get _classIsInterface() {
  453.         return this.r("il2cpp_class_is_interface", "bool", ["pointer"]);
  454.     }
  455.     static get _classIsSubclassOf() {
  456.         return this.r("il2cpp_class_is_subclass_of", "bool", ["pointer", "pointer", "bool"]);
  457.     }
  458.     static get _classIsValueType() {
  459.         return this.r("il2cpp_class_is_valuetype", "bool", ["pointer"]);
  460.     }
  461.     static get _domainAssemblyOpen() {
  462.         return this.r("il2cpp_domain_assembly_open", "pointer", ["pointer", "pointer"]);
  463.     }
  464.     static get _domainGet() {
  465.         return this.r("il2cpp_domain_get", "pointer", []);
  466.     }
  467.     static get _domainGetAssemblies() {
  468.         return this.r("il2cpp_domain_get_assemblies", "pointer", ["pointer", "pointer"]);
  469.     }
  470.     static get _fieldGetModifier() {
  471.         return this.r("il2cpp_field_get_modifier", "pointer", ["pointer"]);
  472.     }
  473.     static get _fieldGetClass() {
  474.         return this.r("il2cpp_field_get_parent", "pointer", ["pointer"]);
  475.     }
  476.     static get _fieldGetFlags() {
  477.         return this.r("il2cpp_field_get_flags", "int", ["pointer"]);
  478.     }
  479.     static get _fieldGetName() {
  480.         return this.r("il2cpp_field_get_name", "pointer", ["pointer"]);
  481.     }
  482.     static get _fieldGetOffset() {
  483.         return this.r("il2cpp_field_get_offset", "int32", ["pointer"]);
  484.     }
  485.     static get _fieldGetStaticValue() {
  486.         return this.r("il2cpp_field_static_get_value", "void", ["pointer", "pointer"]);
  487.     }
  488.     static get _fieldGetType() {
  489.         return this.r("il2cpp_field_get_type", "pointer", ["pointer"]);
  490.     }
  491.     static get _fieldIsLiteral() {
  492.         return this.r("il2cpp_field_is_literal", "bool", ["pointer"]);
  493.     }
  494.     static get _fieldIsStatic() {
  495.         return this.r("il2cpp_field_is_static", "bool", ["pointer"]);
  496.     }
  497.     static get _fieldIsThreadStatic() {
  498.         return this.r("il2cpp_field_is_thread_static", "bool", ["pointer"]);
  499.     }
  500.     static get _fieldSetStaticValue() {
  501.         return this.r("il2cpp_field_static_set_value", "void", ["pointer", "pointer"]);
  502.     }
  503.     static get _free() {
  504.         return this.r("il2cpp_free", "void", ["pointer"]);
  505.     }
  506.     static get _gcCollect() {
  507.         return this.r("il2cpp_gc_collect", "void", ["int"]);
  508.     }
  509.     static get _gcCollectALittle() {
  510.         return this.r("il2cpp_gc_collect_a_little", "void", []);
  511.     }
  512.     static get _gcDisable() {
  513.         return this.r("il2cpp_gc_disable", "void", []);
  514.     }
  515.     static get _gcEnable() {
  516.         return this.r("il2cpp_gc_enable", "void", []);
  517.     }
  518.     static get _gcGetHeapSize() {
  519.         return this.r("il2cpp_gc_get_heap_size", "int64", []);
  520.     }
  521.     static get _gcGetMaxTimeSlice() {
  522.         return this.r("il2cpp_gc_get_max_time_slice_ns", "int64", []);
  523.     }
  524.     static get _gcGetUsedSize() {
  525.         return this.r("il2cpp_gc_get_used_size", "int64", []);
  526.     }
  527.     static get _gcHandleGetTarget() {
  528.         return this.r("il2cpp_gchandle_get_target", "pointer", ["uint32"]);
  529.     }
  530.     static get _gcHandleFree() {
  531.         return this.r("il2cpp_gchandle_free", "void", ["uint32"]);
  532.     }
  533.     static get _gcHandleNew() {
  534.         return this.r("il2cpp_gchandle_new", "uint32", ["pointer", "bool"]);
  535.     }
  536.     static get _gcHandleNewWeakRef() {
  537.         return this.r("il2cpp_gchandle_new_weakref", "uint32", ["pointer", "bool"]);
  538.     }
  539.     static get _gcIsDisabled() {
  540.         return this.r("il2cpp_gc_is_disabled", "bool", []);
  541.     }
  542.     static get _gcIsIncremental() {
  543.         return this.r("il2cpp_gc_is_incremental", "bool", []);
  544.     }
  545.     static get _gcSetMaxTimeSlice() {
  546.         return this.r("il2cpp_gc_set_max_time_slice_ns", "void", ["int64"]);
  547.     }
  548.     static get _gcStartIncrementalCollection() {
  549.         return this.r("il2cpp_gc_start_incremental_collection", "void", []);
  550.     }
  551.     static get _gcStartWorld() {
  552.         return this.r("il2cpp_start_gc_world", "void", []);
  553.     }
  554.     static get _gcStopWorld() {
  555.         return this.r("il2cpp_stop_gc_world", "void", []);
  556.     }
  557.     static get _getCorlib() {
  558.         return this.r("il2cpp_get_corlib", "pointer", []);
  559.     }
  560.     static get _imageGetAssembly() {
  561.         return this.r("il2cpp_image_get_assembly", "pointer", ["pointer"]);
  562.     }
  563.     static get _imageGetClass() {
  564.         return this.r("il2cpp_image_get_class", "pointer", ["pointer", "uint"]);
  565.     }
  566.     static get _imageGetClassCount() {
  567.         return this.r("il2cpp_image_get_class_count", "uint32", ["pointer"]);
  568.     }
  569.     static get _imageGetName() {
  570.         return this.r("il2cpp_image_get_name", "pointer", ["pointer"]);
  571.     }
  572.     static get _init() {
  573.         return this.r("il2cpp_init", "void", []);
  574.     }
  575.     static get _livenessAllocateStruct() {
  576.         return this.r("il2cpp_unity_liveness_allocate_struct", "pointer", ["pointer", "int", "pointer", "pointer", "pointer"]);
  577.     }
  578.     static get _livenessCalculationBegin() {
  579.         return this.r("il2cpp_unity_liveness_calculation_begin", "pointer", ["pointer", "int", "pointer", "pointer", "pointer", "pointer"]);
  580.     }
  581.     static get _livenessCalculationEnd() {
  582.         return this.r("il2cpp_unity_liveness_calculation_end", "void", ["pointer"]);
  583.     }
  584.     static get _livenessCalculationFromStatics() {
  585.         return this.r("il2cpp_unity_liveness_calculation_from_statics", "void", ["pointer"]);
  586.     }
  587.     static get _livenessFinalize() {
  588.         return this.r("il2cpp_unity_liveness_finalize", "void", ["pointer"]);
  589.     }
  590.     static get _livenessFreeStruct() {
  591.         return this.r("il2cpp_unity_liveness_free_struct", "void", ["pointer"]);
  592.     }
  593.     static get _memorySnapshotCapture() {
  594.         return this.r("il2cpp_capture_memory_snapshot", "pointer", []);
  595.     }
  596.     static get _memorySnapshotFree() {
  597.         return this.r("il2cpp_free_captured_memory_snapshot", "void", ["pointer"]);
  598.     }
  599.     static get _memorySnapshotGetClasses() {
  600.         return this.r("il2cpp_memory_snapshot_get_classes", "pointer", ["pointer", "pointer"]);
  601.     }
  602.     static get _memorySnapshotGetGCHandles() {
  603.         return this.r("il2cpp_memory_snapshot_get_gc_handles", ["uint32", "pointer"], ["pointer"]);
  604.     }
  605.     static get _memorySnapshotGetRuntimeInformation() {
  606.         return this.r("il2cpp_memory_snapshot_get_information", ["uint32", "uint32", "uint32", "uint32", "uint32", "uint32"], ["pointer"]);
  607.     }
  608.     static get _methodGetModifier() {
  609.         return this.r("il2cpp_method_get_modifier", "pointer", ["pointer"]);
  610.     }
  611.     static get _methodGetClass() {
  612.         return this.r("il2cpp_method_get_class", "pointer", ["pointer"]);
  613.     }
  614.     static get _methodGetFlags() {
  615.         return this.r("il2cpp_method_get_flags", "uint32", ["pointer", "pointer"]);
  616.     }
  617.     static get _methodGetFromReflection() {
  618.         return this.r("il2cpp_method_get_from_reflection", "pointer", ["pointer"]);
  619.     }
  620.     static get _methodGetName() {
  621.         return this.r("il2cpp_method_get_name", "pointer", ["pointer"]);
  622.     }
  623.     static get _methodGetObject() {
  624.         return this.r("il2cpp_method_get_object", "pointer", ["pointer", "pointer"]);
  625.     }
  626.     static get _methodGetParameterCount() {
  627.         return this.r("il2cpp_method_get_param_count", "uint8", ["pointer"]);
  628.     }
  629.     static get _methodGetParameterName() {
  630.         return this.r("il2cpp_method_get_param_name", "pointer", ["pointer", "uint32"]);
  631.     }
  632.     static get _methodGetParameters() {
  633.         return this.r("il2cpp_method_get_parameters", "pointer", ["pointer", "pointer"]);
  634.     }
  635.     static get _methodGetParameterType() {
  636.         return this.r("il2cpp_method_get_param", "pointer", ["pointer", "uint32"]);
  637.     }
  638.     static get _methodGetPointer() {
  639.         return this.r("il2cpp_method_get_pointer", "pointer", ["pointer"]);
  640.     }
  641.     static get _methodGetReturnType() {
  642.         return this.r("il2cpp_method_get_return_type", "pointer", ["pointer"]);
  643.     }
  644.     static get _methodIsExternal() {
  645.         return this.r("il2cpp_method_is_external", "bool", ["pointer"]);
  646.     }
  647.     static get _methodIsGeneric() {
  648.         return this.r("il2cpp_method_is_generic", "bool", ["pointer"]);
  649.     }
  650.     static get _methodIsInflated() {
  651.         return this.r("il2cpp_method_is_inflated", "bool", ["pointer"]);
  652.     }
  653.     static get _methodIsInstance() {
  654.         return this.r("il2cpp_method_is_instance", "bool", ["pointer"]);
  655.     }
  656.     static get _methodIsSynchronized() {
  657.         return this.r("il2cpp_method_is_synchronized", "bool", ["pointer"]);
  658.     }
  659.     static get _monitorEnter() {
  660.         return this.r("il2cpp_monitor_enter", "void", ["pointer"]);
  661.     }
  662.     static get _monitorExit() {
  663.         return this.r("il2cpp_monitor_exit", "void", ["pointer"]);
  664.     }
  665.     static get _monitorPulse() {
  666.         return this.r("il2cpp_monitor_pulse", "void", ["pointer"]);
  667.     }
  668.     static get _monitorPulseAll() {
  669.         return this.r("il2cpp_monitor_pulse_all", "void", ["pointer"]);
  670.     }
  671.     static get _monitorTryEnter() {
  672.         return this.r("il2cpp_monitor_try_enter", "bool", ["pointer", "uint32"]);
  673.     }
  674.     static get _monitorTryWait() {
  675.         return this.r("il2cpp_monitor_try_wait", "bool", ["pointer", "uint32"]);
  676.     }
  677.     static get _monitorWait() {
  678.         return this.r("il2cpp_monitor_wait", "void", ["pointer"]);
  679.     }
  680.     static get _objectGetClass() {
  681.         return this.r("il2cpp_object_get_class", "pointer", ["pointer"]);
  682.     }
  683.     static get _objectGetVirtualMethod() {
  684.         return this.r("il2cpp_object_get_virtual_method", "pointer", ["pointer", "pointer"]);
  685.     }
  686.     static get _objectInit() {
  687.         return this.r("il2cpp_runtime_object_init_exception", "void", ["pointer", "pointer"]);
  688.     }
  689.     static get _objectNew() {
  690.         return this.r("il2cpp_object_new", "pointer", ["pointer"]);
  691.     }
  692.     static get _objectGetSize() {
  693.         return this.r("il2cpp_object_get_size", "uint32", ["pointer"]);
  694.     }
  695.     static get _objectUnbox() {
  696.         return this.r("il2cpp_object_unbox", "pointer", ["pointer"]);
  697.     }
  698.     static get _resolveInternalCall() {
  699.         return this.r("il2cpp_resolve_icall", "pointer", ["pointer"]);
  700.     }
  701.     static get _stringChars() {
  702.         return this.r("il2cpp_string_chars", "pointer", ["pointer"]);
  703.     }
  704.     static get _stringLength() {
  705.         return this.r("il2cpp_string_length", "int32", ["pointer"]);
  706.     }
  707.     static get _stringNew() {
  708.         return this.r("il2cpp_string_new", "pointer", ["pointer"]);
  709.     }
  710.     static get _stringSetLength() {
  711.         return this.r("il2cpp_string_set_length", "void", ["pointer", "int32"]);
  712.     }
  713.     static get _valueBox() {
  714.         return this.r("il2cpp_value_box", "pointer", ["pointer", "pointer"]);
  715.     }
  716.     static get _threadAttach() {
  717.         return this.r("il2cpp_thread_attach", "pointer", ["pointer"]);
  718.     }
  719.     static get _threadCurrent() {
  720.         return this.r("il2cpp_thread_current", "pointer", []);
  721.     }
  722.     static get _threadGetAllAttachedThreads() {
  723.         return this.r("il2cpp_thread_get_all_attached_threads", "pointer", ["pointer"]);
  724.     }
  725.     static get _threadIsVm() {
  726.         return this.r("il2cpp_is_vm_thread", "bool", ["pointer"]);
  727.     }
  728.     static get _threadDetach() {
  729.         return this.r("il2cpp_thread_detach", "void", ["pointer"]);
  730.     }
  731.     static get _typeGetName() {
  732.         return this.r("il2cpp_type_get_name", "pointer", ["pointer"]);
  733.     }
  734.     static get _typeGetObject() {
  735.         return this.r("il2cpp_type_get_object", "pointer", ["pointer"]);
  736.     }
  737.     static get _typeGetTypeEnum() {
  738.         return this.r("il2cpp_type_get_type", "int", ["pointer"]);
  739.     }
  740.     static get _typeIsByReference() {
  741.         return this.r("il2cpp_type_is_byref", "bool", ["pointer"]);
  742.     }
  743.     static get _typeIsPrimitive() {
  744.         return this.r("il2cpp_type_is_primitive", "bool", ["pointer"]);
  745.     }
  746.     /** @internal */
  747.     static get cModule() {
  748.         if (versioning_1.default.lt(Il2Cpp.unityVersion, "5.3.0") || versioning_1.default.gte(Il2Cpp.unityVersion, "2022.2.0")) {
  749.             (0, console_1.warn)(`current Unity version ${Il2Cpp.unityVersion} is not supported, expect breakage`);
  750.         }
  751.         const offsetsFinderCModule = new CModule(`\
  752. #include <stdint.h>
  753.  
  754. #define OFFSET_OF(name, type) \
  755.     int16_t name (char * p,\
  756.                   type e)\
  757.     {\
  758.         for (int16_t i = 0; i < 512; i++) if (* ((type *) p + i) == e) return i;\
  759.         return -1;\
  760.     }
  761.  
  762. OFFSET_OF (offset_of_int32, int32_t)
  763. OFFSET_OF (offset_of_pointer, void *)
  764.             `);
  765.         const offsetOfInt32 = new NativeFunction(offsetsFinderCModule.offset_of_int32, "int16", ["pointer", "int32"]);
  766.         const offsetOfPointer = new NativeFunction(offsetsFinderCModule.offset_of_pointer, "int16", ["pointer", "pointer"]);
  767.         const SystemString = Il2Cpp.Image.corlib.class("System.String");
  768.         const SystemDateTime = Il2Cpp.Image.corlib.class("System.DateTime");
  769.         const SystemReflectionModule = Il2Cpp.Image.corlib.class("System.Reflection.Module");
  770.         SystemDateTime.initialize();
  771.         SystemReflectionModule.initialize();
  772.         const DaysToMonth365 = (SystemDateTime.tryField("daysmonth") ??
  773.             SystemDateTime.tryField("DaysToMonth365") ??
  774.             SystemDateTime.field("s_daysToMonth365")).value;
  775.         const FilterTypeName = SystemReflectionModule.field("FilterTypeName").value;
  776.         const FilterTypeNameMethodPointer = FilterTypeName.field("method_ptr").value;
  777.         const FilterTypeNameMethod = FilterTypeName.field("method").value;
  778.         const source = `\
  779. #include <stdint.h>
  780. #include <string.h>
  781.  
  782.  
  783. typedef struct _Il2CppObject Il2CppObject;
  784. typedef enum _Il2CppTypeEnum Il2CppTypeEnum;
  785. typedef struct _Il2CppReflectionMethod Il2CppReflectionMethod;
  786. typedef struct _Il2CppManagedMemorySnapshot Il2CppManagedMemorySnapshot;
  787. typedef struct _Il2CppMetadataType Il2CppMetadataType;
  788.  
  789.  
  790. struct _Il2CppObject
  791. {
  792.     void * class;
  793.     void * monitor;
  794. };
  795.  
  796. enum _Il2CppTypeEnum
  797. {
  798.     IL2CPP_TYPE_END = 0x00,
  799.     IL2CPP_TYPE_VOID = 0x01,
  800.     IL2CPP_TYPE_BOOLEAN = 0x02,
  801.     IL2CPP_TYPE_CHAR = 0x03,
  802.     IL2CPP_TYPE_I1 = 0x04,
  803.     IL2CPP_TYPE_U1 = 0x05,
  804.     IL2CPP_TYPE_I2 = 0x06,
  805.     IL2CPP_TYPE_U2 = 0x07,
  806.     IL2CPP_TYPE_I4 = 0x08,
  807.     IL2CPP_TYPE_U4 = 0x09,
  808.     IL2CPP_TYPE_I8 = 0x0a,
  809.     IL2CPP_TYPE_U8 = 0x0b,
  810.     IL2CPP_TYPE_R4 = 0x0c,
  811.     IL2CPP_TYPE_R8 = 0x0d,
  812.     IL2CPP_TYPE_STRING = 0x0e,
  813.     IL2CPP_TYPE_PTR = 0x0f,
  814.     IL2CPP_TYPE_BYREF = 0x10,
  815.     IL2CPP_TYPE_VALUETYPE = 0x11,
  816.     IL2CPP_TYPE_CLASS = 0x12,
  817.     IL2CPP_TYPE_VAR = 0x13,
  818.     IL2CPP_TYPE_ARRAY = 0x14,
  819.     IL2CPP_TYPE_GENERICINST = 0x15,
  820.     IL2CPP_TYPE_TYPEDBYREF = 0x16,
  821.     IL2CPP_TYPE_I = 0x18,
  822.     IL2CPP_TYPE_U = 0x19,
  823.     IL2CPP_TYPE_FNPTR = 0x1b,
  824.     IL2CPP_TYPE_OBJECT = 0x1c,
  825.     IL2CPP_TYPE_SZARRAY = 0x1d,
  826.     IL2CPP_TYPE_MVAR = 0x1e,
  827.     IL2CPP_TYPE_CMOD_REQD = 0x1f,
  828.     IL2CPP_TYPE_CMOD_OPT = 0x20,
  829.     IL2CPP_TYPE_INTERNAL = 0x21,
  830.     IL2CPP_TYPE_MODIFIER = 0x40,
  831.     IL2CPP_TYPE_SENTINEL = 0x41,
  832.     IL2CPP_TYPE_PINNED = 0x45,
  833.     IL2CPP_TYPE_ENUM = 0x55
  834. };
  835.  
  836. struct _Il2CppReflectionMethod
  837. {
  838.     Il2CppObject object;
  839.     void * method;
  840.     void * name;
  841.     void * reftype;
  842. };
  843.  
  844. struct _Il2CppManagedMemorySnapshot
  845. {
  846.     struct Il2CppManagedHeap
  847.     {
  848.         uint32_t section_count;
  849.         void * sections;
  850.     } heap;
  851.     struct Il2CppStacks
  852.     {
  853.         uint32_t stack_count;
  854.         void * stacks;
  855.     } stacks;
  856.     struct Il2CppMetadataSnapshot
  857.     {
  858.         uint32_t type_count;
  859.         Il2CppMetadataType * types;
  860.     } metadata_snapshot;
  861.     struct Il2CppGCHandles
  862.     {
  863.         uint32_t tracked_object_count;
  864.         Il2CppObject ** pointers_to_objects;
  865.     } gc_handles;
  866.     struct Il2CppRuntimeInformation
  867.     {
  868.         uint32_t pointer_size;
  869.         uint32_t object_header_size;
  870.         uint32_t array_header_size;
  871.         uint32_t array_bounds_offset_in_header;
  872.         uint32_t array_size_offset_in_header;
  873.         uint32_t allocation_granularity;
  874.     } runtime_information;
  875.     void * additional_user_information;
  876. };
  877.  
  878. struct _Il2CppMetadataType
  879. {
  880.     uint32_t flags;
  881.     void * fields;
  882.     uint32_t field_count;
  883.     uint32_t statics_size;
  884.     uint8_t * statics;
  885.     uint32_t base_or_element_type_index;
  886.     char * name;
  887.     const char * assembly_name;
  888.     uint64_t type_info_address;
  889.     uint32_t size;
  890. };
  891.  
  892.  
  893. #define THREAD_STATIC_FIELD_OFFSET -1;
  894.  
  895. #define FIELD_ATTRIBUTE_FIELD_ACCESS_MASK 0x0007
  896. #define FIELD_ATTRIBUTE_COMPILER_CONTROLLED 0x0000
  897. #define FIELD_ATTRIBUTE_PRIVATE 0x0001
  898. #define FIELD_ATTRIBUTE_FAM_AND_ASSEM 0x0002
  899. #define FIELD_ATTRIBUTE_ASSEMBLY 0x0003
  900. #define FIELD_ATTRIBUTE_FAMILY 0x0004
  901. #define FIELD_ATTRIBUTE_FAM_OR_ASSEM 0x0005
  902. #define FIELD_ATTRIBUTE_PUBLIC 0x0006
  903.  
  904. #define FIELD_ATTRIBUTE_STATIC 0x0010
  905. #define FIELD_ATTRIBUTE_LITERAL 0x0040
  906.  
  907. #define METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK 0x0007
  908. #define METHOD_ATTRIBUTE_COMPILER_CONTROLLED 0x0000
  909. #define METHOD_ATTRIBUTE_PRIVATE 0x0001
  910. #define METHOD_ATTRIBUTE_FAM_AND_ASSEM 0x0002
  911. #define METHOD_ATTRIBUTE_ASSEMBLY 0x0003
  912. #define METHOD_ATTRIBUTE_FAMILY 0x0004
  913. #define METHOD_ATTRIBUTE_FAM_OR_ASSEM 0x0005
  914. #define METHOD_ATTRIBUTE_PUBLIC 0x0006
  915.  
  916. #define METHOD_ATTRIBUTE_STATIC 0x0010
  917. #define METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL 0x1000
  918. #define METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED 0x0020
  919.  
  920.  
  921. static const char * (*il2cpp_class_get_name) (void *) = (void *) ${this._classGetName};
  922. static int (*il2cpp_field_get_flags) (void *) = (void *) ${this._fieldGetFlags};
  923. static size_t (*il2cpp_field_get_offset) (void *) = (void *) ${this._fieldGetOffset};
  924. static uint32_t (*il2cpp_method_get_flags) (void *, uint32_t *) = (void *) ${this._methodGetFlags};
  925. static char * (*il2cpp_type_get_name) (void *) = (void *) ${this._typeGetName};
  926. static Il2CppTypeEnum (*il2cpp_type_get_type_enum) (void *) = (void *) ${this._typeGetTypeEnum};
  927. static void (*il2cpp_free) (void * pointer) = (void *) ${this._free};
  928.  
  929.  
  930. void
  931. il2cpp_string_set_length (int32_t * string,
  932.                           int32_t length)
  933. {
  934.     *(string + ${offsetOfInt32(Il2Cpp.String.from("vfsfitvnm"), 9)}) = length;
  935. }
  936.  
  937. void *
  938. il2cpp_array_get_elements (int32_t * array)
  939. {
  940.     return array + ${offsetOfInt32(DaysToMonth365, 31) - 1};
  941. }
  942.  
  943. uint8_t
  944. il2cpp_type_is_byref (void * type)
  945. {  
  946.     char * name;
  947.     char last_char;
  948.  
  949.     name = il2cpp_type_get_name (type);
  950.     last_char = name[strlen (name) - 1];
  951.  
  952.     il2cpp_free (name);
  953.     return last_char == '&';
  954. }
  955.  
  956. uint8_t
  957. il2cpp_type_is_primitive (void * type)
  958. {
  959.     Il2CppTypeEnum type_enum;
  960.  
  961.     type_enum = il2cpp_type_get_type_enum (type);
  962.  
  963.     return ((type_enum >= IL2CPP_TYPE_BOOLEAN &&
  964.         type_enum <= IL2CPP_TYPE_R8) ||
  965.         type_enum == IL2CPP_TYPE_I ||
  966.         type_enum == IL2CPP_TYPE_U
  967.     );
  968. }
  969.  
  970. int32_t
  971. il2cpp_class_get_actual_instance_size (int32_t * class)
  972. {
  973.     return *(class + ${offsetOfInt32(SystemString, SystemString.instanceSize - 2)});
  974. }
  975.  
  976. uint8_t
  977. il2cpp_class_get_rank (void * class)
  978. {
  979.     uint8_t rank;
  980.     const char * name;
  981.    
  982.     rank = 0;
  983.     name = il2cpp_class_get_name (class);
  984.  
  985.     for (uint16_t i = strlen (name) - 1; i > 0; i--)
  986.     {
  987.         char c = name[i];
  988.  
  989.         if (c == ']') rank++;
  990.         else if (c == '[' || rank == 0) break;
  991.         else if (c == ',') rank++;
  992.         else break;
  993.     }
  994.  
  995.     return rank;
  996. }
  997.  
  998. const char *
  999. il2cpp_field_get_modifier (void * field)
  1000. {  
  1001.     int flags;
  1002.  
  1003.     flags = il2cpp_field_get_flags (field);
  1004.  
  1005.     switch (flags & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) {
  1006.         case FIELD_ATTRIBUTE_PRIVATE:
  1007.             return "private";
  1008.         case FIELD_ATTRIBUTE_FAM_AND_ASSEM:
  1009.             return "private protected";
  1010.         case FIELD_ATTRIBUTE_ASSEMBLY:
  1011.             return "internal";
  1012.         case FIELD_ATTRIBUTE_FAMILY:
  1013.             return "protected";
  1014.         case FIELD_ATTRIBUTE_FAM_OR_ASSEM:
  1015.             return "protected internal";
  1016.         case FIELD_ATTRIBUTE_PUBLIC:
  1017.             return "public";
  1018.     }
  1019.  
  1020.     return "";
  1021. }
  1022.  
  1023. uint8_t
  1024. il2cpp_field_is_literal (void * field)
  1025. {
  1026.     return (il2cpp_field_get_flags (field) & FIELD_ATTRIBUTE_LITERAL) != 0;
  1027. }
  1028.  
  1029. uint8_t
  1030. il2cpp_field_is_static (void * field)
  1031. {
  1032.     return (il2cpp_field_get_flags (field) & FIELD_ATTRIBUTE_STATIC) != 0;
  1033. }
  1034.  
  1035. uint8_t
  1036. il2cpp_field_is_thread_static (void * field)
  1037. {
  1038.     return il2cpp_field_get_offset (field) == THREAD_STATIC_FIELD_OFFSET;
  1039. }
  1040.  
  1041. const char *
  1042. il2cpp_method_get_modifier (void * method)
  1043. {
  1044.     uint32_t flags;
  1045.  
  1046.     flags = il2cpp_method_get_flags (method, NULL);
  1047.  
  1048.     switch (flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) {
  1049.         case METHOD_ATTRIBUTE_PRIVATE:
  1050.             return "private";
  1051.         case METHOD_ATTRIBUTE_FAM_AND_ASSEM:
  1052.             return "private protected";
  1053.         case METHOD_ATTRIBUTE_ASSEMBLY:
  1054.             return "internal";
  1055.         case METHOD_ATTRIBUTE_FAMILY:
  1056.             return "protected";
  1057.         case METHOD_ATTRIBUTE_FAM_OR_ASSEM:
  1058.             return "protected internal";
  1059.         case METHOD_ATTRIBUTE_PUBLIC:
  1060.             return "public";
  1061.     }
  1062.  
  1063.     return "";
  1064. }
  1065.  
  1066. void *
  1067. il2cpp_method_get_from_reflection (const Il2CppReflectionMethod * method)
  1068. {
  1069.     return method->method;
  1070. }
  1071.  
  1072. void *
  1073. il2cpp_method_get_pointer (void ** method)
  1074. {
  1075.     return * (method + ${offsetOfPointer(FilterTypeNameMethod, FilterTypeNameMethodPointer)});
  1076. }
  1077.  
  1078. uint8_t
  1079. il2cpp_method_is_external (void * method)
  1080. {
  1081.     uint32_t implementation_flags;
  1082.  
  1083.     il2cpp_method_get_flags (method, &implementation_flags);
  1084.  
  1085.     return (implementation_flags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) != 0;
  1086. }
  1087.  
  1088. uint8_t
  1089. il2cpp_method_is_synchronized (void * method)
  1090. {
  1091.     uint32_t implementation_flags;
  1092.  
  1093.     il2cpp_method_get_flags (method, &implementation_flags);
  1094.  
  1095.     return (implementation_flags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) != 0;
  1096. }
  1097.  
  1098. uintptr_t
  1099. il2cpp_memory_snapshot_get_classes (const Il2CppManagedMemorySnapshot * snapshot,
  1100.                                     Il2CppMetadataType ** iter)
  1101. {
  1102.     const int zero;
  1103.     const void * null;
  1104.  
  1105.     if (iter != NULL && snapshot->metadata_snapshot.type_count > zero)
  1106.     {
  1107.         if (*iter == null)
  1108.         {
  1109.             *iter = snapshot->metadata_snapshot.types;
  1110.             return (uintptr_t) (*iter)->type_info_address;
  1111.         }
  1112.         else
  1113.         {
  1114.             Il2CppMetadataType * metadata_type = *iter + 1;
  1115.  
  1116.             if (metadata_type < snapshot->metadata_snapshot.types + snapshot->metadata_snapshot.type_count)
  1117.             {
  1118.                 *iter = metadata_type;
  1119.                 return (uintptr_t) (*iter)->type_info_address;
  1120.             }
  1121.         }
  1122.     }
  1123.     return 0;
  1124. }
  1125.  
  1126. struct Il2CppGCHandles
  1127. il2cpp_memory_snapshot_get_gc_handles (const Il2CppManagedMemorySnapshot * snapshot)
  1128. {
  1129.     return snapshot->gc_handles;
  1130. }
  1131.  
  1132. struct Il2CppRuntimeInformation
  1133. il2cpp_memory_snapshot_get_information (const Il2CppManagedMemorySnapshot * snapshot)
  1134. {
  1135.     return snapshot->runtime_information;
  1136. }
  1137.         `;
  1138.         offsetsFinderCModule.dispose();
  1139.         return new CModule(source);
  1140.     }
  1141.     /** @internal */
  1142.     static r(exportName, retType, argTypes) {
  1143.         const exportPointer = Il2Cpp.module.findExportByName(exportName) ?? this.cModule[exportName];
  1144.         if (exportPointer == null) {
  1145.             (0, console_1.raise)(`cannot resolve export ${exportName}`);
  1146.         }
  1147.         return new NativeFunction(exportPointer, retType, argTypes);
  1148.     }
  1149. }
  1150. __decorate([
  1151.     decorator_cache_getter_1.cache
  1152. ], Il2CppApi, "_alloc", null);
  1153. __decorate([
  1154.     decorator_cache_getter_1.cache
  1155. ], Il2CppApi, "_arrayGetElements", null);
  1156. __decorate([
  1157.     decorator_cache_getter_1.cache
  1158. ], Il2CppApi, "_arrayGetLength", null);
  1159. __decorate([
  1160.     decorator_cache_getter_1.cache
  1161. ], Il2CppApi, "_arrayNew", null);
  1162. __decorate([
  1163.     decorator_cache_getter_1.cache
  1164. ], Il2CppApi, "_assemblyGetImage", null);
  1165. __decorate([
  1166.     decorator_cache_getter_1.cache
  1167. ], Il2CppApi, "_classForEach", null);
  1168. __decorate([
  1169.     decorator_cache_getter_1.cache
  1170. ], Il2CppApi, "_classFromName", null);
  1171. __decorate([
  1172.     decorator_cache_getter_1.cache
  1173. ], Il2CppApi, "_classFromSystemType", null);
  1174. __decorate([
  1175.     decorator_cache_getter_1.cache
  1176. ], Il2CppApi, "_classFromType", null);
  1177. __decorate([
  1178.     decorator_cache_getter_1.cache
  1179. ], Il2CppApi, "_classGetActualInstanceSize", null);
  1180. __decorate([
  1181.     decorator_cache_getter_1.cache
  1182. ], Il2CppApi, "_classGetArrayClass", null);
  1183. __decorate([
  1184.     decorator_cache_getter_1.cache
  1185. ], Il2CppApi, "_classGetArrayElementSize", null);
  1186. __decorate([
  1187.     decorator_cache_getter_1.cache
  1188. ], Il2CppApi, "_classGetAssemblyName", null);
  1189. __decorate([
  1190.     decorator_cache_getter_1.cache
  1191. ], Il2CppApi, "_classGetBaseType", null);
  1192. __decorate([
  1193.     decorator_cache_getter_1.cache
  1194. ], Il2CppApi, "_classGetDeclaringType", null);
  1195. __decorate([
  1196.     decorator_cache_getter_1.cache
  1197. ], Il2CppApi, "_classGetElementClass", null);
  1198. __decorate([
  1199.     decorator_cache_getter_1.cache
  1200. ], Il2CppApi, "_classGetFieldFromName", null);
  1201. __decorate([
  1202.     decorator_cache_getter_1.cache
  1203. ], Il2CppApi, "_classGetFields", null);
  1204. __decorate([
  1205.     decorator_cache_getter_1.cache
  1206. ], Il2CppApi, "_classGetFlags", null);
  1207. __decorate([
  1208.     decorator_cache_getter_1.cache
  1209. ], Il2CppApi, "_classGetImage", null);
  1210. __decorate([
  1211.     decorator_cache_getter_1.cache
  1212. ], Il2CppApi, "_classGetInstanceSize", null);
  1213. __decorate([
  1214.     decorator_cache_getter_1.cache
  1215. ], Il2CppApi, "_classGetInterfaces", null);
  1216. __decorate([
  1217.     decorator_cache_getter_1.cache
  1218. ], Il2CppApi, "_classGetMethodFromName", null);
  1219. __decorate([
  1220.     decorator_cache_getter_1.cache
  1221. ], Il2CppApi, "_classGetMethods", null);
  1222. __decorate([
  1223.     decorator_cache_getter_1.cache
  1224. ], Il2CppApi, "_classGetName", null);
  1225. __decorate([
  1226.     decorator_cache_getter_1.cache
  1227. ], Il2CppApi, "_classGetNamespace", null);
  1228. __decorate([
  1229.     decorator_cache_getter_1.cache
  1230. ], Il2CppApi, "_classGetNestedClasses", null);
  1231. __decorate([
  1232.     decorator_cache_getter_1.cache
  1233. ], Il2CppApi, "_classGetParent", null);
  1234. __decorate([
  1235.     decorator_cache_getter_1.cache
  1236. ], Il2CppApi, "_classGetRank", null);
  1237. __decorate([
  1238.     decorator_cache_getter_1.cache
  1239. ], Il2CppApi, "_classGetStaticFieldData", null);
  1240. __decorate([
  1241.     decorator_cache_getter_1.cache
  1242. ], Il2CppApi, "_classGetValueSize", null);
  1243. __decorate([
  1244.     decorator_cache_getter_1.cache
  1245. ], Il2CppApi, "_classGetType", null);
  1246. __decorate([
  1247.     decorator_cache_getter_1.cache
  1248. ], Il2CppApi, "_classHasReferences", null);
  1249. __decorate([
  1250.     decorator_cache_getter_1.cache
  1251. ], Il2CppApi, "_classInit", null);
  1252. __decorate([
  1253.     decorator_cache_getter_1.cache
  1254. ], Il2CppApi, "_classIsAbstract", null);
  1255. __decorate([
  1256.     decorator_cache_getter_1.cache
  1257. ], Il2CppApi, "_classIsAssignableFrom", null);
  1258. __decorate([
  1259.     decorator_cache_getter_1.cache
  1260. ], Il2CppApi, "_classIsBlittable", null);
  1261. __decorate([
  1262.     decorator_cache_getter_1.cache
  1263. ], Il2CppApi, "_classIsEnum", null);
  1264. __decorate([
  1265.     decorator_cache_getter_1.cache
  1266. ], Il2CppApi, "_classIsGeneric", null);
  1267. __decorate([
  1268.     decorator_cache_getter_1.cache
  1269. ], Il2CppApi, "_classIsInflated", null);
  1270. __decorate([
  1271.     decorator_cache_getter_1.cache
  1272. ], Il2CppApi, "_classIsInterface", null);
  1273. __decorate([
  1274.     decorator_cache_getter_1.cache
  1275. ], Il2CppApi, "_classIsSubclassOf", null);
  1276. __decorate([
  1277.     decorator_cache_getter_1.cache
  1278. ], Il2CppApi, "_classIsValueType", null);
  1279. __decorate([
  1280.     decorator_cache_getter_1.cache
  1281. ], Il2CppApi, "_domainAssemblyOpen", null);
  1282. __decorate([
  1283.     decorator_cache_getter_1.cache
  1284. ], Il2CppApi, "_domainGet", null);
  1285. __decorate([
  1286.     decorator_cache_getter_1.cache
  1287. ], Il2CppApi, "_domainGetAssemblies", null);
  1288. __decorate([
  1289.     decorator_cache_getter_1.cache
  1290. ], Il2CppApi, "_fieldGetModifier", null);
  1291. __decorate([
  1292.     decorator_cache_getter_1.cache
  1293. ], Il2CppApi, "_fieldGetClass", null);
  1294. __decorate([
  1295.     decorator_cache_getter_1.cache
  1296. ], Il2CppApi, "_fieldGetFlags", null);
  1297. __decorate([
  1298.     decorator_cache_getter_1.cache
  1299. ], Il2CppApi, "_fieldGetName", null);
  1300. __decorate([
  1301.     decorator_cache_getter_1.cache
  1302. ], Il2CppApi, "_fieldGetOffset", null);
  1303. __decorate([
  1304.     decorator_cache_getter_1.cache
  1305. ], Il2CppApi, "_fieldGetStaticValue", null);
  1306. __decorate([
  1307.     decorator_cache_getter_1.cache
  1308. ], Il2CppApi, "_fieldGetType", null);
  1309. __decorate([
  1310.     decorator_cache_getter_1.cache
  1311. ], Il2CppApi, "_fieldIsLiteral", null);
  1312. __decorate([
  1313.     decorator_cache_getter_1.cache
  1314. ], Il2CppApi, "_fieldIsStatic", null);
  1315. __decorate([
  1316.     decorator_cache_getter_1.cache
  1317. ], Il2CppApi, "_fieldIsThreadStatic", null);
  1318. __decorate([
  1319.     decorator_cache_getter_1.cache
  1320. ], Il2CppApi, "_fieldSetStaticValue", null);
  1321. __decorate([
  1322.     decorator_cache_getter_1.cache
  1323. ], Il2CppApi, "_free", null);
  1324. __decorate([
  1325.     decorator_cache_getter_1.cache
  1326. ], Il2CppApi, "_gcCollect", null);
  1327. __decorate([
  1328.     decorator_cache_getter_1.cache
  1329. ], Il2CppApi, "_gcCollectALittle", null);
  1330. __decorate([
  1331.     decorator_cache_getter_1.cache
  1332. ], Il2CppApi, "_gcDisable", null);
  1333. __decorate([
  1334.     decorator_cache_getter_1.cache
  1335. ], Il2CppApi, "_gcEnable", null);
  1336. __decorate([
  1337.     decorator_cache_getter_1.cache
  1338. ], Il2CppApi, "_gcGetHeapSize", null);
  1339. __decorate([
  1340.     decorator_cache_getter_1.cache
  1341. ], Il2CppApi, "_gcGetMaxTimeSlice", null);
  1342. __decorate([
  1343.     decorator_cache_getter_1.cache
  1344. ], Il2CppApi, "_gcGetUsedSize", null);
  1345. __decorate([
  1346.     decorator_cache_getter_1.cache
  1347. ], Il2CppApi, "_gcHandleGetTarget", null);
  1348. __decorate([
  1349.     decorator_cache_getter_1.cache
  1350. ], Il2CppApi, "_gcHandleFree", null);
  1351. __decorate([
  1352.     decorator_cache_getter_1.cache
  1353. ], Il2CppApi, "_gcHandleNew", null);
  1354. __decorate([
  1355.     decorator_cache_getter_1.cache
  1356. ], Il2CppApi, "_gcHandleNewWeakRef", null);
  1357. __decorate([
  1358.     decorator_cache_getter_1.cache
  1359. ], Il2CppApi, "_gcIsDisabled", null);
  1360. __decorate([
  1361.     decorator_cache_getter_1.cache
  1362. ], Il2CppApi, "_gcIsIncremental", null);
  1363. __decorate([
  1364.     decorator_cache_getter_1.cache
  1365. ], Il2CppApi, "_gcSetMaxTimeSlice", null);
  1366. __decorate([
  1367.     decorator_cache_getter_1.cache
  1368. ], Il2CppApi, "_gcStartIncrementalCollection", null);
  1369. __decorate([
  1370.     decorator_cache_getter_1.cache
  1371. ], Il2CppApi, "_gcStartWorld", null);
  1372. __decorate([
  1373.     decorator_cache_getter_1.cache
  1374. ], Il2CppApi, "_gcStopWorld", null);
  1375. __decorate([
  1376.     decorator_cache_getter_1.cache
  1377. ], Il2CppApi, "_getCorlib", null);
  1378. __decorate([
  1379.     decorator_cache_getter_1.cache
  1380. ], Il2CppApi, "_imageGetAssembly", null);
  1381. __decorate([
  1382.     decorator_cache_getter_1.cache
  1383. ], Il2CppApi, "_imageGetClass", null);
  1384. __decorate([
  1385.     decorator_cache_getter_1.cache
  1386. ], Il2CppApi, "_imageGetClassCount", null);
  1387. __decorate([
  1388.     decorator_cache_getter_1.cache
  1389. ], Il2CppApi, "_imageGetName", null);
  1390. __decorate([
  1391.     decorator_cache_getter_1.cache
  1392. ], Il2CppApi, "_init", null);
  1393. __decorate([
  1394.     decorator_cache_getter_1.cache
  1395. ], Il2CppApi, "_livenessAllocateStruct", null);
  1396. __decorate([
  1397.     decorator_cache_getter_1.cache
  1398. ], Il2CppApi, "_livenessCalculationBegin", null);
  1399. __decorate([
  1400.     decorator_cache_getter_1.cache
  1401. ], Il2CppApi, "_livenessCalculationEnd", null);
  1402. __decorate([
  1403.     decorator_cache_getter_1.cache
  1404. ], Il2CppApi, "_livenessCalculationFromStatics", null);
  1405. __decorate([
  1406.     decorator_cache_getter_1.cache
  1407. ], Il2CppApi, "_livenessFinalize", null);
  1408. __decorate([
  1409.     decorator_cache_getter_1.cache
  1410. ], Il2CppApi, "_livenessFreeStruct", null);
  1411. __decorate([
  1412.     decorator_cache_getter_1.cache
  1413. ], Il2CppApi, "_memorySnapshotCapture", null);
  1414. __decorate([
  1415.     decorator_cache_getter_1.cache
  1416. ], Il2CppApi, "_memorySnapshotFree", null);
  1417. __decorate([
  1418.     decorator_cache_getter_1.cache
  1419. ], Il2CppApi, "_memorySnapshotGetClasses", null);
  1420. __decorate([
  1421.     decorator_cache_getter_1.cache
  1422. ], Il2CppApi, "_memorySnapshotGetGCHandles", null);
  1423. __decorate([
  1424.     decorator_cache_getter_1.cache
  1425. ], Il2CppApi, "_memorySnapshotGetRuntimeInformation", null);
  1426. __decorate([
  1427.     decorator_cache_getter_1.cache
  1428. ], Il2CppApi, "_methodGetModifier", null);
  1429. __decorate([
  1430.     decorator_cache_getter_1.cache
  1431. ], Il2CppApi, "_methodGetClass", null);
  1432. __decorate([
  1433.     decorator_cache_getter_1.cache
  1434. ], Il2CppApi, "_methodGetFlags", null);
  1435. __decorate([
  1436.     decorator_cache_getter_1.cache
  1437. ], Il2CppApi, "_methodGetFromReflection", null);
  1438. __decorate([
  1439.     decorator_cache_getter_1.cache
  1440. ], Il2CppApi, "_methodGetName", null);
  1441. __decorate([
  1442.     decorator_cache_getter_1.cache
  1443. ], Il2CppApi, "_methodGetObject", null);
  1444. __decorate([
  1445.     decorator_cache_getter_1.cache
  1446. ], Il2CppApi, "_methodGetParameterCount", null);
  1447. __decorate([
  1448.     decorator_cache_getter_1.cache
  1449. ], Il2CppApi, "_methodGetParameterName", null);
  1450. __decorate([
  1451.     decorator_cache_getter_1.cache
  1452. ], Il2CppApi, "_methodGetParameters", null);
  1453. __decorate([
  1454.     decorator_cache_getter_1.cache
  1455. ], Il2CppApi, "_methodGetParameterType", null);
  1456. __decorate([
  1457.     decorator_cache_getter_1.cache
  1458. ], Il2CppApi, "_methodGetPointer", null);
  1459. __decorate([
  1460.     decorator_cache_getter_1.cache
  1461. ], Il2CppApi, "_methodGetReturnType", null);
  1462. __decorate([
  1463.     decorator_cache_getter_1.cache
  1464. ], Il2CppApi, "_methodIsExternal", null);
  1465. __decorate([
  1466.     decorator_cache_getter_1.cache
  1467. ], Il2CppApi, "_methodIsGeneric", null);
  1468. __decorate([
  1469.     decorator_cache_getter_1.cache
  1470. ], Il2CppApi, "_methodIsInflated", null);
  1471. __decorate([
  1472.     decorator_cache_getter_1.cache
  1473. ], Il2CppApi, "_methodIsInstance", null);
  1474. __decorate([
  1475.     decorator_cache_getter_1.cache
  1476. ], Il2CppApi, "_methodIsSynchronized", null);
  1477. __decorate([
  1478.     decorator_cache_getter_1.cache
  1479. ], Il2CppApi, "_monitorEnter", null);
  1480. __decorate([
  1481.     decorator_cache_getter_1.cache
  1482. ], Il2CppApi, "_monitorExit", null);
  1483. __decorate([
  1484.     decorator_cache_getter_1.cache
  1485. ], Il2CppApi, "_monitorPulse", null);
  1486. __decorate([
  1487.     decorator_cache_getter_1.cache
  1488. ], Il2CppApi, "_monitorPulseAll", null);
  1489. __decorate([
  1490.     decorator_cache_getter_1.cache
  1491. ], Il2CppApi, "_monitorTryEnter", null);
  1492. __decorate([
  1493.     decorator_cache_getter_1.cache
  1494. ], Il2CppApi, "_monitorTryWait", null);
  1495. __decorate([
  1496.     decorator_cache_getter_1.cache
  1497. ], Il2CppApi, "_monitorWait", null);
  1498. __decorate([
  1499.     decorator_cache_getter_1.cache
  1500. ], Il2CppApi, "_objectGetClass", null);
  1501. __decorate([
  1502.     decorator_cache_getter_1.cache
  1503. ], Il2CppApi, "_objectGetVirtualMethod", null);
  1504. __decorate([
  1505.     decorator_cache_getter_1.cache
  1506. ], Il2CppApi, "_objectInit", null);
  1507. __decorate([
  1508.     decorator_cache_getter_1.cache
  1509. ], Il2CppApi, "_objectNew", null);
  1510. __decorate([
  1511.     decorator_cache_getter_1.cache
  1512. ], Il2CppApi, "_objectGetSize", null);
  1513. __decorate([
  1514.     decorator_cache_getter_1.cache
  1515. ], Il2CppApi, "_objectUnbox", null);
  1516. __decorate([
  1517.     decorator_cache_getter_1.cache
  1518. ], Il2CppApi, "_resolveInternalCall", null);
  1519. __decorate([
  1520.     decorator_cache_getter_1.cache
  1521. ], Il2CppApi, "_stringChars", null);
  1522. __decorate([
  1523.     decorator_cache_getter_1.cache
  1524. ], Il2CppApi, "_stringLength", null);
  1525. __decorate([
  1526.     decorator_cache_getter_1.cache
  1527. ], Il2CppApi, "_stringNew", null);
  1528. __decorate([
  1529.     decorator_cache_getter_1.cache
  1530. ], Il2CppApi, "_stringSetLength", null);
  1531. __decorate([
  1532.     decorator_cache_getter_1.cache
  1533. ], Il2CppApi, "_valueBox", null);
  1534. __decorate([
  1535.     decorator_cache_getter_1.cache
  1536. ], Il2CppApi, "_threadAttach", null);
  1537. __decorate([
  1538.     decorator_cache_getter_1.cache
  1539. ], Il2CppApi, "_threadCurrent", null);
  1540. __decorate([
  1541.     decorator_cache_getter_1.cache
  1542. ], Il2CppApi, "_threadGetAllAttachedThreads", null);
  1543. __decorate([
  1544.     decorator_cache_getter_1.cache
  1545. ], Il2CppApi, "_threadIsVm", null);
  1546. __decorate([
  1547.     decorator_cache_getter_1.cache
  1548. ], Il2CppApi, "_threadDetach", null);
  1549. __decorate([
  1550.     decorator_cache_getter_1.cache
  1551. ], Il2CppApi, "_typeGetName", null);
  1552. __decorate([
  1553.     decorator_cache_getter_1.cache
  1554. ], Il2CppApi, "_typeGetObject", null);
  1555. __decorate([
  1556.     decorator_cache_getter_1.cache
  1557. ], Il2CppApi, "_typeGetTypeEnum", null);
  1558. __decorate([
  1559.     decorator_cache_getter_1.cache
  1560. ], Il2CppApi, "_typeIsByReference", null);
  1561. __decorate([
  1562.     decorator_cache_getter_1.cache
  1563. ], Il2CppApi, "_typeIsPrimitive", null);
  1564. __decorate([
  1565.     decorator_cache_getter_1.cache
  1566. ], Il2CppApi, "cModule", null);
  1567. Il2Cpp.Api = Il2CppApi;
  1568.  
  1569. },{"../utils/console":32,"decorator-cache-getter":3,"versioning":38}],6:[function(require,module,exports){
  1570. (function (setImmediate){(function (){
  1571. "use strict";
  1572. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1573.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1574.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1575.     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;
  1576.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  1577. };
  1578. var __importDefault = (this && this.__importDefault) || function (mod) {
  1579.     return (mod && mod.__esModule) ? mod : { "default": mod };
  1580. };
  1581. Object.defineProperty(exports, "__esModule", { value: true });
  1582. const decorator_cache_getter_1 = require("decorator-cache-getter");
  1583. const versioning_1 = __importDefault(require("versioning"));
  1584. const console_1 = require("../utils/console");
  1585. const native_wait_1 = require("../utils/native-wait");
  1586. /** */
  1587. class Il2CppBase {
  1588.     constructor() { }
  1589.     /** @internal Gets the Il2Cpp module name. */
  1590.     static get moduleName() {
  1591.         switch (Process.platform) {
  1592.             case "linux":
  1593.                 try {
  1594.                     const _ = Java.androidVersion;
  1595.                     return "libil2cpp.so";
  1596.                 }
  1597.                 catch (e) {
  1598.                     return "GameAssembly.so";
  1599.                 }
  1600.             case "windows":
  1601.                 return "GameAssembly.dll";
  1602.             case "darwin":
  1603.                 try {
  1604.                     return "UnityFramework";
  1605.                 }
  1606.                 catch (e) {
  1607.                     return "GameAssembly.dylib";
  1608.                 }
  1609.         }
  1610.         (0, console_1.raise)(`${Process.platform} is not supported yet`);
  1611.     }
  1612.     /** */
  1613.     static get applicationDataPath() {
  1614.         const get_persistentDataPath = this.internalCall("UnityEngine.Application::get_persistentDataPath", "pointer", []);
  1615.         return new Il2Cpp.String(get_persistentDataPath()).content;
  1616.     }
  1617.     /** */
  1618.     static get applicationIdentifier() {
  1619.         const get_identifier = this.internalCall("UnityEngine.Application::get_identifier", "pointer", []) ??
  1620.             this.internalCall("UnityEngine.Application::get_bundleIdentifier", "pointer", []);
  1621.         return get_identifier ? new Il2Cpp.String(get_identifier()).content : null;
  1622.     }
  1623.     /** Gets the version of the application */
  1624.     static get applicationVersion() {
  1625.         const get_version = this.internalCall("UnityEngine.Application::get_version", "pointer", []);
  1626.         return get_version ? new Il2Cpp.String(get_version()).content : null;
  1627.     }
  1628.     /** Gets the attached threads. */
  1629.     static get attachedThreads() {
  1630.         if (Il2Cpp.currentThread == null) {
  1631.             (0, console_1.raise)("only Il2Cpp threads can invoke Il2Cpp.attachedThreads");
  1632.         }
  1633.         const array = [];
  1634.         const sizePointer = Memory.alloc(Process.pointerSize);
  1635.         const startPointer = Il2Cpp.Api._threadGetAllAttachedThreads(sizePointer);
  1636.         const size = sizePointer.readInt();
  1637.         for (let i = 0; i < size; i++) {
  1638.             array.push(new Il2Cpp.Thread(startPointer.add(i * Process.pointerSize).readPointer()));
  1639.         }
  1640.         return array;
  1641.     }
  1642.     /** Gets the current attached thread, if any. */
  1643.     static get currentThread() {
  1644.         const handle = Il2Cpp.Api._threadCurrent();
  1645.         return handle.isNull() ? null : new Il2Cpp.Thread(handle);
  1646.     }
  1647.     /** Gets the Il2Cpp module as a Frida module. */
  1648.     static get module() {
  1649.         return Process.getModuleByName(this.moduleName);
  1650.     }
  1651.     /** Gets the Unity version of the current application. */
  1652.     static get unityVersion() {
  1653.         const get_unityVersion = this.internalCall("UnityEngine.Application::get_unityVersion", "pointer", []);
  1654.         if (get_unityVersion == null) {
  1655.             (0, console_1.raise)("couldn't determine the Unity version, please specify it manually");
  1656.         }
  1657.         return new Il2Cpp.String(get_unityVersion()).content;
  1658.     }
  1659.     /** @internal */
  1660.     static get unityVersionIsBelow201830() {
  1661.         return versioning_1.default.lt(this.unityVersion, "2018.3.0");
  1662.     }
  1663.     /** Allocates the given amount of bytes. */
  1664.     static alloc(size = Process.pointerSize) {
  1665.         return Il2Cpp.Api._alloc(size);
  1666.     }
  1667.     /** Dumps the application. */
  1668.     static dump(fileName, path) {
  1669.         fileName = fileName ?? `${Il2Cpp.applicationIdentifier ?? "unknown"}_${Il2Cpp.applicationVersion ?? "unknown"}.cs`;
  1670.         const destination = `${path ?? Il2Cpp.applicationDataPath}/${fileName}`;
  1671.         const file = new File(destination, "w");
  1672.         for (const assembly of Il2Cpp.Domain.assemblies) {
  1673.             (0, console_1.inform)(`dumping ${assembly.name}...`);
  1674.             for (const klass of assembly.image.classes) {
  1675.                 file.write(`${klass}\n\n`);
  1676.             }
  1677.         }
  1678.         file.flush();
  1679.         file.close();
  1680.         (0, console_1.ok)(`dump saved to ${destination}`);
  1681.     }
  1682.     /** Frees memory. */
  1683.     static free(pointer) {
  1684.         return Il2Cpp.Api._free(pointer);
  1685.     }
  1686.     /** @internal Waits for Unity and Il2Cpp native libraries to be loaded and initialized. */
  1687.     static async initialize() {
  1688.         if (Process.platform == "darwin") {
  1689.             let il2cppModuleName = Process.findModuleByAddress(Module.findExportByName(null, "il2cpp_init") ?? NULL)?.name;
  1690.             if (il2cppModuleName == undefined) {
  1691.                 il2cppModuleName = await (0, native_wait_1.forModule)("UnityFramework", "GameAssembly.dylib");
  1692.             }
  1693.             Reflect.defineProperty(Il2Cpp, "moduleName", { value: il2cppModuleName });
  1694.         }
  1695.         else {
  1696.             await (0, native_wait_1.forModule)(this.moduleName);
  1697.         }
  1698.         if (Il2Cpp.Api._getCorlib().isNull()) {
  1699.             await new Promise(resolve => {
  1700.                 const interceptor = Interceptor.attach(Il2Cpp.Api._init, {
  1701.                     onLeave() {
  1702.                         interceptor.detach();
  1703.                         setImmediate(resolve);
  1704.                     }
  1705.                 });
  1706.             });
  1707.         }
  1708.     }
  1709.     /** */
  1710.     static installExceptionListener(targetThread = "current") {
  1711.         const threadId = Process.getCurrentThreadId();
  1712.         return Interceptor.attach(Il2Cpp.module.getExportByName("__cxa_throw"), function (args) {
  1713.             if (targetThread == "current" && this.threadId != threadId) {
  1714.                 return;
  1715.             }
  1716.             (0, console_1.inform)(new Il2Cpp.Object(args[0].readPointer()));
  1717.         });
  1718.     }
  1719.     /** */
  1720.     static internalCall(name, retType, argTypes) {
  1721.         const handle = Il2Cpp.Api._resolveInternalCall(Memory.allocUtf8String(name));
  1722.         return handle.isNull() ? null : new NativeFunction(handle, retType, argTypes);
  1723.     }
  1724.     /** Schedules a callback on the Il2Cpp initializer thread. */
  1725.     static scheduleOnInitializerThread(block) {
  1726.         return new Promise(resolve => {
  1727.             const listener = Interceptor.attach(Il2Cpp.Api._threadCurrent, () => {
  1728.                 const currentThreadId = Il2Cpp.currentThread?.id;
  1729.                 if (currentThreadId != undefined && currentThreadId == Il2Cpp.attachedThreads[0].id) {
  1730.                     listener.detach();
  1731.                     const result = block();
  1732.                     setImmediate(() => resolve(result));
  1733.                 }
  1734.             });
  1735.         });
  1736.     }
  1737.     /** Attaches the caller thread to Il2Cpp domain and executes the given block.  */
  1738.     static async perform(block) {
  1739.         await this.initialize();
  1740.         let thread = this.currentThread;
  1741.         const isForeignThread = thread == null;
  1742.         if (thread == null) {
  1743.             thread = Il2Cpp.Domain.attach();
  1744.         }
  1745.         try {
  1746.             const result = block();
  1747.             return result instanceof Promise ? await result : result;
  1748.         }
  1749.         catch (e) {
  1750.             globalThis.console.log(e);
  1751.             throw e;
  1752.         }
  1753.         finally {
  1754.             if (isForeignThread) {
  1755.                 thread.detach();
  1756.             }
  1757.         }
  1758.     }
  1759.     /** Creates a new `Il2Cpp.Tracer` instance. */
  1760.     static trace() {
  1761.         return new Il2Cpp.Tracer();
  1762.     }
  1763. }
  1764. __decorate([
  1765.     decorator_cache_getter_1.cache
  1766. ], Il2CppBase, "applicationDataPath", null);
  1767. __decorate([
  1768.     decorator_cache_getter_1.cache
  1769. ], Il2CppBase, "applicationIdentifier", null);
  1770. __decorate([
  1771.     decorator_cache_getter_1.cache
  1772. ], Il2CppBase, "applicationVersion", null);
  1773. __decorate([
  1774.     decorator_cache_getter_1.cache
  1775. ], Il2CppBase, "module", null);
  1776. __decorate([
  1777.     decorator_cache_getter_1.cache
  1778. ], Il2CppBase, "unityVersion", null);
  1779. __decorate([
  1780.     decorator_cache_getter_1.cache
  1781. ], Il2CppBase, "unityVersionIsBelow201830", null);
  1782. Reflect.set(globalThis, "Il2Cpp", Il2CppBase);
  1783.  
  1784. }).call(this)}).call(this,require("timers").setImmediate)
  1785.  
  1786. },{"../utils/console":32,"../utils/native-wait":34,"decorator-cache-getter":3,"timers":37,"versioning":38}],7:[function(require,module,exports){
  1787. "use strict";
  1788. Object.defineProperty(exports, "__esModule", { value: true });
  1789. /** Filtering utilities. */
  1790. class Il2CppFiltering {
  1791.     constructor() { }
  1792.     /** Creates a filter which includes `element`s whose type can be assigned to `klass` variables. */
  1793.     static Is(klass) {
  1794.         return (element) => {
  1795.             if (element instanceof Il2Cpp.Class) {
  1796.                 return klass.isAssignableFrom(element);
  1797.             }
  1798.             else {
  1799.                 return klass.isAssignableFrom(element.class);
  1800.             }
  1801.         };
  1802.     }
  1803.     /** Creates a filter which includes `element`s whose type corresponds to `klass` type. */
  1804.     static IsExactly(klass) {
  1805.         return (element) => {
  1806.             if (element instanceof Il2Cpp.Class) {
  1807.                 return element.equals(klass);
  1808.             }
  1809.             else {
  1810.                 return element.class.equals(klass);
  1811.             }
  1812.         };
  1813.     }
  1814. }
  1815. Il2Cpp.Filtering = Il2CppFiltering;
  1816.  
  1817. },{}],8:[function(require,module,exports){
  1818. "use strict";
  1819. Object.defineProperty(exports, "__esModule", { value: true });
  1820. require("./base");
  1821. require("./api");
  1822. require("./filtering");
  1823. require("./runtime");
  1824. require("./tracer");
  1825. require("./structs/array");
  1826. require("./structs/assembly");
  1827. require("./structs/class");
  1828. require("./structs/domain");
  1829. require("./structs/field");
  1830. require("./structs/gc");
  1831. require("./structs/gc-handle");
  1832. require("./structs/image");
  1833. require("./structs/memory-snapshot");
  1834. require("./structs/method");
  1835. require("./structs/object");
  1836. require("./structs/parameter");
  1837. require("./structs/pointer");
  1838. require("./structs/reference");
  1839. require("./structs/string");
  1840. require("./structs/thread");
  1841. require("./structs/type");
  1842. require("./structs/type-enum");
  1843. require("./structs/value-type");
  1844.  
  1845. },{"./api":5,"./base":6,"./filtering":7,"./runtime":9,"./structs/array":10,"./structs/assembly":11,"./structs/class":12,"./structs/domain":13,"./structs/field":14,"./structs/gc":16,"./structs/gc-handle":15,"./structs/image":17,"./structs/memory-snapshot":18,"./structs/method":19,"./structs/object":20,"./structs/parameter":21,"./structs/pointer":22,"./structs/reference":23,"./structs/string":24,"./structs/thread":25,"./structs/type":27,"./structs/type-enum":26,"./structs/value-type":28,"./tracer":29}],9:[function(require,module,exports){
  1846. "use strict";
  1847. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1848.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1849.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1850.     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;
  1851.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  1852. };
  1853. Object.defineProperty(exports, "__esModule", { value: true });
  1854. const decorator_cache_getter_1 = require("decorator-cache-getter");
  1855. /** */
  1856. class Il2CppRuntime {
  1857.     constructor() { }
  1858.     /** Gets the allocation granularity. */
  1859.     static get allocationGranularity() {
  1860.         return this.information[5];
  1861.     }
  1862.     /** Gets the size of the Il2CppArray struct. */
  1863.     static get arrayHeaderSize() {
  1864.         return this.information[2];
  1865.     }
  1866.     /** @internal */
  1867.     static get information() {
  1868.         const snapshot = Il2Cpp.MemorySnapshot.capture();
  1869.         try {
  1870.             return Il2Cpp.Api._memorySnapshotGetRuntimeInformation(snapshot);
  1871.         }
  1872.         finally {
  1873.             Il2Cpp.Api._memorySnapshotFree(snapshot);
  1874.         }
  1875.     }
  1876.     /** Gets the pointer size. */
  1877.     static get pointerSize() {
  1878.         return this.information[0];
  1879.     }
  1880.     /** Gets the size of the Il2CppObject struct. */
  1881.     static get objectHeaderSize() {
  1882.         return this.information[1];
  1883.     }
  1884. }
  1885. __decorate([
  1886.     decorator_cache_getter_1.cache
  1887. ], Il2CppRuntime, "information", null);
  1888. Il2Cpp.Runtime = Il2CppRuntime;
  1889.  
  1890. },{"decorator-cache-getter":3}],10:[function(require,module,exports){
  1891. "use strict";
  1892. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1893.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1894.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1895.     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;
  1896.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  1897. };
  1898. Object.defineProperty(exports, "__esModule", { value: true });
  1899. const decorator_cache_getter_1 = require("decorator-cache-getter");
  1900. const console_1 = require("../../utils/console");
  1901. const native_struct_1 = require("../../utils/native-struct");
  1902. /** Represents a `Il2CppArraySize`. */
  1903. class Il2CppArray extends native_struct_1.NativeStruct {
  1904.     /** @internal */
  1905.     static from(klass, lengthOrElements) {
  1906.         const length = typeof lengthOrElements == "number" ? lengthOrElements : lengthOrElements.length;
  1907.         const array = new Il2Cpp.Array(Il2Cpp.Api._arrayNew(klass, length));
  1908.         if (Array.isArray(lengthOrElements)) {
  1909.             array.elements.write(lengthOrElements);
  1910.         }
  1911.         return array;
  1912.     }
  1913.     /** @internal Gets a pointer to the first element of the current array. */
  1914.     get elements() {
  1915.         return new Il2Cpp.Pointer(Il2Cpp.Api._arrayGetElements(this), this.elementType);
  1916.     }
  1917.     /** Gets the size of the object encompassed by the current array. */
  1918.     get elementSize() {
  1919.         return this.elementType.class.arrayElementSize;
  1920.     }
  1921.     /** Gets the type of the object encompassed by the current array. */
  1922.     get elementType() {
  1923.         return this.object.class.type.class.baseType;
  1924.     }
  1925.     /** Gets the total number of elements in all the dimensions of the current array. */
  1926.     get length() {
  1927.         return Il2Cpp.Api._arrayGetLength(this);
  1928.     }
  1929.     /** Gets the encompassing object of the current array. */
  1930.     get object() {
  1931.         return new Il2Cpp.Object(this);
  1932.     }
  1933.     /** Gets the element at the specified index of the current array. */
  1934.     get(index) {
  1935.         if (index < 0 || index >= this.length) {
  1936.             (0, console_1.raise)(`cannot get element at index ${index}: array length is ${this.length}`);
  1937.         }
  1938.         return this.elements.get(index);
  1939.     }
  1940.     /** Sets the element at the specified index of the current array. */
  1941.     set(index, value) {
  1942.         if (index < 0 || index >= this.length) {
  1943.             (0, console_1.raise)(`cannot get element at index ${index}: array length is ${this.length}`);
  1944.         }
  1945.         this.elements.set(index, value);
  1946.     }
  1947.     /** */
  1948.     toString() {
  1949.         return this.isNull() ? "null" : `[${this.elements.read(this.length, 0)}]`;
  1950.     }
  1951.     /** Iterable. */
  1952.     *[Symbol.iterator]() {
  1953.         for (let i = 0; i < this.length; i++) {
  1954.             yield this.elements.get(i);
  1955.         }
  1956.     }
  1957. }
  1958. __decorate([
  1959.     decorator_cache_getter_1.cache
  1960. ], Il2CppArray.prototype, "elements", null);
  1961. __decorate([
  1962.     decorator_cache_getter_1.cache
  1963. ], Il2CppArray.prototype, "elementSize", null);
  1964. __decorate([
  1965.     decorator_cache_getter_1.cache
  1966. ], Il2CppArray.prototype, "elementType", null);
  1967. __decorate([
  1968.     decorator_cache_getter_1.cache
  1969. ], Il2CppArray.prototype, "length", null);
  1970. __decorate([
  1971.     decorator_cache_getter_1.cache
  1972. ], Il2CppArray.prototype, "object", null);
  1973. Il2Cpp.Array = Il2CppArray;
  1974.  
  1975. },{"../../utils/console":32,"../../utils/native-struct":33,"decorator-cache-getter":3}],11:[function(require,module,exports){
  1976. "use strict";
  1977. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1978.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1979.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1980.     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;
  1981.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  1982. };
  1983. Object.defineProperty(exports, "__esModule", { value: true });
  1984. const decorator_cache_getter_1 = require("decorator-cache-getter");
  1985. const native_struct_1 = require("../../utils/native-struct");
  1986. const utils_1 = require("../../utils/utils");
  1987. /** Represents a `Il2CppAssembly`. */
  1988. let Il2CppAssembly = class Il2CppAssembly extends native_struct_1.NonNullNativeStruct {
  1989.     /** Gets the image of this assembly. */
  1990.     get image() {
  1991.         return new Il2Cpp.Image(Il2Cpp.Api._assemblyGetImage(this));
  1992.     }
  1993.     /** Gets the name of this assembly. */
  1994.     get name() {
  1995.         return this.image.name.replace(".dll", "");
  1996.     }
  1997.     /** Gets the encompassing object of the current assembly. */
  1998.     get object() {
  1999.         return Il2Cpp.Image.corlib.class("System.Reflection.Assembly").method("Load").invoke(Il2Cpp.String.from(this.name));
  2000.     }
  2001. };
  2002. __decorate([
  2003.     decorator_cache_getter_1.cache
  2004. ], Il2CppAssembly.prototype, "image", null);
  2005. __decorate([
  2006.     decorator_cache_getter_1.cache
  2007. ], Il2CppAssembly.prototype, "name", null);
  2008. __decorate([
  2009.     decorator_cache_getter_1.cache
  2010. ], Il2CppAssembly.prototype, "object", null);
  2011. Il2CppAssembly = __decorate([
  2012.     utils_1.cacheInstances
  2013. ], Il2CppAssembly);
  2014. Il2Cpp.Assembly = Il2CppAssembly;
  2015.  
  2016. },{"../../utils/native-struct":33,"../../utils/utils":35,"decorator-cache-getter":3}],12:[function(require,module,exports){
  2017. "use strict";
  2018. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2019.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  2020.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  2021.     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;
  2022.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  2023. };
  2024. Object.defineProperty(exports, "__esModule", { value: true });
  2025. const decorator_cache_getter_1 = require("decorator-cache-getter");
  2026. const console_1 = require("../../utils/console");
  2027. const native_struct_1 = require("../../utils/native-struct");
  2028. const utils_1 = require("../../utils/utils");
  2029. /** Represents a `Il2CppClass`. */
  2030. let Il2CppClass = class Il2CppClass extends native_struct_1.NonNullNativeStruct {
  2031.     /** Gets the actual size of the instance of the current class. */
  2032.     get actualInstanceSize() {
  2033.         return Il2Cpp.Api._classGetActualInstanceSize(this);
  2034.     }
  2035.     /** Gets the array class which encompass the current class. */
  2036.     get arrayClass() {
  2037.         return new Il2Cpp.Class(Il2Cpp.Api._classGetArrayClass(this, 1));
  2038.     }
  2039.     /** Gets the size of the object encompassed by the current array class. */
  2040.     get arrayElementSize() {
  2041.         return Il2Cpp.Api._classGetArrayElementSize(this);
  2042.     }
  2043.     /** Gets the name of the assembly in which the current class is defined. */
  2044.     get assemblyName() {
  2045.         return Il2Cpp.Api._classGetAssemblyName(this).readUtf8String();
  2046.     }
  2047.     /** Gets the class that declares the current nested class. */
  2048.     get declaringClass() {
  2049.         const handle = Il2Cpp.Api._classGetDeclaringType(this);
  2050.         return handle.isNull() ? null : new Il2Cpp.Class(handle);
  2051.     }
  2052.     /** Gets the encompassed type of this array, reference, pointer or enum type. */
  2053.     get baseType() {
  2054.         const handle = Il2Cpp.Api._classGetBaseType(this);
  2055.         return handle.isNull() ? null : new Il2Cpp.Type(handle);
  2056.     }
  2057.     /** Gets the class of the object encompassed or referred to by the current array, pointer or reference class. */
  2058.     get elementClass() {
  2059.         const handle = Il2Cpp.Api._classGetElementClass(this);
  2060.         return handle.isNull() ? null : new Il2Cpp.Class(handle);
  2061.     }
  2062.     /** Gets the fields of the current class. */
  2063.     get fields() {
  2064.         return Array.from((0, utils_1.nativeIterator)(this, Il2Cpp.Api._classGetFields, Il2Cpp.Field));
  2065.     }
  2066.     /** Gets the flags of the current class. */
  2067.     get flags() {
  2068.         return Il2Cpp.Api._classGetFlags(this);
  2069.     }
  2070.     /** Gets the amount of generic parameters of this generic class. */
  2071.     get genericParameterCount() {
  2072.         if (!this.isGeneric) {
  2073.             return 0;
  2074.         }
  2075.         return this.type.object.method("GetGenericArguments").invoke().length;
  2076.     }
  2077.     /** Determines whether the GC has tracking references to the current class instances. */
  2078.     get hasReferences() {
  2079.         return !!Il2Cpp.Api._classHasReferences(this);
  2080.     }
  2081.     /** Determines whether ther current class has a valid static constructor. */
  2082.     get hasStaticConstructor() {
  2083.         const staticConstructor = this.tryMethod(".cctor");
  2084.         return staticConstructor != null && !staticConstructor.virtualAddress.isNull();
  2085.     }
  2086.     /** Gets the image in which the current class is defined. */
  2087.     get image() {
  2088.         return new Il2Cpp.Image(Il2Cpp.Api._classGetImage(this));
  2089.     }
  2090.     /** Gets the size of the instance of the current class. */
  2091.     get instanceSize() {
  2092.         return Il2Cpp.Api._classGetInstanceSize(this);
  2093.     }
  2094.     /** Determines whether the current class is abstract. */
  2095.     get isAbstract() {
  2096.         return !!Il2Cpp.Api._classIsAbstract(this);
  2097.     }
  2098.     /** Determines whether the current class is blittable. */
  2099.     get isBlittable() {
  2100.         return !!Il2Cpp.Api._classIsBlittable(this);
  2101.     }
  2102.     /** Determines whether the current class is an enumeration. */
  2103.     get isEnum() {
  2104.         return !!Il2Cpp.Api._classIsEnum(this);
  2105.     }
  2106.     /** Determines whether the current class is a generic one. */
  2107.     get isGeneric() {
  2108.         return !!Il2Cpp.Api._classIsGeneric(this);
  2109.     }
  2110.     /** Determines whether the current class is inflated. */
  2111.     get isInflated() {
  2112.         return !!Il2Cpp.Api._classIsInflated(this);
  2113.     }
  2114.     /** Determines whether the current class is an interface. */
  2115.     get isInterface() {
  2116.         return !!Il2Cpp.Api._classIsInterface(this);
  2117.     }
  2118.     /** Determines whether the current class is a value type. */
  2119.     get isValueType() {
  2120.         return !!Il2Cpp.Api._classIsValueType(this);
  2121.     }
  2122.     /** Gets the interfaces implemented or inherited by the current class. */
  2123.     get interfaces() {
  2124.         return Array.from((0, utils_1.nativeIterator)(this, Il2Cpp.Api._classGetInterfaces, Il2Cpp.Class));
  2125.     }
  2126.     /** Gets the methods implemented by the current class. */
  2127.     get methods() {
  2128.         return Array.from((0, utils_1.nativeIterator)(this, Il2Cpp.Api._classGetMethods, Il2Cpp.Method));
  2129.     }
  2130.     /** Gets the name of the current class. */
  2131.     get name() {
  2132.         return Il2Cpp.Api._classGetName(this).readUtf8String();
  2133.     }
  2134.     /** Gets the namespace of the current class. */
  2135.     get namespace() {
  2136.         return Il2Cpp.Api._classGetNamespace(this).readUtf8String();
  2137.     }
  2138.     /** Gets the classes nested inside the current class. */
  2139.     get nestedClasses() {
  2140.         return Array.from((0, utils_1.nativeIterator)(this, Il2Cpp.Api._classGetNestedClasses, Il2Cpp.Class));
  2141.     }
  2142.     /** Gets the class from which the current class directly inherits. */
  2143.     get parent() {
  2144.         const handle = Il2Cpp.Api._classGetParent(this);
  2145.         return handle.isNull() ? null : new Il2Cpp.Class(handle);
  2146.     }
  2147.     /** Gets the rank (number of dimensions) of the current array class. */
  2148.     get rank() {
  2149.         return Il2Cpp.Api._classGetRank(this);
  2150.     }
  2151.     /** Gets a pointer to the static fields of the current class. */
  2152.     get staticFieldsData() {
  2153.         return Il2Cpp.Api._classGetStaticFieldData(this);
  2154.     }
  2155.     /** Gets the size of the instance - as a value type - of the current class. */
  2156.     get valueSize() {
  2157.         return Il2Cpp.Api._classGetValueSize(this, NULL);
  2158.     }
  2159.     /** Gets the type of the current class. */
  2160.     get type() {
  2161.         return new Il2Cpp.Type(Il2Cpp.Api._classGetType(this));
  2162.     }
  2163.     /** Allocates a new object of the current class. */
  2164.     alloc() {
  2165.         return new Il2Cpp.Object(Il2Cpp.Api._objectNew(this));
  2166.     }
  2167.     /** Gets the field identified by the given name. */
  2168.     field(name) {
  2169.         return this.tryField(name);
  2170.     }
  2171.     /** Builds a generic instance of the current generic class. */
  2172.     inflate(...classes) {
  2173.         if (!this.isGeneric) {
  2174.             (0, console_1.raise)(`cannot inflate class ${this.type.name}: it has no generic parameters`);
  2175.         }
  2176.         if (this.genericParameterCount != classes.length) {
  2177.             (0, console_1.raise)(`cannot inflate class ${this.type.name}: it needs ${this.genericParameterCount} generic parameter(s), not ${classes.length}`);
  2178.         }
  2179.         const types = classes.map(klass => klass.type.object);
  2180.         const typeArray = Il2Cpp.Array.from(Il2Cpp.Image.corlib.class("System.Type"), types);
  2181.         const inflatedType = this.type.object.method("MakeGenericType", 1).invoke(typeArray);
  2182.         return new Il2Cpp.Class(Il2Cpp.Api._classFromSystemType(inflatedType));
  2183.     }
  2184.     /** Calls the static constructor of the current class. */
  2185.     initialize() {
  2186.         Il2Cpp.Api._classInit(this);
  2187.     }
  2188.     /** Determines whether an instance of `other` class can be assigned to a variable of the current type. */
  2189.     isAssignableFrom(other) {
  2190.         return !!Il2Cpp.Api._classIsAssignableFrom(this, other);
  2191.     }
  2192.     /** Determines whether the current class derives from `other` class. */
  2193.     isSubclassOf(other, checkInterfaces) {
  2194.         return !!Il2Cpp.Api._classIsSubclassOf(this, other, +checkInterfaces);
  2195.     }
  2196.     /** Gets the method identified by the given name and parameter count. */
  2197.     method(name, parameterCount = -1) {
  2198.         return this.tryMethod(name, parameterCount);
  2199.     }
  2200.     /** Gets the nested class with the given name. */
  2201.     nested(name) {
  2202.         return this.tryNested(name);
  2203.     }
  2204.     /** Allocates a new object of the current class and calls its default constructor. */
  2205.     new() {
  2206.         const object = this.alloc();
  2207.         const exceptionArray = Memory.alloc(Process.pointerSize);
  2208.         Il2Cpp.Api._objectInit(object, exceptionArray);
  2209.         const exception = exceptionArray.readPointer();
  2210.         if (!exception.isNull()) {
  2211.             (0, console_1.raise)(new Il2Cpp.Object(exception).toString());
  2212.         }
  2213.         return object;
  2214.     }
  2215.     /** Gets the field with the given name. */
  2216.     tryField(name) {
  2217.         const handle = Il2Cpp.Api._classGetFieldFromName(this, Memory.allocUtf8String(name));
  2218.         return handle.isNull() ? null : new Il2Cpp.Field(handle);
  2219.     }
  2220.     /** Gets the method with the given name and parameter count. */
  2221.     tryMethod(name, parameterCount = -1) {
  2222.         const handle = Il2Cpp.Api._classGetMethodFromName(this, Memory.allocUtf8String(name), parameterCount);
  2223.         return handle.isNull() ? null : new Il2Cpp.Method(handle);
  2224.     }
  2225.     /** Gets the nested class with the given name. */
  2226.     tryNested(name) {
  2227.         return this.nestedClasses.find(e => e.name == name);
  2228.     }
  2229.     /** */
  2230.     toString() {
  2231.         const inherited = [this.parent].concat(this.interfaces);
  2232.         return `\
  2233. // ${this.assemblyName}
  2234. ${this.isEnum ? `enum` : this.isValueType ? `struct` : this.isInterface ? `interface` : `class`} \
  2235. ${this.type.name}\
  2236. ${inherited ? ` : ${inherited.map(e => e?.type.name).join(`, `)}` : ``}
  2237. {
  2238.     ${this.fields.join(`\n    `)}
  2239.     ${this.methods.join(`\n    `)}
  2240. }`;
  2241.     }
  2242.     /** Executes a callback for every defined class. */
  2243.     static enumerate(block) {
  2244.         const callback = new NativeCallback(function (klass, _) {
  2245.             block(new Il2Cpp.Class(klass));
  2246.         }, "void", ["pointer", "pointer"]);
  2247.         return Il2Cpp.Api._classForEach(callback, NULL);
  2248.     }
  2249. };
  2250. __decorate([
  2251.     decorator_cache_getter_1.cache
  2252. ], Il2CppClass.prototype, "actualInstanceSize", null);
  2253. __decorate([
  2254.     decorator_cache_getter_1.cache
  2255. ], Il2CppClass.prototype, "arrayClass", null);
  2256. __decorate([
  2257.     decorator_cache_getter_1.cache
  2258. ], Il2CppClass.prototype, "arrayElementSize", null);
  2259. __decorate([
  2260.     decorator_cache_getter_1.cache
  2261. ], Il2CppClass.prototype, "assemblyName", null);
  2262. __decorate([
  2263.     decorator_cache_getter_1.cache
  2264. ], Il2CppClass.prototype, "declaringClass", null);
  2265. __decorate([
  2266.     decorator_cache_getter_1.cache
  2267. ], Il2CppClass.prototype, "baseType", null);
  2268. __decorate([
  2269.     decorator_cache_getter_1.cache
  2270. ], Il2CppClass.prototype, "elementClass", null);
  2271. __decorate([
  2272.     decorator_cache_getter_1.cache
  2273. ], Il2CppClass.prototype, "fields", null);
  2274. __decorate([
  2275.     decorator_cache_getter_1.cache
  2276. ], Il2CppClass.prototype, "flags", null);
  2277. __decorate([
  2278.     decorator_cache_getter_1.cache
  2279. ], Il2CppClass.prototype, "genericParameterCount", null);
  2280. __decorate([
  2281.     decorator_cache_getter_1.cache
  2282. ], Il2CppClass.prototype, "hasReferences", null);
  2283. __decorate([
  2284.     decorator_cache_getter_1.cache
  2285. ], Il2CppClass.prototype, "hasStaticConstructor", null);
  2286. __decorate([
  2287.     decorator_cache_getter_1.cache
  2288. ], Il2CppClass.prototype, "image", null);
  2289. __decorate([
  2290.     decorator_cache_getter_1.cache
  2291. ], Il2CppClass.prototype, "instanceSize", null);
  2292. __decorate([
  2293.     decorator_cache_getter_1.cache
  2294. ], Il2CppClass.prototype, "isAbstract", null);
  2295. __decorate([
  2296.     decorator_cache_getter_1.cache
  2297. ], Il2CppClass.prototype, "isBlittable", null);
  2298. __decorate([
  2299.     decorator_cache_getter_1.cache
  2300. ], Il2CppClass.prototype, "isEnum", null);
  2301. __decorate([
  2302.     decorator_cache_getter_1.cache
  2303. ], Il2CppClass.prototype, "isGeneric", null);
  2304. __decorate([
  2305.     decorator_cache_getter_1.cache
  2306. ], Il2CppClass.prototype, "isInflated", null);
  2307. __decorate([
  2308.     decorator_cache_getter_1.cache
  2309. ], Il2CppClass.prototype, "isInterface", null);
  2310. __decorate([
  2311.     decorator_cache_getter_1.cache
  2312. ], Il2CppClass.prototype, "isValueType", null);
  2313. __decorate([
  2314.     decorator_cache_getter_1.cache
  2315. ], Il2CppClass.prototype, "interfaces", null);
  2316. __decorate([
  2317.     decorator_cache_getter_1.cache
  2318. ], Il2CppClass.prototype, "methods", null);
  2319. __decorate([
  2320.     decorator_cache_getter_1.cache
  2321. ], Il2CppClass.prototype, "name", null);
  2322. __decorate([
  2323.     decorator_cache_getter_1.cache
  2324. ], Il2CppClass.prototype, "namespace", null);
  2325. __decorate([
  2326.     decorator_cache_getter_1.cache
  2327. ], Il2CppClass.prototype, "nestedClasses", null);
  2328. __decorate([
  2329.     decorator_cache_getter_1.cache
  2330. ], Il2CppClass.prototype, "parent", null);
  2331. __decorate([
  2332.     decorator_cache_getter_1.cache
  2333. ], Il2CppClass.prototype, "rank", null);
  2334. __decorate([
  2335.     decorator_cache_getter_1.cache
  2336. ], Il2CppClass.prototype, "staticFieldsData", null);
  2337. __decorate([
  2338.     decorator_cache_getter_1.cache
  2339. ], Il2CppClass.prototype, "valueSize", null);
  2340. __decorate([
  2341.     decorator_cache_getter_1.cache
  2342. ], Il2CppClass.prototype, "type", null);
  2343. __decorate([
  2344.     (0, utils_1.levenshtein)("fields")
  2345. ], Il2CppClass.prototype, "field", null);
  2346. __decorate([
  2347.     (0, utils_1.levenshtein)("methods")
  2348. ], Il2CppClass.prototype, "method", null);
  2349. __decorate([
  2350.     (0, utils_1.levenshtein)("nestedClasses")
  2351. ], Il2CppClass.prototype, "nested", null);
  2352. Il2CppClass = __decorate([
  2353.     utils_1.cacheInstances
  2354. ], Il2CppClass);
  2355. Il2Cpp.Class = Il2CppClass;
  2356.  
  2357. },{"../../utils/console":32,"../../utils/native-struct":33,"../../utils/utils":35,"decorator-cache-getter":3}],13:[function(require,module,exports){
  2358. "use strict";
  2359. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2360.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  2361.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  2362.     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;
  2363.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  2364. };
  2365. Object.defineProperty(exports, "__esModule", { value: true });
  2366. const decorator_cache_getter_1 = require("decorator-cache-getter");
  2367. const utils_1 = require("../../utils/utils");
  2368. /** Represents a `Il2CppDomain`. */
  2369. class Il2CppDomain {
  2370.     constructor() { }
  2371.     /** Gets the assemblies that have been loaded into the execution context of the application domain. */
  2372.     static get assemblies() {
  2373.         const sizePointer = Memory.alloc(Process.pointerSize);
  2374.         const startPointer = Il2Cpp.Api._domainGetAssemblies(this, sizePointer);
  2375.         const count = sizePointer.readInt();
  2376.         const array = new Array(count);
  2377.         for (let i = 0; i < count; i++) {
  2378.             array[i] = new Il2Cpp.Assembly(startPointer.add(i * Process.pointerSize).readPointer());
  2379.         }
  2380.         if (count == 0) {
  2381.             for (const assemblyObject of this.object.method("GetAssemblies").overload().invoke()) {
  2382.                 const assemblyName = assemblyObject.method("GetSimpleName").invoke().content;
  2383.                 if (assemblyName != null) {
  2384.                     array.push(this.assembly(assemblyName));
  2385.                 }
  2386.             }
  2387.         }
  2388.         return array;
  2389.     }
  2390.     /** Gets the application domain handle. */
  2391.     static get handle() {
  2392.         return Il2Cpp.Api._domainGet();
  2393.     }
  2394.     /** Gets the encompassing object of the application domain. */
  2395.     static get object() {
  2396.         return Il2Cpp.Image.corlib.class("System.AppDomain").method("get_CurrentDomain").invoke();
  2397.     }
  2398.     /** Opens and loads the assembly with the given name. */
  2399.     static assembly(name) {
  2400.         return this.tryAssembly(name);
  2401.     }
  2402.     /** Attached a new thread to the application domain. */
  2403.     static attach() {
  2404.         return new Il2Cpp.Thread(Il2Cpp.Api._threadAttach(this));
  2405.     }
  2406.     /** Opens and loads the assembly with the given name. */
  2407.     static tryAssembly(name) {
  2408.         const handle = Il2Cpp.Api._domainAssemblyOpen(this, Memory.allocUtf8String(name));
  2409.         return handle.isNull() ? null : new Il2Cpp.Assembly(handle);
  2410.     }
  2411. }
  2412. __decorate([
  2413.     decorator_cache_getter_1.cache
  2414. ], Il2CppDomain, "assemblies", null);
  2415. __decorate([
  2416.     decorator_cache_getter_1.cache
  2417. ], Il2CppDomain, "handle", null);
  2418. __decorate([
  2419.     decorator_cache_getter_1.cache
  2420. ], Il2CppDomain, "object", null);
  2421. __decorate([
  2422.     (0, utils_1.levenshtein)("assemblies")
  2423. ], Il2CppDomain, "assembly", null);
  2424. Il2Cpp.Domain = Il2CppDomain;
  2425.  
  2426. },{"../../utils/utils":35,"decorator-cache-getter":3}],14:[function(require,module,exports){
  2427. "use strict";
  2428. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2429.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  2430.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  2431.     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;
  2432.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  2433. };
  2434. Object.defineProperty(exports, "__esModule", { value: true });
  2435. const decorator_cache_getter_1 = require("decorator-cache-getter");
  2436. const console_1 = require("../../utils/console");
  2437. const native_struct_1 = require("../../utils/native-struct");
  2438. const utils_1 = require("../utils");
  2439. /** Represents a `FieldInfo`. */
  2440. class Il2CppField extends native_struct_1.NonNullNativeStruct {
  2441.     /** Gets the class in which this field is defined. */
  2442.     get class() {
  2443.         return new Il2Cpp.Class(Il2Cpp.Api._fieldGetClass(this));
  2444.     }
  2445.     /** Gets the flags of the current field. */
  2446.     get flags() {
  2447.         return Il2Cpp.Api._fieldGetFlags(this);
  2448.     }
  2449.     /** Determines whether this field value is known at compile time. */
  2450.     get isLiteral() {
  2451.         return !!Il2Cpp.Api._fieldIsLiteral(this);
  2452.     }
  2453.     /** Determines whether this field is static. */
  2454.     get isStatic() {
  2455.         return !!Il2Cpp.Api._fieldIsStatic(this);
  2456.     }
  2457.     /** Determines whether this field is thread static. */
  2458.     get isThreadStatic() {
  2459.         return !!Il2Cpp.Api._fieldIsThreadStatic(this);
  2460.     }
  2461.     /** Gets the access modifier of this field. */
  2462.     get modifier() {
  2463.         return Il2Cpp.Api._fieldGetModifier(this).readUtf8String();
  2464.     }
  2465.     /** Gets the name of this field. */
  2466.     get name() {
  2467.         return Il2Cpp.Api._fieldGetName(this).readUtf8String();
  2468.     }
  2469.     /** Gets the offset of this field, calculated as the difference with its owner virtual address. */
  2470.     get offset() {
  2471.         return Il2Cpp.Api._fieldGetOffset(this);
  2472.     }
  2473.     /** Gets the type of this field. */
  2474.     get type() {
  2475.         return new Il2Cpp.Type(Il2Cpp.Api._fieldGetType(this));
  2476.     }
  2477.     /** Gets the value of this field. */
  2478.     get value() {
  2479.         const handle = Memory.alloc(Process.pointerSize);
  2480.         Il2Cpp.Api._fieldGetStaticValue(this.handle, handle);
  2481.         return (0, utils_1.read)(handle, this.type);
  2482.     }
  2483.     /** Sets the value of this field. Thread static or literal values cannot be altered yet. */
  2484.     set value(value) {
  2485.         if (this.isThreadStatic || this.isLiteral) {
  2486.             (0, console_1.raise)(`cannot modify the value of field ${this.name}: is thread static or literal`);
  2487.         }
  2488.         const handle = Memory.alloc(Process.pointerSize);
  2489.         (0, utils_1.write)(handle, value, this.type);
  2490.         Il2Cpp.Api._fieldSetStaticValue(this.handle, handle);
  2491.     }
  2492.     /** */
  2493.     toString() {
  2494.         return `\
  2495. ${this.isThreadStatic ? `[ThreadStatic] ` : ``}\
  2496. ${this.isStatic ? `static ` : ``}\
  2497. ${this.type.name} \
  2498. ${this.name}\
  2499. ${this.isLiteral ? ` = ${this.type.class.isEnum ? (0, utils_1.read)(this.value.handle, this.type.class.baseType) : this.value}` : ``};\
  2500. ${this.isThreadStatic || this.isLiteral ? `` : ` // 0x${this.offset.toString(16)}`}`;
  2501.     }
  2502.     /** @internal */
  2503.     withHolder(instance) {
  2504.         let valueHandle = instance.handle.add(this.offset);
  2505.         if (instance instanceof Il2Cpp.ValueType) {
  2506.             valueHandle = valueHandle.sub(Il2Cpp.Runtime.objectHeaderSize);
  2507.         }
  2508.         return new Proxy(this, {
  2509.             get(target, property) {
  2510.                 if (property == "value") {
  2511.                     return (0, utils_1.read)(valueHandle, target.type);
  2512.                 }
  2513.                 return Reflect.get(target, property);
  2514.             },
  2515.             set(target, property, value) {
  2516.                 if (property == "value") {
  2517.                     (0, utils_1.write)(valueHandle, value, target.type);
  2518.                     return true;
  2519.                 }
  2520.                 return Reflect.set(target, property, value);
  2521.             }
  2522.         });
  2523.     }
  2524. }
  2525. __decorate([
  2526.     decorator_cache_getter_1.cache
  2527. ], Il2CppField.prototype, "class", null);
  2528. __decorate([
  2529.     decorator_cache_getter_1.cache
  2530. ], Il2CppField.prototype, "flags", null);
  2531. __decorate([
  2532.     decorator_cache_getter_1.cache
  2533. ], Il2CppField.prototype, "isLiteral", null);
  2534. __decorate([
  2535.     decorator_cache_getter_1.cache
  2536. ], Il2CppField.prototype, "isStatic", null);
  2537. __decorate([
  2538.     decorator_cache_getter_1.cache
  2539. ], Il2CppField.prototype, "isThreadStatic", null);
  2540. __decorate([
  2541.     decorator_cache_getter_1.cache
  2542. ], Il2CppField.prototype, "name", null);
  2543. __decorate([
  2544.     decorator_cache_getter_1.cache
  2545. ], Il2CppField.prototype, "offset", null);
  2546. __decorate([
  2547.     decorator_cache_getter_1.cache
  2548. ], Il2CppField.prototype, "type", null);
  2549. Reflect.set(Il2Cpp, "Field", Il2CppField);
  2550.  
  2551. },{"../../utils/console":32,"../../utils/native-struct":33,"../utils":30,"decorator-cache-getter":3}],15:[function(require,module,exports){
  2552. "use strict";
  2553. Object.defineProperty(exports, "__esModule", { value: true });
  2554. /** Represents a GCHandle. */
  2555. class Il2CppGCHandle {
  2556.     handle;
  2557.     /** @internal */
  2558.     constructor(handle) {
  2559.         this.handle = handle;
  2560.     }
  2561.     /** Gets the object associated to this handle. */
  2562.     get target() {
  2563.         const handle = Il2Cpp.Api._gcHandleGetTarget(this.handle);
  2564.         return handle.isNull() ? null : new Il2Cpp.Object(handle);
  2565.     }
  2566.     /** Frees this handle. */
  2567.     free() {
  2568.         return Il2Cpp.Api._gcHandleFree(this.handle);
  2569.     }
  2570. }
  2571. Il2Cpp.GC.Handle = Il2CppGCHandle;
  2572.  
  2573. },{}],16:[function(require,module,exports){
  2574. "use strict";
  2575. var __importDefault = (this && this.__importDefault) || function (mod) {
  2576.     return (mod && mod.__esModule) ? mod : { "default": mod };
  2577. };
  2578. Object.defineProperty(exports, "__esModule", { value: true });
  2579. const versioning_1 = __importDefault(require("versioning"));
  2580. /** Garbage collector utility functions. */
  2581. class Il2CppGC {
  2582.     constructor() { }
  2583.     /** Gets the heap size in bytes. */
  2584.     static get heapSize() {
  2585.         return Il2Cpp.Api._gcGetHeapSize();
  2586.     }
  2587.     /** Determines whether the garbage collector is disabled. */
  2588.     static get isEnabled() {
  2589.         return !Il2Cpp.Api._gcIsDisabled();
  2590.     }
  2591.     /** Determines whether the garbage collector is incremental. */
  2592.     static get isIncremental() {
  2593.         return !!Il2Cpp.Api._gcIsIncremental();
  2594.     }
  2595.     /** Gets the number of nanoseconds the garbage collector can spend in a collection step. */
  2596.     static get maxTimeSlice() {
  2597.         return Il2Cpp.Api._gcGetMaxTimeSlice();
  2598.     }
  2599.     /** Gets the used heap size in bytes. */
  2600.     static get usedHeapSize() {
  2601.         return Il2Cpp.Api._gcGetUsedSize();
  2602.     }
  2603.     /** Enables or disables the garbage collector. */
  2604.     static set isEnabled(value) {
  2605.         value ? Il2Cpp.Api._gcEnable() : Il2Cpp.Api._gcDisable();
  2606.     }
  2607.     /** Sets the number of nanoseconds the garbage collector can spend in a collection step. */
  2608.     static set maxTimeSlice(nanoseconds) {
  2609.         Il2Cpp.Api._gcSetMaxTimeSlice(nanoseconds);
  2610.     }
  2611.     /** Returns the heap allocated objects of the specified class. This variant reads GC descriptors. */
  2612.     static choose(klass) {
  2613.         const matches = [];
  2614.         const callback = (objects, size, _) => {
  2615.             for (let i = 0; i < size; i++) {
  2616.                 matches.push(new Il2Cpp.Object(objects.add(i * Process.pointerSize).readPointer()));
  2617.             }
  2618.         };
  2619.         const chooseCallback = new NativeCallback(callback, "void", ["pointer", "int", "pointer"]);
  2620.         if (versioning_1.default.gte(Il2Cpp.unityVersion, "2021.2.0")) {
  2621.             const realloc = (handle, size) => {
  2622.                 if (!handle.isNull() && size.compare(0) == 0) {
  2623.                     Il2Cpp.free(handle);
  2624.                     return NULL;
  2625.                 }
  2626.                 else {
  2627.                     return Il2Cpp.alloc(size);
  2628.                 }
  2629.             };
  2630.             const reallocCallback = new NativeCallback(realloc, "pointer", ["pointer", "size_t", "pointer"]);
  2631.             const state = Il2Cpp.Api._livenessAllocateStruct(klass.handle, 0, chooseCallback, NULL, reallocCallback);
  2632.             Il2Cpp.Api._livenessCalculationFromStatics(state);
  2633.             Il2Cpp.Api._livenessFinalize(state);
  2634.             Il2Cpp.Api._livenessFreeStruct(state);
  2635.         }
  2636.         else {
  2637.             const onWorld = new NativeCallback(() => { }, "void", []);
  2638.             const state = Il2Cpp.Api._livenessCalculationBegin(klass.handle, 0, chooseCallback, NULL, onWorld, onWorld);
  2639.             Il2Cpp.Api._livenessCalculationFromStatics(state);
  2640.             Il2Cpp.Api._livenessCalculationEnd(state);
  2641.         }
  2642.         return matches;
  2643.     }
  2644.     /** Forces a garbage collection of the specified generation. */
  2645.     static collect(generation) {
  2646.         Il2Cpp.Api._gcCollect(generation < 0 ? 0 : generation > 2 ? 2 : generation);
  2647.     }
  2648.     /** Forces a garbage collection. */
  2649.     static collectALittle() {
  2650.         Il2Cpp.Api._gcCollectALittle();
  2651.     }
  2652.     /** Resumes all the previously stopped threads. */
  2653.     static startWorld() {
  2654.         return Il2Cpp.Api._gcStartWorld();
  2655.     }
  2656.     /** Performs an incremental garbage collection. */
  2657.     static startIncrementalCollection() {
  2658.         return Il2Cpp.Api._gcStartIncrementalCollection();
  2659.     }
  2660.     /** Stops all threads which may access the garbage collected heap, other than the caller. */
  2661.     static stopWorld() {
  2662.         return Il2Cpp.Api._gcStopWorld();
  2663.     }
  2664. }
  2665. Reflect.set(Il2Cpp, "GC", Il2CppGC);
  2666.  
  2667. },{"versioning":38}],17:[function(require,module,exports){
  2668. "use strict";
  2669. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2670.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  2671.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  2672.     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;
  2673.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  2674. };
  2675. Object.defineProperty(exports, "__esModule", { value: true });
  2676. const decorator_cache_getter_1 = require("decorator-cache-getter");
  2677. const native_struct_1 = require("../../utils/native-struct");
  2678. const utils_1 = require("../../utils/utils");
  2679. /** Represents a `Il2CppImage`. */
  2680. let Il2CppImage = class Il2CppImage extends native_struct_1.NonNullNativeStruct {
  2681.     /** Gets the COR library. */
  2682.     static get corlib() {
  2683.         return new Il2Cpp.Image(Il2Cpp.Api._getCorlib());
  2684.     }
  2685.     /** Gets the assembly in which the current image is defined. */
  2686.     get assembly() {
  2687.         return new Il2Cpp.Assembly(Il2Cpp.Api._imageGetAssembly(this));
  2688.     }
  2689.     /** Gets the amount of classes defined in this image. */
  2690.     get classCount() {
  2691.         return Il2Cpp.Api._imageGetClassCount(this);
  2692.     }
  2693.     /** Gets the classes defined in this image. */
  2694.     get classes() {
  2695.         if (Il2Cpp.unityVersionIsBelow201830) {
  2696.             const types = this.assembly.object.method("GetTypes").invoke(false);
  2697.             // On Unity 5.3.8f1, getting System.Reflection.Emit.OpCodes type name
  2698.             // without iterating all the classes first somehow blows things up at
  2699.             // app startup, hence the `Array.from`.
  2700.             return Array.from(types).map(e => new Il2Cpp.Class(Il2Cpp.Api._classFromSystemType(e)));
  2701.         }
  2702.         else {
  2703.             return Array.from(Array(this.classCount), (_, i) => new Il2Cpp.Class(Il2Cpp.Api._imageGetClass(this, i)));
  2704.         }
  2705.     }
  2706.     /** Gets the name of this image. */
  2707.     get name() {
  2708.         return Il2Cpp.Api._imageGetName(this).readUtf8String();
  2709.     }
  2710.     /** Gets the class with the specified name defined in this image. */
  2711.     class(name) {
  2712.         return this.tryClass(name);
  2713.     }
  2714.     /** Gets the class with the specified name defined in this image. */
  2715.     tryClass(name) {
  2716.         const dotIndex = name.lastIndexOf(".");
  2717.         const classNamespace = Memory.allocUtf8String(dotIndex == -1 ? "" : name.slice(0, dotIndex));
  2718.         const className = Memory.allocUtf8String(name.slice(dotIndex + 1));
  2719.         const handle = Il2Cpp.Api._classFromName(this, classNamespace, className);
  2720.         return handle.isNull() ? null : new Il2Cpp.Class(handle);
  2721.     }
  2722. };
  2723. __decorate([
  2724.     decorator_cache_getter_1.cache
  2725. ], Il2CppImage.prototype, "assembly", null);
  2726. __decorate([
  2727.     decorator_cache_getter_1.cache
  2728. ], Il2CppImage.prototype, "classCount", null);
  2729. __decorate([
  2730.     decorator_cache_getter_1.cache
  2731. ], Il2CppImage.prototype, "classes", null);
  2732. __decorate([
  2733.     decorator_cache_getter_1.cache
  2734. ], Il2CppImage.prototype, "name", null);
  2735. __decorate([
  2736.     (0, utils_1.levenshtein)("classes", e => (e.namespace ? `${e.namespace}.${e.name}` : e.name))
  2737. ], Il2CppImage.prototype, "class", null);
  2738. __decorate([
  2739.     decorator_cache_getter_1.cache
  2740. ], Il2CppImage, "corlib", null);
  2741. Il2CppImage = __decorate([
  2742.     utils_1.cacheInstances
  2743. ], Il2CppImage);
  2744. Il2Cpp.Image = Il2CppImage;
  2745.  
  2746. },{"../../utils/native-struct":33,"../../utils/utils":35,"decorator-cache-getter":3}],18:[function(require,module,exports){
  2747. "use strict";
  2748. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2749.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  2750.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  2751.     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;
  2752.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  2753. };
  2754. Object.defineProperty(exports, "__esModule", { value: true });
  2755. const decorator_cache_getter_1 = require("decorator-cache-getter");
  2756. const native_struct_1 = require("../../utils/native-struct");
  2757. const utils_1 = require("../../utils/utils");
  2758. /** Represents a `Il2CppManagedMemorySnapshot`. */
  2759. class Il2CppMemorySnapshot extends native_struct_1.NonNullNativeStruct {
  2760.     /** Captures a memory snapshot. */
  2761.     static capture() {
  2762.         return new Il2Cpp.MemorySnapshot();
  2763.     }
  2764.     /** Creates a memory snapshot with the given handle. */
  2765.     constructor(handle = Il2Cpp.Api._memorySnapshotCapture()) {
  2766.         super(handle);
  2767.     }
  2768.     /** Gets any initialized class. */
  2769.     get classes() {
  2770.         return Array.from((0, utils_1.nativeIterator)(this, Il2Cpp.Api._memorySnapshotGetClasses, Il2Cpp.Class));
  2771.     }
  2772.     /** Gets the objects tracked by this memory snapshot. */
  2773.     get objects() {
  2774.         const array = [];
  2775.         const [count, start] = Il2Cpp.Api._memorySnapshotGetGCHandles(this);
  2776.         for (let i = 0; i < count; i++) {
  2777.             array.push(new Il2Cpp.Object(start.add(i * Process.pointerSize).readPointer()));
  2778.         }
  2779.         return array;
  2780.     }
  2781.     /** Frees this memory snapshot. */
  2782.     free() {
  2783.         Il2Cpp.Api._memorySnapshotFree(this);
  2784.     }
  2785. }
  2786. __decorate([
  2787.     decorator_cache_getter_1.cache
  2788. ], Il2CppMemorySnapshot.prototype, "classes", null);
  2789. __decorate([
  2790.     decorator_cache_getter_1.cache
  2791. ], Il2CppMemorySnapshot.prototype, "objects", null);
  2792. Il2Cpp.MemorySnapshot = Il2CppMemorySnapshot;
  2793.  
  2794. },{"../../utils/native-struct":33,"../../utils/utils":35,"decorator-cache-getter":3}],19:[function(require,module,exports){
  2795. "use strict";
  2796. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2797.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  2798.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  2799.     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;
  2800.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  2801. };
  2802. Object.defineProperty(exports, "__esModule", { value: true });
  2803. const decorator_cache_getter_1 = require("decorator-cache-getter");
  2804. const console_1 = require("../../utils/console");
  2805. const native_struct_1 = require("../../utils/native-struct");
  2806. const utils_1 = require("../../utils/utils");
  2807. const utils_2 = require("../utils");
  2808. /** Represents a `MethodInfo`. */
  2809. class Il2CppMethod extends native_struct_1.NonNullNativeStruct {
  2810.     /** Gets the class in which this method is defined. */
  2811.     get class() {
  2812.         return new Il2Cpp.Class(Il2Cpp.Api._methodGetClass(this));
  2813.     }
  2814.     /** Gets the flags of the current method. */
  2815.     get flags() {
  2816.         return Il2Cpp.Api._methodGetFlags(this, NULL);
  2817.     }
  2818.     /** Gets the implementation flags of the current method. */
  2819.     get implementationFlags() {
  2820.         const implementationFlagsPointer = Memory.alloc(Process.pointerSize);
  2821.         Il2Cpp.Api._methodGetFlags(this, implementationFlagsPointer);
  2822.         return implementationFlagsPointer.readU32();
  2823.     }
  2824.     /** */
  2825.     get fridaSignature() {
  2826.         const types = [];
  2827.         for (const parameter of this.parameters) {
  2828.             types.push(parameter.type.fridaAlias);
  2829.         }
  2830.         if (!this.isStatic || Il2Cpp.unityVersionIsBelow201830) {
  2831.             types.unshift("pointer");
  2832.         }
  2833.         if (this.isInflated) {
  2834.             types.push("pointer");
  2835.         }
  2836.         return types;
  2837.     }
  2838.     /** Gets the amount of generic parameters of this generic method. */
  2839.     get genericParameterCount() {
  2840.         if (!this.isGeneric) {
  2841.             return 0;
  2842.         }
  2843.         return this.object.method("GetGenericArguments").invoke().length;
  2844.     }
  2845.     /** Determines whether this method is external. */
  2846.     get isExternal() {
  2847.         return !!Il2Cpp.Api._methodIsExternal(this);
  2848.     }
  2849.     /** Determines whether this method is generic. */
  2850.     get isGeneric() {
  2851.         return !!Il2Cpp.Api._methodIsGeneric(this);
  2852.     }
  2853.     /** Determines whether this method is inflated (generic with a concrete type parameter). */
  2854.     get isInflated() {
  2855.         return !!Il2Cpp.Api._methodIsInflated(this);
  2856.     }
  2857.     /** Determines whether this method is static. */
  2858.     get isStatic() {
  2859.         return !Il2Cpp.Api._methodIsInstance(this);
  2860.     }
  2861.     /** Determines whether this method is synchronized. */
  2862.     get isSynchronized() {
  2863.         return !!Il2Cpp.Api._methodIsSynchronized(this);
  2864.     }
  2865.     /** Gets the access modifier of this method. */
  2866.     get modifier() {
  2867.         return Il2Cpp.Api._methodGetModifier(this).readUtf8String();
  2868.     }
  2869.     /** Gets the name of this method. */
  2870.     get name() {
  2871.         return Il2Cpp.Api._methodGetName(this).readUtf8String();
  2872.     }
  2873.     /** @internal */
  2874.     get nativeFunction() {
  2875.         return new NativeFunction(this.virtualAddress, this.returnType.fridaAlias, this.fridaSignature);
  2876.     }
  2877.     /** Gets the encompassing object of the current method. */
  2878.     get object() {
  2879.         return new Il2Cpp.Object(Il2Cpp.Api._methodGetObject(this, NULL));
  2880.     }
  2881.     /** Gets the amount of parameters of this method. */
  2882.     get parameterCount() {
  2883.         return Il2Cpp.Api._methodGetParameterCount(this);
  2884.     }
  2885.     /** Gets the parameters of this method. */
  2886.     get parameters() {
  2887.         return Array.from(Array(this.parameterCount), (_, i) => {
  2888.             const parameterName = Il2Cpp.Api._methodGetParameterName(this, i).readUtf8String();
  2889.             const parameterType = Il2Cpp.Api._methodGetParameterType(this, i);
  2890.             return new Il2Cpp.Parameter(parameterName, i, new Il2Cpp.Type(parameterType));
  2891.         });
  2892.     }
  2893.     /** Gets the relative virtual address (RVA) of this method. */
  2894.     get relativeVirtualAddress() {
  2895.         return this.virtualAddress.sub(Il2Cpp.module.base);
  2896.     }
  2897.     /** Gets the return type of this method. */
  2898.     get returnType() {
  2899.         return new Il2Cpp.Type(Il2Cpp.Api._methodGetReturnType(this));
  2900.     }
  2901.     /** Gets the virtual address (VA) to this method. */
  2902.     get virtualAddress() {
  2903.         return Il2Cpp.Api._methodGetPointer(this);
  2904.     }
  2905.     /** Replaces the body of this method. */
  2906.     set implementation(block) {
  2907.         const startIndex = +!this.isStatic | +Il2Cpp.unityVersionIsBelow201830;
  2908.         const callback = (...args) => {
  2909.             const parameters = this.parameters.map((e, i) => (0, utils_2.fromFridaValue)(args[i + startIndex], e.type));
  2910.             return (0, utils_2.toFridaValue)(block.call(this.isStatic ? this.class : new Il2Cpp.Object(args[0]), ...parameters));
  2911.         };
  2912.         try {
  2913.             Interceptor.replace(this.virtualAddress, new NativeCallback(callback, this.returnType.fridaAlias, this.fridaSignature));
  2914.         }
  2915.         catch (e) {
  2916.             switch (e.message) {
  2917.                 case "access violation accessing 0x0":
  2918.                     (0, console_1.raise)(`cannot implement method ${this.name}: it has a NULL virtual address`);
  2919.                 case `unable to intercept function at ${this.virtualAddress}; please file a bug`:
  2920.                     (0, console_1.warn)(`cannot implement method ${this.name}: it may be a thunk`);
  2921.                     break;
  2922.                 case "already replaced this function":
  2923.                     (0, console_1.warn)(`cannot implement method ${this.name}: already replaced by a thunk`);
  2924.                     break;
  2925.                 default:
  2926.                     throw e;
  2927.             }
  2928.         }
  2929.     }
  2930.     /** Creates a generic instance of the current generic method. */
  2931.     inflate(...classes) {
  2932.         if (!this.isGeneric) {
  2933.             (0, console_1.raise)(`cannot inflate method ${this.name}: it has no generic parameters`);
  2934.         }
  2935.         if (this.genericParameterCount != classes.length) {
  2936.             (0, console_1.raise)(`cannot inflate method ${this.name}: it needs ${this.genericParameterCount} generic parameter(s), not ${classes.length}`);
  2937.         }
  2938.         const types = classes.map(klass => klass.type.object);
  2939.         const typeArray = Il2Cpp.Array.from(Il2Cpp.Image.corlib.class("System.Type"), types);
  2940.         const inflatedMethodObject = this.object.method("MakeGenericMethod", 1).invoke(typeArray);
  2941.         return new Il2Cpp.Method(Il2Cpp.Api._methodGetFromReflection(inflatedMethodObject));
  2942.     }
  2943.     /** Invokes this method. */
  2944.     invoke(...parameters) {
  2945.         if (!this.isStatic) {
  2946.             (0, console_1.raise)(`cannot invoke a non-static method ${this.name}: must be invoked throught a Il2Cpp.Object, not a Il2Cpp.Class`);
  2947.         }
  2948.         return this.invokeRaw(NULL, ...parameters);
  2949.     }
  2950.     /** @internal */
  2951.     invokeRaw(instance, ...parameters) {
  2952.         const allocatedParameters = parameters.map(utils_2.toFridaValue);
  2953.         if (!this.isStatic || Il2Cpp.unityVersionIsBelow201830) {
  2954.             allocatedParameters.unshift(instance);
  2955.         }
  2956.         if (this.isInflated) {
  2957.             allocatedParameters.push(this.handle);
  2958.         }
  2959.         try {
  2960.             const returnValue = this.nativeFunction(...allocatedParameters);
  2961.             return (0, utils_2.fromFridaValue)(returnValue, this.returnType);
  2962.         }
  2963.         catch (e) {
  2964.             if (e == null) {
  2965.                 (0, console_1.raise)("an unexpected native function exception occurred, this is due to parameter types mismatch");
  2966.             }
  2967.             switch (e.message) {
  2968.                 case "bad argument count":
  2969.                     (0, console_1.raise)(`cannot invoke method ${this.name}: it needs ${this.parameterCount} parameter(s), not ${parameters.length}`);
  2970.                 case "expected a pointer":
  2971.                 case "expected number":
  2972.                 case "expected array with fields":
  2973.                     (0, console_1.raise)(`cannot invoke method ${this.name}: parameter types mismatch`);
  2974.             }
  2975.             throw e;
  2976.         }
  2977.     }
  2978.     /** Gets the overloaded method with the given parameter types. */
  2979.     overload(...parameterTypes) {
  2980.         const result = this.tryOverload(...parameterTypes);
  2981.         if (result != undefined)
  2982.             return result;
  2983.         (0, console_1.raise)(`cannot find overloaded method ${this.name}(${parameterTypes})`);
  2984.     }
  2985.     /** Gets the parameter with the given name. */
  2986.     parameter(name) {
  2987.         return this.tryParameter(name);
  2988.     }
  2989.     /** Restore the original method implementation. */
  2990.     revert() {
  2991.         Interceptor.revert(this.virtualAddress);
  2992.         Interceptor.flush();
  2993.     }
  2994.     /** Gets the overloaded method with the given parameter types. */
  2995.     tryOverload(...parameterTypes) {
  2996.         return this.class.methods.find(e => e.name == this.name &&
  2997.             e.parameterCount == parameterTypes.length &&
  2998.             e.parameters.every((e, i) => e.type.name == parameterTypes[i]));
  2999.     }
  3000.     /** Gets the parameter with the given name. */
  3001.     tryParameter(name) {
  3002.         return this.parameters.find(e => e.name == name);
  3003.     }
  3004.     /** */
  3005.     toString() {
  3006.         return `\
  3007. ${this.isStatic ? `static ` : ``}\
  3008. ${this.returnType.name} \
  3009. ${this.name}\
  3010. (${this.parameters.join(`, `)});\
  3011. ${this.virtualAddress.isNull() ? `` : ` // 0x${this.relativeVirtualAddress.toString(16).padStart(8, `0`)}`}`;
  3012.     }
  3013.     /** @internal */
  3014.     withHolder(instance) {
  3015.         return new Proxy(this, {
  3016.             get(target, property) {
  3017.                 switch (property) {
  3018.                     case "invoke":
  3019.                         return target.invokeRaw.bind(target, instance.handle);
  3020.                     case "inflate":
  3021.                     case "overload":
  3022.                     case "tryOverload":
  3023.                         return function (...args) {
  3024.                             return target[property](...args)?.withHolder(instance);
  3025.                         };
  3026.                 }
  3027.                 return Reflect.get(target, property);
  3028.             }
  3029.         });
  3030.     }
  3031. }
  3032. __decorate([
  3033.     decorator_cache_getter_1.cache
  3034. ], Il2CppMethod.prototype, "class", null);
  3035. __decorate([
  3036.     decorator_cache_getter_1.cache
  3037. ], Il2CppMethod.prototype, "flags", null);
  3038. __decorate([
  3039.     decorator_cache_getter_1.cache
  3040. ], Il2CppMethod.prototype, "implementationFlags", null);
  3041. __decorate([
  3042.     decorator_cache_getter_1.cache
  3043. ], Il2CppMethod.prototype, "fridaSignature", null);
  3044. __decorate([
  3045.     decorator_cache_getter_1.cache
  3046. ], Il2CppMethod.prototype, "genericParameterCount", null);
  3047. __decorate([
  3048.     decorator_cache_getter_1.cache
  3049. ], Il2CppMethod.prototype, "isExternal", null);
  3050. __decorate([
  3051.     decorator_cache_getter_1.cache
  3052. ], Il2CppMethod.prototype, "isGeneric", null);
  3053. __decorate([
  3054.     decorator_cache_getter_1.cache
  3055. ], Il2CppMethod.prototype, "isInflated", null);
  3056. __decorate([
  3057.     decorator_cache_getter_1.cache
  3058. ], Il2CppMethod.prototype, "isStatic", null);
  3059. __decorate([
  3060.     decorator_cache_getter_1.cache
  3061. ], Il2CppMethod.prototype, "isSynchronized", null);
  3062. __decorate([
  3063.     decorator_cache_getter_1.cache
  3064. ], Il2CppMethod.prototype, "name", null);
  3065. __decorate([
  3066.     decorator_cache_getter_1.cache
  3067. ], Il2CppMethod.prototype, "nativeFunction", null);
  3068. __decorate([
  3069.     decorator_cache_getter_1.cache
  3070. ], Il2CppMethod.prototype, "object", null);
  3071. __decorate([
  3072.     decorator_cache_getter_1.cache
  3073. ], Il2CppMethod.prototype, "parameterCount", null);
  3074. __decorate([
  3075.     decorator_cache_getter_1.cache
  3076. ], Il2CppMethod.prototype, "parameters", null);
  3077. __decorate([
  3078.     decorator_cache_getter_1.cache
  3079. ], Il2CppMethod.prototype, "relativeVirtualAddress", null);
  3080. __decorate([
  3081.     decorator_cache_getter_1.cache
  3082. ], Il2CppMethod.prototype, "returnType", null);
  3083. __decorate([
  3084.     decorator_cache_getter_1.cache
  3085. ], Il2CppMethod.prototype, "virtualAddress", null);
  3086. __decorate([
  3087.     (0, utils_1.levenshtein)("parameters")
  3088. ], Il2CppMethod.prototype, "parameter", null);
  3089. Reflect.set(Il2Cpp, "Method", Il2CppMethod);
  3090.  
  3091. },{"../../utils/console":32,"../../utils/native-struct":33,"../../utils/utils":35,"../utils":30,"decorator-cache-getter":3}],20:[function(require,module,exports){
  3092. "use strict";
  3093. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  3094.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3095.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  3096.     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;
  3097.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  3098. };
  3099. Object.defineProperty(exports, "__esModule", { value: true });
  3100. const decorator_cache_getter_1 = require("decorator-cache-getter");
  3101. const native_struct_1 = require("../../utils/native-struct");
  3102. /** Represents a `Il2CppObject`. */
  3103. class Il2CppObject extends native_struct_1.NativeStruct {
  3104.     /** Gets the class of this object. */
  3105.     get class() {
  3106.         return new Il2Cpp.Class(Il2Cpp.Api._objectGetClass(this));
  3107.     }
  3108.     /** Gets the size of the current object. */
  3109.     get size() {
  3110.         return Il2Cpp.Api._objectGetSize(this);
  3111.     }
  3112.     /** Acquires an exclusive lock on the current object. */
  3113.     enter() {
  3114.         return Il2Cpp.Api._monitorEnter(this);
  3115.     }
  3116.     /** Release an exclusive lock on the current object. */
  3117.     exit() {
  3118.         return Il2Cpp.Api._monitorExit(this);
  3119.     }
  3120.     /** Gets the field with the given name. */
  3121.     field(name) {
  3122.         return this.class.field(name).withHolder(this);
  3123.     }
  3124.     /** Gets the method with the given name. */
  3125.     method(name, parameterCount = -1) {
  3126.         return this.class.method(name, parameterCount).withHolder(this);
  3127.     }
  3128.     /** Notifies a thread in the waiting queue of a change in the locked object's state. */
  3129.     pulse() {
  3130.         return Il2Cpp.Api._monitorPulse(this);
  3131.     }
  3132.     /** Notifies all waiting threads of a change in the object's state. */
  3133.     pulseAll() {
  3134.         return Il2Cpp.Api._monitorPulseAll(this);
  3135.     }
  3136.     /** Creates a reference to this object. */
  3137.     ref(pin) {
  3138.         return new Il2Cpp.GC.Handle(Il2Cpp.Api._gcHandleNew(this, +pin));
  3139.     }
  3140.     /** Gets the correct virtual method from the given virtual method. */
  3141.     virtualMethod(method) {
  3142.         return new Il2Cpp.Method(Il2Cpp.Api._objectGetVirtualMethod(this, method)).withHolder(this);
  3143.     }
  3144.     /** Attempts to acquire an exclusive lock on the current object. */
  3145.     tryEnter(timeout) {
  3146.         return !!Il2Cpp.Api._monitorTryEnter(this, timeout);
  3147.     }
  3148.     /** Gets the field with the given name. */
  3149.     tryField(name) {
  3150.         return this.class.tryField(name)?.withHolder(this);
  3151.     }
  3152.     /** Gets the field with the given name. */
  3153.     tryMethod(name, parameterCount = -1) {
  3154.         return this.class.tryMethod(name, parameterCount)?.withHolder(this);
  3155.     }
  3156.     /** Releases the lock on an object and attempts to block the current thread until it reacquires the lock. */
  3157.     tryWait(timeout) {
  3158.         return !!Il2Cpp.Api._monitorTryWait(this, timeout);
  3159.     }
  3160.     /** */
  3161.     toString() {
  3162.         return this.isNull() ? "null" : this.method("ToString").invoke().content ?? "null";
  3163.     }
  3164.     /** Unboxes the value type out of this object. */
  3165.     unbox() {
  3166.         return new Il2Cpp.ValueType(Il2Cpp.Api._objectUnbox(this), this.class.type);
  3167.     }
  3168.     /** Releases the lock on an object and blocks the current thread until it reacquires the lock. */
  3169.     wait() {
  3170.         return Il2Cpp.Api._monitorWait(this);
  3171.     }
  3172.     /** Creates a weak reference to this object. */
  3173.     weakRef(trackResurrection) {
  3174.         return new Il2Cpp.GC.Handle(Il2Cpp.Api._gcHandleNewWeakRef(this, +trackResurrection));
  3175.     }
  3176. }
  3177. __decorate([
  3178.     decorator_cache_getter_1.cache
  3179. ], Il2CppObject.prototype, "class", null);
  3180. __decorate([
  3181.     decorator_cache_getter_1.cache
  3182. ], Il2CppObject.prototype, "size", null);
  3183. Il2Cpp.Object = Il2CppObject;
  3184.  
  3185. },{"../../utils/native-struct":33,"decorator-cache-getter":3}],21:[function(require,module,exports){
  3186. "use strict";
  3187. Object.defineProperty(exports, "__esModule", { value: true });
  3188. /** Represents a `ParameterInfo`. */
  3189. class Il2CppParameter {
  3190.     /** Name of this parameter. */
  3191.     name;
  3192.     /** Position of this parameter. */
  3193.     position;
  3194.     /** Type of this parameter. */
  3195.     type;
  3196.     constructor(name, position, type) {
  3197.         this.name = name;
  3198.         this.position = position;
  3199.         this.type = type;
  3200.     }
  3201.     /** */
  3202.     toString() {
  3203.         return `${this.type.name} ${this.name}`;
  3204.     }
  3205. }
  3206. Il2Cpp.Parameter = Il2CppParameter;
  3207.  
  3208. },{}],22:[function(require,module,exports){
  3209. "use strict";
  3210. Object.defineProperty(exports, "__esModule", { value: true });
  3211. const utils_1 = require("../utils");
  3212. const native_struct_1 = require("../../utils/native-struct");
  3213. /** */
  3214. class Il2CppPointer extends native_struct_1.NativeStruct {
  3215.     type;
  3216.     constructor(handle, type) {
  3217.         super(handle);
  3218.         this.type = type;
  3219.     }
  3220.     /** Gets the element at the given index. */
  3221.     get(index) {
  3222.         return (0, utils_1.read)(this.handle.add(index * this.type.class.arrayElementSize), this.type);
  3223.     }
  3224.     /** Reads the given amount of elements starting at the given offset. */
  3225.     read(length, offset = 0) {
  3226.         const values = new Array(length);
  3227.         for (let i = 0; i < length; i++) {
  3228.             values[i] = this.get(i + offset);
  3229.         }
  3230.         return values;
  3231.     }
  3232.     /** Sets the given element at the given index */
  3233.     set(index, value) {
  3234.         (0, utils_1.write)(this.handle.add(index * this.type.class.arrayElementSize), value, this.type);
  3235.     }
  3236.     /** */
  3237.     toString() {
  3238.         return this.handle.toString();
  3239.     }
  3240.     /** Writes the given elements starting at the given index. */
  3241.     write(values, offset = 0) {
  3242.         for (let i = 0; i < values.length; i++) {
  3243.             this.set(i + offset, values[i]);
  3244.         }
  3245.     }
  3246. }
  3247. Il2Cpp.Pointer = Il2CppPointer;
  3248.  
  3249. },{"../../utils/native-struct":33,"../utils":30}],23:[function(require,module,exports){
  3250. "use strict";
  3251. Object.defineProperty(exports, "__esModule", { value: true });
  3252. const utils_1 = require("../utils");
  3253. const native_struct_1 = require("../../utils/native-struct");
  3254. const console_1 = require("../../utils/console");
  3255. /** Represent a parameter passed by reference. */
  3256. class Il2CppReference extends native_struct_1.NativeStruct {
  3257.     type;
  3258.     constructor(handle, type) {
  3259.         super(handle);
  3260.         this.type = type;
  3261.     }
  3262.     /** Gets the element referenced by the current reference. */
  3263.     get value() {
  3264.         return (0, utils_1.read)(this.handle, this.type);
  3265.     }
  3266.     /** Sets the element referenced by the current reference. */
  3267.     set value(value) {
  3268.         (0, utils_1.write)(this.handle, value, this.type);
  3269.     }
  3270.     /** */
  3271.     toString() {
  3272.         return this.isNull() ? "null" : `->${this.value}`;
  3273.     }
  3274.     /** Creates a reference to the specified value. */
  3275.     static to(value, type) {
  3276.         const handle = Memory.alloc(Process.pointerSize);
  3277.         switch (typeof value) {
  3278.             case "boolean":
  3279.                 return new Il2Cpp.Reference(handle.writeS8(+value), Il2Cpp.Image.corlib.class("System.Boolean").type);
  3280.             case "number":
  3281.                 switch (type?.typeEnum) {
  3282.                     case 5 /* U1 */:
  3283.                         return new Il2Cpp.Reference(handle.writeU8(value), type);
  3284.                     case 4 /* I1 */:
  3285.                         return new Il2Cpp.Reference(handle.writeS8(value), type);
  3286.                     case 3 /* Char */:
  3287.                     case 7 /* U2 */:
  3288.                         return new Il2Cpp.Reference(handle.writeU16(value), type);
  3289.                     case 6 /* I2 */:
  3290.                         return new Il2Cpp.Reference(handle.writeS16(value), type);
  3291.                     case 9 /* U4 */:
  3292.                         return new Il2Cpp.Reference(handle.writeU32(value), type);
  3293.                     case 8 /* I4 */:
  3294.                         return new Il2Cpp.Reference(handle.writeS32(value), type);
  3295.                     case 11 /* U8 */:
  3296.                         return new Il2Cpp.Reference(handle.writeU64(value), type);
  3297.                     case 10 /* I8 */:
  3298.                         return new Il2Cpp.Reference(handle.writeS64(value), type);
  3299.                     case 12 /* R4 */:
  3300.                         return new Il2Cpp.Reference(handle.writeFloat(value), type);
  3301.                     case 13 /* R8 */:
  3302.                         return new Il2Cpp.Reference(handle.writeDouble(value), type);
  3303.                 }
  3304.             case "object":
  3305.                 if (value instanceof Il2Cpp.ValueType || value instanceof Il2Cpp.Pointer) {
  3306.                     return new Il2Cpp.Reference(handle.writePointer(value), value.type);
  3307.                 }
  3308.                 else if (value instanceof Il2Cpp.Object) {
  3309.                     return new Il2Cpp.Reference(handle.writePointer(value), value.class.type);
  3310.                 }
  3311.                 else if (value instanceof Il2Cpp.String || value instanceof Il2Cpp.Array) {
  3312.                     return new Il2Cpp.Reference(handle.writePointer(value), value.object.class.type);
  3313.                 }
  3314.                 else if (value instanceof NativePointer) {
  3315.                     switch (type?.typeEnum) {
  3316.                         case 25 /* UnsignedNativeInteger */:
  3317.                         case 24 /* NativeInteger */:
  3318.                             return new Il2Cpp.Reference(handle.writePointer(value), type);
  3319.                     }
  3320.                 }
  3321.                 else if (value instanceof Int64) {
  3322.                     return new Il2Cpp.Reference(handle.writeS64(value), Il2Cpp.Image.corlib.class("System.Int64").type);
  3323.                 }
  3324.                 else if (value instanceof UInt64) {
  3325.                     return new Il2Cpp.Reference(handle.writeU64(value), Il2Cpp.Image.corlib.class("System.UInt64").type);
  3326.                 }
  3327.             default:
  3328.                 (0, console_1.raise)(`don't know how to create a reference to ${value} using type ${type?.name}`);
  3329.        }
  3330.    }
  3331. }
  3332. Il2Cpp.Reference = Il2CppReference;
  3333.  
  3334. },{"../../utils/console":32,"../../utils/native-struct":33,"../utils":30}],24:[function(require,module,exports){
  3335. "use strict";
  3336. Object.defineProperty(exports, "__esModule", { value: true });
  3337. const native_struct_1 = require("../../utils/native-struct");
  3338. /** Represents a `Il2CppString`. */
  3339. class Il2CppString extends native_struct_1.NativeStruct {
  3340.    /** Gets the content of this string. */
  3341.    get content() {
  3342.        return Il2Cpp.Api._stringChars(this).readUtf16String(this.length);
  3343.    }
  3344.    /** Sets the content of this string. */
  3345.    set content(value) {
  3346.        Il2Cpp.Api._stringChars(this).writeUtf16String(value ?? "");
  3347.        Il2Cpp.Api._stringSetLength(this, value?.length ?? 0);
  3348.    }
  3349.    /** Gets the length of this string. */
  3350.    get length() {
  3351.        return Il2Cpp.Api._stringLength(this);
  3352.    }
  3353.    /** Gets the encompassing object of the current string. */
  3354.    get object() {
  3355.        return new Il2Cpp.Object(this);
  3356.    }
  3357.    /** */
  3358.    toString() {
  3359.        return this.isNull() ? "null" : `"${this.content}"`;
  3360.    }
  3361.    /** Creates a new string with the specified content. */
  3362.    static from(content) {
  3363.        return new Il2Cpp.String(Il2Cpp.Api._stringNew(Memory.allocUtf8String(content || "")));
  3364.    }
  3365. }
  3366. Il2Cpp.String = Il2CppString;
  3367.  
  3368. },{"../../utils/native-struct":33}],25:[function(require,module,exports){
  3369. (function (setImmediate){(function (){
  3370. "use strict";
  3371. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  3372.    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3373.    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  3374.    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;
  3375.    return c > 3 && r && Object.defineProperty(target, key, r), r;
  3376. };
  3377. Object.defineProperty(exports, "__esModule", { value: true });
  3378. const decorator_cache_getter_1 = require("decorator-cache-getter");
  3379. const console_1 = require("../../utils/console");
  3380. const native_struct_1 = require("../../utils/native-struct");
  3381. /** Represents a `Il2CppThread`. */
  3382. class Il2CppThread extends native_struct_1.NativeStruct {
  3383.    /** @internal */
  3384.    static get idOffset() {
  3385.        const handle = ptr(Il2Cpp.currentThread.internal.field("thread_id").value.toString());
  3386.        const currentThreadId = Process.getCurrentThreadId();
  3387.        for (let i = 0; i < 1024; i++) {
  3388.            const candidate = handle.add(i).readS32();
  3389.            if (candidate == currentThreadId) {
  3390.                return i;
  3391.            }
  3392.        }
  3393.        (0, console_1.raise)(`couldn't determine the offset for a native thread id value`);
  3394.     }
  3395.     /** Gets the native id of the current thread. */
  3396.     get id() {
  3397.         return ptr(this.internal.field("thread_id").value.toString()).add(Il2Cpp.Thread.idOffset).readS32();
  3398.     }
  3399.     /** @internal Gets the encompassing internal object (System.Threding.InternalThreead) of the current thread. */
  3400.     get internal() {
  3401.         const internalThread = this.object.tryField("internal_thread")?.value;
  3402.         return internalThread ? internalThread : this.object;
  3403.     }
  3404.     /** Determines whether the current thread is the garbage collector finalizer one. */
  3405.     get isFinalizer() {
  3406.         return !Il2Cpp.Api._threadIsVm(this);
  3407.     }
  3408.     /** Gets the encompassing object of the current thread. */
  3409.     get object() {
  3410.         return new Il2Cpp.Object(this);
  3411.     }
  3412.     /** @internal */
  3413.     get staticData() {
  3414.         return this.internal.field("static_data").value;
  3415.     }
  3416.     /** @internal */
  3417.     get synchronizationContext() {
  3418.         const get_ExecutionContext = this.object.tryMethod("GetMutableExecutionContext") || this.object.method("get_ExecutionContext");
  3419.         let synchronizationContext = get_ExecutionContext.invoke().tryMethod("get_SynchronizationContext")?.invoke();
  3420.         if (synchronizationContext == null) {
  3421.             const SystemThreadingSynchronizationContext = Il2Cpp.Image.corlib.class("System.Threading.SynchronizationContext");
  3422.             for (let i = 0; i < 16; i++) {
  3423.                 try {
  3424.                     const candidate = new Il2Cpp.Object(this.staticData
  3425.                         .add(Process.pointerSize * i)
  3426.                         .readPointer()
  3427.                         .readPointer());
  3428.                     if (candidate.class.isSubclassOf(SystemThreadingSynchronizationContext, false)) {
  3429.                         synchronizationContext = candidate;
  3430.                         break;
  3431.                     }
  3432.                 }
  3433.                 catch (e) { }
  3434.             }
  3435.         }
  3436.         if (synchronizationContext == null) {
  3437.             (0, console_1.raise)("couldn't retrieve the SynchronizationContext for this thread.");
  3438.         }
  3439.         return synchronizationContext;
  3440.     }
  3441.     /** Detaches the thread from the application domain. */
  3442.     detach() {
  3443.         return Il2Cpp.Api._threadDetach(this);
  3444.     }
  3445.     /** Schedules a callback on the current thread. */
  3446.     schedule(block, delayMs = 0) {
  3447.         const threadId = this.id;
  3448.         const GetDisplayName = Il2Cpp.Image.corlib.class("Mono.Runtime").method("GetDisplayName");
  3449.         const SendOrPostCallback = Il2Cpp.Image.corlib.class("System.Threading.SendOrPostCallback").alloc();
  3450.         SendOrPostCallback.method(".ctor").invoke(NULL, GetDisplayName.handle);
  3451.         const Post = this.synchronizationContext.method("Post");
  3452.         return new Promise(resolve => {
  3453.             const listener = Interceptor.attach(GetDisplayName.virtualAddress, function () {
  3454.                 if (this.threadId == threadId) {
  3455.                     listener.detach();
  3456.                     const result = block();
  3457.                     setImmediate(() => resolve(result));
  3458.                 }
  3459.             });
  3460.             setTimeout(() => Post.invoke(SendOrPostCallback, NULL), delayMs);
  3461.         });
  3462.     }
  3463. }
  3464. __decorate([
  3465.     decorator_cache_getter_1.cache
  3466. ], Il2CppThread.prototype, "internal", null);
  3467. __decorate([
  3468.     decorator_cache_getter_1.cache
  3469. ], Il2CppThread.prototype, "object", null);
  3470. __decorate([
  3471.     decorator_cache_getter_1.cache
  3472. ], Il2CppThread.prototype, "staticData", null);
  3473. __decorate([
  3474.     decorator_cache_getter_1.cache
  3475. ], Il2CppThread.prototype, "synchronizationContext", null);
  3476. __decorate([
  3477.     decorator_cache_getter_1.cache
  3478. ], Il2CppThread, "idOffset", null);
  3479. Il2Cpp.Thread = Il2CppThread;
  3480.  
  3481. }).call(this)}).call(this,require("timers").setImmediate)
  3482.  
  3483. },{"../../utils/console":32,"../../utils/native-struct":33,"decorator-cache-getter":3,"timers":37}],26:[function(require,module,exports){
  3484. "use strict";
  3485. Object.defineProperty(exports, "__esModule", { value: true });
  3486.  
  3487. },{}],27:[function(require,module,exports){
  3488. "use strict";
  3489. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  3490.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3491.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  3492.     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;
  3493.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  3494. };
  3495. Object.defineProperty(exports, "__esModule", { value: true });
  3496. const decorator_cache_getter_1 = require("decorator-cache-getter");
  3497. const native_struct_1 = require("../../utils/native-struct");
  3498. /** Represents a `Il2CppType`. */
  3499. class Il2CppType extends native_struct_1.NonNullNativeStruct {
  3500.     /** Gets the class of this type. */
  3501.     get class() {
  3502.         return new Il2Cpp.Class(Il2Cpp.Api._classFromType(this));
  3503.     }
  3504.     /** */
  3505.     get fridaAlias() {
  3506.         if (this.isByReference) {
  3507.             return "pointer";
  3508.         }
  3509.         switch (this.typeEnum) {
  3510.             case 1 /* Void */:
  3511.                 return "void";
  3512.             case 2 /* Boolean */:
  3513.                 return "bool";
  3514.             case 3 /* Char */:
  3515.                 return "uchar";
  3516.             case 4 /* I1 */:
  3517.                 return "int8";
  3518.             case 5 /* U1 */:
  3519.                 return "uint8";
  3520.             case 6 /* I2 */:
  3521.                 return "int16";
  3522.             case 7 /* U2 */:
  3523.                 return "uint16";
  3524.             case 8 /* I4 */:
  3525.                 return "int32";
  3526.             case 9 /* U4 */:
  3527.                 return "uint32";
  3528.             case 10 /* I8 */:
  3529.                 return "int64";
  3530.             case 11 /* U8 */:
  3531.                 return "uint64";
  3532.             case 12 /* R4 */:
  3533.                 return "float";
  3534.             case 13 /* R8 */:
  3535.                 return "double";
  3536.             case 17 /* ValueType */:
  3537.                 return getValueTypeFields(this);
  3538.             case 24 /* NativeInteger */:
  3539.             case 25 /* UnsignedNativeInteger */:
  3540.             case 15 /* Pointer */:
  3541.             case 14 /* String */:
  3542.             case 29 /* SingleDimensionalZeroLowerBoundArray */:
  3543.             case 20 /* Array */:
  3544.                 return "pointer";
  3545.             case 18 /* Class */:
  3546.             case 28 /* Object */:
  3547.             case 21 /* GenericInstance */:
  3548.                 return this.class.isValueType ? getValueTypeFields(this) : "pointer";
  3549.             default:
  3550.                 return "pointer";
  3551.         }
  3552.     }
  3553.     /** Determines whether this type is passed by reference. */
  3554.     get isByReference() {
  3555.         return !!Il2Cpp.Api._typeIsByReference(this);
  3556.     }
  3557.     /** Determines whether this type is primitive. */
  3558.     get isPrimitive() {
  3559.         return !!Il2Cpp.Api._typeIsPrimitive(this);
  3560.     }
  3561.     /** Gets the name of this type. */
  3562.     get name() {
  3563.         const handle = Il2Cpp.Api._typeGetName(this);
  3564.         try {
  3565.             return handle.readUtf8String();
  3566.         }
  3567.         finally {
  3568.             Il2Cpp.free(handle);
  3569.         }
  3570.     }
  3571.     /** Gets the encompassing object of the current type. */
  3572.     get object() {
  3573.         return new Il2Cpp.Object(Il2Cpp.Api._typeGetObject(this));
  3574.     }
  3575.     /** Gets the type enum of the current type. */
  3576.     get typeEnum() {
  3577.         return Il2Cpp.Api._typeGetTypeEnum(this);
  3578.     }
  3579.     /** */
  3580.     toString() {
  3581.         return this.name;
  3582.     }
  3583. }
  3584. __decorate([
  3585.     decorator_cache_getter_1.cache
  3586. ], Il2CppType.prototype, "class", null);
  3587. __decorate([
  3588.     decorator_cache_getter_1.cache
  3589. ], Il2CppType.prototype, "fridaAlias", null);
  3590. __decorate([
  3591.     decorator_cache_getter_1.cache
  3592. ], Il2CppType.prototype, "isByReference", null);
  3593. __decorate([
  3594.     decorator_cache_getter_1.cache
  3595. ], Il2CppType.prototype, "isPrimitive", null);
  3596. __decorate([
  3597.     decorator_cache_getter_1.cache
  3598. ], Il2CppType.prototype, "name", null);
  3599. __decorate([
  3600.     decorator_cache_getter_1.cache
  3601. ], Il2CppType.prototype, "object", null);
  3602. __decorate([
  3603.     decorator_cache_getter_1.cache
  3604. ], Il2CppType.prototype, "typeEnum", null);
  3605. function getValueTypeFields(type) {
  3606.     const instanceFields = type.class.fields.filter(f => !f.isStatic);
  3607.     return instanceFields.length == 0 ? ["char"] : instanceFields.map(f => f.type.fridaAlias);
  3608. }
  3609. Reflect.set(Il2Cpp, "Type", Il2CppType);
  3610.  
  3611. },{"../../utils/native-struct":33,"decorator-cache-getter":3}],28:[function(require,module,exports){
  3612. "use strict";
  3613. Object.defineProperty(exports, "__esModule", { value: true });
  3614. const native_struct_1 = require("../../utils/native-struct");
  3615. /** Value type class utility. */
  3616. class Il2CppValueType extends native_struct_1.NativeStruct {
  3617.     type;
  3618.     constructor(handle, type) {
  3619.         super(handle);
  3620.         this.type = type;
  3621.     }
  3622.     /** Boxes the current value type in a object. */
  3623.     box() {
  3624.         return new Il2Cpp.Object(Il2Cpp.Api._valueBox(this.type.class, this));
  3625.     }
  3626.     /** Gets the field with the given name. */
  3627.     field(name) {
  3628.         return this.type.class.field(name).withHolder(this);
  3629.     }
  3630.     /** */
  3631.     toString() {
  3632.         return this.isNull() ? "null" : this.box().toString();
  3633.     }
  3634. }
  3635. Il2Cpp.ValueType = Il2CppValueType;
  3636.  
  3637. },{"../../utils/native-struct":33}],29:[function(require,module,exports){
  3638. "use strict";
  3639. Object.defineProperty(exports, "__esModule", { value: true });
  3640. const console_1 = require("../utils/console");
  3641. const utils_1 = require("./utils");
  3642. /** Tracing utilities. */
  3643. class Il2CppTracer {
  3644.     /** @internal */
  3645.     targets = [];
  3646.     /** @internal */
  3647.     #assemblies;
  3648.     /** @internal */
  3649.     #classes;
  3650.     /** @internal */
  3651.     #methods;
  3652.     /** @internal */
  3653.     #assemblyFilter;
  3654.     /** @internal */
  3655.     #classFilter;
  3656.     /** @internal */
  3657.     #methodFilter;
  3658.     /** @internal */
  3659.     #parameterFilter;
  3660.     domain() {
  3661.         return this;
  3662.     }
  3663.     assemblies(...assemblies) {
  3664.         this.#assemblies = assemblies;
  3665.         return this;
  3666.     }
  3667.     classes(...classes) {
  3668.         this.#classes = classes;
  3669.         return this;
  3670.     }
  3671.     methods(...methods) {
  3672.         this.#methods = methods;
  3673.         return this;
  3674.     }
  3675.     filterAssemblies(filter) {
  3676.         this.#assemblyFilter = filter;
  3677.         return this;
  3678.     }
  3679.     filterClasses(filter) {
  3680.         this.#classFilter = filter;
  3681.         return this;
  3682.     }
  3683.     filterMethods(filter) {
  3684.         this.#methodFilter = filter;
  3685.         return this;
  3686.     }
  3687.     filterParameters(filter) {
  3688.         this.#parameterFilter = filter;
  3689.         return this;
  3690.     }
  3691.     and() {
  3692.         const filterMethod = (method) => {
  3693.             if (this.#parameterFilter == undefined) {
  3694.                 this.targets.push(method);
  3695.                 return;
  3696.             }
  3697.             for (const parameter of method.parameters) {
  3698.                 if (this.#parameterFilter(parameter)) {
  3699.                     this.targets.push(method);
  3700.                     break;
  3701.                 }
  3702.             }
  3703.         };
  3704.         const filterMethods = (values) => {
  3705.             for (const method of values) {
  3706.                 filterMethod(method);
  3707.             }
  3708.         };
  3709.         const filterClass = (klass) => {
  3710.             if (this.#methodFilter == undefined) {
  3711.                 filterMethods(klass.methods);
  3712.                 return;
  3713.             }
  3714.             for (const method of klass.methods) {
  3715.                 if (this.#methodFilter(method)) {
  3716.                     filterMethod(method);
  3717.                 }
  3718.             }
  3719.         };
  3720.         const filterClasses = (values) => {
  3721.             for (const klass of values) {
  3722.                 filterClass(klass);
  3723.             }
  3724.         };
  3725.         const filterAssembly = (assembly) => {
  3726.             if (this.#classFilter == undefined) {
  3727.                 filterClasses(assembly.image.classes);
  3728.                 return;
  3729.             }
  3730.             for (const klass of assembly.image.classes) {
  3731.                 if (this.#classFilter(klass)) {
  3732.                     filterClass(klass);
  3733.                 }
  3734.             }
  3735.         };
  3736.         const filterAssemblies = (assemblies) => {
  3737.             for (const assembly of assemblies) {
  3738.                 filterAssembly(assembly);
  3739.             }
  3740.         };
  3741.         const filterDomain = (domain) => {
  3742.             if (this.#assemblyFilter == undefined) {
  3743.                 filterAssemblies(domain.assemblies);
  3744.                 return;
  3745.             }
  3746.             for (const assembly of domain.assemblies) {
  3747.                 if (this.#assemblyFilter(assembly)) {
  3748.                     filterAssembly(assembly);
  3749.                 }
  3750.             }
  3751.         };
  3752.         this.#methods
  3753.             ? filterMethods(this.#methods)
  3754.             : this.#classes
  3755.                 ? filterClasses(this.#classes)
  3756.                 : this.#assemblies
  3757.                     ? filterAssemblies(this.#assemblies)
  3758.                     : filterDomain(Il2Cpp.Domain);
  3759.         this.#assemblies = undefined;
  3760.         this.#classes = undefined;
  3761.         this.#methods = undefined;
  3762.         this.#assemblyFilter = undefined;
  3763.         this.#classFilter = undefined;
  3764.         this.#methodFilter = undefined;
  3765.         this.#parameterFilter = undefined;
  3766.         return this;
  3767.     }
  3768.     attach(mode = "full") {
  3769.         let count = 0;
  3770.         for (const target of this.targets) {
  3771.             if (target.virtualAddress.isNull()) {
  3772.                 continue;
  3773.             }
  3774.             const offset = `\x1b[2m0x${target.relativeVirtualAddress.toString(16).padStart(8, `0`)}\x1b[0m`;
  3775.             const fullName = `${target.class.type.name}.\x1b[1m${target.name}\x1b[0m`;
  3776.             if (mode == "detailed") {
  3777.                 const startIndex = +!target.isStatic | +Il2Cpp.unityVersionIsBelow201830;
  3778.                 const callback = (...args) => {
  3779.                     const thisParameter = target.isStatic ? undefined : new Il2Cpp.Parameter("this", -1, target.class.type);
  3780.                     const parameters = thisParameter ? [thisParameter].concat(target.parameters) : target.parameters;
  3781.                     (0, console_1.inform)(`\
  3782. ${offset} ${`│ `.repeat(count++)}┌─\x1b[35m${fullName}\x1b[0m(\
  3783. ${parameters.map(e => `\x1b[32m${e.name}\x1b[0m = \x1b[31m${(0, utils_1.fromFridaValue)(args[e.position + startIndex], e.type)}\x1b[0m`).join(`, `)});`);
  3784.                     const returnValue = target.nativeFunction(...args);
  3785.                     (0, console_1.inform)(`\
  3786. ${offset} ${`│ `.repeat(--count)}└─\x1b[33m${fullName}\x1b[0m\
  3787. ${returnValue == undefined ? `` : ` = \x1b[36m${(0, utils_1.fromFridaValue)(returnValue, target.returnType)}`}\x1b[0m;`);
  3788.                     return returnValue;
  3789.                 };
  3790.                 try {
  3791.                     target.revert();
  3792.                     const nativeCallback = new NativeCallback(callback, target.returnType.fridaAlias, target.fridaSignature);
  3793.                     Interceptor.replace(target.virtualAddress, nativeCallback);
  3794.                 }
  3795.                 catch (e) { }
  3796.             }
  3797.             else {
  3798.                 try {
  3799.                     Interceptor.attach(target.virtualAddress, {
  3800.                         onEnter: () => (0, console_1.inform)(`${offset} ${`│ `.repeat(count++)}┌─\x1b[35m${fullName}\x1b[0m`),
  3801.                         onLeave: () => (0, console_1.inform)(`${offset} ${`│ `.repeat(--count)}└─\x1b[33m${fullName}\x1b[0m${count == 0 ? `\n` : ``}`)
  3802.                     });
  3803.                 }
  3804.                 catch (e) { }
  3805.             }
  3806.         }
  3807.     }
  3808. }
  3809. Il2Cpp.Tracer = Il2CppTracer;
  3810.  
  3811. },{"../utils/console":32,"./utils":30}],30:[function(require,module,exports){
  3812. "use strict";
  3813. Object.defineProperty(exports, "__esModule", { value: true });
  3814. exports.toFridaValue = exports.fromFridaValue = exports.write = exports.read = void 0;
  3815. const console_1 = require("../utils/console");
  3816. const native_struct_1 = require("../utils/native-struct");
  3817. /** @internal */
  3818. function read(pointer, type) {
  3819.     switch (type.typeEnum) {
  3820.         case 2 /* Boolean */:
  3821.             return !!pointer.readS8();
  3822.         case 4 /* I1 */:
  3823.             return pointer.readS8();
  3824.         case 5 /* U1 */:
  3825.             return pointer.readU8();
  3826.         case 6 /* I2 */:
  3827.             return pointer.readS16();
  3828.         case 7 /* U2 */:
  3829.             return pointer.readU16();
  3830.         case 8 /* I4 */:
  3831.             return pointer.readS32();
  3832.         case 9 /* U4 */:
  3833.             return pointer.readU32();
  3834.         case 3 /* Char */:
  3835.             return pointer.readU16();
  3836.         case 10 /* I8 */:
  3837.             return pointer.readS64();
  3838.         case 11 /* U8 */:
  3839.             return pointer.readU64();
  3840.         case 12 /* R4 */:
  3841.             return pointer.readFloat();
  3842.         case 13 /* R8 */:
  3843.             return pointer.readDouble();
  3844.         case 24 /* NativeInteger */:
  3845.         case 25 /* UnsignedNativeInteger */:
  3846.             return pointer.readPointer();
  3847.         case 15 /* Pointer */:
  3848.             return new Il2Cpp.Pointer(pointer.readPointer(), type.class.baseType);
  3849.         case 17 /* ValueType */:
  3850.             return new Il2Cpp.ValueType(pointer, type);
  3851.         case 28 /* Object */:
  3852.         case 18 /* Class */:
  3853.             return new Il2Cpp.Object(pointer.readPointer());
  3854.         case 21 /* GenericInstance */:
  3855.             return type.class.isValueType ? new Il2Cpp.ValueType(pointer, type) : new Il2Cpp.Object(pointer.readPointer());
  3856.         case 14 /* String */:
  3857.             return new Il2Cpp.String(pointer.readPointer());
  3858.         case 29 /* SingleDimensionalZeroLowerBoundArray */:
  3859.         case 20 /* Array */:
  3860.             return new Il2Cpp.Array(pointer.readPointer());
  3861.     }
  3862.     (0, console_1.raise)(`read: "${type.name}" (${type.typeEnum}) has not been handled yet. Please file an issue!`);
  3863. }
  3864. exports.read = read;
  3865. /** @internal */
  3866. function write(pointer, value, type) {
  3867.     switch (type.typeEnum) {
  3868.         case 2 /* Boolean */:
  3869.             return pointer.writeS8(+value);
  3870.         case 4 /* I1 */:
  3871.             return pointer.writeS8(value);
  3872.         case 5 /* U1 */:
  3873.             return pointer.writeU8(value);
  3874.         case 6 /* I2 */:
  3875.             return pointer.writeS16(value);
  3876.         case 7 /* U2 */:
  3877.             return pointer.writeU16(value);
  3878.         case 8 /* I4 */:
  3879.             return pointer.writeS32(value);
  3880.         case 9 /* U4 */:
  3881.             return pointer.writeU32(value);
  3882.         case 3 /* Char */:
  3883.             return pointer.writeU16(value);
  3884.         case 10 /* I8 */:
  3885.             return pointer.writeS64(value);
  3886.         case 11 /* U8 */:
  3887.             return pointer.writeU64(value);
  3888.         case 12 /* R4 */:
  3889.             return pointer.writeFloat(value);
  3890.         case 13 /* R8 */:
  3891.             return pointer.writeDouble(value);
  3892.         case 24 /* NativeInteger */:
  3893.         case 25 /* UnsignedNativeInteger */:
  3894.         case 15 /* Pointer */:
  3895.         case 17 /* ValueType */:
  3896.         case 14 /* String */:
  3897.         case 28 /* Object */:
  3898.         case 18 /* Class */:
  3899.         case 29 /* SingleDimensionalZeroLowerBoundArray */:
  3900.         case 20 /* Array */:
  3901.         case 21 /* GenericInstance */:
  3902.             if (value instanceof Il2Cpp.ValueType) {
  3903.                 Memory.copy(pointer, value.handle, type.class.valueSize);
  3904.                 return pointer;
  3905.             }
  3906.             return pointer.writePointer(value);
  3907.     }
  3908.     (0, console_1.raise)(`write: "${type.name}" (${type.typeEnum}) has not been handled yet. Please file an issue!`);
  3909. }
  3910. exports.write = write;
  3911. /** @internal */
  3912. function fromFridaValue(value, type) {
  3913.     if (Array.isArray(value)) {
  3914.         return arrayToValueType(type, value);
  3915.     }
  3916.     else if (value instanceof NativePointer) {
  3917.         if (type.isByReference) {
  3918.             return new Il2Cpp.Reference(value, type);
  3919.         }
  3920.         switch (type.typeEnum) {
  3921.             case 15 /* Pointer */:
  3922.                 return new Il2Cpp.Pointer(value, type.class.baseType);
  3923.             case 14 /* String */:
  3924.                 return new Il2Cpp.String(value);
  3925.             case 18 /* Class */:
  3926.             case 21 /* GenericInstance */:
  3927.             case 28 /* Object */:
  3928.                 return new Il2Cpp.Object(value);
  3929.             case 29 /* SingleDimensionalZeroLowerBoundArray */:
  3930.             case 20 /* Array */:
  3931.                 return new Il2Cpp.Array(value);
  3932.             default:
  3933.                 return value;
  3934.         }
  3935.     }
  3936.     else if (type.typeEnum == 2 /* Boolean */) {
  3937.         return !!value;
  3938.     }
  3939.     else {
  3940.         return value;
  3941.     }
  3942. }
  3943. exports.fromFridaValue = fromFridaValue;
  3944. /** @internal */
  3945. function toFridaValue(value) {
  3946.     if (typeof value == "boolean") {
  3947.         return +value;
  3948.     }
  3949.     else if (value instanceof Il2Cpp.ValueType) {
  3950.         return valueTypeToArray(value);
  3951.     }
  3952.     else {
  3953.         return value;
  3954.     }
  3955. }
  3956. exports.toFridaValue = toFridaValue;
  3957. function valueTypeToArray(value) {
  3958.     const instanceFields = value.type.class.fields.filter(f => !f.isStatic);
  3959.     return instanceFields.length == 0
  3960.         ? [value.handle.readU8()]
  3961.         : instanceFields
  3962.             .map(field => field.withHolder(value).value)
  3963.             .map(value => value instanceof Il2Cpp.ValueType
  3964.             ? valueTypeToArray(value)
  3965.             : value instanceof native_struct_1.NativeStruct
  3966.                 ? value.handle
  3967.                 : typeof value == "boolean"
  3968.                     ? +value
  3969.                     : value);
  3970. }
  3971. function arrayToValueType(type, nativeValues) {
  3972.     function iter(type, startOffset = 0) {
  3973.         const arr = [];
  3974.         for (const field of type.class.fields) {
  3975.             if (!field.isStatic) {
  3976.                 const offset = startOffset + field.offset - Il2Cpp.Runtime.objectHeaderSize;
  3977.                 if (field.type.typeEnum == 17 /* ValueType */ ||
  3978.                     (field.type.typeEnum == 21 /* GenericInstance */ && field.type.class.isValueType)) {
  3979.                     arr.push(...iter(field.type, offset));
  3980.                 }
  3981.                 else {
  3982.                     arr.push([field.type.typeEnum, offset]);
  3983.                 }
  3984.             }
  3985.         }
  3986.         if (arr.length == 0) {
  3987.             arr.push([5 /* U1 */, 0]);
  3988.         }
  3989.         return arr;
  3990.     }
  3991.     const valueType = Memory.alloc(type.class.valueSize);
  3992.     nativeValues = nativeValues.flat(Infinity);
  3993.     const typesAndOffsets = iter(type);
  3994.     for (let i = 0; i < nativeValues.length; i++) {
  3995.         const value = nativeValues[i];
  3996.         const [typeEnum, offset] = typesAndOffsets[i];
  3997.         const pointer = valueType.add(offset);
  3998.         switch (typeEnum) {
  3999.             case 2 /* Boolean */:
  4000.                 pointer.writeS8(value);
  4001.                 break;
  4002.             case 4 /* I1 */:
  4003.                 pointer.writeS8(value);
  4004.                 break;
  4005.             case 5 /* U1 */:
  4006.                 pointer.writeU8(value);
  4007.                 break;
  4008.             case 6 /* I2 */:
  4009.                 pointer.writeS16(value);
  4010.                 break;
  4011.             case 7 /* U2 */:
  4012.                 pointer.writeU16(value);
  4013.                 break;
  4014.             case 8 /* I4 */:
  4015.                 pointer.writeS32(value);
  4016.                 break;
  4017.             case 9 /* U4 */:
  4018.                 pointer.writeU32(value);
  4019.                 break;
  4020.             case 3 /* Char */:
  4021.                 pointer.writeU16(value);
  4022.                 break;
  4023.             case 10 /* I8 */:
  4024.                 pointer.writeS64(value);
  4025.                 break;
  4026.             case 11 /* U8 */:
  4027.                 pointer.writeU64(value);
  4028.                 break;
  4029.             case 12 /* R4 */:
  4030.                 pointer.writeFloat(value);
  4031.                 break;
  4032.             case 13 /* R8 */:
  4033.                 pointer.writeDouble(value);
  4034.                 break;
  4035.             case 24 /* NativeInteger */:
  4036.             case 25 /* UnsignedNativeInteger */:
  4037.             case 15 /* Pointer */:
  4038.             case 29 /* SingleDimensionalZeroLowerBoundArray */:
  4039.             case 20 /* Array */:
  4040.             case 14 /* String */:
  4041.             case 28 /* Object */:
  4042.             case 18 /* Class */:
  4043.             case 21 /* GenericInstance */:
  4044.                 pointer.writePointer(value);
  4045.                 break;
  4046.             default:
  4047.                 (0, console_1.warn)(`arrayToValueType: defaulting ${typeEnum} to pointer`);
  4048.                 pointer.writePointer(value);
  4049.                 break;
  4050.         }
  4051.     }
  4052.     return new Il2Cpp.ValueType(valueType, type);
  4053. }
  4054.  
  4055. },{"../utils/console":32,"../utils/native-struct":33}],31:[function(require,module,exports){
  4056. "use strict";
  4057. Object.defineProperty(exports, "__esModule", { value: true });
  4058. require("./il2cpp");
  4059.  
  4060. },{"./il2cpp":8}],32:[function(require,module,exports){
  4061. "use strict";
  4062. Object.defineProperty(exports, "__esModule", { value: true });
  4063. exports.inform = exports.ok = exports.warn = exports.raise = void 0;
  4064. /** @internal */
  4065. function raise(message) {
  4066.     throw `\x1B[0m\x1B[38;5;9mil2cpp\x1B[0m: ${message}`;
  4067. }
  4068. exports.raise = raise;
  4069. /** @internal */
  4070. function warn(message) {
  4071.     globalThis.console.log(`\x1B[38;5;11mil2cpp\x1B[0m: ${message}`);
  4072. }
  4073. exports.warn = warn;
  4074. /** @internal */
  4075. function ok(message) {
  4076.     globalThis.console.log(`\x1B[38;5;10mil2cpp\x1B[0m: ${message}`);
  4077. }
  4078. exports.ok = ok;
  4079. /** @internal */
  4080. function inform(message) {
  4081.     globalThis.console.log(`\x1B[38;5;12mil2cpp\x1B[0m: ${message}`);
  4082. }
  4083. exports.inform = inform;
  4084.  
  4085. },{}],33:[function(require,module,exports){
  4086. "use strict";
  4087. Object.defineProperty(exports, "__esModule", { value: true });
  4088. exports.NonNullNativeStruct = exports.NativeStruct = void 0;
  4089. /** Scaffold class. */
  4090. class NativeStruct {
  4091.     handle;
  4092.     constructor(handleOrWrapper) {
  4093.         if (handleOrWrapper instanceof NativePointer) {
  4094.             this.handle = handleOrWrapper;
  4095.         }
  4096.         else {
  4097.             this.handle = handleOrWrapper.handle;
  4098.         }
  4099.     }
  4100.     equals(other) {
  4101.         return this.handle.equals(other.handle);
  4102.     }
  4103.     isNull() {
  4104.         return this.handle.isNull();
  4105.     }
  4106. }
  4107. exports.NativeStruct = NativeStruct;
  4108. /** Scaffold class whom pointer cannot be null. */
  4109. class NonNullNativeStruct extends NativeStruct {
  4110.     constructor(handle) {
  4111.         super(handle);
  4112.         if (handle.isNull()) {
  4113.             throw new Error(`Handle for "${this.constructor.name}" cannot be NULL.`);
  4114.         }
  4115.     }
  4116. }
  4117. exports.NonNullNativeStruct = NonNullNativeStruct;
  4118.  
  4119. },{}],34:[function(require,module,exports){
  4120. (function (setImmediate){(function (){
  4121. "use strict";
  4122. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  4123.     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  4124.     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  4125.     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;
  4126.     return c > 3 && r && Object.defineProperty(target, key, r), r;
  4127. };
  4128. var __importDefault = (this && this.__importDefault) || function (mod) {
  4129.     return (mod && mod.__esModule) ? mod : { "default": mod };
  4130. };
  4131. Object.defineProperty(exports, "__esModule", { value: true });
  4132. exports.forModule = void 0;
  4133. const decorator_cache_getter_1 = require("decorator-cache-getter");
  4134. const versioning_1 = __importDefault(require("versioning"));
  4135. class Target {
  4136.     stringEncoding;
  4137.     address;
  4138.     constructor(responsible, name, stringEncoding) {
  4139.         this.stringEncoding = stringEncoding;
  4140.         this.address = Module.findExportByName(responsible, name) ?? NULL;
  4141.     }
  4142.     static get targets() {
  4143.         function info() {
  4144.             switch (Process.platform) {
  4145.                 case "linux":
  4146.                     try {
  4147.                         if (versioning_1.default.gte(Java.androidVersion, "12")) {
  4148.                             return [null, ["__loader_dlopen", "utf8"]];
  4149.                         }
  4150.                         else {
  4151.                             return ["libdl.so", ["dlopen", "utf8"], ["android_dlopen_ext", "utf8"]];
  4152.                         }
  4153.                     }
  4154.                     catch (e) {
  4155.                         return [null, ["dlopen", "utf8"]];
  4156.                     }
  4157.                 case "darwin":
  4158.                     return ["libdyld.dylib", ["dlopen", "utf8"]];
  4159.                 case "windows":
  4160.                     const ll = "LoadLibrary";
  4161.                     return ["kernel32.dll", [`${ll}W`, "utf16"], [`${ll}ExW`, "utf16"], [`${ll}A`, "ansi"], [`${ll}ExA`, "ansi"]];
  4162.             }
  4163.         }
  4164.         const [responsible, ...targets] = info();
  4165.         return targets.map(([name, encoding]) => new Target(responsible, name, encoding)).filter(target => !target.address.isNull());
  4166.     }
  4167.     readString(pointer) {
  4168.         switch (this.stringEncoding) {
  4169.             case "utf8":
  4170.                 return pointer.readUtf8String();
  4171.             case "utf16":
  4172.                 return pointer.readUtf16String();
  4173.             case "ansi":
  4174.                 return pointer.readAnsiString();
  4175.         }
  4176.     }
  4177. }
  4178. __decorate([
  4179.     decorator_cache_getter_1.cache
  4180. ], Target, "targets", null);
  4181. /** @internal */
  4182. function forModule(...moduleNames) {
  4183.     return new Promise(resolve => {
  4184.         for (const moduleName of moduleNames) {
  4185.             const module = Process.findModuleByName(moduleName);
  4186.             if (module != null) {
  4187.                 resolve(moduleName);
  4188.                 return;
  4189.             }
  4190.         }
  4191.         const interceptors = Target.targets.map(target => Interceptor.attach(target.address, {
  4192.             onEnter(args) {
  4193.                 this.modulePath = target.readString(args[0]) ?? "";
  4194.             },
  4195.             onLeave(returnValue) {
  4196.                 if (returnValue.isNull())
  4197.                     return;
  4198.                 for (const moduleName of moduleNames) {
  4199.                     if (!this.modulePath.endsWith(moduleName))
  4200.                         continue;
  4201.                     setImmediate(() => interceptors.forEach(i => i.detach()));
  4202.                     resolve(moduleName);
  4203.                 }
  4204.             }
  4205.         }));
  4206.     });
  4207. }
  4208. exports.forModule = forModule;
  4209.  
  4210. }).call(this)}).call(this,require("timers").setImmediate)
  4211.  
  4212. },{"decorator-cache-getter":3,"timers":37,"versioning":38}],35:[function(require,module,exports){
  4213. "use strict";
  4214. Object.defineProperty(exports, "__esModule", { value: true });
  4215. exports.levenshtein = exports.cacheInstances = exports.nativeIterator = void 0;
  4216. const fastest_levenshtein_1 = require("fastest-levenshtein");
  4217. const console_1 = require("./console");
  4218. /** @internal */
  4219. function* nativeIterator(holder, nativeFunction, Class) {
  4220.     const iterator = Memory.alloc(Process.pointerSize);
  4221.     let handle;
  4222.     while (!(handle = nativeFunction(holder, iterator)).isNull()) {
  4223.         yield new Class(handle);
  4224.     }
  4225. }
  4226. exports.nativeIterator = nativeIterator;
  4227. /** @internal */
  4228. function cacheInstances(Class) {
  4229.     const instanceCache = new Map();
  4230.     return new Proxy(Class, {
  4231.         construct(Target, argArray) {
  4232.             const handle = argArray[0].toUInt32();
  4233.             if (!instanceCache.has(handle)) {
  4234.                 instanceCache.set(handle, new Target(argArray[0]));
  4235.             }
  4236.             return instanceCache.get(handle);
  4237.         }
  4238.     });
  4239. }
  4240. exports.cacheInstances = cacheInstances;
  4241. /** @internal */
  4242. function levenshtein(candidatesKey, nameGetter = e => e.name) {
  4243.     return function (_, propertyKey, descriptor) {
  4244.         const original = descriptor.value;
  4245.         descriptor.value = function (key, ...args) {
  4246.             const result = original.call(this, key, ...args);
  4247.             if (result != null)
  4248.                 return result;
  4249.             const closestMatch = (0, fastest_levenshtein_1.closest)(key, this[candidatesKey].map(nameGetter));
  4250.             (0, console_1.raise)(`couldn't find ${propertyKey} ${key} in ${this.name}${closestMatch ? `, did you mean ${closestMatch}?` : ``}`);
  4251.        };
  4252.    };
  4253. }
  4254. exports.levenshtein = levenshtein;
  4255.  
  4256. },{"./console":32,"fastest-levenshtein":4}],36:[function(require,module,exports){
  4257. // shim for using process in browser
  4258. var process = module.exports = {};
  4259.  
  4260. // cached from whatever global is present so that test runners that stub it
  4261. // don't break things.  But we need to wrap it in a try catch in case it is
  4262. // wrapped in strict mode code which doesn't define any globals.  It's inside a
  4263. // function because try/catches deoptimize in certain engines.
  4264.  
  4265. var cachedSetTimeout;
  4266. var cachedClearTimeout;
  4267.  
  4268. function defaultSetTimout() {
  4269.     throw new Error('setTimeout has not been defined');
  4270. }
  4271. function defaultClearTimeout () {
  4272.     throw new Error('clearTimeout has not been defined');
  4273. }
  4274. (function () {
  4275.     try {
  4276.         if (typeof setTimeout === 'function') {
  4277.             cachedSetTimeout = setTimeout;
  4278.         } else {
  4279.             cachedSetTimeout = defaultSetTimout;
  4280.         }
  4281.     } catch (e) {
  4282.         cachedSetTimeout = defaultSetTimout;
  4283.     }
  4284.     try {
  4285.         if (typeof clearTimeout === 'function') {
  4286.             cachedClearTimeout = clearTimeout;
  4287.         } else {
  4288.             cachedClearTimeout = defaultClearTimeout;
  4289.         }
  4290.     } catch (e) {
  4291.         cachedClearTimeout = defaultClearTimeout;
  4292.     }
  4293. } ())
  4294. function runTimeout(fun) {
  4295.     if (cachedSetTimeout === setTimeout) {
  4296.         //normal enviroments in sane situations
  4297.         return setTimeout(fun, 0);
  4298.     }
  4299.     // if setTimeout wasn't available but was latter defined
  4300.     if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  4301.         cachedSetTimeout = setTimeout;
  4302.         return setTimeout(fun, 0);
  4303.     }
  4304.     try {
  4305.         // when when somebody has screwed with setTimeout but no I.E. maddness
  4306.         return cachedSetTimeout(fun, 0);
  4307.     } catch(e){
  4308.         try {
  4309.             // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4310.             return cachedSetTimeout.call(null, fun, 0);
  4311.         } catch(e){
  4312.             // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  4313.             return cachedSetTimeout.call(this, fun, 0);
  4314.         }
  4315.     }
  4316.  
  4317.  
  4318. }
  4319. function runClearTimeout(marker) {
  4320.     if (cachedClearTimeout === clearTimeout) {
  4321.         //normal enviroments in sane situations
  4322.         return clearTimeout(marker);
  4323.     }
  4324.     // if clearTimeout wasn't available but was latter defined
  4325.     if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  4326.         cachedClearTimeout = clearTimeout;
  4327.         return clearTimeout(marker);
  4328.     }
  4329.     try {
  4330.         // when when somebody has screwed with setTimeout but no I.E. maddness
  4331.         return cachedClearTimeout(marker);
  4332.     } catch (e){
  4333.         try {
  4334.             // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
  4335.             return cachedClearTimeout.call(null, marker);
  4336.         } catch (e){
  4337.             // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  4338.             // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  4339.             return cachedClearTimeout.call(this, marker);
  4340.         }
  4341.     }
  4342.  
  4343.  
  4344.  
  4345. }
  4346. var queue = [];
  4347. var draining = false;
  4348. var currentQueue;
  4349. var queueIndex = -1;
  4350.  
  4351. function cleanUpNextTick() {
  4352.     if (!draining || !currentQueue) {
  4353.         return;
  4354.     }
  4355.     draining = false;
  4356.     if (currentQueue.length) {
  4357.         queue = currentQueue.concat(queue);
  4358.     } else {
  4359.         queueIndex = -1;
  4360.     }
  4361.     if (queue.length) {
  4362.         drainQueue();
  4363.     }
  4364. }
  4365.  
  4366. function drainQueue() {
  4367.     if (draining) {
  4368.         return;
  4369.     }
  4370.     var timeout = runTimeout(cleanUpNextTick);
  4371.     draining = true;
  4372.  
  4373.     var len = queue.length;
  4374.     while(len) {
  4375.         currentQueue = queue;
  4376.         queue = [];
  4377.         while (++queueIndex < len) {
  4378.             if (currentQueue) {
  4379.                 currentQueue[queueIndex].run();
  4380.             }
  4381.         }
  4382.         queueIndex = -1;
  4383.         len = queue.length;
  4384.     }
  4385.     currentQueue = null;
  4386.     draining = false;
  4387.     runClearTimeout(timeout);
  4388. }
  4389.  
  4390. process.nextTick = function (fun) {
  4391.     var args = new Array(arguments.length - 1);
  4392.     if (arguments.length > 1) {
  4393.         for (var i = 1; i < arguments.length; i++) {
  4394.             args[i - 1] = arguments[i];
  4395.         }
  4396.     }
  4397.     queue.push(new Item(fun, args));
  4398.     if (queue.length === 1 && !draining) {
  4399.         runTimeout(drainQueue);
  4400.     }
  4401. };
  4402.  
  4403. // v8 likes predictible objects
  4404. function Item(fun, array) {
  4405.     this.fun = fun;
  4406.     this.array = array;
  4407. }
  4408. Item.prototype.run = function () {
  4409.     this.fun.apply(null, this.array);
  4410. };
  4411. process.title = 'browser';
  4412. process.browser = true;
  4413. process.env = {};
  4414. process.argv = [];
  4415. process.version = ''; // empty string to avoid regexp issues
  4416. process.versions = {};
  4417.  
  4418. function noop() {}
  4419.  
  4420. process.on = noop;
  4421. process.addListener = noop;
  4422. process.once = noop;
  4423. process.off = noop;
  4424. process.removeListener = noop;
  4425. process.removeAllListeners = noop;
  4426. process.emit = noop;
  4427. process.prependListener = noop;
  4428. process.prependOnceListener = noop;
  4429.  
  4430. process.listeners = function (name) { return [] }
  4431.  
  4432. process.binding = function (name) {
  4433.     throw new Error('process.binding is not supported');
  4434. };
  4435.  
  4436. process.cwd = function () { return '/' };
  4437. process.chdir = function (dir) {
  4438.     throw new Error('process.chdir is not supported');
  4439. };
  4440. process.umask = function() { return 0; };
  4441.  
  4442. },{}],37:[function(require,module,exports){
  4443. (function (setImmediate,clearImmediate){(function (){
  4444. var nextTick = require('process/browser.js').nextTick;
  4445. var apply = Function.prototype.apply;
  4446. var slice = Array.prototype.slice;
  4447. var immediateIds = {};
  4448. var nextImmediateId = 0;
  4449.  
  4450. // DOM APIs, for completeness
  4451.  
  4452. exports.setTimeout = function() {
  4453.   return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  4454. };
  4455. exports.setInterval = function() {
  4456.   return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  4457. };
  4458. exports.clearTimeout =
  4459. exports.clearInterval = function(timeout) { timeout.close(); };
  4460.  
  4461. function Timeout(id, clearFn) {
  4462.   this._id = id;
  4463.   this._clearFn = clearFn;
  4464. }
  4465. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  4466. Timeout.prototype.close = function() {
  4467.   this._clearFn.call(window, this._id);
  4468. };
  4469.  
  4470. // Does not start the time, just sets up the members needed.
  4471. exports.enroll = function(item, msecs) {
  4472.   clearTimeout(item._idleTimeoutId);
  4473.   item._idleTimeout = msecs;
  4474. };
  4475.  
  4476. exports.unenroll = function(item) {
  4477.   clearTimeout(item._idleTimeoutId);
  4478.   item._idleTimeout = -1;
  4479. };
  4480.  
  4481. exports._unrefActive = exports.active = function(item) {
  4482.   clearTimeout(item._idleTimeoutId);
  4483.  
  4484.   var msecs = item._idleTimeout;
  4485.   if (msecs >= 0) {
  4486.     item._idleTimeoutId = setTimeout(function onTimeout() {
  4487.       if (item._onTimeout)
  4488.         item._onTimeout();
  4489.     }, msecs);
  4490.   }
  4491. };
  4492.  
  4493. // That's not how node.js implements it but the exposed api is the same.
  4494. exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
  4495.   var id = nextImmediateId++;
  4496.   var args = arguments.length < 2 ? false : slice.call(arguments, 1);
  4497.  
  4498.   immediateIds[id] = true;
  4499.  
  4500.   nextTick(function onNextTick() {
  4501.     if (immediateIds[id]) {
  4502.       // fn.call() is faster so we optimize for the common use-case
  4503.       // @see http://jsperf.com/call-apply-segu
  4504.       if (args) {
  4505.         fn.apply(null, args);
  4506.       } else {
  4507.         fn.call(null);
  4508.       }
  4509.       // Prevent ids from leaking
  4510.       exports.clearImmediate(id);
  4511.     }
  4512.   });
  4513.  
  4514.   return id;
  4515. };
  4516.  
  4517. exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
  4518.   delete immediateIds[id];
  4519. };
  4520. }).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
  4521.  
  4522. },{"process/browser.js":36,"timers":37}],38:[function(require,module,exports){
  4523. /**
  4524.  * Semantic Version Number
  4525.  * @author 闲耘 <[email protected]>
  4526.  *
  4527.  * @usage
  4528.  *    var version = new Versioning("1.2.3")
  4529.  *    version > 1
  4530.  *    version.eq(1)
  4531.  */
  4532.  
  4533.  
  4534. // Semantic Versioning Delimiter.
  4535. var delimiter = ".";
  4536.  
  4537. var Version = function(version){
  4538.   this._version = String(version);
  4539. };
  4540.  
  4541. function compare(v1, v2, complete){
  4542.   v1 = String(v1);
  4543.   v2 = String(v2);
  4544.   if(v1 === v2){return 0;}
  4545.   var v1s = v1.split(delimiter);
  4546.   var v2s = v2.split(delimiter);
  4547.   var len = Math[complete ? "max" : "min"](v1s.length, v2s.length);
  4548.   for(var i=0; i<len; i++){
  4549.     v1s[i] = "undefined"===typeof v1s[i] ? 0 : parseInt(v1s[i], 10);
  4550.     v2s[i] = "undefined"===typeof v2s[i] ? 0 : parseInt(v2s[i], 10);
  4551.     if(v1s[i] > v2s[i]){return 1;}
  4552.     if(v1s[i] < v2s[i]){return -1;}
  4553.   }
  4554.   return 0;
  4555. }
  4556.  
  4557. Version.compare = function(v1, v2){
  4558.   return compare(v1, v2, true);
  4559. };
  4560.  
  4561. /**
  4562.  * @param {String} v1.
  4563.  * @param {String} v2.
  4564.  * @return {Boolean} true if v1 equals v2.
  4565.  *
  4566.  *    Version.eq("6.1", "6"); // true.
  4567.  *    Version.eq("6.1.2", "6.1"); // true.
  4568.  */
  4569. Version.eq = function(v1, v2, strict){
  4570.   return compare(v1, v2, strict) === 0;
  4571. };
  4572.  
  4573. /**
  4574.  * @param {String} v1.
  4575.  * @param {String} v2.
  4576.  * @return {Boolean} return true
  4577.  */
  4578. Version.gt = function(v1, v2){
  4579.   return compare(v1, v2, true) > 0;
  4580. };
  4581.  
  4582. Version.gte = function(v1, v2){
  4583.   return compare(v1, v2, true) >= 0;
  4584. };
  4585.  
  4586. Version.lt = function(v1, v2){
  4587.   return compare(v1, v2, true) < 0;
  4588. };
  4589.  
  4590. Version.lte = function(v1, v2){
  4591.   return compare(v1, v2, true) <= 0;
  4592. };
  4593.  
  4594. Version.prototype = {
  4595.   // new Version("6.1").eq(6); // true.
  4596.   // new Version("6.1.2").eq("6.1"); // true.
  4597.   eq: function(version){
  4598.     return Version.eq(this._version, version);
  4599.   },
  4600.  
  4601.   gt: function(version){
  4602.     return Version.gt(this._version, version);
  4603.   },
  4604.  
  4605.   gte: function(version){
  4606.     return Version.gte(this._version, version);
  4607.   },
  4608.  
  4609.   lt: function(version){
  4610.     return Version.lt(this._version, version);
  4611.   },
  4612.  
  4613.   lte: function(version){
  4614.     return Version.lte(this._version, version);
  4615.   },
  4616.  
  4617.   valueOf: function(){
  4618.     return parseFloat(
  4619.       this._version.split(delimiter).slice(0, 2).join(delimiter),
  4620.       10);
  4621.   },
  4622.  
  4623.   /**
  4624.    * XXX: ""+ver 调用的转型方法是 valueOf,而不是 toString,这个有点悲剧。
  4625.    * 只能使用 String(ver) 或 ver.toString() 方法。
  4626.    * @param {Number} precision, 返回的版本号精度。默认返回完整版本号。
  4627.    * @return {String}
  4628.    */
  4629.   toString: function(precision){
  4630.     return "undefined" === typeof precision ? this._version :
  4631.       this._version.split(delimiter).slice(0, precision).join(delimiter);
  4632.   }
  4633. };
  4634.  
  4635.  
  4636. module.exports = Version;
  4637.  
  4638. },{}]},{},[1])
  4639.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement