@efffrida/il2cpp-bridge 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Extensions.d.ts +85 -0
- package/dist/Extensions.d.ts.map +1 -0
- package/dist/Extensions.js +177 -0
- package/dist/Extensions.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Extensions.ts +239 -0
- package/src/index.ts +6 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
* @category Extensions
|
|
4
|
+
*/
|
|
5
|
+
import "frida-il2cpp-bridge";
|
|
6
|
+
/**
|
|
7
|
+
* @since 1.0.0
|
|
8
|
+
* @category Extensions
|
|
9
|
+
*/
|
|
10
|
+
export declare class Dictionary<K extends Il2Cpp.Field.Type = Il2Cpp.Field.Type, V extends Il2Cpp.Field.Type = Il2Cpp.Field.Type> extends Il2Cpp.Object {
|
|
11
|
+
/** Gets the pairs count of the current dictionary. */
|
|
12
|
+
get length(): number;
|
|
13
|
+
/** Gets all keys of the current dictionary. */
|
|
14
|
+
get keys(): Array<K>;
|
|
15
|
+
/** Gets all values of the current dictionary. */
|
|
16
|
+
get values(): Array<V>;
|
|
17
|
+
/** Gets all pairs of the current dictionary. */
|
|
18
|
+
get entries(): Array<[K, V]>;
|
|
19
|
+
/** Gets the value by the specified key of the current dictionary. */
|
|
20
|
+
get(key: K): V;
|
|
21
|
+
/** Sets the pair of the current dictionary. */
|
|
22
|
+
set(key: K, value: V): void;
|
|
23
|
+
/** Adds a new key to the current dictionary. */
|
|
24
|
+
add(key: K, value: V): void;
|
|
25
|
+
/** Clears the current dictionary. */
|
|
26
|
+
clear(): void;
|
|
27
|
+
/** Determines if the key is in the current dictionary. */
|
|
28
|
+
containsKey(key: K): boolean;
|
|
29
|
+
/** Determines if the value is in the current dictionary. */
|
|
30
|
+
containsValue(value: V): boolean;
|
|
31
|
+
/** Finds a key in the current dictionary and returns its index. */
|
|
32
|
+
find(key: K): number;
|
|
33
|
+
/** Removes the given key from the current dictionary. */
|
|
34
|
+
remove(key: K): boolean;
|
|
35
|
+
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
36
|
+
toString(): string;
|
|
37
|
+
toRecord(keys?: Array<K> | undefined): Record<string, V>;
|
|
38
|
+
/** The Dictionary class. */
|
|
39
|
+
static get class(): Il2Cpp.Class;
|
|
40
|
+
/** Lifts an Il2Cpp.Object to a Dictionary. */
|
|
41
|
+
static lift<K extends Il2Cpp.Field.Type = Il2Cpp.Field.Type, V extends Il2Cpp.Field.Type = Il2Cpp.Field.Type>(object: Il2Cpp.Object): Dictionary<K, V>;
|
|
42
|
+
/** Creates a new dictionary with the given elements. */
|
|
43
|
+
static of<K extends Il2Cpp.Field.Type = Il2Cpp.Field.Type, V extends Il2Cpp.Field.Type = Il2Cpp.Field.Type>(keyClass: Il2Cpp.Class, valueClass: Il2Cpp.Class, elements?: Map<K, V> | undefined): Dictionary<K, V>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @since 1.0.0
|
|
47
|
+
* @category Extensions
|
|
48
|
+
*/
|
|
49
|
+
export declare class List<T extends Il2Cpp.Field.Type = Il2Cpp.Field.Type> extends Il2Cpp.Object {
|
|
50
|
+
get capacity(): number;
|
|
51
|
+
set capacity(value: number);
|
|
52
|
+
/** Gets the element count of the current list. */
|
|
53
|
+
get length(): number;
|
|
54
|
+
/** Gets the value by the specified index of the current list. */
|
|
55
|
+
get(index: number): T;
|
|
56
|
+
/** Sets the element of the current list. */
|
|
57
|
+
set(index: number, value: T): void;
|
|
58
|
+
/** Adds a new element to the current list. */
|
|
59
|
+
add(item: T): void;
|
|
60
|
+
/** Clears the current list. */
|
|
61
|
+
clear(): void;
|
|
62
|
+
/** Determines if the key is in the current list. */
|
|
63
|
+
contains(item: T): boolean;
|
|
64
|
+
/** Determines the index of the element of the current list. */
|
|
65
|
+
indexOf(item: T): number;
|
|
66
|
+
/** Inserts an element at the given index of the current list. */
|
|
67
|
+
insert(index: number, item: T): void;
|
|
68
|
+
/** Removes a data element from the current list. */
|
|
69
|
+
remove(item: T): boolean;
|
|
70
|
+
/** Reverses the current list. */
|
|
71
|
+
reverse(): void;
|
|
72
|
+
/** Sorts the current list. */
|
|
73
|
+
sort(): void;
|
|
74
|
+
/** Converts the current list to an array. */
|
|
75
|
+
get toArray(): Il2Cpp.Array<T>;
|
|
76
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
77
|
+
toString(): string;
|
|
78
|
+
/** The List class. */
|
|
79
|
+
static get class(): Il2Cpp.Class;
|
|
80
|
+
/** Lifts an Il2Cpp.Array to a List. */
|
|
81
|
+
static lift<T extends Il2Cpp.Field.Type = Il2Cpp.Field.Type>(object: Il2Cpp.Object): List<T>;
|
|
82
|
+
/** Creates a new list with the given elements. */
|
|
83
|
+
static of<T extends Il2Cpp.Field.Type = Il2Cpp.Field.Type>(klass: Il2Cpp.Class, elements?: Array<T> | undefined): List<T>;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=Extensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Extensions.d.ts","sourceRoot":"","sources":["../src/Extensions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,qBAAqB,CAAC;AAI7B;;;GAGG;AACH,qBAAa,UAAU,CACnB,CAAC,SAAS,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAC/C,CAAC,SAAS,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAE/C,SAAQ,MAAM,CAAC,MAAM;IAErB,sDAAsD;IACtD,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,+CAA+C;IAC/C,IAAW,IAAI,IAAI,KA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IAAI,EAAE,CAAC,GAAG,OAAO;IAI/B,iCAAiC;IAC1B,OAAO,IAAI,IAAI;IAItB,8BAA8B;IACvB,IAAI,IAAI,IAAI;IAInB,6CAA6C;IAC7C,IAAW,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAEpC;IAEO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC;IAMhC,QAAQ,IAAI,MAAM;IAIlC,sBAAsB;IACtB,WAAkB,KAAK,iBAEtB;IAED,uCAAuC;WACzB,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IAInG,kDAAkD;WACpC,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAC5D,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,QAAQ,GAAE,KAAK,CAAC,CAAC,CAAC,GAAG,SAAc,GACpC,IAAI,CAAC,CAAC,CAAC;CAQb"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
* @category Extensions
|
|
4
|
+
*/
|
|
5
|
+
import "frida-il2cpp-bridge";
|
|
6
|
+
import { Array, Option, Record } from "effect";
|
|
7
|
+
/**
|
|
8
|
+
* @since 1.0.0
|
|
9
|
+
* @category Extensions
|
|
10
|
+
*/
|
|
11
|
+
export class Dictionary extends Il2Cpp.Object {
|
|
12
|
+
/** Gets the pairs count of the current dictionary. */
|
|
13
|
+
get length() {
|
|
14
|
+
return this.method("get_Count").invoke();
|
|
15
|
+
}
|
|
16
|
+
/** Gets all keys of the current dictionary. */
|
|
17
|
+
get keys() {
|
|
18
|
+
const keys = Il2Cpp.array(this.class.generics[0], this.length);
|
|
19
|
+
this.method("get_Keys").invoke().method("CopyTo").invoke(keys, 0);
|
|
20
|
+
return Array.fromIterable(keys);
|
|
21
|
+
}
|
|
22
|
+
/** Gets all values of the current dictionary. */
|
|
23
|
+
get values() {
|
|
24
|
+
const values = Il2Cpp.array(this.class.generics[1], this.length);
|
|
25
|
+
this.method("get_Values").invoke().method("CopyTo").invoke(values, 0);
|
|
26
|
+
return Array.fromIterable(values);
|
|
27
|
+
}
|
|
28
|
+
/** Gets all pairs of the current dictionary. */
|
|
29
|
+
get entries() {
|
|
30
|
+
return Array.zip(this.keys, this.values);
|
|
31
|
+
}
|
|
32
|
+
/** Gets the value by the specified key of the current dictionary. */
|
|
33
|
+
get(key) {
|
|
34
|
+
return this.method("get_Item").invoke(key);
|
|
35
|
+
}
|
|
36
|
+
/** Sets the pair of the current dictionary. */
|
|
37
|
+
set(key, value) {
|
|
38
|
+
this.method("set_Item").invoke(key, value);
|
|
39
|
+
}
|
|
40
|
+
/** Adds a new key to the current dictionary. */
|
|
41
|
+
add(key, value) {
|
|
42
|
+
this.method("Add").invoke(key, value);
|
|
43
|
+
}
|
|
44
|
+
/** Clears the current dictionary. */
|
|
45
|
+
clear() {
|
|
46
|
+
this.method("Clear").invoke();
|
|
47
|
+
}
|
|
48
|
+
/** Determines if the key is in the current dictionary. */
|
|
49
|
+
containsKey(key) {
|
|
50
|
+
return this.method("ContainsKey").invoke(key);
|
|
51
|
+
}
|
|
52
|
+
/** Determines if the value is in the current dictionary. */
|
|
53
|
+
containsValue(value) {
|
|
54
|
+
return this.method("ContainsValue").invoke(value);
|
|
55
|
+
}
|
|
56
|
+
/** Finds a key in the current dictionary and returns its index. */
|
|
57
|
+
find(key) {
|
|
58
|
+
return this.method("FindEntry").invoke(key);
|
|
59
|
+
}
|
|
60
|
+
/** Removes the given key from the current dictionary. */
|
|
61
|
+
remove(key) {
|
|
62
|
+
return this.method("Remove").invoke(key);
|
|
63
|
+
}
|
|
64
|
+
*[Symbol.iterator]() {
|
|
65
|
+
const entries = this.entries;
|
|
66
|
+
for (let i = 0; i < this.length; i++) {
|
|
67
|
+
yield entries[i];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
toString() {
|
|
71
|
+
return this.isNull() ? "null" : `{${[...this.entries].map(([k, v]) => `${k}: ${v}`).join(", ")}}`;
|
|
72
|
+
}
|
|
73
|
+
toRecord(keys) {
|
|
74
|
+
return Record.fromEntries(Array.filterMap(keys ?? this.keys, key => Option.product(key instanceof Il2Cpp.String ? Option.fromNullable(key.content) : Option.some(key.toString()), this.containsKey(key) ? Option.some(this.get(key)) : Option.none())));
|
|
75
|
+
}
|
|
76
|
+
/** The Dictionary class. */
|
|
77
|
+
static get class() {
|
|
78
|
+
return Il2Cpp.corlib.class("System.Collections.Generic.Dictionary`2");
|
|
79
|
+
}
|
|
80
|
+
/** Lifts an Il2Cpp.Object to a Dictionary. */
|
|
81
|
+
static lift(object) {
|
|
82
|
+
return new Dictionary(object.handle);
|
|
83
|
+
}
|
|
84
|
+
/** Creates a new dictionary with the given elements. */
|
|
85
|
+
static of(keyClass, valueClass, elements) {
|
|
86
|
+
const dictionary = new Dictionary(Dictionary.class.inflate(keyClass, valueClass).alloc());
|
|
87
|
+
for (const [key, value] of elements ?? []) {
|
|
88
|
+
dictionary.set(key, value);
|
|
89
|
+
}
|
|
90
|
+
return dictionary;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @since 1.0.0
|
|
95
|
+
* @category Extensions
|
|
96
|
+
*/
|
|
97
|
+
export class List extends Il2Cpp.Object {
|
|
98
|
+
get capacity() {
|
|
99
|
+
return this.method("get_Capacity").invoke();
|
|
100
|
+
}
|
|
101
|
+
set capacity(value) {
|
|
102
|
+
this.method("set_Capacity").invoke(value);
|
|
103
|
+
}
|
|
104
|
+
/** Gets the element count of the current list. */
|
|
105
|
+
get length() {
|
|
106
|
+
return this.method("get_Count").invoke();
|
|
107
|
+
}
|
|
108
|
+
/** Gets the value by the specified index of the current list. */
|
|
109
|
+
get(index) {
|
|
110
|
+
return this.method("get_Item").invoke(index);
|
|
111
|
+
}
|
|
112
|
+
/** Sets the element of the current list. */
|
|
113
|
+
set(index, value) {
|
|
114
|
+
this.method("set_Item").invoke(index, value);
|
|
115
|
+
}
|
|
116
|
+
/** Adds a new element to the current list. */
|
|
117
|
+
add(item) {
|
|
118
|
+
this.method("Add").invoke(item);
|
|
119
|
+
}
|
|
120
|
+
/** Clears the current list. */
|
|
121
|
+
clear() {
|
|
122
|
+
this.method("Clear").invoke();
|
|
123
|
+
}
|
|
124
|
+
/** Determines if the key is in the current list. */
|
|
125
|
+
contains(item) {
|
|
126
|
+
return this.method("Contains").invoke(item);
|
|
127
|
+
}
|
|
128
|
+
/** Determines the index of the element of the current list. */
|
|
129
|
+
indexOf(item) {
|
|
130
|
+
return this.method("IndexOf").invoke(item);
|
|
131
|
+
}
|
|
132
|
+
/** Inserts an element at the given index of the current list. */
|
|
133
|
+
insert(index, item) {
|
|
134
|
+
this.method("Insert").invoke(index, item);
|
|
135
|
+
}
|
|
136
|
+
/** Removes a data element from the current list. */
|
|
137
|
+
remove(item) {
|
|
138
|
+
return this.method("Remove").invoke(item);
|
|
139
|
+
}
|
|
140
|
+
/** Reverses the current list. */
|
|
141
|
+
reverse() {
|
|
142
|
+
this.method("Reverse").invoke();
|
|
143
|
+
}
|
|
144
|
+
/** Sorts the current list. */
|
|
145
|
+
sort() {
|
|
146
|
+
this.method("Sort").invoke();
|
|
147
|
+
}
|
|
148
|
+
/** Converts the current list to an array. */
|
|
149
|
+
get toArray() {
|
|
150
|
+
return this.method("ToArray").invoke();
|
|
151
|
+
}
|
|
152
|
+
*[Symbol.iterator]() {
|
|
153
|
+
for (let i = 0; i < this.length; i++) {
|
|
154
|
+
yield this.get(i);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
toString() {
|
|
158
|
+
return this.toArray.toString();
|
|
159
|
+
}
|
|
160
|
+
/** The List class. */
|
|
161
|
+
static get class() {
|
|
162
|
+
return Il2Cpp.corlib.class("System.Collections.Generic.List`1");
|
|
163
|
+
}
|
|
164
|
+
/** Lifts an Il2Cpp.Array to a List. */
|
|
165
|
+
static lift(object) {
|
|
166
|
+
return new List(object.handle);
|
|
167
|
+
}
|
|
168
|
+
/** Creates a new list with the given elements. */
|
|
169
|
+
static of(klass, elements = []) {
|
|
170
|
+
const list = new List(List.class.inflate(klass).alloc());
|
|
171
|
+
for (const element of elements) {
|
|
172
|
+
list.add(element);
|
|
173
|
+
}
|
|
174
|
+
return list;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=Extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Extensions.js","names":["Array","Option","Record","Dictionary","Il2Cpp","Object","length","method","invoke","keys","array","class","generics","fromIterable","values","entries","zip","get","key","set","value","add","clear","containsKey","containsValue","find","remove","Symbol","iterator","i","toString","isNull","map","k","v","join","toRecord","fromEntries","filterMap","product","String","fromNullable","content","some","none","corlib","lift","object","handle","of","keyClass","valueClass","elements","dictionary","inflate","alloc","List","capacity","index","item","contains","indexOf","insert","reverse","sort","toArray","klass","list","element"],"sources":["../src/Extensions.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;AAKA,OAAO,qBAAqB;AAE5B,SAASA,KAAK,EAAEC,MAAM,EAAEC,MAAM,QAAQ,QAAQ;AAE9C;;;;AAIA,OAAM,MAAOC,UAIT,SAAQC,MAAM,CAACC,MAAM;EAErB;EACA,IAAWC,MAAMA,CAAA;IACb,OAAO,IAAI,CAACC,MAAM,CAAS,WAAW,CAAC,CAACC,MAAM,EAAE;EACpD;EAEA;EACA,IAAWC,IAAIA,CAAA;IACX,MAAMA,IAAI,GAAGL,MAAM,CAACM,KAAK,CAAI,IAAI,CAACC,KAAK,CAACC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAACN,MAAM,CAAC;IACjE,IAAI,CAACC,MAAM,CAAgB,UAAU,CAA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AACvB,MAAM,EAAEuB,CAAC,EAAE,EAAE;MAClC,MAAM,IAAI,CAACZ,GAAG,CAACY,CAAC,CAAC;IACrB;EACJ;EAEgBC,QAAQA,CAAA;IACpB,OAAO,IAAI,CAACmC,OAAO,CAACnC,QAAQ,EAAE;EAClC;EAEA;EACO,WAAWnB,KAAKA,CAAA;IACnB,OAAOP,MAAM,CAACyC,MAAM,CAAClC,KAAK,CAAC,mCAAmC,CAAC;EACnE;EAEA;EACO,OAAOmC,IAAIA,CAAkDC,MAAqB;IACrF,OAAO,IAAIS,IAAI,CAAIT,MAAM,CAACC,MAAM,CAAC;EACrC;EAEA;EACO,OAAOC,EAAEA,CACZiB,KAAmB,EACnBd,QAAA,GAAiC,EAAE;IAEnC,MAAMe,IAAI,GAAG,IAAIX,IAAI,CAAIA,IAAI,CAAC7C,KAAK,CAAC2C,OAAO,CAACY,KAAK,CAAC,CAACX,KAAK,EAAE,CAAC;IAC3D,KAAK,MAAMa,OAAO,IAAIhB,QAAQ,EAAE;MAC5Be,IAAI,CAAC9C,GAAG,CAAC+C,OAAO,CAAC;IACrB;IAEA,OAAOD,IAAI;EACf","ignoreList":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,11 @@ export * as Class from "./Class.ts";
|
|
|
16
16
|
* @category Equivalence
|
|
17
17
|
*/
|
|
18
18
|
export * as Equivalence from "./Equivalence.ts";
|
|
19
|
+
/**
|
|
20
|
+
* @since 1.0.0
|
|
21
|
+
* @category Extensions
|
|
22
|
+
*/
|
|
23
|
+
export * as Extensions from "./Extensions.ts";
|
|
19
24
|
/**
|
|
20
25
|
* @since 1.0.0
|
|
21
26
|
* @category FridaIl2cppBridge
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;GAGG;AACH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC;;;GAGG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAE/C;;;GAGG;AACH,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;GAGG;AACH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC;;;GAGG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAE/C;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,11 @@ export * as Class from "./Class.js";
|
|
|
16
16
|
* @category Equivalence
|
|
17
17
|
*/
|
|
18
18
|
export * as Equivalence from "./Equivalence.js";
|
|
19
|
+
/**
|
|
20
|
+
* @since 1.0.0
|
|
21
|
+
* @category Extensions
|
|
22
|
+
*/
|
|
23
|
+
export * as Extensions from "./Extensions.js";
|
|
19
24
|
/**
|
|
20
25
|
* @since 1.0.0
|
|
21
26
|
* @category FridaIl2cppBridge
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Assembly","Class","Equivalence","FridaIl2cppBridge"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;;;;AAIA,OAAO,KAAKA,QAAQ,MAAM,eAAe;AAEzC;;;;AAIA,OAAO,KAAKC,KAAK,MAAM,YAAY;AAEnC;;;;AAIA,OAAO,KAAKC,WAAW,MAAM,kBAAkB;AAE/C;;;;AAIA,OAAO,KAAKC,iBAAiB,MAAM,wBAAwB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Assembly","Class","Equivalence","Extensions","FridaIl2cppBridge"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;;;;AAIA,OAAO,KAAKA,QAAQ,MAAM,eAAe;AAEzC;;;;AAIA,OAAO,KAAKC,KAAK,MAAM,YAAY;AAEnC;;;;AAIA,OAAO,KAAKC,WAAW,MAAM,kBAAkB;AAE/C;;;;AAIA,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C;;;;AAIA,OAAO,KAAKC,iBAAiB,MAAM,wBAAwB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@efffrida/il2cpp-bridge",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "effect-ts frida-il2cpp-bridge",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"frida.re",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"effect": "3.19.13",
|
|
41
41
|
"vitest": "4.0.16",
|
|
42
42
|
"@efffrida/polyfills": "0.0.2",
|
|
43
|
-
"@efffrida/vitest-pool": "0.0.
|
|
43
|
+
"@efffrida/vitest-pool": "0.0.8"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"effect": "3.19.13"
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
* @category Extensions
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import "frida-il2cpp-bridge";
|
|
7
|
+
|
|
8
|
+
import { Array, Option, Record } from "effect";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
* @category Extensions
|
|
13
|
+
*/
|
|
14
|
+
export class Dictionary<
|
|
15
|
+
K extends Il2Cpp.Field.Type = Il2Cpp.Field.Type,
|
|
16
|
+
V extends Il2Cpp.Field.Type = Il2Cpp.Field.Type,
|
|
17
|
+
>
|
|
18
|
+
extends Il2Cpp.Object
|
|
19
|
+
{
|
|
20
|
+
/** Gets the pairs count of the current dictionary. */
|
|
21
|
+
public get length(): number {
|
|
22
|
+
return this.method<number>("get_Count").invoke();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Gets all keys of the current dictionary. */
|
|
26
|
+
public get keys(): Array<K> {
|
|
27
|
+
const keys = Il2Cpp.array<K>(this.class.generics[0], this.length);
|
|
28
|
+
this.method<Il2Cpp.Object>("get_Keys").invoke().method("CopyTo").invoke(keys, 0);
|
|
29
|
+
return Array.fromIterable(keys);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Gets all values of the current dictionary. */
|
|
33
|
+
public get values(): Array<V> {
|
|
34
|
+
const values = Il2Cpp.array<V>(this.class.generics[1], this.length);
|
|
35
|
+
this.method<Il2Cpp.Object>("get_Values").invoke().method("CopyTo").invoke(values, 0);
|
|
36
|
+
return Array.fromIterable(values);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Gets all pairs of the current dictionary. */
|
|
40
|
+
public get entries(): Array<[K, V]> {
|
|
41
|
+
return Array.zip(this.keys, this.values);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Gets the value by the specified key of the current dictionary. */
|
|
45
|
+
public get(key: K): V {
|
|
46
|
+
return this.method<V>("get_Item").invoke(key);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Sets the pair of the current dictionary. */
|
|
50
|
+
public set(key: K, value: V): void {
|
|
51
|
+
this.method<void>("set_Item").invoke(key, value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Adds a new key to the current dictionary. */
|
|
55
|
+
public add(key: K, value: V): void {
|
|
56
|
+
this.method<void>("Add").invoke(key, value);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Clears the current dictionary. */
|
|
60
|
+
public clear(): void {
|
|
61
|
+
this.method<void>("Clear").invoke();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Determines if the key is in the current dictionary. */
|
|
65
|
+
public containsKey(key: K): boolean {
|
|
66
|
+
return this.method<boolean>("ContainsKey").invoke(key);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Determines if the value is in the current dictionary. */
|
|
70
|
+
public containsValue(value: V): boolean {
|
|
71
|
+
return this.method<boolean>("ContainsValue").invoke(value);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Finds a key in the current dictionary and returns its index. */
|
|
75
|
+
public find(key: K): number {
|
|
76
|
+
return this.method<number>("FindEntry").invoke(key);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Removes the given key from the current dictionary. */
|
|
80
|
+
public remove(key: K): boolean {
|
|
81
|
+
return this.method<boolean>("Remove").invoke(key);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public *[Symbol.iterator](): IterableIterator<[K, V]> {
|
|
85
|
+
const entries = this.entries;
|
|
86
|
+
for (let i = 0; i < this.length; i++) {
|
|
87
|
+
yield entries[i];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public override toString(): string {
|
|
92
|
+
return this.isNull() ? "null" : `{${[...this.entries].map(([k, v]) => `${k}: ${v}`).join(", ")}}`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public toRecord(keys?: Array<K> | undefined): Record<string, V> {
|
|
96
|
+
return Record.fromEntries(
|
|
97
|
+
Array.filterMap(keys ?? this.keys, (key) =>
|
|
98
|
+
Option.product(
|
|
99
|
+
key instanceof Il2Cpp.String ? Option.fromNullable(key.content) : Option.some(key.toString()),
|
|
100
|
+
this.containsKey(key) ? Option.some(this.get(key)) : Option.none()
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The Dictionary class. */
|
|
107
|
+
public static get class() {
|
|
108
|
+
return Il2Cpp.corlib.class("System.Collections.Generic.Dictionary`2");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Lifts an Il2Cpp.Object to a Dictionary. */
|
|
112
|
+
public static lift<
|
|
113
|
+
K extends Il2Cpp.Field.Type = Il2Cpp.Field.Type,
|
|
114
|
+
V extends Il2Cpp.Field.Type = Il2Cpp.Field.Type,
|
|
115
|
+
>(object: Il2Cpp.Object): Dictionary<K, V> {
|
|
116
|
+
return new Dictionary<K, V>(object.handle);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Creates a new dictionary with the given elements. */
|
|
120
|
+
public static of<K extends Il2Cpp.Field.Type = Il2Cpp.Field.Type, V extends Il2Cpp.Field.Type = Il2Cpp.Field.Type>(
|
|
121
|
+
keyClass: Il2Cpp.Class,
|
|
122
|
+
valueClass: Il2Cpp.Class,
|
|
123
|
+
elements?: Map<K, V> | undefined
|
|
124
|
+
): Dictionary<K, V> {
|
|
125
|
+
const dictionary = new Dictionary<K, V>(Dictionary.class.inflate(keyClass, valueClass).alloc());
|
|
126
|
+
for (const [key, value] of elements ?? []) {
|
|
127
|
+
dictionary.set(key, value);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return dictionary;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @since 1.0.0
|
|
136
|
+
* @category Extensions
|
|
137
|
+
*/
|
|
138
|
+
export class List<T extends Il2Cpp.Field.Type = Il2Cpp.Field.Type> extends Il2Cpp.Object {
|
|
139
|
+
public get capacity(): number {
|
|
140
|
+
return this.method<number>("get_Capacity").invoke();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public set capacity(value: number) {
|
|
144
|
+
this.method("set_Capacity").invoke(value);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Gets the element count of the current list. */
|
|
148
|
+
public get length(): number {
|
|
149
|
+
return this.method<number>("get_Count").invoke();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Gets the value by the specified index of the current list. */
|
|
153
|
+
public get(index: number): T {
|
|
154
|
+
return this.method<T>("get_Item").invoke(index);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Sets the element of the current list. */
|
|
158
|
+
public set(index: number, value: T): void {
|
|
159
|
+
this.method("set_Item").invoke(index, value);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Adds a new element to the current list. */
|
|
163
|
+
public add(item: T): void {
|
|
164
|
+
this.method("Add").invoke(item);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Clears the current list. */
|
|
168
|
+
public clear(): void {
|
|
169
|
+
this.method("Clear").invoke();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Determines if the key is in the current list. */
|
|
173
|
+
public contains(item: T): boolean {
|
|
174
|
+
return this.method<boolean>("Contains").invoke(item);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Determines the index of the element of the current list. */
|
|
178
|
+
public indexOf(item: T): number {
|
|
179
|
+
return this.method<number>("IndexOf").invoke(item);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Inserts an element at the given index of the current list. */
|
|
183
|
+
public insert(index: number, item: T): void {
|
|
184
|
+
this.method("Insert").invoke(index, item);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Removes a data element from the current list. */
|
|
188
|
+
public remove(item: T): boolean {
|
|
189
|
+
return this.method<boolean>("Remove").invoke(item);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Reverses the current list. */
|
|
193
|
+
public reverse(): void {
|
|
194
|
+
this.method("Reverse").invoke();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Sorts the current list. */
|
|
198
|
+
public sort(): void {
|
|
199
|
+
this.method("Sort").invoke();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Converts the current list to an array. */
|
|
203
|
+
public get toArray(): Il2Cpp.Array<T> {
|
|
204
|
+
return this.method<Il2Cpp.Array<T>>("ToArray").invoke();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
public *[Symbol.iterator](): IterableIterator<T> {
|
|
208
|
+
for (let i = 0; i < this.length; i++) {
|
|
209
|
+
yield this.get(i);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
public override toString(): string {
|
|
214
|
+
return this.toArray.toString();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** The List class. */
|
|
218
|
+
public static get class() {
|
|
219
|
+
return Il2Cpp.corlib.class("System.Collections.Generic.List`1");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Lifts an Il2Cpp.Array to a List. */
|
|
223
|
+
public static lift<T extends Il2Cpp.Field.Type = Il2Cpp.Field.Type>(object: Il2Cpp.Object): List<T> {
|
|
224
|
+
return new List<T>(object.handle);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Creates a new list with the given elements. */
|
|
228
|
+
public static of<T extends Il2Cpp.Field.Type = Il2Cpp.Field.Type>(
|
|
229
|
+
klass: Il2Cpp.Class,
|
|
230
|
+
elements: Array<T> | undefined = []
|
|
231
|
+
): List<T> {
|
|
232
|
+
const list = new List<T>(List.class.inflate(klass).alloc());
|
|
233
|
+
for (const element of elements) {
|
|
234
|
+
list.add(element);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return list;
|
|
238
|
+
}
|
|
239
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -20,6 +20,12 @@ export * as Class from "./Class.ts"
|
|
|
20
20
|
*/
|
|
21
21
|
export * as Equivalence from "./Equivalence.ts"
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @since 1.0.0
|
|
25
|
+
* @category Extensions
|
|
26
|
+
*/
|
|
27
|
+
export * as Extensions from "./Extensions.ts"
|
|
28
|
+
|
|
23
29
|
/**
|
|
24
30
|
* @since 1.0.0
|
|
25
31
|
* @category FridaIl2cppBridge
|