From 1bd42a73e612f50c68d802acda674c21a30e980c Mon Sep 17 00:00:00 2001 From: kat Date: Thu, 18 May 2023 12:44:11 -0400 Subject: Add ReadPointer to BinaryReader class --- binaryninjaapi.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 21549c92..f4b1d9dc 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -5516,6 +5516,14 @@ namespace BinaryNinja { */ uint64_t Read64(); + /*! Read a pointer (size of BinaryView::GetAddressSize()) from the current cursor position and advance + and advance it that many bytes + + \throws ReadException + \return The value that was read + */ + uint64_t ReadPointer(); + /*! Read a uint16_t from the current cursor position, explicitly as a little endian value, and advance the cursor by 4 bytes @@ -5540,6 +5548,14 @@ namespace BinaryNinja { */ uint64_t ReadLE64(); + /*! Read a pointer (size of BinaryView::GetAddressSize()) as little-endian from the current cursor + position and advance and advance it that many bytes + + \throws ReadException + \return The value that was read + */ + uint64_t ReadLEPointer(); + /*! Read a uint16_t from the current cursor position, explicitly as a big endian value, and advance the cursor by 4 bytes @@ -5564,6 +5580,14 @@ namespace BinaryNinja { */ uint64_t ReadBE64(); + /*! Read a pointer (size of BinaryView::GetAddressSize()) as big-endian from the current cursor + position and advance and advance it that many bytes + + \throws ReadException + \return The value that was read + */ + uint64_t ReadBEPointer(); + /*! Try reading a value, returning false whenever that read fails \param dest Address to write the bytes to @@ -5616,6 +5640,13 @@ namespace BinaryNinja { */ bool TryRead64(uint64_t& result); + /*! Try reading a pointer (size of BinaryView::GetAddressSize()) + + \param result Reference to a uint64_t to write to + \return Whether the read succeeded. + */ + bool TryReadPointer(uint64_t& result); + /*! Try reading a uint16_t, explicitly as little endian \param result Reference to a uint16_t to write to @@ -5637,6 +5668,13 @@ namespace BinaryNinja { */ bool TryReadLE64(uint64_t& result); + /*! Try reading a pointer (size of BinaryView::GetAddressSize()) as little-endian + + \param result Reference to a uint64_t to write to + \return Whether the read succeeded. + */ + bool TryReadLEPointer(uint64_t& result); + /*! Try reading a uint16_t, explicitly as big endian \param result Reference to a uint16_t to write to @@ -5658,6 +5696,13 @@ namespace BinaryNinja { */ bool TryReadBE64(uint64_t& result); + /*! Try reading a pointer (size of BinaryView::GetAddressSize()) as big-endian + + \param result Reference to a uint64_t to write to + \return Whether the read succeeded. + */ + bool TryReadBEPointer(uint64_t& result); + /*! Get the current cursor position \return The current cursor position -- cgit v1.3.1