MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / Prepare

Method Prepare

Libraries/unrar/rarvm.cpp:39–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38
39void RarVM::Prepare(byte *Code,uint CodeSize,VM_PreparedProgram *Prg)
40{
41 // Calculate the single byte XOR checksum to check validity of VM code.
42 byte XorSum=0;
43 for (uint I=1;I<CodeSize;I++)
44 XorSum^=Code[I];
45
46 if (XorSum!=Code[0])
47 return;
48
49 struct StandardFilters
50 {
51 uint Length;
52 uint CRC;
53 VM_StandardFilters Type;
54 } static StdList[]={
55 53, 0xad576887, VMSF_E8,
56 57, 0x3cd7e57e, VMSF_E8E9,
57 120, 0x3769893f, VMSF_ITANIUM,
58 29, 0x0e06077d, VMSF_DELTA,
59 149, 0x1c2c5dc8, VMSF_RGB,
60 216, 0xbc85e701, VMSF_AUDIO
61 };
62 uint CodeCRC=CRC32(0xffffffff,Code,CodeSize)^0xffffffff;
63 for (uint I=0;I<ASIZE(StdList);I++)
64 if (StdList[I].CRC==CodeCRC && StdList[I].Length==CodeSize)
65 {
66 Prg->Type=StdList[I].Type;
67 break;
68 }
69}
70
71
72uint RarVM::ReadData(BitInput &Inp)

Callers 1

AddVMCodeMethod · 0.80

Calls 1

CRC32Function · 0.85

Tested by

no test coverage detected