Skip to content

Commit 46bd0f3

Browse files
authored
Update wrapFunction example (#62)
1. Search for the function with the requested name instead of the empty name. 2. Save updated file.
1 parent 3c2009c commit 46bd0f3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

dyninstAPI/wrapFunction.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int main(int argc, char** argv) {
3737

3838
auto find_func = [appImage](std::string const& name) -> BPatch_function* {
3939
std::vector<BPatch_function*> funcs;
40-
appImage->findFunction("", funcs);
40+
appImage->findFunction(name.c_str(), funcs);
4141
if(funcs.size() != 1) {
4242
std::cerr << "Unable to find '" << name << "'\n";
4343
return nullptr;
@@ -71,4 +71,6 @@ int main(int argc, char** argv) {
7171
}
7272

7373
appBin->wrapFunction(original_malloc, fast_malloc, syms[0]);
74+
std::string new_name = std::string(argv[1]) + ".rewr";
75+
appBin->writeFile(new_name.c_str());
7476
}

0 commit comments

Comments
 (0)