CRMDecompressor.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright (C) Teemu Suutari */
  2. #ifndef CRMDECOMPRESSOR_HPP
  3. #define CRMDECOMPRESSOR_HPP
  4. #include "Decompressor.hpp"
  5. #include "XPKDecompressor.hpp"
  6. namespace ancient::internal
  7. {
  8. class CRMDecompressor : public Decompressor, public XPKDecompressor
  9. {
  10. public:
  11. CRMDecompressor(const Buffer &packedData,uint32_t recursionLevel,bool verify);
  12. CRMDecompressor(uint32_t hdr,uint32_t recursionLevel,const Buffer &packedData,std::shared_ptr<XPKDecompressor::State> &state,bool verify);
  13. virtual ~CRMDecompressor();
  14. virtual const std::string &getName() const noexcept override final;
  15. virtual const std::string &getSubName() const noexcept override final;
  16. virtual size_t getPackedSize() const noexcept override final;
  17. virtual size_t getRawSize() const noexcept override final;
  18. virtual void decompressImpl(Buffer &rawData,bool verify) override final;
  19. virtual void decompressImpl(Buffer &rawData,const Buffer &previousData,bool verify) override final;
  20. static bool detectHeader(uint32_t hdr) noexcept;
  21. static bool detectHeaderXPK(uint32_t hdr) noexcept;
  22. static std::shared_ptr<Decompressor> create(const Buffer &packedData,bool exactSizeKnown,bool verify);
  23. static std::shared_ptr<XPKDecompressor> create(uint32_t hdr,uint32_t recursionLevel,const Buffer &packedData,std::shared_ptr<XPKDecompressor::State> &state,bool verify);
  24. private:
  25. const Buffer &_packedData;
  26. uint32_t _packedSize=0;
  27. uint32_t _rawSize=0;
  28. bool _isLZH=false; // "normal" compression or LZH compression
  29. bool _isSampled=false; // normal or "sampled" i.e. obsfuscated
  30. bool _isXPKDelta=false; // If delta encoding defined in XPK
  31. };
  32. }
  33. #endif