DynamoRIO / DynamoRIO/dynamorio

add API support for calling the original function when replacing

Open
#497 4 comments 0 reactions 0 assignees View on GitHub
Component-API help wanted Migrated Priority-Medium Type-Feature Usability
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

_From [bruen...@google.com](https://code.google.com/u/109494838902877177630/) on June 15, 2011 10:44:59_

It's a little too complex to call an additional function as the
application. Here's what I came up with (untested):

Pick a target app bb: some callee entrance is probably best to avoid reg
spills. Keep just the first of the original instrs in that bb (to avoid
recursing) and throw out the rest (presumably the first is not a control
transfer). Put your call as the second (and final) instr. If the first
instr is at least as long as your call, you can set the translation field
such that the mangled return address will be the address of the second
original instr. Otherwise, you can either include more initial instrs, or
split the call into a push and a jump.

The complexity comes from the restrictions on the ctis in a bb and the
restrictions on the translation fields staying within the original bb
bounds.

Perhaps the simplest way to support this would be to have drwrap_replace()
provide support for the replacement code to call the original w/o
recursing. This should be much simpler than a general
call-app-code-from-client-code feature.

_Original issue: http://code.google.com/p/dynamorio/issues/detail?id=497_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.