diff options
| author | jakob <jakob@memeware.net> | 2017-08-29 16:02:44 -0400 |
|---|---|---|
| committer | jakob <jakob@memeware.net> | 2017-08-29 16:02:44 -0400 |
| commit | 749c1d3e310a3df5d6f2ce10135129aa3f6142b7 (patch) | |
| tree | 6c7b00c7b9b1ec462bb5e63ff765754df183a860 /hypodermic/ptrace.py | |
| parent | a0aac5609c87443ea12d04ffb280234c24d13e3f (diff) | |
setup.py and the makefile both install the wrapper library properly now
Diffstat (limited to 'hypodermic/ptrace.py')
| -rw-r--r-- | hypodermic/ptrace.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/hypodermic/ptrace.py b/hypodermic/ptrace.py index 7a14dea..f54d982 100644 --- a/hypodermic/ptrace.py +++ b/hypodermic/ptrace.py @@ -18,6 +18,7 @@ """ctypes wrapper for ptrace.""" import ctypes +import os.path class Process(object): @@ -38,8 +39,9 @@ class Process(object): Raises: TypeError: If the pid argument is not an int, or if the path argument is not a string. - OSError: If the pid cannot be attached to, or if the process - could not be created for the given binary. + OSError: If the pid cannot be attached to, if the process could + not be created for the given binary, or if any wrapper + libraries could not be loaded. """ def __init__(self, pid=0, path=""): @@ -64,7 +66,17 @@ class Process(object): self.detach() def _load_ffi_methods(self): - self._so = ctypes.cdll.LoadLibrary("/tmp/libhypodermicw.so") + # setuptools/cython hack. + script_path = os.path.abspath(os.path.dirname(__file__)) + + for filename in os.listdir(os.path.join(script_path, "..")): + if filename.startswith("libhypodermicw"): + lib_path = os.path.join(script_path, "..", filename) + break + else: + raise OSError("Could not find wrapper library.") + + self._so = ctypes.cdll.LoadLibrary(lib_path) self._new_proc = self._so.new_proc self._attach = self._so.attach self._detach = self._so.detach |