rarvm.hpp 985 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef _RAR_VM_
  2. #define _RAR_VM_
  3. #define VM_MEMSIZE 0x40000
  4. #define VM_MEMMASK (VM_MEMSIZE-1)
  5. enum VM_StandardFilters {
  6. VMSF_NONE, VMSF_E8, VMSF_E8E9, VMSF_ITANIUM, VMSF_RGB, VMSF_AUDIO,
  7. VMSF_DELTA
  8. };
  9. struct VM_PreparedProgram
  10. {
  11. VM_PreparedProgram()
  12. {
  13. FilteredDataSize=0;
  14. Type=VMSF_NONE;
  15. }
  16. VM_StandardFilters Type;
  17. uint InitR[7];
  18. byte *FilteredData;
  19. uint FilteredDataSize;
  20. };
  21. class RarVM
  22. {
  23. private:
  24. bool ExecuteStandardFilter(VM_StandardFilters FilterType);
  25. uint FilterItanium_GetBits(byte *Data,uint BitPos,uint BitCount);
  26. void FilterItanium_SetBits(byte *Data,uint BitField,uint BitPos,uint BitCount);
  27. byte *Mem;
  28. uint R[8];
  29. public:
  30. RarVM();
  31. ~RarVM();
  32. void Init();
  33. void Prepare(byte *Code,uint CodeSize,VM_PreparedProgram *Prg);
  34. void Execute(VM_PreparedProgram *Prg);
  35. void SetMemory(size_t Pos,byte *Data,size_t DataSize);
  36. static uint ReadData(BitInput &Inp);
  37. };
  38. #endif