DynamoRIO / DynamoRIO/dynamorio
Problems with function wrapping when multiple addresses for the same name exist
- Dominant language
- C
- Stars
- 3.2k
- Forks
- 629
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 31
Description
**Describe the bug**
Hi there! Firstly,thanks for your great work. But recently I tried to use dynamorio to wrap functions, like this:
```
static void module_load_event(void *drcontext, const module_data_t *mod, bool loaded) {
dr_printf("Module loaded: %s\n", mod->full_path);
dr_printf("total functions: %d\n", num_functions);
for (int i = 0; i < num_functions; i++) {
app_pc towrap = (app_pc)dr_get_proc_address(mod->handle, function_names[i]);
if (towrap != NULL) {
dr_printf("Wrapping function: %s at address %p\n", function_names[i], towrap);
drwrap_wrap_ex(towrap, generic_wrap_pre, generic_wrap_post, (void *)function_names[i], 0);
} else {
dr_printf("Failed to locate function: %s in module %s\n", function_names[i], mod->full_path);
}
}
}
```
the output is:
```
Module loaded: /usr/lib/x86_64-linux-gnu/libc.so.6
total functions: 3
Wrapping function: memcpy at address 0x00007f0dfca0ecb0
Wrapping function: printf at address 0x00007f0dfc9be5b0
Wrapping function: strcpy at address 0x00007f0dfcac1b70
```
the outputs shows that dynamorio can wrap functions like 'memcpy' 'strcpy' and 'printf' but the problem is that when I do
```
static void generic_wrap_pre(void *wrapcxt, void **user_data) {
const char *func_name = (const char *)*user_data;
dr_printf("Function %s is called\n", func_name); // Added logging
call_stack.push(func_name);
}
```
and when 'memcpy' 'strcpy' and 'printf' are called in target binary, only `printf` can be traced, other two can't be traced..
**To Reproduce**
Steps to reproduce the behavior:
Like above
my command is:
` ../DynamoRIO-Linux-10.0.19811/bin64/drrun -c client_printGraph.so -- test/buffer_overflow`
**Versions**
- What version of DynamoRIO are you using? master version
- Does the latest build from https://github.com/DynamoRIO/dynamorio/releases solve the problem? no
- What operating system version are you running on? ("Windows 10" is *not* sufficient: give the release number.) Linux 6.1.0-23-amd64
- Is your application 32-bit or 64-bit? 64bit
Contributor guide
Assessment
This issue has not been assessed yet.