Project

General

Profile

« Previous | Next » 

Revision 85937f3a

Added by tenderlovemaking (Aaron Patterson) over 2 years ago

[ruby/fiddle] Add a helper method for reading/writing memory
(https://github.com/ruby/fiddle/pull/123)

This commit adds two new methods, Fiddle::Pointer.read and
Fiddle::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:

Fiddle::Pointer.read(address, 5) # read 5 bytes 

We can also write to an address without allocating a Pointer object:

Fiddle::Pointer.write(address, "bytes") # write 5 bytes 

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.


https://github.com/ruby/fiddle/commit/04238cefed

Co-authored-by: Sutou Kouhei