2022-12-01 22:47:39 +01:00
|
|
|
#ifndef SIGCACHE_H
|
|
|
|
#define SIGCACHE_H
|
|
|
|
|
|
|
|
#include "protoc/sig_map.pb.h"
|
|
|
|
|
|
|
|
#define SIGDB_MAGIC (('p'<<24)+('a'<<16)+('M'<<8)+'S')
|
2022-12-02 22:14:46 +01:00
|
|
|
#define SIGDB_DICT_SIZE 20
|
|
|
|
|
2023-02-26 22:25:18 +01:00
|
|
|
#define SIGDB_MAJOR_VERSION 0x2 // Increment when library changes are made.
|
2024-01-30 13:50:07 +01:00
|
|
|
#define SIGDB_MINOR_VERSION 0xA // Increment when SDK updates are released.
|
2022-12-02 12:12:13 +01:00
|
|
|
|
2022-12-01 22:47:39 +01:00
|
|
|
class CSigCache
|
|
|
|
{
|
|
|
|
public:
|
2022-12-04 14:16:12 +01:00
|
|
|
CSigCache()
|
|
|
|
: m_bInitialized(false)
|
|
|
|
, m_bDisabled(false) {};
|
2022-12-02 22:14:46 +01:00
|
|
|
~CSigCache() {};
|
|
|
|
|
2022-12-04 14:16:12 +01:00
|
|
|
void SetDisabled(const bool bDisabled);
|
|
|
|
void InvalidateMap();
|
|
|
|
|
2023-06-12 18:40:16 +02:00
|
|
|
void AddEntry(const char* szPattern, const uint64_t nRVA);
|
|
|
|
bool FindEntry(const char* szPattern, uint64_t& nRVA);
|
2022-12-02 12:12:13 +01:00
|
|
|
|
2023-10-15 16:29:26 +02:00
|
|
|
bool ReadCache(const char* szCacheFile);
|
2023-06-19 22:36:46 +02:00
|
|
|
bool WriteCache(const char* szCacheFile) const;
|
2022-12-01 22:47:39 +01:00
|
|
|
|
2022-12-02 22:14:46 +01:00
|
|
|
private:
|
2022-12-04 14:16:12 +01:00
|
|
|
bool CompressBlob(const size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const;
|
|
|
|
bool DecompressBlob(const size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const;
|
2022-12-02 22:14:46 +01:00
|
|
|
|
2022-12-01 22:47:39 +01:00
|
|
|
SigMap_Pb m_Cache;
|
|
|
|
bool m_bInitialized;
|
2022-12-04 14:16:12 +01:00
|
|
|
bool m_bDisabled;
|
2022-12-01 22:47:39 +01:00
|
|
|
};
|
2023-03-20 00:24:40 +01:00
|
|
|
extern CSigCache g_SigCache;
|
2022-12-01 22:47:39 +01:00
|
|
|
|
2022-12-02 22:14:46 +01:00
|
|
|
#pragma pack(push, 1)
|
2022-12-01 22:47:39 +01:00
|
|
|
struct SigDBHeader_t
|
|
|
|
{
|
|
|
|
int m_nMagic;
|
2022-12-02 22:14:46 +01:00
|
|
|
uint16_t m_nMajorVersion;
|
|
|
|
uint16_t m_nMinorVersion;
|
|
|
|
uint64_t m_nBlobSizeMem;
|
|
|
|
uint64_t m_nBlobSizeDisk;
|
2022-12-04 01:33:10 +01:00
|
|
|
uint32_t m_nBlobChecksum;
|
2022-12-01 22:47:39 +01:00
|
|
|
};
|
2022-12-02 22:14:46 +01:00
|
|
|
#pragma pack(pop)
|
2022-12-01 22:47:39 +01:00
|
|
|
|
|
|
|
#endif // !SIGCACHE_H
|