declare namespace Il2Cpp { /** */ const application: { /** * Gets the data path name of the current application, e.g. * `/data/emulated/0/Android/data/com.example.application/files` * on Android. * * **This information is not guaranteed to exist.** * * ```ts * Il2Cpp.perform(() => { * // prints /data/emulated/0/Android/data/com.example.application/files * console.log(Il2Cpp.application.dataPath); * }); * ``` */ readonly dataPath: string | null; /** * Gets the identifier name of the current application, e.g. * `com.example.application` on Android. * * In case the identifier cannot be retrieved, the main module name is * returned instead, which typically is the process name. * * ```ts * Il2Cpp.perform(() => { * // prints com.example.application * console.log(Il2Cpp.application.identifier); * }); * ``` */ readonly identifier: string; /** * Gets the version name of the current application, e.g. `4.12.8`. * * In case the version cannot be retrieved, an hash of the IL2CPP * module is returned instead. * * ```ts * Il2Cpp.perform(() => { * // prints 4.12.8 * console.log(Il2Cpp.application.version); * }); * ``` */ readonly version: string; }; /** * Gets the Unity version of the current application. * * **It is possible to override or manually set its value using * {@link Il2Cpp.$config.unityVersion}:** * ```ts * Il2Cpp.$config.unityVersion = "5.3.5f1"; * * Il2Cpp.perform(() => { * // prints 5.3.5f1 * console.log(Il2Cpp.unityVersion); * }); * ``` * * When overriding its value, the user has to make sure to set a valid * value so that it gets matched by the following regular expression: * ``` * (20\d{2}|\d)\.(\d)\.(\d{1,2})(?:[abcfp]|rc){0,2}\d? * ``` */ const unityVersion: string; } declare namespace Il2Cpp { /** Create a boxed primitive */ function boxed(value: T, type?: T extends number ? "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32" | "int64" | "uint64" | "char" : T extends NativePointer ? "intptr" | "uintptr" : never): Il2Cpp.Object; } declare namespace Il2Cpp { /** * Set of configurations users can override. It is for advanced use cases, * when certain values cannot be detected automatically. \ * For reference, see: * - {@link Il2Cpp.module}; * - {@link Il2Cpp.unityVersion}; * - {@link Il2Cpp.exports}; */ const $config: { moduleName?: string; unityVersion?: string; exports?: Record<`il2cpp_${string}`, () => NativePointer>; }; } declare namespace Il2Cpp { /** * @deprecated * Dumps the application, i.e. it creates a dummy `.cs` file that contains * all the class, field and method declarations. * * The dump is very useful when it comes to inspecting the application as * you can easily search for succulent members using a simple text search, * hence this is typically the very first thing it should be done when * working with a new application. \ * Keep in mind the dump is version, platform and arch dependentend, so * it has to be re-genereated if any of these changes. * * The file is generated in the **target** device, so you might need to * pull it to the host device afterwards. * * Dumping *may* require a file name and a directory path (a place where the * application can write to). If not provided, the target path is generated * automatically using the information from {@link Il2Cpp.application}. * * ```ts * Il2Cpp.perform(() => { * Il2Cpp.dump(); * }); * ``` * * For instance, the dump resembles the following: * ``` * class Mono.DataConverter.PackContext : System.Object * { * System.Byte[] buffer; // 0x10 * System.Int32 next; // 0x18 * System.String description; // 0x20 * System.Int32 i; // 0x28 * Mono.DataConverter conv; // 0x30 * System.Int32 repeat; // 0x38 * System.Int32 align; // 0x3c * * System.Void Add(System.Byte[] group); // 0x012ef4f0 * System.Byte[] Get(); // 0x012ef6ec * System.Void .ctor(); // 0x012ef78c * } * ``` */ function dump(fileName?: string, path?: string): void; /** * @deprecated * Just like {@link Il2Cpp.dump}, but a `.cs` file per assembly is * generated instead of having a single big `.cs` file. For instance, all * classes within `System.Core` and `System.Runtime.CompilerServices.Unsafe` * are dumped into `System/Core.cs` and * `System/Runtime/CompilerServices/Unsafe.cs`, respectively. * * ```ts * Il2Cpp.perform(() => { * Il2Cpp.dumpTree(); * }); * ``` */ function dumpTree(path?: string, ignoreAlreadyExistingDirectory?: boolean): void; } declare namespace Il2Cpp { /** * Installs a listener to track any thrown (unrecoverable) C# exception. \ * This may be useful when incurring in `abort was called` errors. * * By default, it only tracks exceptions that were thrown by the *caller* * thread. * * **It may not work for every platform.** * * ```ts * Il2Cpp.perform(() => { * Il2Cpp.installExceptionListener("all"); * * // rest of the code * }); * ``` * * For instance, it may print something along: * ``` * System.NullReferenceException: Object reference not set to an instance of an object. * at AddressableLoadWrapper+d__3[T].MoveNext () [0x00000] in <00000000000000000000000000000000>:0 * at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 * ``` */ function installExceptionListener(targetThread?: "current" | "all"): InvocationListener; } declare namespace Il2Cpp { /** * The **core** object where all the necessary IL2CPP native functions are * held. \ * `frida-il2cpp-bridge` is built around this object by providing an * easy-to-use abstraction layer: the user isn't expected to use it directly, * but it can in case of advanced use cases. * * The exports depends on the Unity version, hence some of them may be * unavailable; moreover, they are searched by **name** (e.g. * `il2cpp_class_from_name`) hence they might get stripped, hidden or * renamed by a nasty obfuscator. * * However, it is possible to override or set the handle of any of the * exports using {@link Il2Cpp.$config.exports}: * ```ts * Il2Cpp.$config.exports = { * il2cpp_image_get_class: () => Il2Cpp.module.base.add(0x1204c), * il2cpp_class_get_parent: () => { * return Memory.scanSync(Il2Cpp.module.base, Il2Cpp.module.size, "2f 10 ee 10 34 a8")[0].address; * }, * }; * * Il2Cpp.perform(() => { * // ... * }); * ``` */ const exports: { readonly alloc: NativeFunction; readonly arrayGetLength: NativeFunction; readonly arrayNew: NativeFunction; readonly assemblyGetImage: NativeFunction; readonly classForEach: NativeFunction; readonly classFromName: NativeFunction; readonly classFromObject: NativeFunction; readonly classGetArrayClass: NativeFunction; readonly classGetArrayElementSize: NativeFunction; readonly classGetAssemblyName: NativeFunction; readonly classGetBaseType: NativeFunction; readonly classGetDeclaringType: NativeFunction; readonly classGetElementClass: NativeFunction; readonly classGetFieldFromName: NativeFunction; readonly classGetFields: NativeFunction; readonly classGetFlags: NativeFunction; readonly classGetImage: NativeFunction; readonly classGetInstanceSize: NativeFunction; readonly classGetInterfaces: NativeFunction; readonly classGetMethodFromName: NativeFunction; readonly classGetMethods: NativeFunction; readonly classGetName: NativeFunction; readonly classGetNamespace: NativeFunction; readonly classGetNestedClasses: NativeFunction; readonly classGetParent: NativeFunction; readonly classGetStaticFieldData: NativeFunction; readonly classGetValueTypeSize: NativeFunction; readonly classGetType: NativeFunction; readonly classHasReferences: NativeFunction; readonly classInitialize: NativeFunction; readonly classIsAbstract: NativeFunction; readonly classIsAssignableFrom: NativeFunction; readonly classIsBlittable: NativeFunction; readonly classIsEnum: NativeFunction; readonly classIsGeneric: NativeFunction; readonly classIsInflated: NativeFunction; readonly classIsInterface: NativeFunction; readonly classIsSubclassOf: NativeFunction; readonly classIsValueType: NativeFunction; readonly domainGetAssemblyFromName: NativeFunction; readonly domainGet: NativeFunction; readonly domainGetAssemblies: NativeFunction; readonly fieldGetClass: NativeFunction; readonly fieldGetFlags: NativeFunction; readonly fieldGetName: NativeFunction; readonly fieldGetOffset: NativeFunction; readonly fieldGetStaticValue: NativeFunction; readonly fieldGetType: NativeFunction; readonly fieldSetStaticValue: NativeFunction; readonly free: NativeFunction; readonly gcCollect: NativeFunction; readonly gcCollectALittle: NativeFunction; readonly gcDisable: NativeFunction; readonly gcEnable: NativeFunction; readonly gcGetHeapSize: NativeFunction; readonly gcGetMaxTimeSlice: NativeFunction; readonly gcGetUsedSize: NativeFunction; readonly gcHandleGetTarget: NativeFunction; readonly gcHandleFree: NativeFunction; readonly gcHandleNew: NativeFunction; readonly gcHandleNewWeakRef: NativeFunction; readonly gcIsDisabled: NativeFunction; readonly gcIsIncremental: NativeFunction; readonly gcSetMaxTimeSlice: NativeFunction; readonly gcStartIncrementalCollection: NativeFunction; readonly gcStartWorld: NativeFunction; readonly gcStopWorld: NativeFunction; readonly getCorlib: NativeFunction; readonly imageGetAssembly: NativeFunction; readonly imageGetClass: NativeFunction; readonly imageGetClassCount: NativeFunction; readonly imageGetName: NativeFunction; readonly initialize: NativeFunction; readonly livenessAllocateStruct: NativeFunction; readonly livenessCalculationBegin: NativeFunction; readonly livenessCalculationEnd: NativeFunction; readonly livenessCalculationFromStatics: NativeFunction; readonly livenessFinalize: NativeFunction; readonly livenessFreeStruct: NativeFunction; readonly memorySnapshotCapture: NativeFunction; readonly memorySnapshotFree: NativeFunction; readonly memorySnapshotGetClasses: NativeFunction; readonly memorySnapshotGetObjects: NativeFunction; readonly methodGetClass: NativeFunction; readonly methodGetFlags: NativeFunction; readonly methodGetName: NativeFunction; readonly methodGetObject: NativeFunction; readonly methodGetParameterCount: NativeFunction; readonly methodGetParameterName: NativeFunction; readonly methodGetParameters: NativeFunction; readonly methodGetParameterType: NativeFunction; readonly methodGetReturnType: NativeFunction; readonly methodIsGeneric: NativeFunction; readonly methodIsInflated: NativeFunction; readonly methodIsInstance: NativeFunction; readonly monitorEnter: NativeFunction; readonly monitorExit: NativeFunction; readonly monitorPulse: NativeFunction; readonly monitorPulseAll: NativeFunction; readonly monitorTryEnter: NativeFunction; readonly monitorTryWait: NativeFunction; readonly monitorWait: NativeFunction; readonly objectGetClass: NativeFunction; readonly objectGetVirtualMethod: NativeFunction; readonly objectInitialize: NativeFunction; readonly objectNew: NativeFunction; readonly objectGetSize: NativeFunction; readonly objectUnbox: NativeFunction; readonly resolveInternalCall: NativeFunction; readonly stringGetChars: NativeFunction; readonly stringGetLength: NativeFunction; readonly stringNew: NativeFunction; readonly valueTypeBox: NativeFunction; readonly threadAttach: NativeFunction; readonly threadDetach: NativeFunction; readonly threadGetAttachedThreads: NativeFunction; readonly threadGetCurrent: NativeFunction; readonly threadIsVm: NativeFunction; readonly typeEquals: NativeFunction; readonly typeGetClass: NativeFunction; readonly typeGetName: NativeFunction; readonly typeGetObject: NativeFunction; readonly typeGetTypeEnum: NativeFunction; }; } declare namespace Il2Cpp { /** * Creates a filter to include elements whose type can be assigned to a * variable of the given class. \ * It relies on {@link Il2Cpp.Class.isAssignableFrom}. * * ```ts * const IComparable = Il2Cpp.corlib.class("System.IComparable"); * * const objects = [ * Il2Cpp.corlib.class("System.Object").new(), * Il2Cpp.corlib.class("System.String").new() * ]; * * const comparables = objects.filter(Il2Cpp.is(IComparable)); * ``` */ function is(klass: Il2Cpp.Class): (element: T) => boolean; /** * Creates a filter to include elements whose type can be corresponds to * the given class. \ * It compares the native handle of the element classes. * * ```ts * const String = Il2Cpp.corlib.class("System.String"); * * const objects = [ * Il2Cpp.corlib.class("System.Object").new(), * Il2Cpp.corlib.class("System.String").new() * ]; * * const strings = objects.filter(Il2Cpp.isExactly(String)); * ``` */ function isExactly(klass: Il2Cpp.Class): (element: T) => boolean; } declare namespace Il2Cpp { /** * The object literal to interacts with the garbage collector. */ const gc: { /** * Gets the heap size in bytes. */ readonly heapSize: Int64; /** * Determines whether the garbage collector is enabled. */ isEnabled: boolean; /** * Determines whether the garbage collector is incremental * ([source](https://docs.unity3d.com/Manual/performance-incremental-garbage-collection.html)). */ readonly isIncremental: boolean; /** * Gets the number of nanoseconds the garbage collector can spend in a * collection step. */ get maxTimeSlice(): Int64; /** * Sets the number of nanoseconds the garbage collector can spend in * a collection step. */ set maxTimeSlice(nanoseconds: number | Int64); /** * Gets the used heap size in bytes. */ readonly usedHeapSize: Int64; /** * Returns the heap allocated objects of the specified class. \ * This variant reads GC descriptors. */ choose(klass: Il2Cpp.Class): Il2Cpp.Object[]; /** * Forces a garbage collection of the specified generation. */ collect(generation: 0 | 1 | 2): void; /** * Forces a garbage collection. */ collectALittle(): void; /** * Resumes all the previously stopped threads. */ startWorld(): void; /** * Performs an incremental garbage collection. */ startIncrementalCollection(): void; /** * Stops all threads which may access the garbage collected heap, other * than the caller. */ stopWorld(): void; }; } /** Scaffold class. */ declare class NativeStruct implements ObjectWrapper { readonly handle: NativePointer; constructor(handleOrWrapper: NativePointerValue); equals(other: NativeStruct): boolean; isNull(): boolean; asNullable(): this | null; } declare namespace Il2Cpp { /** * Allocates the given amount of bytes - it's equivalent to C's `malloc`. \ * The allocated memory should be freed manually. */ function alloc(size?: number | UInt64): NativePointer; /** * Frees a previously allocated memory using {@link Il2Cpp.alloc} - it's * equivalent to C's `free`.. * * ```ts * const handle = Il2Cpp.alloc(64); * * // ... * * Il2Cpp.free(handle); * ``` */ function free(pointer: NativePointerValue): void; } declare namespace Il2Cpp { /** * Gets the IL2CPP module (a *native library*), that is where the IL2CPP * exports will be searched for (see {@link Il2Cpp.exports}). * * The module is located by its name: * - Android: `libil2cpp.so` * - Linux: `GameAssembly.so` * - Windows: `GameAssembly.dll` * - iOS: `UnityFramework` * - macOS: `GameAssembly.dylib` * * On iOS and macOS, IL2CPP exports may be located within a module having * a different name. * * In any case, it is possible to override or set the IL2CPP module name * using {@link Il2Cpp.$config.moduleName}: * ```ts * Il2Cpp.$config.moduleName = "CustomName.dylib"; * * Il2Cpp.perform(() => { * // ... * }); * ``` */ const module: Module; } declare namespace Il2Cpp { /** * Wraps the given primitive or value type in a `System.Nullable`, also * known as a nullable value type (`T?`), to represent primitive or value * types that _might_ be null * ([ref](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/nullable-value-types)). \ * Reference types **shall not** be turned into nullable, as they are * already covered by the C# `null` keywork and `new Il2Cpp.Object(NULL)` in Frida. * * ```ts * const nullableBoolean = Il2Cpp.nullable(false); * const nullableInt32 = Il2Cpp.nullable(13); * const nullableValueType = Il2Cpp.nullable(myValueType); * * const nullableNumber = Il2Cpp.nullable(13, Il2Cpp.corlib.class("System.UInt16")); * const nullableUnsignedPointer = Il2Cpp.nullable(ptr(0xdeadbeef), Il2Cpp.corlib.class("System.UIntPtr")); * * const nullPrimitiveOrValueType = Il2Cpp.nullable(null, Il2Cpp.corlib.class("...")); * ``` * Internally, `System.Nullable` prepends to the value type values * layout a boolean to indicate whether it's not null: * ```c# * struct System.Nullable : System.ValueType * { * System.Boolean hasValue; // 0x10 * System.Int32 value; // 0x14 * ... * } */ function nullable(value: null | number | NativePointer, klass: Il2Cpp.Class): Il2Cpp.ValueType; function nullable(value: boolean | number | Int64 | UInt64 | NativePointer | Il2Cpp.ValueType): Il2Cpp.ValueType; } declare namespace Il2Cpp { /** Attaches the caller thread to Il2Cpp domain and executes the given block. */ function perform(block: () => T | Promise, flag?: "free" | "bind" | "leak" | "main"): Promise; } declare namespace Il2Cpp { class Tracer { #private; constructor(applier: Il2Cpp.Tracer.Apply); /** */ thread(thread: Il2Cpp.Thread): Pick & Il2Cpp.Tracer.ChooseTargets; /** Determines whether print duplicate logs. */ verbose(value: boolean): Il2Cpp.Tracer.ChooseTargets; /** Sets the application domain as the place where to find the target methods. */ domain(): Il2Cpp.Tracer.FilterAssemblies; /** Sets the passed `assemblies` as the place where to find the target methods. */ assemblies(...assemblies: Il2Cpp.Assembly[]): Il2Cpp.Tracer.FilterClasses; /** Sets the passed `classes` as the place where to find the target methods. */ classes(...classes: Il2Cpp.Class[]): Il2Cpp.Tracer.FilterMethods; /** Sets the passed `methods` as the target methods. */ methods(...methods: Il2Cpp.Method[]): Il2Cpp.Tracer.FilterParameters; /** Filters the assemblies where to find the target methods. */ filterAssemblies(filter: (assembly: Il2Cpp.Assembly) => boolean): Il2Cpp.Tracer.FilterClasses; /** Filters the classes where to find the target methods. */ filterClasses(filter: (klass: Il2Cpp.Class) => boolean): Il2Cpp.Tracer.FilterMethods; /** Filters the target methods. */ filterMethods(filter: (method: Il2Cpp.Method) => boolean): Il2Cpp.Tracer.FilterParameters; /** Filters the target methods. */ filterParameters(filter: (parameter: Il2Cpp.Parameter) => boolean): Pick; /** Commits the current changes by finding the target methods. */ and(): Il2Cpp.Tracer.ChooseTargets & Pick; /** Starts tracing. */ attach(): void; } namespace Tracer { type Configure = Pick & Il2Cpp.Tracer.ChooseTargets; type ChooseTargets = Pick; type FilterAssemblies = FilterClasses & Pick; type FilterClasses = FilterMethods & Pick; type FilterMethods = FilterParameters & Pick; type FilterParameters = Pick & Pick; interface State { depth: number; buffer: string[]; history: Set; flush: () => void; } type Apply = (method: Il2Cpp.Method, state: Il2Cpp.Tracer.State, threadId: number) => void; } /** */ function trace(parameters?: boolean): Il2Cpp.Tracer.Configure; /** */ function backtrace(mode?: Backtracer): Il2Cpp.Tracer.Configure; } declare namespace Il2Cpp { class Array extends NativeStruct implements Iterable { /** Gets the Il2CppArray struct size, possibly equal to `Process.pointerSize * 4`. */ static get headerSize(): number; /** Gets the size of the object encompassed by the current array. */ get elementSize(): number; /** Gets the type of the object encompassed by the current array. */ get elementType(): Il2Cpp.Type; /** Gets the total number of elements in all the dimensions of the current array. */ get length(): number; /** Gets the encompassing object of the current array. */ get object(): Il2Cpp.Object; /** Gets the element at the specified index of the current array. */ get(index: number): T; /** Sets the element at the specified index of the current array. */ set(index: number, value: T): void; /** */ toString(): string; /** Iterable. */ [Symbol.iterator](): IterableIterator; } /** Creates a new empty array of the given length. */ function array(klass: Il2Cpp.Class, length: number): Il2Cpp.Array; /** Creates a new array with the given elements. */ function array(klass: Il2Cpp.Class, elements: T[]): Il2Cpp.Array; } declare namespace Il2Cpp { class Assembly extends NativeStruct { /** Gets the image of this assembly. */ get image(): Il2Cpp.Image; /** Gets the name of this assembly. */ get name(): string; /** Gets the encompassing object of the current assembly. */ get object(): Il2Cpp.Object; } } declare namespace Il2Cpp { class Class extends NativeStruct { /** Gets the actual size of the instance of the current class. */ get actualInstanceSize(): number; /** Gets the array class which encompass the current class. */ get arrayClass(): Il2Cpp.Class; /** Gets the size of the object encompassed by the current array class. */ get arrayElementSize(): number; /** Gets the name of the assembly in which the current class is defined. */ get assemblyName(): string; /** Gets the class that declares the current nested class. */ get declaringClass(): Il2Cpp.Class | null; /** Gets the encompassed type of this array, reference, pointer or enum type. */ get baseType(): Il2Cpp.Type | null; /** Gets the class of the object encompassed or referred to by the current array, pointer or reference class. */ get elementClass(): Il2Cpp.Class | null; /** Gets the fields of the current class. */ get fields(): Il2Cpp.Field[]; /** Gets the flags of the current class. */ get flags(): number; /** Gets the full name (namespace + name) of the current class. */ get fullName(): string; /** Gets the generic class of the current class if the current class is inflated. */ get genericClass(): Il2Cpp.Class | null; /** Gets the generics parameters of this generic class. */ get generics(): Il2Cpp.Class[]; /** Determines whether the GC has tracking references to the current class instances. */ get hasReferences(): boolean; /** Determines whether ther current class has a valid static constructor. */ get hasStaticConstructor(): boolean; /** Gets the image in which the current class is defined. */ get image(): Il2Cpp.Image; /** Gets the size of the instance of the current class. */ get instanceSize(): number; /** Determines whether the current class is abstract. */ get isAbstract(): boolean; /** Determines whether the current class is blittable. */ get isBlittable(): boolean; /** Determines whether the current class is an enumeration. */ get isEnum(): boolean; /** Determines whether the current class is a generic one. */ get isGeneric(): boolean; /** Determines whether the current class is inflated. */ get isInflated(): boolean; /** Determines whether the current class is an interface. */ get isInterface(): boolean; /** Determines whether the current class is a struct. */ get isStruct(): boolean; /** Determines whether the current class is a value type. */ get isValueType(): boolean; /** Gets the interfaces implemented or inherited by the current class. */ get interfaces(): Il2Cpp.Class[]; /** Gets the methods implemented by the current class. */ get methods(): Il2Cpp.Method[]; /** Gets the name of the current class. */ get name(): string; /** Gets the namespace of the current class. */ get namespace(): string | undefined; /** Gets the classes nested inside the current class. */ get nestedClasses(): Il2Cpp.Class[]; /** Gets the class from which the current class directly inherits. */ get parent(): Il2Cpp.Class | null; /** Gets the pointer class of the current class. */ get pointerClass(): Il2Cpp.Class; /** Gets the rank (number of dimensions) of the current array class. */ get rank(): number; /** Gets a pointer to the static fields of the current class. */ get staticFieldsData(): NativePointer; /** Gets the size of the instance - as a value type - of the current class. */ get valueTypeSize(): number; /** Gets the type of the current class. */ get type(): Il2Cpp.Type; /** Allocates a new object of the current class. */ alloc(): Il2Cpp.Object; /** Gets the field identified by the given name. */ field(name: string): Il2Cpp.Field; /** Gets the hierarchy of the current class. */ hierarchy(options?: { includeCurrent?: boolean; }): Generator; /** Builds a generic instance of the current generic class. */ inflate(...classes: Il2Cpp.Class[]): Il2Cpp.Class; /** Calls the static constructor of the current class. */ initialize(): Il2Cpp.Class; /** Determines whether an instance of `other` class can be assigned to a variable of the current type. */ isAssignableFrom(other: Il2Cpp.Class): boolean; /** Determines whether the current class derives from `other` class. */ isSubclassOf(other: Il2Cpp.Class, checkInterfaces: boolean): boolean; /** Gets the method identified by the given name and parameter count. */ method(name: string, parameterCount?: number): Il2Cpp.Method; /** Gets the nested class with the given name. */ nested(name: string): Il2Cpp.Class; /** Allocates a new object of the current class and calls its default constructor. */ new(): Il2Cpp.Object; /** Gets the field with the given name. */ tryField(name: string): Il2Cpp.Field | null; /** Gets the method with the given name and parameter count. */ tryMethod(name: string, parameterCount?: number): Il2Cpp.Method | null; /** Gets the nested class with the given name. */ tryNested(name: string): Il2Cpp.Class | undefined; /** */ toString(): string; /** Executes a callback for every defined class. */ static enumerate(block: (klass: Il2Cpp.Class) => void): void; } } declare namespace Il2Cpp { /** Creates a delegate object of the given delegate class. */ function delegate

(klass: Il2Cpp.Class, block: (...args: P) => R): Il2Cpp.Object; } declare namespace Il2Cpp { class Domain extends NativeStruct { /** Gets the assemblies that have been loaded into the execution context of the application domain. */ get assemblies(): Il2Cpp.Assembly[]; /** Gets the encompassing object of the application domain. */ get object(): Il2Cpp.Object; /** Opens and loads the assembly with the given name. */ assembly(name: string): Il2Cpp.Assembly; /** Attached a new thread to the application domain. */ attach(): Il2Cpp.Thread; /** Opens and loads the assembly with the given name. */ tryAssembly(name: string): Il2Cpp.Assembly | null; } /** Gets the application domain. */ const domain: Il2Cpp.Domain; } declare namespace Il2Cpp { class Field extends NativeStruct { /** Gets the class in which this field is defined. */ get class(): Il2Cpp.Class; /** Gets the flags of the current field. */ get flags(): number; /** Determines whether this field value is known at compile time. */ get isLiteral(): boolean; /** Determines whether this field is static. */ get isStatic(): boolean; /** Determines whether this field is thread static. */ get isThreadStatic(): boolean; /** Gets the access modifier of this field. */ get modifier(): string | undefined; /** Gets the name of this field. */ get name(): string; /** Gets the offset of this field, calculated as the difference with its owner virtual address. */ get offset(): number; /** Gets the type of this field. */ get type(): Il2Cpp.Type; /** Gets the value of this field. */ get value(): T; /** Sets the value of this field. Thread static or literal values cannot be altered yet. */ set value(value: T); /** */ toString(): string; } /** * A {@link Il2Cpp.Field} bound to a {@link Il2Cpp.Object} or a * {@link Il2Cpp.ValueType} (also known as *instances*). * ```ts * const object: Il2Cpp.Object = Il2Cpp.string("Hello, world!").object; * const m_length: Il2Cpp.BoundField = object.field("m_length"); * const length = m_length.value; // 13 * ``` * Of course, binding a static field does not make sense and may cause * unwanted behaviors. * * Binding can be done manually with: * ```ts * const SystemString = Il2Cpp.corlib.class("System.String"); * const m_length: Il2Cpp.Field = SystemString.field("m_length"); * * const object: Il2Cpp.Object = Il2Cpp.string("Hello, world!").object; * // @ts-ignore * const m_length_bound: Il2Cpp.BoundField = m_length.bind(object); * ``` */ interface BoundField extends Field { } namespace Field { type Type = boolean | number | Int64 | UInt64 | NativePointer | Il2Cpp.Pointer | Il2Cpp.ValueType | Il2Cpp.Object | Il2Cpp.String | Il2Cpp.Array; const enum Attributes { FieldAccessMask = 7, PrivateScope = 0, Private = 1, FamilyAndAssembly = 2, Assembly = 3, Family = 4, FamilyOrAssembly = 5, Public = 6, Static = 16, InitOnly = 32, Literal = 64, NotSerialized = 128, SpecialName = 512, PinvokeImpl = 8192, ReservedMask = 38144, RTSpecialName = 1024, HasFieldMarshal = 4096, HasDefault = 32768, HasFieldRVA = 256 } } } declare namespace Il2Cpp { class GCHandle { readonly handle: number; /** Gets the object associated to this handle. */ get target(): Il2Cpp.Object | null; /** Frees this handle. */ free(): void; } } declare namespace Il2Cpp { class Image extends NativeStruct { /** Gets the assembly in which the current image is defined. */ get assembly(): Il2Cpp.Assembly; /** Gets the amount of classes defined in this image. */ get classCount(): number; /** Gets the classes defined in this image. */ get classes(): Il2Cpp.Class[]; /** Gets the name of this image. */ get name(): string; /** Gets the class with the specified name defined in this image. */ class(name: string): Il2Cpp.Class; /** Gets the class with the specified name defined in this image. */ tryClass(name: string): Il2Cpp.Class | null; } /** Gets the COR library. */ const corlib: Il2Cpp.Image; } declare namespace Il2Cpp { class MemorySnapshot extends NativeStruct { /** Captures a memory snapshot. */ static capture(): Il2Cpp.MemorySnapshot; /** Creates a memory snapshot with the given handle. */ constructor(handle?: NativePointer); /** Gets any initialized class. */ get classes(): Il2Cpp.Class[]; /** Gets the objects tracked by this memory snapshot. */ get objects(): Il2Cpp.Object[]; /** Frees this memory snapshot. */ free(): void; } /** */ function memorySnapshot(block: (memorySnapshot: Omit) => T): T; } declare namespace Il2Cpp { class Method extends NativeStruct { /** Gets the class in which this method is defined. */ get class(): Il2Cpp.Class; /** Gets the flags of the current method. */ get flags(): number; /** Gets the implementation flags of the current method. */ get implementationFlags(): number; /** */ get fridaSignature(): NativeCallbackArgumentType[]; /** Gets the generic parameters of this generic method. */ get generics(): Il2Cpp.Class[]; /** Determines whether this method is external. */ get isExternal(): boolean; /** Determines whether this method is generic. */ get isGeneric(): boolean; /** Determines whether this method is inflated (generic with a concrete type parameter). */ get isInflated(): boolean; /** Determines whether this method is static. */ get isStatic(): boolean; /** Determines whether this method is synchronized. */ get isSynchronized(): boolean; /** Gets the access modifier of this method. */ get modifier(): string | undefined; /** Gets the name of this method. */ get name(): string; /** Gets the encompassing object of the current method. */ get object(): Il2Cpp.Object; /** Gets the amount of parameters of this method. */ get parameterCount(): number; /** Gets the parameters of this method. */ get parameters(): Il2Cpp.Parameter[]; /** Gets the relative virtual address (RVA) of this method. */ get relativeVirtualAddress(): NativePointer; /** Gets the return type of this method. */ get returnType(): Il2Cpp.Type; /** Gets the virtual address (VA) of this method. */ get virtualAddress(): NativePointer; /** Replaces the body of this method. */ set implementation(block: (this: Il2Cpp.Class | Il2Cpp.Object | Il2Cpp.ValueType, ...parameters: Il2Cpp.Parameter.Type[]) => T); /** Creates a generic instance of the current generic method. */ inflate(...classes: Il2Cpp.Class[]): Il2Cpp.Method; /** Invokes this method. */ invoke(...parameters: Il2Cpp.Parameter.Type[]): T; /** Gets the overloaded method with the given parameter types. */ overload(...typeNamesOrClasses: (string | Il2Cpp.Class)[]): Il2Cpp.Method; /** Gets the parameter with the given name. */ parameter(name: string): Il2Cpp.Parameter; /** Restore the original method implementation. */ revert(): void; /** Gets the overloaded method with the given parameter types. */ tryOverload(...typeNamesOrClasses: (string | Il2Cpp.Class)[]): Il2Cpp.Method | undefined; /** Gets the parameter with the given name. */ tryParameter(name: string): Il2Cpp.Parameter | undefined; /** */ toString(): string; } /** * A {@link Il2Cpp.Method} bound to a {@link Il2Cpp.Object} or a * {@link Il2Cpp.ValueType} (also known as *instances*). \ * Invoking bound methods will pass the assigned instance as `this`. * ```ts * const object: Il2Cpp.Object = Il2Cpp.string("Hello, world!").object; * const GetLength: Il2Cpp.BoundMethod = object.method("GetLength"); * // There is no need to pass the object when invoking GetLength! * const length = GetLength.invoke(); // 13 * ``` * Of course, binding a static method does not make sense and may cause * unwanted behaviors. \ * * Binding can be done manually with: * ```ts * const SystemString = Il2Cpp.corlib.class("System.String"); * const GetLength: Il2Cpp.Method = SystemString.method("GetLength"); * * const object: Il2Cpp.Object = Il2Cpp.string("Hello, world!").object; * // @ts-ignore * const GetLengthBound: Il2Cpp.BoundMethod = GetLength.bind(object); * ``` */ interface BoundMethod extends Method { } namespace Method { type ReturnType = void | Il2Cpp.Field.Type | Il2Cpp.Reference; const enum Attributes { MemberAccessMask = 7, PrivateScope = 0, Private = 1, FamilyAndAssembly = 2, Assembly = 3, Family = 4, FamilyOrAssembly = 5, Public = 6, Static = 16, Final = 32, Virtual = 64, HideBySig = 128, CheckAccessOnOverride = 512, VtableLayoutMask = 256, ReuseSlot = 0, NewSlot = 256, Abstract = 1024, SpecialName = 2048, PinvokeImpl = 8192, UnmanagedExport = 8, RTSpecialName = 4096, ReservedMask = 53248, HasSecurity = 16384, RequireSecObject = 32768 } const enum ImplementationAttribute { CodeTypeMask = 3, IntermediateLanguage = 0, Native = 1, OptimizedIntermediateLanguage = 2, Runtime = 3, ManagedMask = 4, Unmanaged = 4, Managed = 0, ForwardRef = 16, PreserveSig = 128, InternalCall = 4096, Synchronized = 32, NoInlining = 8, AggressiveInlining = 256, NoOptimization = 64, SecurityMitigations = 1024, MaxMethodImplVal = 65535 } } } declare namespace Il2Cpp { class Object extends NativeStruct { /** Gets the Il2CppObject struct size, possibly equal to `Process.pointerSize * 2`. */ static get headerSize(): number; /** * Returns the same object, but having its parent class as class. * It basically is the C# `base` keyword, so that parent members can be * accessed. * * **Example** \ * Consider the following classes: * ```csharp * class Foo * { * int foo() * { * return 1; * } * } * class Bar : Foo * { * new int foo() * { * return 2; * } * } * ``` * then: * ```ts * const Bar: Il2Cpp.Class = ...; * const bar = Bar.new(); * * console.log(bar.foo()); // 2 * console.log(bar.base.foo()); // 1 * ``` */ get base(): Il2Cpp.Object; /** Gets the class of this object. */ get class(): Il2Cpp.Class; /** Returns a monitor for this object. */ get monitor(): Il2Cpp.Object.Monitor; /** Gets the size of the current object. */ get size(): number; /** Gets the non-static field with the given name of the current class hierarchy. */ field(name: string): Il2Cpp.BoundField; /** Gets the non-static method with the given name (and optionally parameter count) of the current class hierarchy. */ method(name: string, parameterCount?: number): Il2Cpp.BoundMethod; /** Creates a reference to this object. */ ref(pin: boolean): Il2Cpp.GCHandle; /** Gets the correct virtual method from the given virtual method. */ virtualMethod(method: Il2Cpp.Method): Il2Cpp.BoundMethod; /** Gets the non-static field with the given name of the current class hierarchy, if it exists. */ tryField(name: string): Il2Cpp.BoundField | undefined; /** Gets the non-static method with the given name (and optionally parameter count) of the current class hierarchy, if it exists. */ tryMethod(name: string, parameterCount?: number): Il2Cpp.BoundMethod | undefined; /** */ toString(): string; /** Unboxes the value type (either a primitive, a struct or an enum) out of this object. */ unbox(): Il2Cpp.ValueType; /** Creates a weak reference to this object. */ weakRef(trackResurrection: boolean): Il2Cpp.GCHandle; } namespace Object { class Monitor { /** Acquires an exclusive lock on the current object. */ enter(): void; /** Release an exclusive lock on the current object. */ exit(): void; /** Notifies a thread in the waiting queue of a change in the locked object's state. */ pulse(): void; /** Notifies all waiting threads of a change in the object's state. */ pulseAll(): void; /** Attempts to acquire an exclusive lock on the current object. */ tryEnter(timeout: number): boolean; /** Releases the lock on an object and attempts to block the current thread until it reacquires the lock. */ tryWait(timeout: number): boolean; /** Releases the lock on an object and blocks the current thread until it reacquires the lock. */ wait(): void; } } } declare namespace Il2Cpp { class Parameter { /** Name of this parameter. */ readonly name: string; /** Position of this parameter. */ readonly position: number; /** Type of this parameter. */ readonly type: Il2Cpp.Type; constructor(name: string, position: number, type: Il2Cpp.Type); /** */ toString(): string; } namespace Parameter { type Type = Il2Cpp.Field.Type | Il2Cpp.Reference; } } declare namespace Il2Cpp { class Pointer extends NativeStruct { readonly type: Il2Cpp.Type; constructor(handle: NativePointer, type: Il2Cpp.Type); /** Gets the element at the given index. */ get(index: number): T; /** Reads the given amount of elements starting at the given offset. */ read(length: number, offset?: number): T[]; /** Sets the given element at the given index */ set(index: number, value: T): void; /** */ toString(): string; /** Writes the given elements starting at the given index. */ write(values: T[], offset?: number): void; } } declare namespace Il2Cpp { class Reference extends NativeStruct { readonly type: Il2Cpp.Type; constructor(handle: NativePointer, type: Il2Cpp.Type); /** Gets the element referenced by the current reference. */ get value(): T; /** Sets the element referenced by the current reference. */ set value(value: T); /** */ toString(): string; } function reference(value: T, type: Il2Cpp.Type): Il2Cpp.Reference; function reference>(value: T): Il2Cpp.Reference; } declare namespace Il2Cpp { class String extends NativeStruct { /** Gets the content of this string. */ get content(): string | null; /** @unsafe Sets the content of this string - it may write out of bounds! */ set content(value: string | null); /** Gets the length of this string. */ get length(): number; /** Gets the encompassing object of the current string. */ get object(): Il2Cpp.Object; /** */ toString(): string; } /** Creates a new string with the specified content. */ function string(content: string | null): Il2Cpp.String; } declare namespace Il2Cpp { class Thread extends NativeStruct { /** Gets the native id of the current thread. */ get id(): number; /** Gets the encompassing internal object (System.Threding.InternalThreead) of the current thread. */ get internal(): Il2Cpp.Object; /** Determines whether the current thread is the garbage collector finalizer one. */ get isFinalizer(): boolean; /** Gets the managed id of the current thread. */ get managedId(): number; /** Gets the encompassing object of the current thread. */ get object(): Il2Cpp.Object; /** Detaches the thread from the application domain. */ detach(): void; /** Schedules a callback on the current thread. */ schedule(block: () => T): Promise; } /** Gets the attached threads. */ const attachedThreads: Il2Cpp.Thread[]; /** Gets the current attached thread, if any. */ const currentThread: Il2Cpp.Thread | null; /** Gets the current attached thread, if any. */ const mainThread: Il2Cpp.Thread; } declare namespace Il2Cpp { class Type extends NativeStruct { /** */ static get Enum(): { VAR: number; MVAR: number; VOID: number; BOOLEAN: number; CHAR: number; BYTE: number; UBYTE: number; SHORT: number; USHORT: number; INT: number; UINT: number; LONG: number; ULONG: number; NINT: number; NUINT: number; FLOAT: number; DOUBLE: number; POINTER: number; VALUE_TYPE: number; OBJECT: number; STRING: number; CLASS: number; ARRAY: number; NARRAY: number; GENERIC_INSTANCE: number; } & { [x: number]: "VAR" | "MVAR" | "VOID" | "BOOLEAN" | "CHAR" | "BYTE" | "UBYTE" | "SHORT" | "USHORT" | "INT" | "UINT" | "LONG" | "ULONG" | "NINT" | "NUINT" | "FLOAT" | "DOUBLE" | "POINTER" | "VALUE_TYPE" | "OBJECT" | "STRING" | "CLASS" | "ARRAY" | "NARRAY" | "GENERIC_INSTANCE"; }; /** Gets the class of this type. */ get class(): Il2Cpp.Class; /** */ get fridaAlias(): NativeCallbackArgumentType; /** Determines whether this type is passed by reference. */ get isByReference(): boolean; /** Determines whether this type is primitive. */ get isPrimitive(): boolean; /** Gets the name of this type. */ get name(): string; /** Gets the encompassing object of the current type. */ get object(): Il2Cpp.Object; /** Gets the {@link Il2Cpp.Type.Enum} value of the current type. */ get enumValue(): number; is(other: Il2Cpp.Type): boolean; /** */ toString(): string; } } declare namespace Il2Cpp { class ValueType extends NativeStruct { readonly type: Il2Cpp.Type; constructor(handle: NativePointer, type: Il2Cpp.Type); /** Boxes the current value type in a object. */ box(): Il2Cpp.Object; /** Gets the non-static field with the given name of the current class hierarchy. */ field(name: string): Il2Cpp.BoundField; /** Gets the non-static method with the given name (and optionally parameter count) of the current class hierarchy. */ method(name: string, parameterCount?: number): Il2Cpp.BoundMethod; /** Gets the non-static field with the given name of the current class hierarchy, if it exists. */ tryField(name: string): Il2Cpp.BoundField | undefined; /** Gets the non-static method with the given name (and optionally parameter count) of the current class hierarchy, if it exists. */ tryMethod(name: string, parameterCount?: number): Il2Cpp.BoundMethod | undefined; /** */ toString(): string; } }