From f7fcc7c0723a876054cf2200753b32c32a6a867f Mon Sep 17 00:00:00 2001 From: Kirill Batuzov Date: Mon, 24 Feb 2025 15:25:46 +0300 Subject: [PATCH] Update wrapFunction example 1. Search for the function with the requested name instead of the empty name. 2. Save updated file. --- dyninstAPI/wrapFunction.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dyninstAPI/wrapFunction.cpp b/dyninstAPI/wrapFunction.cpp index 67fd327..6c3d694 100644 --- a/dyninstAPI/wrapFunction.cpp +++ b/dyninstAPI/wrapFunction.cpp @@ -37,7 +37,7 @@ int main(int argc, char** argv) { auto find_func = [appImage](std::string const& name) -> BPatch_function* { std::vector funcs; - appImage->findFunction("", funcs); + appImage->findFunction(name.c_str(), funcs); if(funcs.size() != 1) { std::cerr << "Unable to find '" << name << "'\n"; return nullptr; @@ -71,4 +71,6 @@ int main(int argc, char** argv) { } appBin->wrapFunction(original_malloc, fast_malloc, syms[0]); + std::string new_name = std::string(argv[1]) + ".rewr"; + appBin->writeFile(new_name.c_str()); }