mirror of
https://github.com/LisherSong/ps5-web-file-manager.git
synced 2026-10-06 08:00:23 +02:00
New RAR engine for v1.9, replacing dmc_unrar 1.7.0. dmc_unrar only
dispatches RAR5 compression version 5 (switch(file->version) case
0x5000); WinRAR 6.x/7.x writes version 6 -> DMC_UNRAR_FILE_UNSUPPORTED_VERSION
-> user-facing "corrupt archive" on real v6 archives (diagnosed 2026-09-05
from a v6:8M:m0:m3 test file). unrar 7.20.1 natively supports v6,
encrypted and multi-volume RAR.
Vendored into third_party/unrar7/ (new dir) so the tree stays buildable
while src/rar_extract.c still references the dmc facade. Contents are a
verbatim copy of opello/unrar @97e1780 (159 files, v7.20.1) plus two
project files:
- unrar_c_api.h (C facade shim: platform types + dll.hpp re-export)
- VENDORED.md (source pin, build model, license notes)
Build model verified on host (MinGW g++ 16.2, Windows):
- all 49 UnRARDll.vcxproj sources compile with
-std=c++17 -DRARDLL -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
- links + runs: RARGetDllVersion() = 9 (smoke binary in .build/, ignored)
- Windows link additionally needs -lpowrprof
License: UnRAR freeware license (not GPL) - free to use for handling RAR
archives; cannot be used to build a RAR-compatible archiver. THIRD_PARTY_NOTICES
update lands with the engine swap commit.
Next (v1.9 work items): engine swap in rar_extract.c, Makefile .cpp rules,
fixtures + host tests, frontend password/multi-volume, then ELF build.
67 lines
1.2 KiB
C++
67 lines
1.2 KiB
C++
void CryptData::SetKey13(const char *Password)
|
|
{
|
|
Key13[0]=Key13[1]=Key13[2]=0;
|
|
for (size_t I=0;Password[I]!=0;I++)
|
|
{
|
|
byte P=Password[I];
|
|
Key13[0]+=P;
|
|
Key13[1]^=P;
|
|
Key13[2]+=P;
|
|
Key13[2]=(byte)rotls(Key13[2],1,8);
|
|
}
|
|
}
|
|
|
|
|
|
void CryptData::SetKey15(const char *Password)
|
|
{
|
|
InitCRC32(CRCTab);
|
|
uint PswCRC=CRC32(0xffffffff,Password,strlen(Password));
|
|
Key15[0]=PswCRC&0xffff;
|
|
Key15[1]=(PswCRC>>16)&0xffff;
|
|
Key15[2]=Key15[3]=0;
|
|
for (size_t I=0;Password[I]!=0;I++)
|
|
{
|
|
byte P=Password[I];
|
|
Key15[2]^=P^CRCTab[P];
|
|
Key15[3]+=ushort(P+(CRCTab[P]>>16));
|
|
}
|
|
}
|
|
|
|
|
|
void CryptData::SetCmt13Encryption()
|
|
{
|
|
Method=CRYPT_RAR13;
|
|
Key13[0]=0;
|
|
Key13[1]=7;
|
|
Key13[2]=77;
|
|
}
|
|
|
|
|
|
void CryptData::Decrypt13(byte *Data,size_t Count)
|
|
{
|
|
while (Count--)
|
|
{
|
|
Key13[1]+=Key13[2];
|
|
Key13[0]+=Key13[1];
|
|
*Data-=Key13[0];
|
|
Data++;
|
|
}
|
|
}
|
|
|
|
|
|
void CryptData::Crypt15(byte *Data,size_t Count)
|
|
{
|
|
while (Count--)
|
|
{
|
|
Key15[0]+=0x1234;
|
|
Key15[1]^=CRCTab[(Key15[0] & 0x1fe)>>1];
|
|
Key15[2]-=ushort(CRCTab[(Key15[0] & 0x1fe)>>1]>>16);
|
|
Key15[0]^=Key15[2];
|
|
Key15[3]=rotrs(Key15[3]&0xffff,1,16)^Key15[1];
|
|
Key15[3]=rotrs(Key15[3]&0xffff,1,16);
|
|
Key15[0]^=Key15[3];
|
|
*Data^=(byte)(Key15[0]>>8);
|
|
Data++;
|
|
}
|
|
}
|