MCPcopy Create free account
hub / github.com/GrowthEase/GameSentry / arrayToValueType

Function arrayToValueType

lib/component/agent/utils.js:216–319  ·  view source on GitHub ↗
(type, nativeValues)

Source from the content-addressed store, hash-verified

214}
215
216function arrayToValueType(type, nativeValues) {
217 function iter(type, startOffset = 0) {
218 const arr = [];
219 for (const field of type.class.fields) {
220 if (!field.isStatic) {
221 const offset = startOffset + field.offset - Il2Cpp.Runtime.objectHeaderSize;
222 if (field.type.typeEnum == 17 /* ValueType */ ||
223 (field.type.typeEnum == 21 /* GenericInstance */ && field.type.class.isValueType)) {
224 arr.push(...iter(field.type, offset));
225 } else {
226 arr.push([field.type.typeEnum, offset]);
227 }
228 }
229 }
230 if (arr.length == 0) {
231 arr.push([5 /* U1 */, 0]);
232 }
233 return arr;
234 }
235
236 const valueType = Memory.alloc(type.class.valueSize);
237 nativeValues = nativeValues.flat(Infinity);
238 const typesAndOffsets = iter(type);
239 for (let i = 0; i < nativeValues.length; i++) {
240 const value = nativeValues[i];
241 const [typeEnum, offset] = typesAndOffsets[i];
242 const pointer = valueType.add(offset);
243 switch (typeEnum) {
244 case 2 /* Boolean */
245 :
246 pointer.writeS8(value);
247 break;
248 case 4 /* I1 */
249 :
250 pointer.writeS8(value);
251 break;
252 case 5 /* U1 */
253 :
254 pointer.writeU8(value);
255 break;
256 case 6 /* I2 */
257 :
258 pointer.writeS16(value);
259 break;
260 case 7 /* U2 */
261 :
262 pointer.writeU16(value);
263 break;
264 case 8 /* I4 */
265 :
266 pointer.writeS32(value);
267 break;
268 case 9 /* U4 */
269 :
270 pointer.writeU32(value);
271 break;
272 case 3 /* Char */
273 :

Callers 1

fromFridaValueFunction · 0.85

Calls 2

iterFunction · 0.85
allocMethod · 0.45

Tested by

no test coverage detected