Class: Toaster::PtraceUtil
- Inherits:
-
Object
- Object
- Toaster::PtraceUtil
- Defined in:
- lib/toaster/state/ptrace_util.rb
Constant Summary collapse
- WORD_SIZE =
8
Class Method Summary collapse
Class Method Details
.get_filename_for_fd(pid, fd) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/toaster/state/ptrace_util.rb', line 38 def self.get_filename_for_fd(pid, fd) path = "/proc/#{pid}/fd/#{fd}" begin return File.readlink(path) rescue return nil end end |
.read_string(ptrace_target, addr) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/toaster/state/ptrace_util.rb', line 17 def self.read_string(ptrace_target, addr) str = "" do_continue = true iter = 0 while do_continue v = ptrace_target.text.peek(addr + (WORD_SIZE * iter)) (0..7).each do |shift_bytes| shift = 8 * shift_bytes byte = (v >> shift) & 0xFF if byte == 0 #puts "END OF STRING!!" do_continue = false break end str += byte.chr end iter += 1 end return str end |