frida-il2cpp-bridge-my
Version:
(my:Support IOS)Frida module to dump, manipulate and hijack any IL2CPP application at runtime with a high level of abstraction.
67 lines (66 loc) • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createNC = exports.createNF = void 0;
function getTypeAliasForFrida(type) {
switch (type) {
case "ansistring":
case "utf8string":
case "utf16string":
case "cstring":
return "pointer";
default:
return type;
}
}
function refinedToRaw(value, type) {
switch (typeof value) {
case "boolean":
return +value;
case "string": {
switch (type) {
case "utf8string":
return Memory.allocUtf8String(value);
case "utf16string":
return Memory.allocUtf16String(value);
case "ansistring":
return Memory.allocAnsiString(value);
}
break;
}
}
return value;
}
function rawToRefined(value, type) {
switch (typeof value) {
case "number":
if (type == "bool")
return !!value;
break;
case "object": {
if (value instanceof NativePointer) {
switch (type) {
case "utf8string":
return value.readUtf8String();
case "utf16string":
return value.readUtf16String();
case "ansistring":
return value.readAnsiString();
case "cstring":
return value.readCString();
}
}
break;
}
}
return value;
}
function createNF(address, retType, argTypes, options) {
const fn = new NativeFunction(address, getTypeAliasForFrida(retType), argTypes.map(getTypeAliasForFrida), options);
return (...args) => rawToRefined(fn(...args.map((v, i) => refinedToRaw(v, argTypes[i]))), retType);
}
exports.createNF = createNF;
function createNC(callback, retType, argTypes, abi) {
const cb = (...params) => refinedToRaw(callback(...params.map((v, i) => rawToRefined(v, argTypes[i]))), retType);
return new NativeCallback(cb, getTypeAliasForFrida(retType), argTypes.map(getTypeAliasForFrida), abi);
}
exports.createNC = createNC;