Closed tenderlove closed 1 year ago
Hmm. Fiddle::Pointer[value] and Fiddle::Pointer[address, length] may be confused. How about Fiddle::Pointer.read/Fiddle::Pointer.write (like IO.read/IO.write) instead?
That sounds good to me. I wish we could use []
and []=
, but I agree it's confusing.
This commit adds two new methods,
Fiddle::Pointer.read
andFiddle::Pointer.write
. Both methods take an address, and will read or write bytes at that address respectively.For example we can read from an address without making a Pointer object:
We can also write to an address without allocating a Pointer object:
This allows us to read / write memory at arbitrary addresses without instantiating a new
Fiddle::Pointer
object.Examples where this API would be useful 1 2 3
I also added a writer method for the same reasons as the reader.