r5sdk/r5dev/public/tier0/sigcache.h
Kawe Mazidjatari 359820615f Move low level code to tier0/tier1
Moved to tier0/tier1 so it could be compiled into a static library in the future.
2023-05-06 22:59:01 +02:00

58 lines
1.4 KiB
C++

#ifndef SIGCACHE_H
#define SIGCACHE_H
#include "protoc/sig_map.pb.h"
#define SIGDB_MAGIC (('p'<<24)+('a'<<16)+('M'<<8)+'S')
#define SIGDB_DICT_SIZE 20
#define SIGDB_MAJOR_VERSION 0x2 // Increment when library changes are made.
#define SIGDB_MINOR_VERSION 0x4 // Increment when SDK updates are released.
#ifdef DEDICATED
#define SIGDB_FILE "cfg/server/startup.bin"
#else
#define SIGDB_FILE "cfg/client/startup.bin"
#endif
class CSigCache
{
public:
CSigCache()
: m_bInitialized(false)
, m_bDisabled(false) {};
~CSigCache() {};
void SetDisabled(const bool bDisabled);
void InvalidateMap();
void AddEntry(const string& svPattern, const uint64_t nRVA);
bool FindEntry(const string& svPattern, uint64_t& nRVA) const;
bool LoadCache(const string& svCacheFile);
bool WriteCache(const string& svCacheFile) const;
private:
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;
SigMap_Pb m_Cache;
bool m_bInitialized;
bool m_bDisabled;
};
extern CSigCache g_SigCache;
#pragma pack(push, 1)
struct SigDBHeader_t
{
int m_nMagic;
uint16_t m_nMajorVersion;
uint16_t m_nMinorVersion;
uint64_t m_nBlobSizeMem;
uint64_t m_nBlobSizeDisk;
uint32_t m_nBlobChecksum;
};
#pragma pack(pop)
#endif // !SIGCACHE_H