Sha256: 949ac071087a5268065493cdc0ef5778fbe75c4967b760a0d3cdf24a913aa59a
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
class Ragweed::Process include Ragweed attr_reader :pid def initialize(pid); @pid = pid; end ## Read/write ranges of data or fixnums to/from the process by address. def read(off, sz=4096) a = [] max = off+sz while off < max a.push(Ragweed::Wraptux::ptrace(Ragweed::Wraptux::Ptrace::PEEK_TEXT, @pid, off, 0)) return a.pack('L*') if a.last == -1 and FFI.errno != 0 off+=4 end a.pack('L*') end ## ptrace sucks, writing 8 or 16 bytes will probably ## result in failure unless you PTRACE_POKE first and ## get the rest of the original value at the address def write(off, data) while off < data.size Ragweed::Wraptux::ptrace(Ragweed::Wraptux::Ptrace::POKE_TEXT, @pid, off, data[off,4].unpack('L').first) off += 4 end end def read32(off); read(off, 4).unpack("L").first; end def read16(off); read(off, 2).unpack("v").first; end def read8(off); read(off, 1)[0]; end def write32(off, v); write(off, [v].pack("L")); end def write16(off, v); write(off, [v].pack("v")); end def write8(off, v); write(off, v.chr); end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ragweed-0.2.3-java | lib/ragweed/wraptux/process.rb |
ragweed-0.2.3 | lib/ragweed/wraptux/process.rb |