The following implementation of the iRawFile
interface encapsulates access to untyped memory blocks as file access. We will use this class to access uncompressed data in archives.
class clMemRawFile: public iRawFile { public:
The parameterized constructor initializes the pointer to a data buffer and its size:
clMemRawFile( const uint8_t* BufPtr, size_t BufSize, bool OwnsBuffer ) : FOwnsBuffer( OwnsBuffer ) , FBuffer( BufPtr ) , FBufferSize( BufSize ) {}
The memory mapping is trivial for a memory block, we just return the stored raw pointer:
virtual const uint8_t* GetFileData() const override { return FBuffer; } virtual uint64_t GetFileSize() const override { return FBufferSize; } private: const uint8_t* FBuffer; size_t FBufferSize; };
We will return to this class once we deal with archive file reading. Now, let's get familiar with one more important concept required to access .apk
packages transparently.