MCPcopy Create free account
hub / github.com/axhlzy/Il2CppHookScripts / arrayToValueType

Function arrayToValueType

Il2cppHook/_Ufunc.js:12898–12980  ·  view source on GitHub ↗
(type, nativeValues)

Source from the content-addressed store, hash-verified

12896 : value);
12897}
12898function arrayToValueType(type, nativeValues) {
12899 function iter(type, startOffset = 0) {
12900 const arr = [];
12901 for (const field of type.class.fields) {
12902 if (!field.isStatic) {
12903 const offset = startOffset + field.offset - Il2Cpp.Runtime.objectHeaderSize;
12904 if (field.type.typeEnum == 17 /* ValueType */ ||
12905 (field.type.typeEnum == 21 /* GenericInstance */ && field.type.class.isValueType)) {
12906 arr.push(...iter(field.type, offset));
12907 }
12908 else {
12909 arr.push([field.type.typeEnum, offset]);
12910 }
12911 }
12912 }
12913 if (arr.length == 0) {
12914 arr.push([5 /* U1 */, 0]);
12915 }
12916 return arr;
12917 }
12918 const valueType = Memory.alloc(type.class.valueSize);
12919 nativeValues = nativeValues.flat(Infinity);
12920 const typesAndOffsets = iter(type);
12921 for (let i = 0; i < nativeValues.length; i++) {
12922 const value = nativeValues[i];
12923 const [typeEnum, offset] = typesAndOffsets[i];
12924 const pointer = valueType.add(offset);
12925 switch (typeEnum) {
12926 case 2 /* Boolean */:
12927 pointer.writeS8(value);
12928 break;
12929 case 4 /* I1 */:
12930 pointer.writeS8(value);
12931 break;
12932 case 5 /* U1 */:
12933 pointer.writeU8(value);
12934 break;
12935 case 6 /* I2 */:
12936 pointer.writeS16(value);
12937 break;
12938 case 7 /* U2 */:
12939 pointer.writeU16(value);
12940 break;
12941 case 8 /* I4 */:
12942 pointer.writeS32(value);
12943 break;
12944 case 9 /* U4 */:
12945 pointer.writeU32(value);
12946 break;
12947 case 3 /* Char */:
12948 pointer.writeU16(value);
12949 break;
12950 case 10 /* I8 */:
12951 pointer.writeS64(value);
12952 break;
12953 case 11 /* U8 */:
12954 pointer.writeU64(value);
12955 break;

Callers 1

fromFridaValueFunction · 0.85

Calls 2

iterFunction · 0.85
allocMethod · 0.45

Tested by

no test coverage detected