| 2 | const utils = require("../utils/utils") |
| 3 | |
| 4 | function dump_lua(package_name, module_dlopen,sendflag) { |
| 5 | const app_path = `/data/data/${package_name}/luadump/`; |
| 6 | Interceptor.attach(module_dlopen.findExportByName("luaL_loadbufferx"), { |
| 7 | onEnter: function (args) { |
| 8 | const name = Memory.readCString(args[3]); |
| 9 | if (name.length < 50 && name.length > 0) { |
| 10 | this.Path = name.substring(0, name.lastIndexOf("/")); |
| 11 | this.file = name.substring(name.lastIndexOf("/") + 1, name.length); |
| 12 | if (utils.access(app_path + this.Path) == -1) { |
| 13 | utils.folder_mkdirs(this.Path, app_path); |
| 14 | } |
| 15 | if (utils.access(app_path + name) == 0) { |
| 16 | if (name != "chunk" && name != "Init") { |
| 17 | const data = utils.readFile(app_path + name); |
| 18 | if(data.data == null){ |
| 19 | helper.send_message("error","open "+app_path + name+" failed !") |
| 20 | return |
| 21 | } |
| 22 | args[2] = new NativePointer(ptr(data.size)); |
| 23 | args[1].writeByteArray(data.data.readByteArray(data.size)); |
| 24 | helper.send_message(sendflag, "load lua file :"+app_path + name) |
| 25 | } |
| 26 | } else { |
| 27 | utils.Dump(app_path + name, args[1], args[2].toInt32()); |
| 28 | helper.send_message(sendflag, "dump :"+app_path + name) |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | }) |
| 33 | } |
| 34 | |
| 35 | module.exports = { |
| 36 | dump_lua |