Skip to content

Commit

Permalink
Keep the handle active while dump the executable
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryQuan committed Oct 15, 2023
1 parent c4f1739 commit 358d50d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
5 changes: 3 additions & 2 deletions Sources/appdecrypt/dump.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ func mremap_encrypted(_: UnsafeMutableRawPointer, _: Int, _: UInt32, _: UInt32,

class Dump {
let consoleIO = ConsoleIO()
let linkTool = LinkTool()
func staticMode() {
if CommandLine.argc < 3 {
consoleIO.printUsage()
Expand Down Expand Up @@ -106,7 +105,8 @@ class Dump {

for (i, sourcePath) in needDumpFilePaths.enumerated() {
let targetPath = dumpedFilePaths[i]
linkTool.launch(binary: targetPath)
// Please see https://github.com/NyaMisty/fouldecrypt/issues/15#issuecomment-1722561492
let handle = dlopen(targetPath, RTLD_LAZY | RTLD_GLOBAL)
Dump.mapFile(path: sourcePath, mutable: false) { base_size, base_descriptor, base_error, base_raw in
if let base = base_raw {
Dump.mapFile(path: targetPath, mutable: true) { dupe_size, dupe_descriptor, dupe_error, dupe_raw in
Expand Down Expand Up @@ -156,6 +156,7 @@ class Dump {
consoleIO.writeMessage("Read \(sourcePath) Fail with \(base_error)", to: .error)
}
}
dlclose(handle)
}
}

Expand Down
17 changes: 0 additions & 17 deletions Sources/appdecrypt/linktool.swift

This file was deleted.

0 comments on commit 358d50d

Please sign in to comment.