Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About attaching to a running process #2468

Closed
moliam opened this issue Jun 6, 2017 · 1 comment
Closed

About attaching to a running process #2468

moliam opened this issue Jun 6, 2017 · 1 comment

Comments

@moliam
Copy link

moliam commented Jun 6, 2017

Lately I'm working on adopting DR as a component in software testing tool(on x64 linux). Unfortunately, when using DR to attach to a running process, the following error occured:
ERROR : attaching to running processes is not yet implemented.
Moreover, instrument a process from the beginning with options "-use_ptrace" also failed, and the error reads:
<Application (8095). Unable to place the heap in a manner that satisfies all 32bit displacement requirements. Check -vm_base, -vm_offset, -heap_in_lower_4GB, and dll preferred base addresses for issues.>
(The second problem can be mitigated by setting "heap_in_lower_4GB" value to true. But only mitigated, still unsuccessful instrumentation. )

But fortunately, after reviewing the source code of DR, I found that in fact almost all the codes attaching-to-running-process needs are already there. And then I modified and added several lines of code and realize this function, at least on my computer.
There are only three aspects that I modified:

  1. A stable control of a running process. That is, the mechanism of pausing a running process and running shellcode.
  2. Some environment variables must be commonly known(I don't use "shared" here because they are two distinct processes) between the instrumented process and drrun. In the current version, most of the environment vars are shared via execv, where child process can inherit from the parent(drrun). This is not suitable for attaching to a running process and leads to malfunctions.
  3. In the init func of libdrpreload.so, just return 0.

So I am interested in what problems are the authors encoutering when realizing the attaching mechanism. Maybe there are some deeper problems I don't know, because I only reviewed the code for around three days. If you are interested in my naive implementation of attaching to a running process, I can commit that.

@derekbruening
Copy link
Contributor

There are no deep problems on UNIX: the main pieces are pretty much there as parts of other features, but nobody ever put them together as a first-class supported feature, just because nobody ever needed it with high enough priority. We would be happy to accept contributions that finish it off. Issue #38 covers the feature. (This issue seems more like an email to dynamorio-devs -- closing as a dup. Please submit patches with #38 as the issue.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants