MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / seek

Method seek

rust/src/binary_reader.rs:103–123  ·  view source on GitHub ↗

Seek to the specified position.

(&mut self, pos: SeekFrom)

Source from the content-addressed store, hash-verified

101impl Seek for BinaryReader {
102 /// Seek to the specified position.
103 fn seek(&mut self, pos: SeekFrom) -> std::io::Result<u64> {
104 match pos {
105 SeekFrom::Current(offset) => self.seek_to_relative_offset(offset),
106 SeekFrom::Start(offset) => self.seek_to_offset(offset),
107 SeekFrom::End(end_offset) => {
108 // We do NOT need to add the image base here as
109 // the reader (unlike the writer) can set the virtual base.
110 let offset =
111 self.view
112 .len()
113 .checked_add_signed(end_offset)
114 .ok_or(std::io::Error::new(
115 ErrorKind::Other,
116 "Seeking from end overflowed",
117 ))?;
118 self.seek_to_offset(offset);
119 }
120 };
121
122 Ok(self.offset())
123 }
124}
125
126impl Read for BinaryReader {

Callers 7

cb_get_lengthMethod · 0.45
cb_readMethod · 0.45
cb_writeMethod · 0.45
test_binary_reader_seekFunction · 0.45
test_binary_reader_readFunction · 0.45
test_binary_writer_seekFunction · 0.45
test_binary_writer_writeFunction · 0.45

Calls 4

seek_to_offsetMethod · 0.45
lenMethod · 0.45
offsetMethod · 0.45

Tested by 4

test_binary_reader_seekFunction · 0.36
test_binary_reader_readFunction · 0.36
test_binary_writer_seekFunction · 0.36
test_binary_writer_writeFunction · 0.36