Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
FileView Class Reference

A read-only view of the file that refuses reads outside it. More...

Public Member Functions

 FileView (const uint8_t *Data, size_t Size)
size_t Size () const
const uint8_t * Data () const
bool Contains (uint64_t Offset, uint64_t Length) const
template<typename T>
bool Read (uint64_t Offset, T *Out) const
 Copies a T from Offset. False when it doesn't fit in the file.

Detailed Description

A read-only view of the file that refuses reads outside it.

Definition at line 65 of file pe_features.cpp.

Constructor & Destructor Documentation

◆ FileView()

FileView::FileView ( const uint8_t * Data,
size_t Size )
inline

Definition at line 67 of file pe_features.cpp.

67: m_data(Data), m_size(Size) {}
const uint8_t * Data() const
size_t Size() const

References Data(), and Size().

Member Function Documentation

◆ Contains()

bool FileView::Contains ( uint64_t Offset,
uint64_t Length ) const
inline

Definition at line 72 of file pe_features.cpp.

73 {
74 return Offset <= m_size && Length <= m_size - Offset;
75 }

Referenced by ExtractPeFeatures(), and Read().

◆ Data()

const uint8_t * FileView::Data ( ) const
inline

Definition at line 70 of file pe_features.cpp.

70{ return m_data; }

Referenced by FileView().

◆ Read()

template<typename T>
bool FileView::Read ( uint64_t Offset,
T * Out ) const
inline

Copies a T from Offset. False when it doesn't fit in the file.

Definition at line 79 of file pe_features.cpp.

80 {
81 if (!Contains(Offset, sizeof(T))) {
82 return false;
83 }
84 memcpy(Out, m_data + Offset, sizeof(T)); // the file has no alignment guarantees
85 return true;
86 }
bool Contains(uint64_t Offset, uint64_t Length) const

References Contains().

◆ Size()

size_t FileView::Size ( ) const
inline

Definition at line 69 of file pe_features.cpp.

69{ return m_size; }

Referenced by FileView().


The documentation for this class was generated from the following file: