daima
daima
e[i]){var
c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!
0);var a=new Error("Cannot find module '"+i+"'");throw
a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i]
[0].call(p.exports,function(r){var n=e[i][1][r];return o(n||
r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof
require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:
[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ZipUtils = void 0;
exports.ZipUtils = {
test: function () {
this.zipFolder("/data/data/com.tencent.ro/files/Script",
"/data/data/com.tencent.ro/files/Script.zip");
},
zipFolder: function (folderPath, outputPath, callback) {
return Java.perform(function () {
var Thread = Java.use('java.lang.Thread');
var Runnable = Java.registerClass({
// 实现 Runnable 接口
name: 'com.example.ZipRunnable',
implements: [Java.use('java.lang.Runnable')],
methods: {
run: function () {
var FileOutputStream =
Java.use('java.io.FileOutputStream');
var ZipOutputStream =
Java.use('java.util.zip.ZipOutputStream');
var ZipEntry = Java.use('java.util.zip.ZipEntry');
var FileInputStream = Java.use('java.io.FileInputStream');
var File = Java.use('java.io.File');
var totalFiles = 0;
var processedFiles = 0;
var fos = FileOutputStream.$new(outputPath);
var zos = ZipOutputStream.$new(fos);
function countFiles(file) {
if (file.isDirectory()) {
var files = file.listFiles();
for (var i = 0; i < files.length; i++) {
countFiles(files[i]);
}
}
else {
totalFiles++;
}
}
function addFileToZip(file, parentDir) {
if (file.isDirectory()) {
var files = file.listFiles();
for (var i = 0; i < files.length; i++) {
addFileToZip(files[i], parentDir +
file.getName() + "/");
}
}
else {
var entryName = parentDir + file.getName();
var entry = ZipEntry.$new(entryName);
zos.putNextEntry(entry);
var fis = FileInputStream.
$new(file.getAbsolutePath());
var buffer = Java.array('byte',
Array(1024).fill(0));
var length;
while ((length = fis.read(buffer)) != -1) {
zos.write(buffer, 0, length);
}
fis.close();
zos.closeEntry();
processedFiles++;
console.log("Doing Cpp2IL files Zip one Folder
Progress: " + (processedFiles / totalFiles * 100).toFixed(2) + "%");
}
}
var folder = File.$new(folderPath);
if (!folder.isDirectory()) {
throw new Error('Provided path is not a directory');
}
countFiles(folder);
addFileToZip(folder, "");
zos.close();
fos.close();
// 如果没有错误发生,调用回调函数并指示成功
Java.scheduleOnMainThread(function () {
callback(true);
});
}
}
});
var thread = Thread.$new(Runnable.$new());
thread.start();
});
}
};
},{}],2:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SoName = void 0;
exports.SoName = "libil2cpp.so";
},{}],3:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSoInfo = exports.CSFileDir = exports.ZipOutCSFile = exports.OutCSFile =
exports.DUMP_FILE_PATH = exports.path = exports.soName = exports.IOSDumpName =
exports.UNITY_VER = exports.UnityVer = exports.pkg_name = void 0;
exports.pkg_name = "com.linekong.zmgg";
exports.UnityVer = {
V_2017_4_31f1: "2017.4.31f1",
V_2018_4_36f1: "2018.4.36f1",
V_2020: "2020",
};
exports.UNITY_VER = exports.UnityVer.V_2018_4_36f1;
exports.IOSDumpName = "UnityFramework";
exports.soName = "libil2cpp.so";
exports.path = "/data/data/" + exports.pkg_name;
exports.DUMP_FILE_PATH = exports.path + "/dump.cs";
exports.OutCSFile = true;
exports.ZipOutCSFile = true;
exports.CSFileDir = "/data/data/" + exports.pkg_name + "/files/Script";
exports.useSoInfo = false;
},{}],4:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dumper = void 0;
const dumpconfig_1 = require("./dumpconfig");
const il2cppApi_1 = require("./il2cpp/il2cppApi");
const logger_1 = require("./logger");
const CSFileOut_1 = require("./il2cpp/CSFileOut");
const tabledefs_1 = require("./il2cpp/tabledefs");
const Il2CppTypeEnum_1 = require("./il2cpp/Il2CppTypeEnum");
const utils_1 = require("./il2cpp/struct/utils");
const IOSUtils_1 = require("./ios/IOSUtils");
const ZipUtils_1 = require("./and/ZipUtils");
let classAllCount = 0;
console.log("platform:" + Process.platform);
let file = undefined;
let il2cpp_got = false;
let once = false;
let klassMap = new Map();
exports.dumper = {
waitInject: function () {
(0, logger_1.log)("waitInject");
let open = Module.findExportByName(null, "open");
//fopen 替换
(0, logger_1.log)("等待 Il2cpp:" + open);
if (open != null) {
Interceptor.attach(open, {
onEnter: function (args) {
let path = args[0].readCString();
// log("path:" + path);
if (path.indexOf(dumpconfig_1.soName) !== -1) {
this.hook = true;
}
},
onLeave: function (retval) {
// log("this.hook:" + this.hook);
if (this.hook) {
il2cpp_got = true;
// Interceptor.detachAll();
exports.dumper.start();
}
}
});
}
},
start: function () {
if (Process.platform === "darwin") {
dumpconfig_1.soName = dumpconfig_1.IOSDumpName;
}
let module = Process.findModuleByName(dumpconfig_1.soName);
(0, logger_1.log)("module:" + module);
if (module == null) {
setTimeout(function () {
//执行
exports.dumper.start();
}, 3000);
return;
}
//延迟一下
(0, logger_1.log)("module " + module.path + " addr " + module.base);
setTimeout(function () {
if (once) {
return;
}
once = true;
module = Process.findModuleByName(dumpconfig_1.soName);
let baseAddress = module.base;
(0, logger_1.log)("base address:" + baseAddress);
let domain = il2cppApi_1.il2cppApi.il2cpp_domain_get();
il2cppApi_1.il2cppApi.il2cpp_thread_attach(domain);
let size_t = Memory.alloc(Process.pointerSize);
(0, logger_1.log)("domain:" + domain + " baseAddress:" + baseAddress);
//可能还没加载
let assemblies =
il2cppApi_1.il2cppApi.il2cpp_domain_get_assemblies(domain, size_t);
let assemblies_count = size_t.readInt();
(0, logger_1.log)("assemblies_count:" + assemblies_count + "
pointerSize:" + Process.pointerSize
+ " assemblies:" + assemblies);
if (assemblies_count === 0) {
setTimeout(function () {
this.start();
}, 2000);
return;
}
let il2CppImageArray = new Array();
for (let i = 0; i < assemblies_count; i++) {
let assembly = assemblies.add(Process.pointerSize *
i).readPointer();
let Il2CppImage =
il2cppApi_1.il2cppApi.il2cpp_assembly_get_image(assembly);
let typeStart = Il2CppImage.typeStart();
(0, logger_1.log)("typeStart:" + typeStart + " name:" +
Il2CppImage.nameNoExt() + " typeCount:" + Il2CppImage.typeCount());
let isInterpreterImage = Il2CppImage.IsInterpreterImage();
if (!isInterpreterImage) {
exports.dumper.out(" // Image :" + i + " " +
Il2CppImage.nameNoExt() + " - " + Il2CppImage.typeStart() + "\n");
}
else {
exports.dumper.out(" // Image :" + i + " " +
Il2CppImage.nameNoExt() + " - " + Il2CppImage.typeStart() + "---> HybridCLR Dll\
n");
}
il2CppImageArray.push(Il2CppImage);
}
for (let i = 0; i < il2CppImageArray.length; i++) {
(0, logger_1.log)("process: " + (i + 1) + "/" + assemblies_count);
let Il2CppImage = il2CppImageArray[i];
let nameNoExt = Il2CppImage.nameNoExt();
let start = Il2CppImage.typeStart();
let class_count = Il2CppImage.typeCount();
// log("name:"+nameNoExt +" start:"+start +" count:"+class_count)
// if (nameNoExt === "Assembly-CSharp") {
// // dll
// this.out("\n//assembly Image -->:" + nameNoExt + "
startIndex:" + start + " typeCount:" + class_count);
exports.dumper.findAllClass(Il2CppImage);
// }
}
(0, logger_1.log)("dump end");
(0, logger_1.log)("classAllCount:" + classAllCount);
// log("nativeFunNotExistMap:" + il2cppApi.nativeFunNotExistMap.size);
// if (il2cppApi.nativeFunNotExistMap.size > 0) {
// // log("some NativeFun is un exist ,parser will be not
accurate :");
// il2cppApi.nativeFunNotExistMap.forEach(function (value, key) {
// log(key + "");
// })
// }
if (dumpconfig_1.OutCSFile && Process.platform === "linux") {
let index = 0;
klassMap.forEach(function (value, key) {
(0, logger_1.log)("process cs class " + index + "/" +
klassMap.size);
index++;
CSFileOut_1.CSFileOut.outClass(key, value);
});
(0, logger_1.log)("out CSFile success");
// log("create cs file " + il2CppClass.name());
// CSFileOut.outClass(il2CppClass, csStr);
// csStr="";
}
(0, logger_1.log)("all work is done");
if (Process.platform === "darwin") {
(0, logger_1.log)("this is in IOS platform out path is in " +
IOSUtils_1.IOSUtils.getDocumentDir() + "/dump.cs");
}
else {
if (dumpconfig_1.OutCSFile && Process.platform === "linux") {
if (dumpconfig_1.ZipOutCSFile) {
ZipUtils_1.ZipUtils.zipFolder(dumpconfig_1.CSFileDir,
dumpconfig_1.CSFileDir + ".zip", function (ok) {
if (ok) {
// log("zip success");
(0, logger_1.log)("this is in Android platform out
path is in " + dumpconfig_1.DUMP_FILE_PATH);
(0, logger_1.log)("Cpp2IL Zip Done Path:" +
dumpconfig_1.CSFileDir + ".zip");
}
else {
(0, logger_1.log)("zip error");
}
});
}
else {
(0, logger_1.log)("Cpp2IL Zip Done Path:" +
dumpconfig_1.CSFileDir);
}
}
else {
(0, logger_1.log)("this is in Android platform out path is in
" + dumpconfig_1.DUMP_FILE_PATH);
}
}
}, 15000);
},
findAllClass: function (il2cppImage) {
let class_count = il2cppImage.typeCount();
(0, logger_1.log)("findAllClass " + il2cppImage.name() + " class_count:" +
class_count);
for (let i = 0; i < class_count; i++) {
(0, logger_1.log)("class process:" + (i + 1) + "/" + class_count + " in
" + il2cppImage.name());
let il2CppClass = il2cppImage.getClass(i);
let il2CppType = il2CppClass.getType();
let declaringType = il2CppClass.getDeclaringType();
if (!declaringType.isNull()) {
// log("declaringType:" + declaringType.name() + " class:" +
il2CppClass.name());
}
let csStr = this.dumpClass(il2CppType);
this.out(csStr);
klassMap.set(il2CppClass, csStr);
}
},
sleep: function (ms) {
return new Promise(resolve => setTimeout(resolve, ms));
},
dumpClass: function (il2CppType) {
let csStr = "";
let s = this.dumpType(il2CppType, csStr);
return s;
},
parserType: function (il2CppType) {
let il2cppTypeGetType =
il2cppApi_1.il2cppApi.il2cpp_type_get_type(il2CppType);
switch (il2cppTypeGetType) {
case tabledefs_1.Tabledefs.IL2CPP_TYPE_VOID:
return "void";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_BOOLEAN:
return "bool";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_CHAR:
return "char";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_I1:
return "short";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_U1:
return "ushort";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_I2:
return "Int16";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_U2:
return "UInt16";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_I4:
return "int";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_U4:
return "uint";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_I8:
return "Int64";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_U8:
return "UInt64";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_R4:
return "float";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_R8:
return "double";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_STRING:
return "string";
}
let il2CppClass = il2cppApi_1.il2cppApi.il2cpp_class_from_type(il2CppType);
return il2CppClass.getGenericName();
},
dumpType: function (il2CppType, csStr) {
let klass = il2cppApi_1.il2cppApi.il2cpp_class_from_type(il2CppType);
let il2CppImage = il2cppApi_1.il2cppApi.il2cpp_class_get_image(klass);
csStr += "\n//Namespace:" + klass.namespaze() + " Image->" +
il2CppImage.name() + "\n";
let flags = klass.flags();
let Serializable = flags &
tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_SERIALIZABLE;
if (Serializable) {
csStr += '[Serializable]\n';
}
let visibility = flags &
tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_VISIBILITY_MASK;
switch (visibility) {
case tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_PUBLIC:
case tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_NESTED_PUBLIC:
csStr += "public ";
break;
case tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_NOT_PUBLIC:
case tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_NESTED_FAM_AND_ASSEM:
case tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_NESTED_ASSEMBLY:
csStr += "internal ";
break;
case tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_NESTED_PRIVATE:
csStr += "private ";
break;
case tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_NESTED_FAMILY:
csStr += "protected ";
break;
case tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_NESTED_FAM_OR_ASSEM:
csStr += "protected internal ";
break;
}
let isValuetype = klass.valueType();
let IsEnum = klass.enumType();
if (flags & tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_ABSTRACT && flags &
tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_SEALED) {
csStr += "static ";
}
else if (!(flags & tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_INTERFACE) && flags
& tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_ABSTRACT) {
csStr += "abstract ";
}
else if (!isValuetype && !IsEnum && flags &
tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_SEALED) {
csStr += "sealed ";
}
if (flags & tabledefs_1.Tabledefs.TYPE_ATTRIBUTE_INTERFACE) {
csStr += "interface ";
}
else if (IsEnum) {
csStr += "enum ";
}
else if (isValuetype) {
csStr += "struct ";
}
else {
csStr += "class ";
}
let name = klass.name();
//获取泛型
if (name.indexOf("`") !== -1) {
let split = name.split("`");
name = split[0];
name = name + klass.getGenericName();
}
csStr += name + " ";
let klass_parent = klass.parent();
let hasParent = false;
if (!isValuetype && !IsEnum && !klass_parent.isNull()) {
let parent_cls_type = klass_parent.getType();
let typeEnum = parent_cls_type.getTypeEnum();
if (typeEnum === Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_OBJECT) {
//not out
}
else {
hasParent = true;
csStr += ": " + klass_parent.name();
}
}
//实现接口类
let iter = Memory.alloc(Process.pointerSize);
let interfaces;
while (!(interfaces = klass.getInterfaces(iter)).isNull()) {
let interfaces_name = interfaces.name();
if (interfaces_name.indexOf("`") !== -1) {
let split = interfaces_name.split("`");
interfaces_name = split[0];
interfaces_name = interfaces_name + interfaces.getGenericName();
}
if (!hasParent) {
csStr += ": " + interfaces_name;
hasParent = true;
}
else {
csStr += ", " + interfaces_name;
}
}
csStr += "\n{\n";
csStr += this.dumpFiled(klass);
csStr += this.dumpPropertyInfo(klass);
csStr += this.dumpMethod(klass);
csStr += "\n}";
return csStr;
},
methodNeedReturnValue: function (returnType) {
let il2cppTypeGetType =
il2cppApi_1.il2cppApi.il2cpp_type_get_type(returnType);
switch (il2cppTypeGetType) {
case tabledefs_1.Tabledefs.IL2CPP_TYPE_VOID:
return "";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_BOOLEAN:
return "return false;";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_CHAR:
return "return '\0';";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_I1:
return "return 0;";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_U1:
return "return 0;";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_I2:
return "return 0;";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_U2:
return "return 0;";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_I4:
return "return 0;";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_U4:
return "return 0;";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_I8:
return "return 0;";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_U8:
return "return 0;";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_R4:
return "return 0;";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_R8:
return "return 0;";
case tabledefs_1.Tabledefs.IL2CPP_TYPE_STRING:
return "return null;";
default:
return "return null;";
}
},
dumpMethod: function (klass) {
let out = "";
let iter = Memory.alloc(Process.pointerSize);
let methodInfo;
let isFirst = true;
let baseAddr = Module.findBaseAddress(dumpconfig_1.soName);
while (!(methodInfo = klass.getMethods(iter)).isNull()) {
if (isFirst) {
out += "\n\t//methods\n";
isFirst = false;
}
let methodPointer = methodInfo.getMethodPointer();
let generic = methodInfo.is_generic();
let inflated = methodInfo.is_inflated();
// log("generic:"+generic +" inflated:"+inflated
+"name:"+methodInfo.name());
if (!methodPointer.isNull()) {
let number = methodPointer - baseAddr;
if (number === 0x4CC8B94) {
let nativePointer = klass.add(16).readPointer();
logHHex(nativePointer);
(0, logger_1.log)("class :" + klass.name() + "length:" +
klass.name().length);
}
out += "\t// RVA: 0x" + number.toString(16).toUpperCase();
out += " VA: 0x";
out += methodPointer.toString(16).toUpperCase();
}
else {
out += "\t// RVA: 0x VA: 0x0";
}
//非必须
// log("slot:" + methodInfo.getSlot());
// if (methodInfo.getSlot() !== 65535) {
// this.out(" Slot: " + methodInfo.getSlot());
// }
out += "\n\t";
let methodModifier =
utils_1.utils.get_method_modifier(methodInfo.getFlags());
out += methodModifier;
let returnType = methodInfo.getReturnType();
let return_cls =
il2cppApi_1.il2cppApi.il2cpp_class_from_type(returnType);
let methodName = methodInfo.name().replaceAll(".", "_").replaceAll("<",
"_").replaceAll(">", "_");
out += exports.dumper.parserType(returnType) + " " + methodName + "(";
let paramCount = methodInfo.getParamCount();
// log("paramCount:" + paramCount);
if (paramCount > 0) {
for (let i = 0; i < paramCount; i++) {
let paramType = methodInfo.getParam(i);
let paramCls =
il2cppApi_1.il2cppApi.il2cpp_class_from_type(paramType);
let name = paramCls.name();
//获取泛型
if (name.indexOf("`") !== -1) {
let split = name.split("`");
name = split[0];
name = name + paramCls.getGenericName();
}
else {
name = exports.dumper.parserType(paramType);
}
out += name + " " + methodInfo.getParamName(i);
if (i + 1 !== paramCount) {
out += ", ";
}
else {
out += ") { " + this.methodNeedReturnValue(returnType) +
" }\n";
}
}
}
else {
out += "){ " + this.methodNeedReturnValue(returnType) + " }\n";
}
}
return out;
},
dumpPropertyInfo: function (klass) {
let out = "";
let iter = Memory.alloc(Process.pointerSize);
let propertyInfo;
let isFirst = true;
while (!(propertyInfo = klass.getProperties(iter)).isNull()) {
if (isFirst) {
out += "\n\t// Properties\n";
isFirst = false;
}
out += "\t";
//获取 getSet
// log(" dumpPropertyInfo get:" + propertyInfo.getMethod().isNull());
let pro_class;
let method = propertyInfo.getMethod();
let setMethod = propertyInfo.setMethod();
if (method.isNull() && setMethod.isNull()) {
let name = propertyInfo.getName();
if (name !== "") {
out += "// unknow property:" + name + "\n";
}
continue;
}
if (!method.isNull()) {
if (klass.name() === "JSONNode"
|| klass.name() === "LCRole") {
continue;
}
let methodModifier =
utils_1.utils.get_method_modifier(method.getFlags());
// let methodPointer = method.getMethodPointer()
// log("methodModifier:" + methodModifier + " methodPointer:" +
methodPointer);
out += methodModifier;
try {
pro_class =
il2cppApi_1.il2cppApi.il2cpp_class_from_type(method.getReturnType());
}
catch (e) {
pro_class = null;
}
}
else if (!setMethod.isNull()) {
let setModifier =
utils_1.utils.get_method_modifier(setMethod.getFlags());
out += setModifier;
pro_class =
il2cppApi_1.il2cppApi.il2cpp_class_from_type(setMethod.getReturnType());
}
if (pro_class === null) {
out += "// unknow type : " + method.name();
(0, logger_1.log)("unknow type: " + klass.name());
}
else {
out += exports.dumper.parserType(pro_class.getType()) + " " +
propertyInfo.getName() + " { ";
if (!method.isNull()) {
out += "get; ";
}
if (!setMethod.isNull()) {
out += "set; ";
}
out += "}\n";
}
// log("pro_class:"+pro_class +"propertyInfo:"+propertyInfo.getName()
+" method:"+method +" setMethod:"+setMethod)
}
return out;
},
dumpFiled: function (klass) {
let out = "";
// log("dumpFiled class :" + klass.name())
let filedCount = klass.filedCount();
// log("fieldCount:" + filedCount);
let enumType = klass.enumType();
if (filedCount > 0) {
let iter = Memory.alloc(Process.pointerSize);
let filedInfo;
out += "\t//Fileds\n";
while (!(filedInfo = klass.getFieldsInfo(iter)).isNull()) {
let flags = filedInfo.getFlags();
out += "\t";
let access = flags &
tabledefs_1.Tabledefs.FIELD_ATTRIBUTE_FIELD_ACCESS_MASK;
switch (access) {
case tabledefs_1.Tabledefs.FIELD_ATTRIBUTE_PRIVATE:
out += "private ";
break;
case tabledefs_1.Tabledefs.FIELD_ATTRIBUTE_PUBLIC:
if (!enumType) {
out += "public ";
}
break;
case tabledefs_1.Tabledefs.FIELD_ATTRIBUTE_FAMILY:
out += "protected ";
break;
case tabledefs_1.Tabledefs.FIELD_ATTRIBUTE_ASSEMBLY:
case tabledefs_1.Tabledefs.FIELD_ATTRIBUTE_FAM_AND_ASSEM:
out += "internal ";
break;
case tabledefs_1.Tabledefs.FIELD_ATTRIBUTE_FAM_OR_ASSEM:
out += "protected internal ";
break;
}
let isConst = false;
if (flags & tabledefs_1.Tabledefs.FIELD_ATTRIBUTE_LITERAL) {
if (!enumType) {
out += "const ";
isConst = true;
}
}
else {
if (flags & tabledefs_1.Tabledefs.FIELD_ATTRIBUTE_STATIC) {
out += "static ";
}
if (flags & tabledefs_1.Tabledefs.FIELD_ATTRIBUTE_INIT_ONLY) {
out += "readonly ";
}
}
let fieldClass = filedInfo.getFiledClass();
let name = fieldClass.name(); //参数名
let offset = filedInfo.getOffset(); //偏移
// //如果是泛型变量则进行补充
if (name.indexOf("`") !== -1) { //`1 `2 `3 说明是泛型类型 解析泛型变量
let genericName = fieldClass.getGenericName();
let split = name.split("`");
name = split[0];
name = name + genericName;
}
else {
name = exports.dumper.parserType(filedInfo.getType());
}
if (enumType && name === "int" &&
filedInfo.getFiledName().includes("value__")) {
//ignore this default enum value
continue;
}
else {
if (enumType) {
out += filedInfo.getFiledName();
}
else {
out += name + " " + filedInfo.getFiledName();
}
}
//获取常量的初始值
// let filed_info_cpp_type = filedInfo.getType(); //获取变量参数类型
// log("filed_info_cpp_type:" + filed_info_cpp_type.getTypeEnum() +
name + " " + filedInfo.getFiledName());
if (flags & tabledefs_1.Tabledefs.FIELD_ATTRIBUTE_LITERAL) {
let staticValue = filedInfo.getStaticValue();
if (staticValue !== null) {
out += " = " + staticValue;
}
if (enumType) {
out += ",\n";
}
else {
out += ";\n";
}
}
else if (isConst) {
let staticValue = filedInfo.getStaticValue();
if (staticValue !== null) {
out += " = " + staticValue;
}
out += ";\n";
}
else {
out += " ;// 0x" + offset.toString(16).toUpperCase() + "\n";
}
}
}
return out;
},
out: function (string) {
if (file === undefined) {
if (Process.platform === "darwin") {
let documentDir = IOSUtils_1.IOSUtils.getDocumentDir();
file = new File(documentDir + "/dump.cs", "wb");
}
else {
(0, logger_1.log)("android dump path " +
dumpconfig_1.DUMP_FILE_PATH);
file = new File(dumpconfig_1.DUMP_FILE_PATH, "wb");
}
}
file.write(string);
file.flush();
}
};
},{"./and/ZipUtils":1,"./dumpconfig":3,"./il2cpp/CSFileOut":5,"./il2cpp/
Il2CppTypeEnum":7,"./il2cpp/il2cppApi":9,"./il2cpp/struct/utils":21,"./il2cpp/
tabledefs":22,"./ios/IOSUtils":24,"./logger":26}],5:
[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CSFileOut = void 0;
const dumpconfig_1 = require("../dumpconfig");
const FileUtils_1 = require("./FileUtils");
const il2cppApi_1 = require("./il2cppApi");
exports.CSFileOut = {
createDir: function (filePath) {
let split = filePath.split('/');
let path = "";
for (let i = 0; i < split.length; i++) {
if (i + 1 === split.length) {
break;
}
else {
path += split[i] + "/";
FileUtils_1.FileUtils.createDir(path);
}
}
},
addParentAndInterfaceNamespaze(klass) {
let parent = klass.parent();
if (!parent.isNull()) {
let namespaze = parent.namespaze();
if (namespaze !== "") {
klass.addNeedNameSpace(namespaze);
}
}
let interfaces;
// interfaces
let iter = Memory.alloc(Process.pointerSize);
while (!(interfaces = klass.getInterfaces(iter)).isNull()) {
let interfaceNameSpace = interfaces.namespaze();
// log("interfaceNameSpace " + interfaceNameSpace)
if (interfaceNameSpace !== "") {
klass.addNeedNameSpace(interfaceNameSpace);
}
}
},
addFieldTypeNamespaze(klass) {
//Field type
let filedCount = klass.filedCount();
if (filedCount > 0) {
let iter = Memory.alloc(Process.pointerSize);
let filedInfo;
while (!(filedInfo = klass.getFieldsInfo(iter)).isNull()) {
let fieldClass = filedInfo.getFiledClass();
if (fieldClass.namespaze() !== "") {
klass.addNeedNameSpace(fieldClass.namespaze());
}
}
}
//property
},
addPropertyInfo: function (klass) {
let iter = Memory.alloc(Process.pointerSize);
let propertyInfo;
while (!(propertyInfo = klass.getProperties(iter)).isNull()) {
let pro_class;
let method = propertyInfo.getMethod();
let setMethod = propertyInfo.setMethod();
if (method.isNull() && setMethod.isNull()) {
continue;
}
if (!method.isNull()) {
pro_class =
il2cppApi_1.il2cppApi.il2cpp_class_from_type(method.getReturnType());
}
else if (!setMethod.isNull()) {
pro_class =
il2cppApi_1.il2cppApi.il2cpp_class_from_type(setMethod.getReturnType());
}
klass.addNeedNameSpace(pro_class.namespaze());
}
},
addMethodInfo: function (klass) {
let iter = Memory.alloc(Process.pointerSize);
let methodInfo;
while (!(methodInfo = klass.getMethods(iter)).isNull()) {
let returnType = methodInfo.getReturnType();
let return_cls =
il2cppApi_1.il2cppApi.il2cpp_class_from_type(returnType);
let paramCount = methodInfo.getParamCount();
klass.addNeedNameSpace(return_cls.namespaze());
if (paramCount > 0) {
for (let i = 0; i < paramCount; i++) {
let paramType = methodInfo.getParam(i);
let paramCls =
il2cppApi_1.il2cppApi.il2cpp_class_from_type(paramType);
klass.addNeedNameSpace(paramCls.namespaze());
}
}
}
},
outClass: function (klass, csStr) {
if (klass.isNull()) {
return;
}
let il2CppImage = il2cppApi_1.il2cppApi.il2cpp_class_get_image(klass);
let nameNoExt = il2CppImage.nameNoExt();
// system dll dont need out
if (nameNoExt === "mscorlib" || nameNoExt === "Mono.Security") {
return;
}
if (nameNoExt === "System" || nameNoExt === "System.Xml" || nameNoExt ===
"System.Core" || nameNoExt === "System.Configuration") {
return;
}
if (nameNoExt === "Newtonsoft.Json") {
return;
}
//unity dll dont need
if (nameNoExt.includes("UnityEngine")) {
return;
}
if (klass.name() === "<Module>") { //ignore <Module>
return;
}
if (klass.name().includes("<>__")) { //ignore <>__*
return;
}
//ignore <PrivateImplementationDetails>
if (klass.name().includes("<PrivateImplementationDetails>")) {
return;
}
if (klass.name().includes("$ArrayType")) {
return;
}
if (klass.name().includes("=")) {
return;
}
if (klass.name().includes("<")) {
return;
}
if (klass.name().includes("`")) { //dont need generic class
return;
}
// log("need out klass " + klass.name())
//生成 cs 文件
//parent
this.addParentAndInterfaceNamespaze(klass);
this.addFieldTypeNamespaze(klass);
this.addPropertyInfo(klass);
this.addMethodInfo(klass);
let outCs = "";
for (let i = 0; i < klass.needNameSpace.length; i++) {
//this class need namespace
let needNameSpaceElement = klass.needNameSpace[i];
// log("needNameSpace " + needNameSpaceElement)
if (needNameSpaceElement !== "") {
outCs += "using " + needNameSpaceElement + ";\n";
}
}
outCs += "\n";
//import namespace
let namespaze = klass.namespaze();
if (namespaze !== "") {
outCs += "namespace " + namespaze + "{\n";
outCs += csStr;
outCs += "}\n";
}
else {
outCs += csStr;
}
let filePath;
if (namespaze !== "") {
filePath = dumpconfig_1.CSFileDir + "/" + nameNoExt + "/" + namespaze +
"/" + klass.name() + ".cs";
}
else {
filePath = dumpconfig_1.CSFileDir + "/" + nameNoExt + "/" +
klass.name() + ".cs";
}
// log("filePath " + filePath);
//create dir
this.createDir(filePath);
//write file
FileUtils_1.FileUtils.writeFile(filePath, outCs);
}
};
},{"../dumpconfig":3,"./FileUtils":6,"./il2cppApi":9}],6:
[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileUtils = void 0;
const logger_1 = require("../logger");
var mkdir = new NativeFunction(Module.findExportByName("libc.so", 'mkdir'), 'int',
['pointer', 'int']);
var access = new NativeFunction(Module.findExportByName("libc.so", 'access'),
'int', ['pointer', 'int']);
const F_OK = 0; // 用于检查文件的存在性
const libc = Process.getModuleByName('libc.so');
const fopen = new NativeFunction(libc.getExportByName('fopen'), 'pointer',
['pointer', 'pointer']);
const fwrite = new NativeFunction(libc.getExportByName('fwrite'), 'uint',
['pointer', 'uint', 'uint', 'pointer']);
const fclose = new NativeFunction(libc.getExportByName('fclose'), 'int',
['pointer']);
const strlen = new NativeFunction(Module.findExportByName(null, 'strlen'),
'size_t', ['pointer']);
var strerror = new NativeFunction(Module.findExportByName("libc.so", 'strerror'),
'pointer', ['int']);
exports.FileUtils = {
writeFile: function (path, data) {
//use java
//
const file = fopen(Memory.allocUtf8String(path),
Memory.allocUtf8String('w'));
if (file.isNull()) {
console.error('Failed to open file');
return;
}
let dataPtr = Memory.allocUtf8String(data);
const dataSize = strlen(dataPtr) + 0;
const bytesWritten = fwrite(dataPtr, 1, dataSize, file);
if (bytesWritten !== dataSize) {
console.error('Failed to write to file');
fclose(file);
return;
}
fclose(file);
// log("file out success");
},
createFile: function (outpath) {
},
createDir: function (path) {
let nativePointer = Memory.allocUtf8String(path);
if (access(nativePointer, F_OK) === -1) {
// log("create Dir "+path)
let result = mkdir(nativePointer, 0o777);
if (result === 0) {
// log("Directory created successfully: " + path);
}
else {
var errnoPtr = Module.findExportByName(null, "__errno");
var errno = Memory.readPointer(ptr(errnoPtr)).toInt32();
// 获取并打印错误消息
var strerror = new
NativeFunction(Module.findExportByName("libc.so", 'strerror'), 'pointer', ['int']);
var messagePtr = strerror(errno);
var message = Memory.readUtf8String(messagePtr);
(0, logger_1.log)("Failed to create directory: " + path + ".
Reason: " + message);
}
}
}
};
},{"../logger":26}],7:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Il2CppTypeEnum = void 0;
exports.Il2CppTypeEnum = {
IL2CPP_TYPE_END: 0x00,
IL2CPP_TYPE_VOID: 0x01,
IL2CPP_TYPE_BOOLEAN: 0x02,
IL2CPP_TYPE_CHAR: 0x03,
IL2CPP_TYPE_I1: 0x04,
IL2CPP_TYPE_U1: 0x05,
IL2CPP_TYPE_I2: 0x06,
IL2CPP_TYPE_U2: 0x07,
IL2CPP_TYPE_I4: 0x08,
IL2CPP_TYPE_U4: 0x09,
IL2CPP_TYPE_I8: 0x0a,
IL2CPP_TYPE_U8: 0x0b,
IL2CPP_TYPE_R4: 0x0c,
IL2CPP_TYPE_R8: 0x0d,
IL2CPP_TYPE_STRING: 0x0e,
IL2CPP_TYPE_PTR: 0x0f,
IL2CPP_TYPE_BYREF: 0x10,
IL2CPP_TYPE_VALUETYPE: 0x11,
IL2CPP_TYPE_CLASS: 0x12,
IL2CPP_TYPE_VAR: 0x13,
IL2CPP_TYPE_ARRAY: 0x14,
IL2CPP_TYPE_GENERICINST: 0x15,
IL2CPP_TYPE_TYPEDBYREF: 0x16,
IL2CPP_TYPE_I: 0x18,
IL2CPP_TYPE_U: 0x19,
IL2CPP_TYPE_FNPTR: 0x1b,
IL2CPP_TYPE_OBJECT: 0x1c,
IL2CPP_TYPE_SZARRAY: 0x1d,
IL2CPP_TYPE_MVAR: 0x1e,
IL2CPP_TYPE_CMOD_REQD: 0x1f,
IL2CPP_TYPE_CMOD_OPT: 0x20,
IL2CPP_TYPE_INTERNAL: 0x21,
IL2CPP_TYPE_MODIFIER: 0x40,
IL2CPP_TYPE_SENTINEL: 0x41,
IL2CPP_TYPE_PINNED: 0x45,
IL2CPP_TYPE_ENUM: 0x55
};
},{}],8:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Il2cppString = void 0;
const NativeStruct_1 = require("../../struct/NativeStruct");
const il2cppApi_1 = require("../../il2cppApi");
class Il2cppString extends NativeStruct_1.NativeStruct {
static parserString(str) {
// 获取 MonoString 的长度
if (str.isNull()) {
return "空";
}
// logHHex(str)
let il2CppBase = Process.pointerSize * 2;
var length = Memory.readU32(str.add(il2CppBase));
// 获取 MonoString 的字符数据的指针(UTF-16 编码)
var charsPtr = str.add(il2CppBase + 0x4);
// 从 UTF-16 编码的字符数据创建 JavaScript 字符串
return Memory.readUtf16String(charsPtr, length);
}
static parser(systemString) {
if (systemString.isNull()) {
return "指针空";
}
let length = il2cppApi_1.il2cppApi.il2cpp_string_length(systemString);
let il2cppStringChars =
il2cppApi_1.il2cppApi.il2cpp_string_chars(systemString);
let content = "";
for (let i = 0; i < length; i++) {
let offset = i * 2;
let s = il2cppStringChars.add(offset).readU16().toString(16);
if (s.toString().length === 2) {
let s2 = il2cppStringChars.add(offset).readCString();
content = content + s2;
}
else {
//转换 unicode
let unicode = "\\u" + s.toString();
let decodeUnicode1 = this.decodeUnicode(unicode);
content = content + decodeUnicode1;
}
}
return content;
}
getCString() {
if (this.isNull()) {
return "指针空";
}
let length = this.getLength();
//长度 4 字节本身偏移 16 从 20 位开始
let il2cppStringChars = il2cppApi_1.il2cppApi.il2cpp_string_chars(this);
let content = "";
for (let i = 0; i < length; i++) {
let offset = i * 2;
let s = il2cppStringChars.add(offset).readU16().toString(16);
// console.log("il2cppStringChars:" + s);
//转 unicode
if (s.toString().length === 2) {
let s2 = il2cppStringChars.add(offset).readCString();
// log("s2:"+s2);
content = content + s2;
}
else {
//转换 unicode
let unicode = "\\u" + s.toString();
// log("unicode:" + unicode);
let decodeUnicode1 = this.decodeUnicode(unicode);
content = content + decodeUnicode1;
// log("s2:"+this.decodeUnicode(unicode));
}
// let s1 = String.fromCharCode(unicode);
}
if (content === undefined) {
return "";
}
return content;
}
getLength() {
return il2cppApi_1.il2cppApi.il2cpp_string_length(this);
}
static decodeUnicode(str) {
let replace = str.replace(/\\/g, "%");
return unescape(replace);
}
}
exports.Il2cppString = Il2cppString;
},{"../../il2cppApi":9,"../../struct/NativeStruct":19}],9:
[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.il2cppApi = void 0;
const Il2CppImage_1 = require("./struct/Il2CppImage");
const Il2CppClass_1 = require("./struct/Il2CppClass");
const Il2CppType_1 = require("./struct/Il2CppType");
const Il2CppFieldInfo_1 = require("./struct/Il2CppFieldInfo");
const Il2CppPropertyInfo_1 = require("./struct/Il2CppPropertyInfo");
const MethodInfo_1 = require("./struct/MethodInfo");
const dumpconfig_1 = require("../dumpconfig");
const LinkerHelper_1 = require("../linker/LinkerHelper");
let il2CppHandle = null;
let nativeFunMap = new Map();
let dlsym = null;
exports.il2cppApi = {
nativeFunNotExistMap: new Map(),
il2cpp_array_new: function (klass, size) {
let il2cpp_array_new = this.load("il2cpp_array_new", 'pointer', ['pointer',
'uint64']);
return il2cpp_array_new(klass, size);
},
il2cpp_array_get_byte_length: function (array) {
let il2cpp_array_get_byte_length =
this.load("il2cpp_array_get_byte_length", 'uint32', ['pointer']);
return il2cpp_array_get_byte_length(array);
},
il2cpp_domain_get: function () {
return this.load("il2cpp_domain_get", 'pointer', []);
},
il2cpp_thread_attach: function (domain) {
return this.load("il2cpp_thread_attach", 'pointer', ['pointer']);
},
il2cpp_string_length: function (Il2cppString) {
let il2cpp_string_length = this.load("il2cpp_string_length", "int",
['pointer']);
return il2cpp_string_length(Il2cppString);
},
il2cpp_string_chars: function (Il2cppString) {
let il2cpp_string_chars = this.load("il2cpp_string_chars", "pointer",
['pointer']);
return il2cpp_string_chars(Il2cppString);
},
il2cpp_string_new: function (str) {
let il2cpp_string_new = this.load("il2cpp_string_new", "pointer",
['pointer']);
return il2cpp_string_new(str);
},
il2cpp_domain_get_assemblies: function (il2Cppdomain, size_t) {
let il2cpp_domain_get_assemblies =
this.load("il2cpp_domain_get_assemblies", 'pointer', ['pointer', 'pointer']);
return il2cpp_domain_get_assemblies(il2Cppdomain, size_t);
},
il2cpp_gc_collect_a_little: function () {
let il2cpp_gc_collect_a_little = this.load("il2cpp_gc_collect_a_little" +
"", 'pointer', ['pointer', 'pointer']);
return il2cpp_gc_collect_a_little(il2Cppdomain, size_t);
},
il2cpp_assembly_get_image: function (il2Cppassembly) {
let il2cpp_assembly_get_image = this.load("il2cpp_assembly_get_image",
'pointer', ['pointer']);
try {
return new
Il2CppImage_1.Il2CppImage(il2cpp_assembly_get_image(il2Cppassembly));
}
catch (e) {
return new Il2CppImage_1.Il2CppImage(il2Cppassembly.readPointer());
}
},
il2cpp_image_get_class_count: function (image) {
// size_t il2cpp_image_get_class_count(const Il2CppImage * image)
let il2cpp_image_get_class_count =
this.load("il2cpp_image_get_class_count", "pointer", ['pointer']);
if (il2cpp_image_get_class_count !== undefined) {
return il2cpp_image_get_class_count(image).toUInt32();
}
else {
return image.getOffsetTypeCount();
}
},
il2cpp_image_get_name: function (Il2CppImage) {
let il2cpp_image_get_name = this.load("il2cpp_image_get_name", "pointer",
['pointer']);
return il2cpp_image_get_name(Il2CppImage);
},
il2cpp_image_get_class: function (il2CppImage, index) {
// // const Il2CppClass* il2cpp_image_get_class(const Il2CppImage * image,
size_t index)
let il2cpp_image_get_class = this.load("il2cpp_image_get_class", 'pointer',
['pointer', 'int']);
let il2cppImageGetClass = il2cpp_image_get_class(il2CppImage, index);
return new Il2CppClass_1.Il2CppClass(il2cppImageGetClass);
},
il2cpp_class_get_type: function (il2CppClass) {
let il2cpp_class_get_type = this.load("il2cpp_class_get_type", 'pointer',
["pointer"]);
return new Il2CppType_1.Il2CppType(il2cpp_class_get_type(il2CppClass));
},
il2cpp_class_get_element_class: function (cls) {
let il2cpp_class_get_element_class =
this.load("il2cpp_class_get_element_class", 'pointer', ["pointer"]);
return new Il2CppClass_1.Il2CppClass(il2cpp_class_get_element_class(cls));
},
il2cpp_class_get_declaring_type: function (cls) {
let il2cpp_class_get_declaring_type =
this.load("il2cpp_class_get_declaring_type", 'pointer', ["pointer"]);
return new Il2CppClass_1.Il2CppClass(il2cpp_class_get_declaring_type(cls));
},
il2cpp_class_from_type: function (Il2CppType) {
let il2cpp_class_from_type = this.load("il2cpp_class_from_type", "pointer",
["pointer"]);
if (Il2CppType === null) {
return null;
}
return new Il2CppClass_1.Il2CppClass(il2cpp_class_from_type(Il2CppType));
},
il2cpp_class_get_image: function (klass) {
let il2cpp_class_get_image = this.load("il2cpp_class_get_image", "pointer",
["pointer"]);
return new Il2CppImage_1.Il2CppImage(il2cpp_class_get_image(klass));
},
il2cpp_class_from_name: function (Il2cppImage, nameSpaze, name) {
let il2cpp_class_from_name = this.load("il2cpp_class_from_name", "pointer",
["pointer", "pointer", "pointer"]);
let nameSpaze_t = Memory.allocUtf8String(nameSpaze);
let name_t = Memory.allocUtf8String(name);
return new Il2CppClass_1.Il2CppClass(il2cpp_class_from_name(Il2cppImage,
nameSpaze_t, name_t));
},
il2cpp_class_enum_basetype: function (Il2CppClass) {
let il2cpp_class_enum_basetype = this.load("il2cpp_class_enum_basetype",
"pointer", ["pointer"]);
return new
Il2CppType_1.Il2CppType(il2cpp_class_enum_basetype(Il2CppClass));
},
il2cpp_class_value_size: function (Il2CppClass, align) {
let il2cpp_class_value_size = this.load("il2cpp_class_value_size", "int32",
["pointer", "pointer"]);
return il2cpp_class_value_size(Il2CppClass);
},
il2cpp_class_get_flags: function (Il2CppClass) {
let il2cpp_class_get_flags = this.load("il2cpp_class_get_flags", "int",
["pointer"]);
return il2cpp_class_get_flags(Il2CppClass);
},
il2cpp_class_is_valuetype: function (Il2CppClass) {
let il2cpp_class_is_valuetype = this.load("il2cpp_class_is_valuetype",
"bool", ["pointer"]);
return il2cpp_class_is_valuetype(Il2CppClass);
},
il2cpp_class_is_generic: function (Il2CppClass) {
let il2cpp_class_is_generic = this.load("il2cpp_class_is_generic", "bool",
["pointer"]);
return il2cpp_class_is_generic(Il2CppClass);
},
il2cpp_class_is_enum: function (Il2CppClass) {
let il2cpp_class_is_enum = this.load("il2cpp_class_is_enum", "bool",
["pointer"]);
return il2cpp_class_is_enum(Il2CppClass);
},
il2cpp_class_get_name: function (Il2CppClass) {
let il2cpp_class_get_name = this.load("il2cpp_class_get_name", "pointer",
["pointer"]);
return il2cpp_class_get_name(Il2CppClass);
},
il2cpp_class_get_parent: function (Il2CppClass) {
let il2cpp_class_get_parent = this.load("il2cpp_class_get_parent",
"pointer", ["pointer"]);
return il2cpp_class_get_parent(Il2CppClass);
},
il2cpp_class_get_interfaces: function (cls, iter) {
let il2cpp_class_get_interfaces = this.load("il2cpp_class_get_interfaces",
'pointer', ['pointer', 'pointer']);
return new Il2CppClass_1.Il2CppClass(il2cpp_class_get_interfaces(cls,
iter));
},
il2cpp_class_get_namespace: function (Il2CppClass) {
let il2cpp_class_get_namespace = this.load("il2cpp_class_get_namespace",
'pointer', ['pointer']);
return il2cpp_class_get_namespace(Il2CppClass);
},
il2cpp_class_num_fields: function (Il2CppClass) {
let il2cpp_class_num_fields = this.load("il2cpp_class_num_fields",
'size_t', ['pointer']);
return il2cpp_class_num_fields(Il2CppClass);
},
il2cpp_class_get_fields: function (Il2CppClass, iter) {
let il2cpp_class_get_fields = this.load("il2cpp_class_get_fields",
'pointer', ['pointer', 'pointer']);
return new
Il2CppFieldInfo_1.Il2CppFieldInfo(il2cpp_class_get_fields(Il2CppClass, iter));
},
il2cpp_class_get_properties: function (Il2CppClass, iter) {
let il2cpp_class_get_properties = this.load("il2cpp_class_get_properties",
'pointer', ['pointer', 'pointer']);
return new
Il2CppPropertyInfo_1.Il2CppPropertyInfo(il2cpp_class_get_properties(Il2CppClass,
iter));
},
il2cpp_class_get_methods: function (Il2CppClass, iter) {
let il2cpp_class_get_methods = this.load("il2cpp_class_get_methods",
'pointer', ['pointer', 'pointer']);
return new MethodInfo_1.MethodInfo(il2cpp_class_get_methods(Il2CppClass,
iter));
},
il2cpp_class_get_method_from_name: function (Il2CppClass, name, argsCount) {
let il2cpp_class_get_method_from_name =
this.load("il2cpp_class_get_method_from_name", 'pointer', ['pointer', 'pointer',
"int"]);
let name_t = Memory.allocUtf8String(name);
return new
MethodInfo_1.MethodInfo(il2cpp_class_get_method_from_name(Il2CppClass, name_t,
argsCount));
},
il2cpp_type_get_type: function (Il2CppType) {
let il2cpp_type_get_type = this.load("il2cpp_type_get_type", 'int',
['pointer']);
return il2cpp_type_get_type(Il2CppType);
},
/**
* 非必要参数
* @param Il2CppType
* @returns {number|*}
*/
il2cpp_type_is_byref: function (Il2CppType) {
let il2cpp_type_is_byref = this.load("il2cpp_type_is_byref", "bool",
["pointer"]);
// log(" il2cpp_type_is_byref:"+il2cpp_type_is_byref);
if (il2cpp_type_is_byref !== undefined) {
return il2cpp_type_is_byref(Il2CppType);
}
return Il2CppType.add(4).readS8();
},
il2cpp_type_get_attrs: function (Il2cppType) {
let il2cpp_type_get_attrs = this.load("il2cpp_type_get_attrs", "int32",
["pointer"]);
return il2cpp_type_get_attrs(Il2cppType);
},
il2cpp_type_get_object: function (Il2CppType) {
let il2cpp_type_get_object = this.load("il2cpp_type_get_object", 'pointer',
['pointer']);
return il2cpp_type_get_object(Il2CppType);
},
il2cpp_type_get_name: function (Il2CppType) {
let il2cpp_type_get_name = this.load("il2cpp_type_get_name", 'pointer',
['pointer']);
try {
return il2cpp_type_get_name(Il2CppType);
}
catch (e) {
return null;
}
},
il2cpp_field_static_get_value: function (FieldInfo, value) {
let il2cpp_field_static_get_value =
this.load("il2cpp_field_static_get_value", 'void', ['pointer', 'pointer']);
return il2cpp_field_static_get_value(FieldInfo, value);
},
il2cpp_field_get_parent: function (FieldInfo) {
let il2cpp_field_get_parent = this.load("il2cpp_field_get_parent",
'pointer', ['pointer']);
return new Il2CppClass_1.Il2CppClass(il2cpp_field_get_parent(FieldInfo));
},
il2cpp_field_get_flags: function (FieldInfo) {
let il2cpp_field_get_flags = this.load("il2cpp_field_get_flags", "int",
['pointer']);
return il2cpp_field_get_flags(FieldInfo);
},
il2cpp_field_get_type: function (FieldInfo) {
let il2cpp_field_get_type = this.load("il2cpp_field_get_type", "pointer",
['pointer']);
return new Il2CppType_1.Il2CppType(il2cpp_field_get_type(FieldInfo));
},
il2cpp_field_get_name: function (FieldInfo) {
let il2cpp_field_get_name = this.load("il2cpp_field_get_name", "pointer",
['pointer']);
return il2cpp_field_get_name(FieldInfo);
},
il2cpp_field_get_offset: function (FieldInfo) {
let il2cpp_field_get_offset = this.load("il2cpp_field_get_offset",
"size_t", ['pointer']);
return il2cpp_field_get_offset(FieldInfo);
},
il2cpp_property_get_get_method: function (PropertyInfo) {
let il2cpp_property_get_get_method =
this.load("il2cpp_property_get_get_method", "pointer", ['pointer']);
return new
MethodInfo_1.MethodInfo(il2cpp_property_get_get_method(PropertyInfo));
},
il2cpp_property_get_set_method: function (PropertyInfo) {
let il2cpp_property_get_set_method =
this.load("il2cpp_property_get_set_method", "pointer", ['pointer']);
return new
MethodInfo_1.MethodInfo(il2cpp_property_get_set_method(PropertyInfo));
},
il2cpp_property_get_name: function (PropertyInfo) {
let il2cpp_property_get_name = this.load("il2cpp_property_get_name",
"pointer", ['pointer']);
return il2cpp_property_get_name(PropertyInfo);
},
il2cpp_method_get_flags: function (method, iflags) {
let il2cpp_method_get_flags_api = this.load("il2cpp_method_get_flags",
"uint32", ['pointer', 'uint32']);
return il2cpp_method_get_flags_api(method, iflags);
},
il2cpp_method_get_name: function (method) {
let il2cpp_method_get_name = this.load("il2cpp_method_get_name", "pointer",
['pointer']);
return il2cpp_method_get_name(method);
},
il2cpp_method_get_class: function (method) {
let il2cpp_method_get_class = this.load("il2cpp_method_get_class",
"pointer", ['pointer']);
return il2cpp_method_get_class(method);
},
il2cpp_method_get_pointer: function (method) {
//版本兼容有问题
let il2cpp_method_get_pointer = this.load("il2cpp_method_get_pointer",
"pointer", ['pointer']);
if (il2cpp_method_get_pointer !== undefined) {
return il2cpp_method_get_pointer(method);
}
return method.readPointer();
},
il2cpp_method_get_param_count: function (method) {
let il2cpp_method_get_param_count =
this.load("il2cpp_method_get_param_count", "uint32", ['pointer']);
return il2cpp_method_get_param_count(method);
},
il2cpp_method_get_return_type: function (method) {
let il2cpp_method_get_return_type =
this.load("il2cpp_method_get_return_type", "pointer", ['pointer']);
return new Il2CppType_1.Il2CppType(il2cpp_method_get_return_type(method));
},
il2cpp_method_get_param: function (method, index) {
let il2cpp_method_get_param = this.load("il2cpp_method_get_param",
"pointer", ['pointer', 'uint32']);
return new Il2CppType_1.Il2CppType(il2cpp_method_get_param(method, index));
},
il2cpp_method_is_generic: function (method) {
let il2cpp_method_is_generic = this.load("il2cpp_method_is_generic",
"bool", ['pointer']);
return il2cpp_method_is_generic(method);
},
il2cpp_array_length(arg) {
let il2cpp_array_length = this.load("il2cpp_array_length", "uint32",
['pointer']);
return il2cpp_array_length(arg);
},
il2cpp_method_is_inflated: function (method) {
let il2cpp_method_is_inflated = this.load("il2cpp_method_is_inflated",
"bool", ['pointer']);
return il2cpp_method_is_inflated(method);
},
il2cpp_method_get_param_name: function (method, index) {
let il2cpp_method_get_param_name =
this.load("il2cpp_method_get_param_name", "pointer", ['pointer', 'uint32']);
return il2cpp_method_get_param_name(method, index);
},
/**
* 使用内存缓存加快 dump 速度
* @param exportName
* @param reType
* @param argTypes
* @returns {any}
*/
load: function (exportName, reType, argTypes) {
if (dumpconfig_1.useSoInfo) {
if (il2CppHandle === null) {
il2CppHandle = LinkerHelper_1.linkerHelper.getIl2CppHandle();
}
if (dlsym === null) {
let dlsymAddr = Module.findExportByName(null, "dlsym");
dlsym = new NativeFunction(dlsymAddr, 'pointer', ['pointer',
'pointer']);
}
let cacheFun = nativeFunMap.get(exportName);
if (cacheFun == null) {
let isExist = this.nativeFunNotExistMap.get(exportName);
if (isExist === -1) {
return undefined;
}
let nativePointer = dlsym(il2CppHandle,
Memory.allocUtf8String(exportName));
if (nativePointer == null) {
this.nativeFunNotExistMap.set(exportName, -1);
return undefined;
}
else {
cacheFun = new NativeFunction(nativePointer, reType, argTypes);
nativeFunMap.set(exportName, cacheFun);
}
}
return nativeFunMap.get(exportName);
}
else {
let cacheFun = nativeFunMap.get(exportName);
if (cacheFun == null) {
let isExist = this.nativeFunNotExistMap.get(exportName);
if (isExist === -1) {
return undefined;
}
let nativePointer = Module.findExportByName(dumpconfig_1.soName,
exportName);
if (nativePointer == null) {
this.nativeFunNotExistMap.set(exportName, -1);
return undefined;
}
else {
cacheFun = new NativeFunction(nativePointer, reType, argTypes);
nativeFunMap.set(exportName, cacheFun);
}
}
return nativeFunMap.get(exportName);
}
},
};
},{"../dumpconfig":3,"../linker/LinkerHelper":25,"./struct/Il2CppClass":10,"./
struct/Il2CppFieldInfo":11,"./struct/Il2CppImage":15,"./struct/
Il2CppPropertyInfo":16,"./struct/Il2CppType":17,"./struct/MethodInfo":18}],10:
[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Il2CppClass = void 0;
const NativeStruct_1 = require("./NativeStruct");
const il2cppApi_1 = require("../il2cppApi");
const Il2CppImage_1 = require("./Il2CppImage");
class Il2CppClass extends NativeStruct_1.NativeStruct {
constructor(pointer) {
super(pointer);
this.needNameSpace = [];
}
addNeedNameSpace(str) {
if (!this.needNameSpace.includes(str)) {
this.needNameSpace.push(str);
}
}
name() {
return il2cppApi_1.il2cppApi.il2cpp_class_get_name(this).readCString();
}
image() {
return new
Il2CppImage_1.Il2CppImage(il2cppApi_1.il2cppApi.il2cpp_class_get_image(this));
}
namespaze() {
return
il2cppApi_1.il2cppApi.il2cpp_class_get_namespace(this).readCString();
}
flags() {
return il2cppApi_1.il2cppApi.il2cpp_class_get_flags(this);
}
valueType() {
return il2cppApi_1.il2cppApi.il2cpp_class_is_valuetype(this);
}
enumType() {
return il2cppApi_1.il2cppApi.il2cpp_class_is_enum(this);
}
isGeneric() {
return il2cppApi_1.il2cppApi.il2cpp_class_is_generic(this);
}
/**
* class_type
*/
getType() {
return il2cppApi_1.il2cppApi.il2cpp_class_get_type(this);
}
getElementClass() {
return il2cppApi_1.il2cppApi.il2cpp_class_get_element_class(this);
}
getDeclaringType() {
return il2cppApi_1.il2cppApi.il2cpp_class_get_declaring_type(this);
}
filedCount() {
return il2cppApi_1.il2cppApi.il2cpp_class_num_fields(this);
}
/**
*
* @returns {Il2CppType}
*/
getEnumBaseType() {
return il2cppApi_1.il2cppApi.il2cpp_class_enum_basetype(this);
}
getFieldsInfo(iter) {
return il2cppApi_1.il2cppApi.il2cpp_class_get_fields(this, iter);
}
getProperties(iter) {
return il2cppApi_1.il2cppApi.il2cpp_class_get_properties(this, iter);
}
getMethods(iter) {
return il2cppApi_1.il2cppApi.il2cpp_class_get_methods(this, iter);
}
/**
* 获取泛型参数名
* @returns {string}
*/
getGenericName() {
let type = this.getType();
let name = this.name();
if (name.indexOf("`") !== -1) {
// log("获取 Type:Il2cpp:"+this.name() +" nameSpaze:"+this.namespaze());
let il2cppTypeGetName = type.getName();
if (il2cppTypeGetName == null) {
return name;
}
let split = name.split("`");
name = split[0];
let indexOf = il2cppTypeGetName.indexOf(name);
let s = il2cppTypeGetName.substr(indexOf + name.length,
il2cppTypeGetName.length - name.length);
let genericT = "\<System.Object\>";
// log(" genericT:"+genericT);
if (s === genericT) {
return "\<T\>";
}
return s;
}
return name;
}
parent() {
return new
Il2CppClass(il2cppApi_1.il2cppApi.il2cpp_class_get_parent(this));
}
getInterfaces(iter) {
return il2cppApi_1.il2cppApi.il2cpp_class_get_interfaces(this, iter);
}
}
exports.Il2CppClass = Il2CppClass;
},{"../il2cppApi":9,"./Il2CppImage":15,"./NativeStruct":19}],11:
[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Il2CppFieldInfo = void 0;
const NativeStruct_1 = require("./NativeStruct");
const il2cppApi_1 = require("../il2cppApi");
const utils_1 = require("./utils");
const Il2CppClass_1 = require("./Il2CppClass");
class Il2CppFieldInfo extends NativeStruct_1.NativeStruct {
getFlags() {
return il2cppApi_1.il2cppApi.il2cpp_field_get_flags(this);
}
/**
* 获取变量参数类型
* @returns {Il2CppType}
*/
getType() {
return il2cppApi_1.il2cppApi.il2cpp_field_get_type(this);
}
/**
* 获取 静态常量
* @param value
*/
getStaticValue() {
let value = Memory.alloc(Process.pointerSize);
il2cppApi_1.il2cppApi.il2cpp_field_static_get_value(this, value);
return utils_1.utils.readTypeEnumValue(value, this.getType().getTypeEnum(),
this.getFiledClass());
}
/**
* 获取变量 class
* @returns {Il2CppClass}
*/
getFiledClass() {
let type = this.getType();
return il2cppApi_1.il2cppApi.il2cpp_class_from_type(type);
}
getParent() {
let il2CppClass = il2cppApi_1.il2cppApi.il2cpp_field_get_parent(this);
return new Il2CppClass_1.Il2CppClass(il2CppClass);
}
/**
* 获取变量参数的命名
* @returns {string}
*/
getFiledName() {
return il2cppApi_1.il2cppApi.il2cpp_field_get_name(this).readCString();
}
/**
* 获取偏移
* @returns {*}
*/
getOffset() {
return il2cppApi_1.il2cppApi.il2cpp_field_get_offset(this);
}
}
exports.Il2CppFieldInfo = Il2CppFieldInfo;
},{"../il2cppApi":9,"./Il2CppClass":10,"./NativeStruct":19,"./utils":21}],12:
[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Il2CppGenericContext = void 0;
const NativeStruct_1 = require("./NativeStruct");
const Il2CppGenericInst_1 = require("./Il2CppGenericInst");
class Il2CppGenericContext extends NativeStruct_1.NativeStruct {
method_inst() {
return new Il2CppGenericInst_1.Il2CppGenericInst(this.add(0x8));
}
}
exports.Il2CppGenericContext = Il2CppGenericContext;
},{"./Il2CppGenericInst":13,"./NativeStruct":19}],13:
[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Il2CppGenericInst = void 0;
const NativeStruct_1 = require("./NativeStruct");
class Il2CppGenericInst extends NativeStruct_1.NativeStruct {
type_argc() {
return this.readU32();
}
}
exports.Il2CppGenericInst = Il2CppGenericInst;
},{"./NativeStruct":19}],14:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Il2CppGenericMethod = void 0;
const NativeStruct_1 = require("./NativeStruct");
const Il2CppGenericContext_1 = require("./Il2CppGenericContext");
class Il2CppGenericMethod extends NativeStruct_1.NativeStruct {
context() {
return new Il2CppGenericContext_1.Il2CppGenericContext(this.add(0x8));
}
}
exports.Il2CppGenericMethod = Il2CppGenericMethod;
},{"./Il2CppGenericContext":12,"./NativeStruct":19}],15:
[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Il2CppImage = void 0;
const NativeStruct_1 = require("./NativeStruct");
const il2cppApi_1 = require("../il2cppApi");
const structItem_1 = require("./structItem");
const dumpconfig_1 = require("../../dumpconfig");
let il2CppImage_struct = new Array();
il2CppImage_struct.push(new structItem_1.StructItem("name", Process.pointerSize));
il2CppImage_struct.push(new structItem_1.StructItem("nameNoExt",
Process.pointerSize));
il2CppImage_struct.push(new structItem_1.StructItem("assemblyIndex",
Process.pointerSize));
il2CppImage_struct.push(new structItem_1.StructItem("typeStart", 4));
il2CppImage_struct.push(new structItem_1.StructItem("typeCount", 4));
il2CppImage_struct.push(new structItem_1.StructItem("exportedTypeStart", 4));
let kMetadataIndexBits = 22;
let kMetadataImageIndexExtraShiftBitsA = 6;
let kMetadataImageIndexExtraShiftBitsB = 4;
let kMetadataImageIndexExtraShiftBitsC = 2;
let kMetadataImageIndexExtraShiftBitsD = 0;
let kInvalidIndex = -1;
let kMetadataIndexMaskA = (1 << (kMetadataIndexBits +
kMetadataImageIndexExtraShiftBitsA)) - 1;
class Il2CppImage extends NativeStruct_1.NativeStruct {
name() {
return il2cppApi_1.il2cppApi.il2cpp_image_get_name(this).readCString();
}
token() {
return this.add(0x40).readU32();
}
IsInterpreterImage() {
let index = this.token();
// log("got token "+index);
return index !== kInvalidIndex && (index & ~kMetadataIndexMaskA) !== 0;
}
nameNoExt() {
let name1 = this.name();
return name1.replace(".dll", "");
}
typeStart() {
return this.get("typeStart").readPointer().toInt32();
}
typeCount() {
return il2cppApi_1.il2cppApi.il2cpp_image_get_class_count(this);
// return this.getOffsetTypeCount();
}
getOffsetTypeCount() {
if (dumpconfig_1.UNITY_VER === dumpconfig_1.UnityVer.V_2020) {
return this.add(24).readPointer().toInt32();
}
else {
return this.get("typeCount").readPointer().toInt32();
}
}
getClass(index) {
return il2cppApi_1.il2cppApi.il2cpp_image_get_class(this, index);
}
get(params) {
return this.add((0, structItem_1.getStructOffset)(il2CppImage_struct,
params));
}
}
exports.Il2CppImage = Il2CppImage;
},{"../../dumpconfig":3,"../il2cppApi":9,"./NativeStruct":19,"./
structItem":20}],16:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Il2CppPropertyInfo = void 0;
const NativeStruct_1 = require("./NativeStruct");
const il2cppApi_1 = require("../il2cppApi");
class Il2CppPropertyInfo extends NativeStruct_1.NativeStruct {
/**
* 获取方法信息
* @returns {MethodInfo}
*/
getMethod() {
return il2cppApi_1.il2cppApi.il2cpp_property_get_get_method(this);
}
setMethod() {
return il2cppApi_1.il2cppApi.il2cpp_property_get_set_method(this);
}
getName() {
return il2cppApi_1.il2cppApi.il2cpp_property_get_name(this).readCString();
}
}
exports.Il2CppPropertyInfo = Il2CppPropertyInfo;
},{"../il2cppApi":9,"./NativeStruct":19}],17:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Il2CppType = void 0;
const NativeStruct_1 = require("./NativeStruct");
const il2cppApi_1 = require("../il2cppApi");
const logger_1 = require("../../logger");
class Il2CppType extends NativeStruct_1.NativeStruct {
getName() {
let il2cppTypeGetName = il2cppApi_1.il2cppApi.il2cpp_type_get_name(this);
if (il2cppTypeGetName == null) {
return null;
}
else {
return il2cppTypeGetName.readCString();
}
}
getTypeEnum() {
return il2cppApi_1.il2cppApi.il2cpp_type_get_type(this);
}
byref() {
let il2cppTypeIsByref = il2cppApi_1.il2cppApi.il2cpp_type_is_byref(this);
(0, logger_1.log)(" il2cppTypeIsByref:" + il2cppTypeIsByref);
return il2cppTypeIsByref;
}
}
exports.Il2CppType = Il2CppType;
},{"../../logger":26,"../il2cppApi":9,"./NativeStruct":19}],18:
[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MethodInfo = void 0;
const NativeStruct_1 = require("./NativeStruct");
const il2cppApi_1 = require("../il2cppApi");
const logger_1 = require("../../logger");
const config_1 = require("../../config");
const Il2CppClass_1 = require("./Il2CppClass");
const Il2CppGenericMethod_1 = require("./Il2CppGenericMethod");
const METHOD_INFO_OFFSET_SLOT = 76;
class MethodInfo extends NativeStruct_1.NativeStruct {
getGenericMethod() {
return new Il2CppGenericMethod_1.Il2CppGenericMethod(this.add(0x38));
}
getFlags() {
return il2cppApi_1.il2cppApi.il2cpp_method_get_flags(this, 0);
}
getMethodPointer() {
return il2cppApi_1.il2cppApi.il2cpp_method_get_pointer(this);
}
getMethodPointerOffsetToInt() {
let methodPointer = this.getMethodPointer();
// log("methodPointer:"+methodPointer);
if (methodPointer.isNull()) {
return 0;
}
let baseAddr = Module.findBaseAddress(config_1.soName);
return methodPointer - baseAddr;
}
getMethodPointerOffset() {
let methodPointer = this.getMethodPointer();
(0, logger_1.log)("methodPointer:" + methodPointer);
if (methodPointer.isNull()) {
return "0x0";
}
let baseAddr = Module.findBaseAddress(config_1.soName);
let number = methodPointer - baseAddr;
return number.toString(16).toUpperCase();
}
getSlot() {
return this.add(METHOD_INFO_OFFSET_SLOT).readU16();
}
name() {
return il2cppApi_1.il2cppApi.il2cpp_method_get_name(this).readCString();
}
getParamCount() {
return il2cppApi_1.il2cppApi.il2cpp_method_get_param_count(this);
}
getParam(index) {
return il2cppApi_1.il2cppApi.il2cpp_method_get_param(this, index);
}
getParamName(index) {
return il2cppApi_1.il2cppApi.il2cpp_method_get_param_name(this,
index).readCString();
}
/**
* 获取返回类型
* @returns {Il2CppType}
*/
getReturnType() {
return il2cppApi_1.il2cppApi.il2cpp_method_get_return_type(this);
}
is_generic() {
return il2cppApi_1.il2cppApi.il2cpp_method_is_generic(this);
}
is_inflated() {
return il2cppApi_1.il2cppApi.il2cpp_method_is_inflated(this);
}
getClass() {
return new
Il2CppClass_1.Il2CppClass(il2cppApi_1.il2cppApi.il2cpp_method_get_class(this));
}
invoker_method() {
return this.add(0x8).readPointer();
}
}
exports.MethodInfo = MethodInfo;
},{"../../config":2,"../../logger":26,"../il2cppApi":9,"./Il2CppClass":10,"./
Il2CppGenericMethod":14,"./NativeStruct":19}],19:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NativeStruct = void 0;
class NativeStruct extends NativePointer {
constructor(pointer) {
super(pointer);
}
}
exports.NativeStruct = NativeStruct;
},{}],20:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStructOffset = exports.StructItem = void 0;
function StructItem(param, size) {
this.param = param;
this.size = size;
}
exports.StructItem = StructItem;
function getStructOffset(struct, name) {
let all = 0;
for (let i = 0; i < struct.length; i++) {
let item = struct[i];
let param = item.param;
let size = item.size;
if (param === name) {
if (i === 0) {
return 0;
}
else {
return all;
}
}
else {
all = all + size;
}
}
}
exports.getStructOffset = getStructOffset;
},{}],21:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.utils = void 0;
const Il2CppTypeEnum_1 = require("../Il2CppTypeEnum");
const tabledefs_1 = require("../tabledefs");
const Il2cppString_1 = require("../hacker/struct/Il2cppString");
exports.utils = {
readTypeEnumValue: function (pointer, typeEnum, fieldClass) {
switch (typeEnum) {
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_BOOLEAN:
return !!pointer.readS8();
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_I1:
return pointer.readS8();
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_I2:
return pointer.readS16();
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_U2:
return pointer.readU16();
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_I4:
return pointer.readS32();
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_U4:
return pointer.readU32();
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_CHAR:
return pointer.readU16();
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_I8:
return pointer.readS64();
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_U8:
return pointer.readU64();
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_R4:
return pointer.readFloat();
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_R8:
return pointer.readDouble();
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_VALUETYPE:
let enumBaseType = fieldClass.getEnumBaseType();
// log("baseType:"+enumBaseType.getTypeEnum()
+"pointer:"+pointer.readS32());
if (enumBaseType.getTypeEnum() ===
Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_I4) {
return pointer.readS32();
}
return null;
case Il2CppTypeEnum_1.Il2CppTypeEnum.IL2CPP_TYPE_STRING:
return "\"" +
Il2cppString_1.Il2cppString.parserString(pointer.readPointer()) + "\"";
default:
// log("readTypeEnumValue: unknown typeEnum:" + typeEnum);
return null;
}
},
get_method_static: function (flags) {
if (flags & tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_STATIC) {
return true;
}
else {
return false;
}
},
get_method_modifier: function (flags) {
let content;
let access = flags &
tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK;
switch (access) {
case tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_PRIVATE:
content = "private ";
break;
case tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_PUBLIC:
content = "public ";
break;
case tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_FAMILY:
content = "protected ";
break;
case tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_ASSEM:
case tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_FAM_AND_ASSEM:
content = "internal ";
break;
case tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_FAM_OR_ASSEM:
content = "protected internal ";
break;
}
if (flags & tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_STATIC) {
content = content + "static ";
}
if (flags & tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_ABSTRACT) {
content = content + "abstract ";
if ((flags & tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_VTABLE_LAYOUT_MASK)
=== tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_REUSE_SLOT) {
content = content + "override ";
}
}
else if (flags & tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_FINAL) {
if ((flags & tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_VTABLE_LAYOUT_MASK)
=== tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_REUSE_SLOT) {
content = content + "sealed override ";
}
}
else if (flags & tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_VIRTUAL) {
if ((flags & tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_VTABLE_LAYOUT_MASK)
=== tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_NEW_SLOT) {
content = content + "virtual ";
}
else {
content = content + "override ";
}
}
if (flags & tabledefs_1.Tabledefs.METHOD_ATTRIBUTE_PINVOKE_IMPL) {
content = content + "extern ";
}
return content;
}
};
},{"../Il2CppTypeEnum":7,"../hacker/struct/Il2cppString":8,"../tabledefs":22}],22:
[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tabledefs = void 0;
//---tabledefs
exports.Tabledefs = {
TYPE_ATTRIBUTE_SERIALIZABLE: 0x00002000,
TYPE_ATTRIBUTE_VISIBILITY_MASK: 0x00000007,
TYPE_ATTRIBUTE_NOT_PUBLIC: 0x00000000,
TYPE_ATTRIBUTE_PUBLIC: 0x00000001,
TYPE_ATTRIBUTE_NESTED_PUBLIC: 0x00000002,
TYPE_ATTRIBUTE_NESTED_PRIVATE: 0x00000003,
TYPE_ATTRIBUTE_NESTED_FAMILY: 0x00000004,
TYPE_ATTRIBUTE_NESTED_ASSEMBLY: 0x00000005,
TYPE_ATTRIBUTE_NESTED_FAM_AND_ASSEM: 0x00000006,
TYPE_ATTRIBUTE_NESTED_FAM_OR_ASSEM: 0x00000007,
TYPE_ATTRIBUTE_ABSTRACT: 0x00000080,
TYPE_ATTRIBUTE_SEALED: 0x00000100,
TYPE_ATTRIBUTE_SPECIAL_NAME: 0x00000400,
TYPE_ATTRIBUTE_CLASS_SEMANTIC_MASK: 0x00000020,
TYPE_ATTRIBUTE_CLASS: 0x00000000,
TYPE_ATTRIBUTE_INTERFACE: 0x00000020,
FIELD_ATTRIBUTE_FIELD_ACCESS_MASK: 0x0007,
FIELD_ATTRIBUTE_COMPILER_CONTROLLED: 0x0000,
FIELD_ATTRIBUTE_PRIVATE: 0x0001,
FIELD_ATTRIBUTE_FAM_AND_ASSEM: 0x0002,
FIELD_ATTRIBUTE_ASSEMBLY: 0x0003,
FIELD_ATTRIBUTE_FAMILY: 0x0004,
FIELD_ATTRIBUTE_FAM_OR_ASSEM: 0x0005,
FIELD_ATTRIBUTE_PUBLIC: 0x0006,
FIELD_ATTRIBUTE_STATIC: 0x0010,
FIELD_ATTRIBUTE_INIT_ONLY: 0x0020,
FIELD_ATTRIBUTE_LITERAL: 0x0040,
FIELD_ATTRIBUTE_NOT_SERIALIZED: 0x0080,
FIELD_ATTRIBUTE_SPECIAL_NAME: 0x0200,
FIELD_ATTRIBUTE_PINVOKE_IMPL: 0x2000,
/* For runtime use only */
FIELD_ATTRIBUTE_RESERVED_MASK: 0x9500,
FIELD_ATTRIBUTE_RT_SPECIAL_NAME: 0x0400,
FIELD_ATTRIBUTE_HAS_FIELD_MARSHAL: 0x1000,
FIELD_ATTRIBUTE_HAS_DEFAULT: 0x8000,
FIELD_ATTRIBUTE_HAS_FIELD_RVA: 0x0100,
/*
* Method Attributes (22.1.9)
*/
METHOD_IMPL_ATTRIBUTE_CODE_TYPE_MASK: 0x0003,
METHOD_IMPL_ATTRIBUTE_IL: 0x0000,
METHOD_IMPL_ATTRIBUTE_NATIVE: 0x0001,
METHOD_IMPL_ATTRIBUTE_OPTIL: 0x0002,
METHOD_IMPL_ATTRIBUTE_RUNTIME: 0x0003,
METHOD_IMPL_ATTRIBUTE_MANAGED_MASK: 0x0004,
METHOD_IMPL_ATTRIBUTE_UNMANAGED: 0x0004,
METHOD_IMPL_ATTRIBUTE_MANAGED: 0x0000,
METHOD_IMPL_ATTRIBUTE_FORWARD_REF: 0x0010,
METHOD_IMPL_ATTRIBUTE_PRESERVE_SIG: 0x0080,
METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL: 0x1000,
METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED: 0x0020,
METHOD_IMPL_ATTRIBUTE_NOINLINING: 0x0008,
METHOD_IMPL_ATTRIBUTE_MAX_METHOD_IMPL_VAL: 0xffff,
METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK: 0x0007,
METHOD_ATTRIBUTE_COMPILER_CONTROLLED: 0x0000,
METHOD_ATTRIBUTE_PRIVATE: 0x0001,
METHOD_ATTRIBUTE_FAM_AND_ASSEM: 0x0002,
METHOD_ATTRIBUTE_ASSEM: 0x0003,
METHOD_ATTRIBUTE_FAMILY: 0x0004,
METHOD_ATTRIBUTE_FAM_OR_ASSEM: 0x0005,
METHOD_ATTRIBUTE_PUBLIC: 0x0006,
METHOD_ATTRIBUTE_STATIC: 0x0010,
METHOD_ATTRIBUTE_FINAL: 0x0020,
METHOD_ATTRIBUTE_VIRTUAL: 0x0040,
METHOD_ATTRIBUTE_HIDE_BY_SIG: 0x0080,
METHOD_ATTRIBUTE_VTABLE_LAYOUT_MASK: 0x0100,
METHOD_ATTRIBUTE_REUSE_SLOT: 0x0000,
METHOD_ATTRIBUTE_NEW_SLOT: 0x0100,
METHOD_ATTRIBUTE_STRICT: 0x0200,
METHOD_ATTRIBUTE_ABSTRACT: 0x0400,
METHOD_ATTRIBUTE_SPECIAL_NAME: 0x0800,
METHOD_ATTRIBUTE_PINVOKE_IMPL: 0x2000,
METHOD_ATTRIBUTE_UNMANAGED_EXPORT: 0x0008,
/*
* For runtime use only
*/
METHOD_ATTRIBUTE_RESERVED_MASK: 0xd000,
METHOD_ATTRIBUTE_RT_SPECIAL_NAME: 0x1000,
METHOD_ATTRIBUTE_HAS_SECURITY: 0x4000,
METHOD_ATTRIBUTE_REQUIRE_SEC_OBJECT: 0x8000,
//Il2CppMetadataUsage
kIl2CppMetadataUsageInvalid: 0x0,
kIl2CppMetadataUsageTypeInfo: 0x1,
kIl2CppMetadataUsageIl2CppType: 0x2,
kIl2CppMetadataUsageMethodDef: 0x3,
kIl2CppMetadataUsageFieldInfo: 0x4,
kIl2CppMetadataUsageStringLiteral: 0x5,
kIl2CppMetadataUsageMethodRef: 0x6,
IL2CPP_TYPE_END: 0x00,
IL2CPP_TYPE_VOID: 0x01,
IL2CPP_TYPE_BOOLEAN: 0x02,
IL2CPP_TYPE_CHAR: 0x03,
IL2CPP_TYPE_I1: 0x04,
IL2CPP_TYPE_U1: 0x05,
IL2CPP_TYPE_I2: 0x06,
IL2CPP_TYPE_U2: 0x07,
IL2CPP_TYPE_I4: 0x08,
IL2CPP_TYPE_U4: 0x09,
IL2CPP_TYPE_I8: 0x0a,
IL2CPP_TYPE_U8: 0x0b,
IL2CPP_TYPE_R4: 0x0c,
IL2CPP_TYPE_R8: 0x0d,
IL2CPP_TYPE_STRING: 0x0e,
IL2CPP_TYPE_PTR: 0x0f,
IL2CPP_TYPE_BYREF: 0x10,
IL2CPP_TYPE_VALUETYPE: 0x11,
IL2CPP_TYPE_CLASS: 0x12,
IL2CPP_TYPE_VAR: 0x13,
IL2CPP_TYPE_ARRAY: 0x14,
IL2CPP_TYPE_GENERICINST: 0x15,
IL2CPP_TYPE_TYPEDBYREF: 0x16,
IL2CPP_TYPE_I: 0x18,
IL2CPP_TYPE_U: 0x19,
IL2CPP_TYPE_FNPTR: 0x1b,
IL2CPP_TYPE_OBJECT: 0x1c,
IL2CPP_TYPE_SZARRAY: 0x1d,
IL2CPP_TYPE_MVAR: 0x1e,
IL2CPP_TYPE_CMOD_REQD: 0x1f,
IL2CPP_TYPE_CMOD_OPT: 0x20,
IL2CPP_TYPE_INTERNAL: 0x21,
IL2CPP_TYPE_MODIFIER: 0x40,
IL2CPP_TYPE_SENTINEL: 0x41,
IL2CPP_TYPE_PINNED: 0x45,
IL2CPP_TYPE_ENUM: 0x55
};
},{}],23:[function(require,module,exports){
(function (setImmediate){(function (){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const safeSelf_1 = require("./safeSelf");
const dumper_1 = require("./dumper");
setImmediate(main);
function main() {
// init_array 通用模板的注入
safeSelf_1.SafeSelf.start();
dumper_1.dumper.start();
}
}).call(this)}).call(this,require("timers").setImmediate)
},{"./dumper":4,"./safeSelf":27,"timers":29}],24:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IOSUtils = void 0;
exports.IOSUtils = {
stringToU16Bytes: function (str) {
var byteArray = [];
for (var i = 0; i < str.length; i++) {
var charCode = str.charCodeAt(i);
byteArray.push(charCode & 0xFF); // 获取低 8 位
byteArray.push(0x0);
}
return byteArray;
},
getDocumentDir: function () {
let nativePointer = Module.findExportByName(null,
"NSSearchPathForDirectoriesInDomains");
let NSSearchPathForDirectoriesInDomains = new NativeFunction(nativePointer,
"pointer", ["int", "int", "int"]);
var NSDocumentDirectory = 9;
var NSUserDomainMask = 1;
var npdirs = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, 1);
return ObjC.Object(npdirs).objectAtIndex_(0).toString();
},
};
},{}],25:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.linkerHelper = void 0;
const logger_1 = require("../logger");
const dumpconfig_1 = require("../dumpconfig");
function resolveLinkerSymbol(moduleName, symbolName) {
let module = Process.findModuleByName(moduleName);
let moduleSymbolDetails = module.enumerateSymbols();
for (let i = 0; i < moduleSymbolDetails.length; i++) {
if (moduleSymbolDetails[i].name === symbolName) {
return moduleSymbolDetails[i].address;
}
}
return address;
}
exports.linkerHelper = {
getIl2CppHandle: function () {
// linker64 arm64
const solist_get_headAddr = resolveLinkerSymbol("linker64",
'__dl__Z15solist_get_headv');
const solist_get_somainAddr = resolveLinkerSymbol("linker64",
'__dl__Z17solist_get_somainv');
const solist_get_head = new NativeFunction(solist_get_headAddr, 'pointer',
[]);
const solist_get_somain = new NativeFunction(solist_get_somainAddr,
'pointer', []);
const soinfo_get_realpath = new
NativeFunction(resolveLinkerSymbol("linker64", '__dl__ZNK6soinfo12get_realpathEv'),
'pointer', ['pointer']);
const soinfo_to_handle = new NativeFunction(resolveLinkerSymbol("linker64",
'__dl__ZN6soinfo9to_handleEv'), 'pointer', ['pointer']);
// 调用函数以获取 solist 的头部和 somain
const solist_head = solist_get_head();
const somain = solist_get_somain();
// 创建存储 soinfo_t 对象的数组
let linker_solist = [];
// 计算结构体成员 'next' 的偏移量
let STRUCT_OFFSET_solist_next = 0;
for (let i = 0; i < 1024 / Process.pointerSize; i++) {
if (Memory.readPointer(solist_head.add(i *
Process.pointerSize)).equals(somain)) {
STRUCT_OFFSET_solist_next = i * Process.pointerSize;
break;
}
}
// 根据 'next' 的偏移量遍历链表
let current = solist_head;
while (!current.isNull()) {
linker_solist.push(current);
current = Memory.readPointer(current.add(STRUCT_OFFSET_solist_next));
}
// 打印结果
console.log(`Found ${linker_solist.length} soinfo_t objects.`);
let il2cpphandle = null;
linker_solist.forEach((soinfo, index) => {
const realpath = soinfo_get_realpath(soinfo);
// log("realpath " + realpath.readCString());
if (realpath.readCString().includes(dumpconfig_1.soName)) {
//转换 handle
const handle = soinfo_to_handle(soinfo);
(0, logger_1.log)("got il2cpp handle " + handle);
il2cpphandle = handle;
}
});
return il2cpphandle;
}
};
},{"../dumpconfig":3,"../logger":26}],26:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogColor = exports.logColor = exports.logHHexLength = exports.logHHex =
exports.log4Android = exports.log4AndroidE = exports.log4AndroidW =
exports.log4AndroidI = exports.log4AndroidV = exports.log4AndroidD = exports.log =
void 0;
const DEBUG = false;
const INTOOLS = false;
function log(msg) {
if (DEBUG) {
log4Android(msg);
}
else {
console.log(msg);
}
}
exports.log = log;
function log4AndroidD(msg, tag) {
let log = "android.util.Log";
let log_cls = Java.use(log);
log_cls.d(tag, msg);
}
exports.log4AndroidD = log4AndroidD;
function log4AndroidV(msg, tag) {
let log = "android.util.Log";
let log_cls = Java.use(log);
log_cls.v(tag, msg);
}
exports.log4AndroidV = log4AndroidV;
function log4AndroidI(msg, tag) {
let log = "android.util.Log";
let log_cls = Java.use(log);
log_cls.i(tag, msg);
}
exports.log4AndroidI = log4AndroidI;
function log4AndroidW(msg, tag) {
let log = "android.util.Log";
let log_cls = Java.use(log);
log_cls.w(tag, msg);
}
exports.log4AndroidW = log4AndroidW;
function log4AndroidE(msg, tag) {
let log = "android.util.Log";
let log_cls = Java.use(log);
log_cls.e(tag, msg);
}
exports.log4AndroidE = log4AndroidE;
function log4Android(msg) {
let log = "android.util.Log";
let log_cls = Java.use(log);
log_cls.w("Dumper", msg);
}
exports.log4Android = log4Android;
function logHHex(pointer) {
let s = hexdump(pointer, {
offset: 0,
length: 64,
header: true,
ansi: true
});
console.log(s);
}
exports.logHHex = logHHex;
function logHHexLength(pointer, length) {
console.log(hexdump(pointer, {
offset: 0,
length: length,
header: true,
ansi: true
}));
}
exports.logHHexLength = logHHexLength;
function logColor(message, type) {
if (DEBUG) {
log4Android(message);
return;
}
if (INTOOLS) {
log(message);
return;
}
if (type == undefined) {
log(message);
return;
}
switch (type) {
case exports.LogColor.WHITE:
log(message);
break;
case exports.LogColor.RED:
console.error(message);
break;
case exports.LogColor.YELLOW:
console.warn(message);
break;
default:
console.log("\x1b[" + type + "m" + message + "\x1b[0m");
break;
}
}
exports.logColor = logColor;
exports.LogColor = {
WHITE: 0,
RED: 1,
YELLOW: 3,
C31: 31,
C32: 32,
C33: 33,
C34: 34,
C35: 35,
C36: 36,
C41: 41,
C42: 42,
C43: 43,
C44: 44,
C45: 45,
C46: 46,
C90: 90,
C91: 91,
C92: 92,
C93: 93,
C94: 94,
C95: 95,
C96: 96,
C97: 97,
C100: 100,
C101: 101,
C102: 102,
C103: 103,
C104: 104,
C105: 105,
C106: 106,
C107: 107
};
},{}],27:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SafeSelf = void 0;
exports.SafeSelf = {
start: function () {
let connect = Module.findExportByName(null, "connect");
if (connect != null) {
Interceptor.attach(connect, {
onEnter: function (args) {
let arg = args[1];
let port = arg.add(0x2).readUShort();
if (port === 41577
|| port === 35421) {
//写值
// logHHex(arg)
arg.add(0x2).writeUShort(26151);
}
}
});
}
}
};
},{}],28:[function(require,module,exports){
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout)
{
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't
trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the
global object for 'this', hopfully our context correct otherwise it will throw a
global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) &&
clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't
trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the
global object for 'this', hopfully our context correct otherwise it will throw a
global error.
// Some versions of I.E. have different rules for clearTimeout vs
setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
},{}],29:[function(require,module,exports){
(function (setImmediate,clearImmediate){(function (){
var nextTick = require('process/browser.js').nextTick;
var apply = Function.prototype.apply;
var slice = Array.prototype.slice;
var immediateIds = {};
var nextImmediateId = 0;
exports.setTimeout = function() {
return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
};
exports.setInterval = function() {
return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
};
exports.clearTimeout =
exports.clearInterval = function(timeout) { timeout.close(); };
// Does not start the time, just sets up the members needed.
exports.enroll = function(item, msecs) {
clearTimeout(item._idleTimeoutId);
item._idleTimeout = msecs;
};
exports.unenroll = function(item) {
clearTimeout(item._idleTimeoutId);
item._idleTimeout = -1;
};
// That's not how node.js implements it but the exposed api is the same.
exports.setImmediate = typeof setImmediate === "function" ? setImmediate :
function(fn) {
var id = nextImmediateId++;
var args = arguments.length < 2 ? false : slice.call(arguments, 1);
immediateIds[id] = true;
nextTick(function onNextTick() {
if (immediateIds[id]) {
// fn.call() is faster so we optimize for the common use-case
// @see http://jsperf.com/call-apply-segu
if (args) {
fn.apply(null, args);
} else {
fn.call(null);
}
// Prevent ids from leaking
exports.clearImmediate(id);
}
});
return id;
};
},{"process/browser.js":28,"timers":29}]},{},[23])