seven_zip_ruby 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +39 -0
- data/README.md +176 -0
- data/Rakefile +47 -0
- data/ext/C/Types.h +254 -0
- data/ext/CPP/7zip/Archive/IArchive.h +234 -0
- data/ext/CPP/7zip/IDecl.h +15 -0
- data/ext/CPP/7zip/IPassword.h +24 -0
- data/ext/CPP/7zip/IProgress.h +33 -0
- data/ext/CPP/7zip/IStream.h +58 -0
- data/ext/CPP/7zip/PropID.h +76 -0
- data/ext/CPP/Common/MyCom.h +225 -0
- data/ext/CPP/Common/MyGuidDef.h +54 -0
- data/ext/CPP/Common/MyInitGuid.h +22 -0
- data/ext/CPP/Common/MyUnknown.h +13 -0
- data/ext/CPP/Common/MyWindows.h +204 -0
- data/ext/CPP/Common/Types.h +11 -0
- data/ext/CPP/Windows/PropVariant.h +56 -0
- data/ext/CPP/include_windows/basetyps.h +19 -0
- data/ext/CPP/include_windows/tchar.h +89 -0
- data/ext/CPP/include_windows/windows.h +194 -0
- data/ext/p7zip/Asm/x64/7zCrcT8U.asm +103 -0
- data/ext/p7zip/Asm/x86/7zCrcT8U.asm +101 -0
- data/ext/p7zip/C/7zBuf.h +39 -0
- data/ext/p7zip/C/7zBuf2.c +45 -0
- data/ext/p7zip/C/7zCrc.c +76 -0
- data/ext/p7zip/C/7zCrc.h +25 -0
- data/ext/p7zip/C/7zCrcOpt.c +34 -0
- data/ext/p7zip/C/7zCrcT8.c +43 -0
- data/ext/p7zip/C/7zStream.c +169 -0
- data/ext/p7zip/C/7zVersion.h +7 -0
- data/ext/p7zip/C/Aes.c +284 -0
- data/ext/p7zip/C/Aes.h +38 -0
- data/ext/p7zip/C/Alloc.back3 +238 -0
- data/ext/p7zip/C/Alloc.c +280 -0
- data/ext/p7zip/C/Alloc.c.back +243 -0
- data/ext/p7zip/C/Alloc.c.back2 +222 -0
- data/ext/p7zip/C/Alloc.h +27 -0
- data/ext/p7zip/C/Bra.c +133 -0
- data/ext/p7zip/C/Bra.h +68 -0
- data/ext/p7zip/C/Bra86.c +85 -0
- data/ext/p7zip/C/BraIA64.c +67 -0
- data/ext/p7zip/C/BwtSort.c +516 -0
- data/ext/p7zip/C/BwtSort.h +30 -0
- data/ext/p7zip/C/CpuArch.c +168 -0
- data/ext/p7zip/C/CpuArch.h +155 -0
- data/ext/p7zip/C/Delta.c +62 -0
- data/ext/p7zip/C/Delta.h +23 -0
- data/ext/p7zip/C/HuffEnc.c +146 -0
- data/ext/p7zip/C/HuffEnc.h +27 -0
- data/ext/p7zip/C/LzFind.c +761 -0
- data/ext/p7zip/C/LzFind.h +115 -0
- data/ext/p7zip/C/LzFindMt.c +793 -0
- data/ext/p7zip/C/LzFindMt.h +105 -0
- data/ext/p7zip/C/LzHash.h +54 -0
- data/ext/p7zip/C/Lzma2Dec.c +356 -0
- data/ext/p7zip/C/Lzma2Dec.h +84 -0
- data/ext/p7zip/C/Lzma2Enc.c +477 -0
- data/ext/p7zip/C/Lzma2Enc.h +66 -0
- data/ext/p7zip/C/LzmaDec.c +999 -0
- data/ext/p7zip/C/LzmaDec.h +231 -0
- data/ext/p7zip/C/LzmaEnc.c +2268 -0
- data/ext/p7zip/C/LzmaEnc.h +80 -0
- data/ext/p7zip/C/LzmaUtil/Lzma86Dec.c +61 -0
- data/ext/p7zip/C/LzmaUtil/Lzma86Dec.h +51 -0
- data/ext/p7zip/C/LzmaUtil/Lzma86Enc.c +113 -0
- data/ext/p7zip/C/LzmaUtil/Lzma86Enc.h +78 -0
- data/ext/p7zip/C/MtCoder.c +327 -0
- data/ext/p7zip/C/MtCoder.h +98 -0
- data/ext/p7zip/C/Ppmd.h +85 -0
- data/ext/p7zip/C/Ppmd7.c +708 -0
- data/ext/p7zip/C/Ppmd7.h +140 -0
- data/ext/p7zip/C/Ppmd7Dec.c +187 -0
- data/ext/p7zip/C/Ppmd7Enc.c +185 -0
- data/ext/p7zip/C/Ppmd8.c +1120 -0
- data/ext/p7zip/C/Ppmd8.h +133 -0
- data/ext/p7zip/C/Ppmd8Dec.c +155 -0
- data/ext/p7zip/C/Ppmd8Enc.c +161 -0
- data/ext/p7zip/C/RotateDefs.h +20 -0
- data/ext/p7zip/C/Sha256.c +204 -0
- data/ext/p7zip/C/Sha256.h +26 -0
- data/ext/p7zip/C/Sort.c +93 -0
- data/ext/p7zip/C/Sort.h +20 -0
- data/ext/p7zip/C/Threads.c +582 -0
- data/ext/p7zip/C/Threads.h +123 -0
- data/ext/p7zip/C/Types.h +254 -0
- data/ext/p7zip/C/Xz.c +88 -0
- data/ext/p7zip/C/Xz.h +252 -0
- data/ext/p7zip/C/XzCrc64.c +33 -0
- data/ext/p7zip/C/XzCrc64.h +26 -0
- data/ext/p7zip/C/XzDec.c +875 -0
- data/ext/p7zip/C/XzEnc.c +497 -0
- data/ext/p7zip/C/XzEnc.h +25 -0
- data/ext/p7zip/C/XzIn.c +306 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zCompressionMode.cpp +3 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zCompressionMode.h +50 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zDecode.cpp +332 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zDecode.h +68 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zEncode.cpp +444 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zEncode.h +55 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zExtract.cpp +270 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderInStream.cpp +123 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderInStream.h +58 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderOutStream.cpp +149 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderOutStream.h +58 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHandler.cpp +482 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHandler.h +119 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHandlerOut.cpp +483 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHeader.cpp +14 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHeader.h +97 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zIn.cpp +1276 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zIn.h +245 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zItem.h +268 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zOut.cpp +866 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zOut.h +152 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zProperties.cpp +164 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zProperties.h +22 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zRegister.cpp +18 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zSpecStream.cpp +24 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zSpecStream.h +35 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zUpdate.cpp +1216 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zUpdate.h +88 -0
- data/ext/p7zip/CPP/7zip/Archive/ApmHandler.cpp +356 -0
- data/ext/p7zip/CPP/7zip/Archive/ArchiveExports.cpp +135 -0
- data/ext/p7zip/CPP/7zip/Archive/ArjHandler.cpp +798 -0
- data/ext/p7zip/CPP/7zip/Archive/Bz2Handler.cpp +423 -0
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabBlockInStream.cpp +189 -0
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabBlockInStream.h +44 -0
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabHandler.cpp +929 -0
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabHandler.h +28 -0
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabHeader.cpp +15 -0
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabHeader.h +44 -0
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabIn.cpp +272 -0
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabIn.h +161 -0
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabItem.h +63 -0
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabRegister.cpp +13 -0
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHandler.cpp +721 -0
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHandler.h +29 -0
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHeader.cpp +24 -0
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHeader.h +28 -0
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmIn.cpp +937 -0
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmIn.h +244 -0
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmRegister.cpp +13 -0
- data/ext/p7zip/CPP/7zip/Archive/Com/ComHandler.cpp +239 -0
- data/ext/p7zip/CPP/7zip/Archive/Com/ComHandler.h +28 -0
- data/ext/p7zip/CPP/7zip/Archive/Com/ComIn.cpp +389 -0
- data/ext/p7zip/CPP/7zip/Archive/Com/ComIn.h +119 -0
- data/ext/p7zip/CPP/7zip/Archive/Com/ComRegister.cpp +13 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2.cpp +121 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2.h +174 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2MT.cpp +240 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2MT.h +80 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2ST.cpp +239 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2ST.h +88 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/CrossThreadProgress.cpp +15 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/CrossThreadProgress.h +37 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/DummyOutStream.cpp +22 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/DummyOutStream.h +24 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/FindSignature.cpp +62 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/FindSignature.h +12 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/HandlerOut.cpp +623 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/HandlerOut.h +87 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/InStreamWithCRC.cpp +42 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/InStreamWithCRC.h +67 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/ItemNameUtils.cpp +61 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/ItemNameUtils.h +24 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/MultiStream.cpp +190 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/MultiStream.h +84 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp +18 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithCRC.h +36 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp +18 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithSha1.h +36 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/ParseProperties.cpp +177 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/ParseProperties.h +18 -0
- data/ext/p7zip/CPP/7zip/Archive/CpioHandler.cpp +624 -0
- data/ext/p7zip/CPP/7zip/Archive/CramfsHandler.cpp +644 -0
- data/ext/p7zip/CPP/7zip/Archive/DebHandler.cpp +413 -0
- data/ext/p7zip/CPP/7zip/Archive/DeflateProps.cpp +118 -0
- data/ext/p7zip/CPP/7zip/Archive/DeflateProps.h +35 -0
- data/ext/p7zip/CPP/7zip/Archive/DllExports2.cpp +76 -0
- data/ext/p7zip/CPP/7zip/Archive/DmgHandler.cpp +918 -0
- data/ext/p7zip/CPP/7zip/Archive/ElfHandler.cpp +534 -0
- data/ext/p7zip/CPP/7zip/Archive/FatHandler.cpp +996 -0
- data/ext/p7zip/CPP/7zip/Archive/FlvHandler.cpp +544 -0
- data/ext/p7zip/CPP/7zip/Archive/GzHandler.cpp +698 -0
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsHandler.cpp +243 -0
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsHandler.h +26 -0
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsIn.cpp +480 -0
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsIn.h +154 -0
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsRegister.cpp +13 -0
- data/ext/p7zip/CPP/7zip/Archive/IArchive.h +234 -0
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHandler.cpp +326 -0
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHandler.h +30 -0
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHeader.cpp +21 -0
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHeader.h +61 -0
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoIn.cpp +453 -0
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoIn.h +315 -0
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoItem.h +141 -0
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoRegister.cpp +13 -0
- data/ext/p7zip/CPP/7zip/Archive/LzhHandler.cpp +775 -0
- data/ext/p7zip/CPP/7zip/Archive/LzmaHandler.cpp +430 -0
- data/ext/p7zip/CPP/7zip/Archive/MachoHandler.cpp +500 -0
- data/ext/p7zip/CPP/7zip/Archive/MbrHandler.cpp +507 -0
- data/ext/p7zip/CPP/7zip/Archive/MslzHandler.cpp +257 -0
- data/ext/p7zip/CPP/7zip/Archive/MubHandler.cpp +266 -0
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisDecode.cpp +130 -0
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisDecode.h +47 -0
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisHandler.cpp +510 -0
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisHandler.h +43 -0
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisIn.cpp +1461 -0
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisIn.h +181 -0
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisRegister.cpp +13 -0
- data/ext/p7zip/CPP/7zip/Archive/NtfsHandler.cpp +1764 -0
- data/ext/p7zip/CPP/7zip/Archive/PeHandler.cpp +1752 -0
- data/ext/p7zip/CPP/7zip/Archive/PpmdHandler.cpp +456 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarHandler.cpp +869 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarHandler.h +66 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarHeader.cpp +21 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarHeader.h +205 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarIn.cpp +478 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarIn.h +123 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarItem.cpp +55 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarItem.h +79 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarRegister.cpp +13 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp +78 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarVolumeInStream.h +49 -0
- data/ext/p7zip/CPP/7zip/Archive/RpmHandler.cpp +292 -0
- data/ext/p7zip/CPP/7zip/Archive/SplitHandler.cpp +366 -0
- data/ext/p7zip/CPP/7zip/Archive/SquashfsHandler.cpp +2155 -0
- data/ext/p7zip/CPP/7zip/Archive/SwfHandler.cpp +706 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandler.cpp +386 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandler.h +61 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandlerOut.cpp +122 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHeader.cpp +25 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHeader.h +108 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarIn.cpp +207 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarIn.h +17 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarItem.h +72 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarOut.cpp +187 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarOut.h +28 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarRegister.cpp +18 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarUpdate.cpp +139 -0
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarUpdate.h +34 -0
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfHandler.cpp +451 -0
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfHandler.h +37 -0
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfIn.cpp +876 -0
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfIn.h +375 -0
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfRegister.cpp +13 -0
- data/ext/p7zip/CPP/7zip/Archive/VhdHandler.cpp +734 -0
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandler.cpp +660 -0
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandler.h +77 -0
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandlerOut.cpp +639 -0
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimIn.cpp +855 -0
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimIn.h +297 -0
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimRegister.cpp +18 -0
- data/ext/p7zip/CPP/7zip/Archive/XarHandler.cpp +588 -0
- data/ext/p7zip/CPP/7zip/Archive/XzHandler.cpp +707 -0
- data/ext/p7zip/CPP/7zip/Archive/ZHandler.cpp +161 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipAddCommon.cpp +379 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipAddCommon.h +56 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipCompressionMode.h +42 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandler.cpp +822 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandler.h +101 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp +537 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHeader.cpp +36 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHeader.h +284 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipIn.cpp +893 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipIn.h +125 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItem.cpp +181 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItem.h +281 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItemEx.h +34 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipOut.cpp +289 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipOut.h +56 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipRegister.cpp +18 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipUpdate.cpp +1076 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipUpdate.h +58 -0
- data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile +328 -0
- data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile.depend +4962 -0
- data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile.list +265 -0
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7zFM.txt +163 -0
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7zG.txt +131 -0
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7za.txt +253 -0
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_ALL.txt +32 -0
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_Format7zFree.txt +290 -0
- data/ext/p7zip/CPP/7zip/CMAKE/generate.sh +37 -0
- data/ext/p7zip/CPP/7zip/CMAKE/generate_xcode.sh +32 -0
- data/ext/p7zip/CPP/7zip/Common/CWrappers.cpp +226 -0
- data/ext/p7zip/CPP/7zip/Common/CWrappers.h +109 -0
- data/ext/p7zip/CPP/7zip/Common/CreateCoder.cpp +293 -0
- data/ext/p7zip/CPP/7zip/Common/CreateCoder.h +98 -0
- data/ext/p7zip/CPP/7zip/Common/FilePathAutoRename.cpp +55 -0
- data/ext/p7zip/CPP/7zip/Common/FilePathAutoRename.h +10 -0
- data/ext/p7zip/CPP/7zip/Common/FileStreams.cpp +273 -0
- data/ext/p7zip/CPP/7zip/Common/FileStreams.h +134 -0
- data/ext/p7zip/CPP/7zip/Common/FilterCoder.cpp +247 -0
- data/ext/p7zip/CPP/7zip/Common/FilterCoder.h +128 -0
- data/ext/p7zip/CPP/7zip/Common/InBuffer.cpp +83 -0
- data/ext/p7zip/CPP/7zip/Common/InBuffer.h +81 -0
- data/ext/p7zip/CPP/7zip/Common/InOutTempBuffer.cpp +122 -0
- data/ext/p7zip/CPP/7zip/Common/InOutTempBuffer.h +48 -0
- data/ext/p7zip/CPP/7zip/Common/LimitedStreams.cpp +154 -0
- data/ext/p7zip/CPP/7zip/Common/LimitedStreams.h +125 -0
- data/ext/p7zip/CPP/7zip/Common/LockedStream.cpp +23 -0
- data/ext/p7zip/CPP/7zip/Common/LockedStream.h +38 -0
- data/ext/p7zip/CPP/7zip/Common/MemBlocks.cpp +183 -0
- data/ext/p7zip/CPP/7zip/Common/MemBlocks.h +71 -0
- data/ext/p7zip/CPP/7zip/Common/MethodId.cpp +27 -0
- data/ext/p7zip/CPP/7zip/Common/MethodId.h +10 -0
- data/ext/p7zip/CPP/7zip/Common/MethodProps.cpp +99 -0
- data/ext/p7zip/CPP/7zip/Common/MethodProps.h +41 -0
- data/ext/p7zip/CPP/7zip/Common/OffsetStream.cpp +35 -0
- data/ext/p7zip/CPP/7zip/Common/OffsetStream.h +25 -0
- data/ext/p7zip/CPP/7zip/Common/OutBuffer.cpp +116 -0
- data/ext/p7zip/CPP/7zip/Common/OutBuffer.h +64 -0
- data/ext/p7zip/CPP/7zip/Common/OutMemStream.cpp +142 -0
- data/ext/p7zip/CPP/7zip/Common/OutMemStream.h +96 -0
- data/ext/p7zip/CPP/7zip/Common/ProgressMt.cpp +53 -0
- data/ext/p7zip/CPP/7zip/Common/ProgressMt.h +46 -0
- data/ext/p7zip/CPP/7zip/Common/ProgressUtils.cpp +42 -0
- data/ext/p7zip/CPP/7zip/Common/ProgressUtils.h +34 -0
- data/ext/p7zip/CPP/7zip/Common/RegisterArc.h +32 -0
- data/ext/p7zip/CPP/7zip/Common/RegisterCodec.h +33 -0
- data/ext/p7zip/CPP/7zip/Common/StreamBinder.cpp +152 -0
- data/ext/p7zip/CPP/7zip/Common/StreamBinder.h +38 -0
- data/ext/p7zip/CPP/7zip/Common/StreamObjects.cpp +221 -0
- data/ext/p7zip/CPP/7zip/Common/StreamObjects.h +135 -0
- data/ext/p7zip/CPP/7zip/Common/StreamUtils.cpp +56 -0
- data/ext/p7zip/CPP/7zip/Common/StreamUtils.h +13 -0
- data/ext/p7zip/CPP/7zip/Common/VirtThread.cpp +46 -0
- data/ext/p7zip/CPP/7zip/Common/VirtThread.h +23 -0
- data/ext/p7zip/CPP/7zip/Compress/ArjDecoder1.cpp +309 -0
- data/ext/p7zip/CPP/7zip/Compress/ArjDecoder1.h +98 -0
- data/ext/p7zip/CPP/7zip/Compress/ArjDecoder2.cpp +90 -0
- data/ext/p7zip/CPP/7zip/Compress/ArjDecoder2.h +59 -0
- data/ext/p7zip/CPP/7zip/Compress/BZip2Const.h +54 -0
- data/ext/p7zip/CPP/7zip/Compress/BZip2Crc.cpp +26 -0
- data/ext/p7zip/CPP/7zip/Compress/BZip2Crc.h +31 -0
- data/ext/p7zip/CPP/7zip/Compress/BZip2Decoder.cpp +943 -0
- data/ext/p7zip/CPP/7zip/Compress/BZip2Decoder.h +205 -0
- data/ext/p7zip/CPP/7zip/Compress/BZip2Encoder.cpp +895 -0
- data/ext/p7zip/CPP/7zip/Compress/BZip2Encoder.h +245 -0
- data/ext/p7zip/CPP/7zip/Compress/BZip2Register.cpp +20 -0
- data/ext/p7zip/CPP/7zip/Compress/Bcj2Coder.cpp +386 -0
- data/ext/p7zip/CPP/7zip/Compress/Bcj2Coder.h +115 -0
- data/ext/p7zip/CPP/7zip/Compress/Bcj2Register.cpp +19 -0
- data/ext/p7zip/CPP/7zip/Compress/BcjCoder.cpp +15 -0
- data/ext/p7zip/CPP/7zip/Compress/BcjCoder.h +19 -0
- data/ext/p7zip/CPP/7zip/Compress/BcjRegister.cpp +19 -0
- data/ext/p7zip/CPP/7zip/Compress/BitlDecoder.cpp +24 -0
- data/ext/p7zip/CPP/7zip/Compress/BitlDecoder.h +141 -0
- data/ext/p7zip/CPP/7zip/Compress/BitlEncoder.h +57 -0
- data/ext/p7zip/CPP/7zip/Compress/BitmDecoder.h +66 -0
- data/ext/p7zip/CPP/7zip/Compress/BitmEncoder.h +50 -0
- data/ext/p7zip/CPP/7zip/Compress/BranchCoder.cpp +19 -0
- data/ext/p7zip/CPP/7zip/Compress/BranchCoder.h +44 -0
- data/ext/p7zip/CPP/7zip/Compress/BranchMisc.cpp +37 -0
- data/ext/p7zip/CPP/7zip/Compress/BranchMisc.h +14 -0
- data/ext/p7zip/CPP/7zip/Compress/BranchRegister.cpp +30 -0
- data/ext/p7zip/CPP/7zip/Compress/ByteSwap.cpp +73 -0
- data/ext/p7zip/CPP/7zip/Compress/CodecExports.cpp +160 -0
- data/ext/p7zip/CPP/7zip/Compress/CopyCoder.cpp +67 -0
- data/ext/p7zip/CPP/7zip/Compress/CopyCoder.h +34 -0
- data/ext/p7zip/CPP/7zip/Compress/CopyRegister.cpp +14 -0
- data/ext/p7zip/CPP/7zip/Compress/Deflate64Register.cpp +20 -0
- data/ext/p7zip/CPP/7zip/Compress/DeflateConst.h +134 -0
- data/ext/p7zip/CPP/7zip/Compress/DeflateDecoder.cpp +353 -0
- data/ext/p7zip/CPP/7zip/Compress/DeflateDecoder.h +157 -0
- data/ext/p7zip/CPP/7zip/Compress/DeflateEncoder.cpp +986 -0
- data/ext/p7zip/CPP/7zip/Compress/DeflateEncoder.h +211 -0
- data/ext/p7zip/CPP/7zip/Compress/DeflateRegister.cpp +21 -0
- data/ext/p7zip/CPP/7zip/Compress/DeltaFilter.cpp +112 -0
- data/ext/p7zip/CPP/7zip/Compress/DllExports.cpp +39 -0
- data/ext/p7zip/CPP/7zip/Compress/DllExports2.cpp +28 -0
- data/ext/p7zip/CPP/7zip/Compress/HuffmanDecoder.h +89 -0
- data/ext/p7zip/CPP/7zip/Compress/ImplodeDecoder.cpp +219 -0
- data/ext/p7zip/CPP/7zip/Compress/ImplodeDecoder.h +57 -0
- data/ext/p7zip/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp +89 -0
- data/ext/p7zip/CPP/7zip/Compress/ImplodeHuffmanDecoder.h +34 -0
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp +531 -0
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp +1018 -0
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h +48 -0
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp +311 -0
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h +20 -0
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/makefile +173 -0
- data/ext/p7zip/CPP/7zip/Compress/LzOutWindow.cpp +14 -0
- data/ext/p7zip/CPP/7zip/Compress/LzOutWindow.h +66 -0
- data/ext/p7zip/CPP/7zip/Compress/LzhDecoder.cpp +220 -0
- data/ext/p7zip/CPP/7zip/Compress/LzhDecoder.h +106 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Decoder.cpp +189 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Decoder.h +73 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Encoder.cpp +94 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Encoder.h +36 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Register.cpp +20 -0
- data/ext/p7zip/CPP/7zip/Compress/LzmaDecoder.cpp +252 -0
- data/ext/p7zip/CPP/7zip/Compress/LzmaDecoder.h +84 -0
- data/ext/p7zip/CPP/7zip/Compress/LzmaEncoder.cpp +149 -0
- data/ext/p7zip/CPP/7zip/Compress/LzmaEncoder.h +36 -0
- data/ext/p7zip/CPP/7zip/Compress/LzmaRegister.cpp +20 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzx.h +61 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzx86Converter.cpp +90 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzx86Converter.h +46 -0
- data/ext/p7zip/CPP/7zip/Compress/LzxDecoder.cpp +387 -0
- data/ext/p7zip/CPP/7zip/Compress/LzxDecoder.h +159 -0
- data/ext/p7zip/CPP/7zip/Compress/Mtf8.h +193 -0
- data/ext/p7zip/CPP/7zip/Compress/PpmdDecoder.cpp +167 -0
- data/ext/p7zip/CPP/7zip/Compress/PpmdDecoder.h +78 -0
- data/ext/p7zip/CPP/7zip/Compress/PpmdEncoder.cpp +119 -0
- data/ext/p7zip/CPP/7zip/Compress/PpmdEncoder.h +48 -0
- data/ext/p7zip/CPP/7zip/Compress/PpmdRegister.cpp +21 -0
- data/ext/p7zip/CPP/7zip/Compress/PpmdZip.cpp +223 -0
- data/ext/p7zip/CPP/7zip/Compress/PpmdZip.h +72 -0
- data/ext/p7zip/CPP/7zip/Compress/QuantumDecoder.cpp +175 -0
- data/ext/p7zip/CPP/7zip/Compress/QuantumDecoder.h +264 -0
- data/ext/p7zip/CPP/7zip/Compress/RangeCoder.h +205 -0
- data/ext/p7zip/CPP/7zip/Compress/RangeCoderBit.h +114 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar/makefile +34 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar/makefile.depend +158 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar/makefile.list +64 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar1Decoder.cpp +480 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar1Decoder.h +88 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar2Decoder.cpp +391 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar2Decoder.h +174 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar3Decoder.cpp +897 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar3Decoder.h +267 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar3Vm.cpp +1091 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar3Vm.h +179 -0
- data/ext/p7zip/CPP/7zip/Compress/RarCodecsRegister.cpp +26 -0
- data/ext/p7zip/CPP/7zip/Compress/ShrinkDecoder.cpp +145 -0
- data/ext/p7zip/CPP/7zip/Compress/ShrinkDecoder.h +38 -0
- data/ext/p7zip/CPP/7zip/Compress/ZDecoder.cpp +159 -0
- data/ext/p7zip/CPP/7zip/Compress/ZDecoder.h +42 -0
- data/ext/p7zip/CPP/7zip/Compress/ZlibDecoder.cpp +89 -0
- data/ext/p7zip/CPP/7zip/Compress/ZlibDecoder.h +48 -0
- data/ext/p7zip/CPP/7zip/Compress/ZlibEncoder.cpp +61 -0
- data/ext/p7zip/CPP/7zip/Compress/ZlibEncoder.h +48 -0
- data/ext/p7zip/CPP/7zip/Crypto/7zAes.cpp +244 -0
- data/ext/p7zip/CPP/7zip/Crypto/7zAes.h +117 -0
- data/ext/p7zip/CPP/7zip/Crypto/7zAesRegister.cpp +18 -0
- data/ext/p7zip/CPP/7zip/Crypto/HmacSha1.cpp +109 -0
- data/ext/p7zip/CPP/7zip/Crypto/HmacSha1.h +39 -0
- data/ext/p7zip/CPP/7zip/Crypto/MyAes.cpp +48 -0
- data/ext/p7zip/CPP/7zip/Crypto/MyAes.h +38 -0
- data/ext/p7zip/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp +83 -0
- data/ext/p7zip/CPP/7zip/Crypto/Pbkdf2HmacSha1.h +21 -0
- data/ext/p7zip/CPP/7zip/Crypto/RandGen.cpp +107 -0
- data/ext/p7zip/CPP/7zip/Crypto/RandGen.h +21 -0
- data/ext/p7zip/CPP/7zip/Crypto/Rar20Crypto.cpp +133 -0
- data/ext/p7zip/CPP/7zip/Crypto/Rar20Crypto.h +50 -0
- data/ext/p7zip/CPP/7zip/Crypto/RarAes.cpp +134 -0
- data/ext/p7zip/CPP/7zip/Crypto/RarAes.h +47 -0
- data/ext/p7zip/CPP/7zip/Crypto/Sha1.cpp +229 -0
- data/ext/p7zip/CPP/7zip/Crypto/Sha1.h +68 -0
- data/ext/p7zip/CPP/7zip/Crypto/WzAes.cpp +221 -0
- data/ext/p7zip/CPP/7zip/Crypto/WzAes.h +125 -0
- data/ext/p7zip/CPP/7zip/Crypto/ZipCrypto.cpp +88 -0
- data/ext/p7zip/CPP/7zip/Crypto/ZipCrypto.h +56 -0
- data/ext/p7zip/CPP/7zip/Crypto/ZipStrong.cpp +164 -0
- data/ext/p7zip/CPP/7zip/Crypto/ZipStrong.h +47 -0
- data/ext/p7zip/CPP/7zip/Guid.txt +170 -0
- data/ext/p7zip/CPP/7zip/ICoder.h +186 -0
- data/ext/p7zip/CPP/7zip/IDecl.h +15 -0
- data/ext/p7zip/CPP/7zip/IPassword.h +24 -0
- data/ext/p7zip/CPP/7zip/IProgress.h +33 -0
- data/ext/p7zip/CPP/7zip/IStream.h +58 -0
- data/ext/p7zip/CPP/7zip/MyVersion.h +11 -0
- data/ext/p7zip/CPP/7zip/PREMAKE/generate.sh +18 -0
- data/ext/p7zip/CPP/7zip/PREMAKE/premake4.lua +263 -0
- data/ext/p7zip/CPP/7zip/PropID.h +76 -0
- data/ext/p7zip/CPP/7zip/QMAKE/7ZA/7ZA.pro +228 -0
- data/ext/p7zip/CPP/7zip/QMAKE/7ZA/7ZA_osx.pro +228 -0
- data/ext/p7zip/CPP/7zip/QMAKE/test_emul/test_emul.pro +26 -0
- data/ext/p7zip/CPP/7zip/TEST/TestUI/TestUI.cpp +560 -0
- data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile +33 -0
- data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile.depend +577 -0
- data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile.list +16 -0
- data/ext/p7zip/CPP/Common/AutoPtr.h +35 -0
- data/ext/p7zip/CPP/Common/Buffer.h +77 -0
- data/ext/p7zip/CPP/Common/CRC.cpp +7 -0
- data/ext/p7zip/CPP/Common/C_FileIO.cpp +88 -0
- data/ext/p7zip/CPP/Common/C_FileIO.h +47 -0
- data/ext/p7zip/CPP/Common/ComTry.h +18 -0
- data/ext/p7zip/CPP/Common/CommandLineParser.cpp +230 -0
- data/ext/p7zip/CPP/Common/CommandLineParser.h +72 -0
- data/ext/p7zip/CPP/Common/Defs.h +20 -0
- data/ext/p7zip/CPP/Common/DynamicBuffer.h +50 -0
- data/ext/p7zip/CPP/Common/IntToString.cpp +77 -0
- data/ext/p7zip/CPP/Common/IntToString.h +19 -0
- data/ext/p7zip/CPP/Common/Lang.cpp +130 -0
- data/ext/p7zip/CPP/Common/Lang.h +28 -0
- data/ext/p7zip/CPP/Common/ListFileUtils.cpp +75 -0
- data/ext/p7zip/CPP/Common/ListFileUtils.h +11 -0
- data/ext/p7zip/CPP/Common/MyCom.h +225 -0
- data/ext/p7zip/CPP/Common/MyException.h +14 -0
- data/ext/p7zip/CPP/Common/MyGuidDef.h +54 -0
- data/ext/p7zip/CPP/Common/MyInitGuid.h +22 -0
- data/ext/p7zip/CPP/Common/MyMap.cpp +140 -0
- data/ext/p7zip/CPP/Common/MyMap.h +28 -0
- data/ext/p7zip/CPP/Common/MyString.cpp +206 -0
- data/ext/p7zip/CPP/Common/MyString.h +601 -0
- data/ext/p7zip/CPP/Common/MyUnknown.h +13 -0
- data/ext/p7zip/CPP/Common/MyVector.cpp +87 -0
- data/ext/p7zip/CPP/Common/MyVector.h +266 -0
- data/ext/p7zip/CPP/Common/MyWindows.cpp +111 -0
- data/ext/p7zip/CPP/Common/MyWindows.h +218 -0
- data/ext/p7zip/CPP/Common/MyXml.cpp +209 -0
- data/ext/p7zip/CPP/Common/MyXml.h +40 -0
- data/ext/p7zip/CPP/Common/NewHandler.h +16 -0
- data/ext/p7zip/CPP/Common/StdInStream.cpp +100 -0
- data/ext/p7zip/CPP/Common/StdInStream.h +32 -0
- data/ext/p7zip/CPP/Common/StdOutStream.cpp +93 -0
- data/ext/p7zip/CPP/Common/StdOutStream.h +35 -0
- data/ext/p7zip/CPP/Common/StringConvert.cpp +181 -0
- data/ext/p7zip/CPP/Common/StringConvert.h +73 -0
- data/ext/p7zip/CPP/Common/StringToInt.cpp +90 -0
- data/ext/p7zip/CPP/Common/StringToInt.h +18 -0
- data/ext/p7zip/CPP/Common/TextConfig.cpp +138 -0
- data/ext/p7zip/CPP/Common/TextConfig.h +22 -0
- data/ext/p7zip/CPP/Common/Types.h +11 -0
- data/ext/p7zip/CPP/Common/UTFConvert.cpp +145 -0
- data/ext/p7zip/CPP/Common/UTFConvert.h +11 -0
- data/ext/p7zip/CPP/Common/Wildcard.cpp +462 -0
- data/ext/p7zip/CPP/Common/Wildcard.h +80 -0
- data/ext/p7zip/CPP/Windows/COM.cpp +37 -0
- data/ext/p7zip/CPP/Windows/COM.h +69 -0
- data/ext/p7zip/CPP/Windows/Clipboard.cpp +160 -0
- data/ext/p7zip/CPP/Windows/Clipboard.h +28 -0
- data/ext/p7zip/CPP/Windows/CommonDialog.h +19 -0
- data/ext/p7zip/CPP/Windows/Control/ComboBox.h +82 -0
- data/ext/p7zip/CPP/Windows/Control/Controls.cpp +515 -0
- data/ext/p7zip/CPP/Windows/Control/Dialog.cpp +560 -0
- data/ext/p7zip/CPP/Windows/Control/Dialog.h +179 -0
- data/ext/p7zip/CPP/Windows/Control/DialogImpl.h +73 -0
- data/ext/p7zip/CPP/Windows/Control/Edit.h +24 -0
- data/ext/p7zip/CPP/Windows/Control/ListView.h +164 -0
- data/ext/p7zip/CPP/Windows/Control/ProgressBar.h +34 -0
- data/ext/p7zip/CPP/Windows/Control/Static.h +23 -0
- data/ext/p7zip/CPP/Windows/Control/StatusBar.h +56 -0
- data/ext/p7zip/CPP/Windows/Control/Window2.cpp +211 -0
- data/ext/p7zip/CPP/Windows/Control/Window2.h +111 -0
- data/ext/p7zip/CPP/Windows/DLL.cpp +193 -0
- data/ext/p7zip/CPP/Windows/DLL.h +48 -0
- data/ext/p7zip/CPP/Windows/Defs.h +17 -0
- data/ext/p7zip/CPP/Windows/Error.cpp +58 -0
- data/ext/p7zip/CPP/Windows/Error.h +33 -0
- data/ext/p7zip/CPP/Windows/FileDir.cpp +927 -0
- data/ext/p7zip/CPP/Windows/FileDir.h +115 -0
- data/ext/p7zip/CPP/Windows/FileFind.cpp +604 -0
- data/ext/p7zip/CPP/Windows/FileFind.h +126 -0
- data/ext/p7zip/CPP/Windows/FileIO.cpp +475 -0
- data/ext/p7zip/CPP/Windows/FileIO.h +110 -0
- data/ext/p7zip/CPP/Windows/FileName.cpp +50 -0
- data/ext/p7zip/CPP/Windows/FileName.h +27 -0
- data/ext/p7zip/CPP/Windows/Menu.h +4 -0
- data/ext/p7zip/CPP/Windows/NtCheck.h +44 -0
- data/ext/p7zip/CPP/Windows/PropVariant.cpp +243 -0
- data/ext/p7zip/CPP/Windows/PropVariant.h +56 -0
- data/ext/p7zip/CPP/Windows/PropVariantConversions.cpp +142 -0
- data/ext/p7zip/CPP/Windows/PropVariantConversions.h +14 -0
- data/ext/p7zip/CPP/Windows/PropVariantUtils.cpp +78 -0
- data/ext/p7zip/CPP/Windows/PropVariantUtils.h +28 -0
- data/ext/p7zip/CPP/Windows/Registry.cpp +313 -0
- data/ext/p7zip/CPP/Windows/Registry.h +113 -0
- data/ext/p7zip/CPP/Windows/ResourceString.h +22 -0
- data/ext/p7zip/CPP/Windows/Shell.h +21 -0
- data/ext/p7zip/CPP/Windows/Synchronization.cpp +157 -0
- data/ext/p7zip/CPP/Windows/Synchronization.h +187 -0
- data/ext/p7zip/CPP/Windows/Synchronization2.h +218 -0
- data/ext/p7zip/CPP/Windows/System.cpp +166 -0
- data/ext/p7zip/CPP/Windows/System.h +16 -0
- data/ext/p7zip/CPP/Windows/Thread.h +41 -0
- data/ext/p7zip/CPP/Windows/Time.cpp +88 -0
- data/ext/p7zip/CPP/Windows/Time.h +21 -0
- data/ext/p7zip/CPP/Windows/Window.cpp +101 -0
- data/ext/p7zip/CPP/Windows/Window.h +43 -0
- data/ext/p7zip/CPP/include_windows/basetyps.h +19 -0
- data/ext/p7zip/CPP/include_windows/tchar.h +89 -0
- data/ext/p7zip/CPP/include_windows/windows.h +194 -0
- data/ext/p7zip/CPP/myWindows/StdAfx.h +124 -0
- data/ext/p7zip/CPP/myWindows/config.h +67 -0
- data/ext/p7zip/CPP/myWindows/initguid.h +4 -0
- data/ext/p7zip/CPP/myWindows/makefile +21 -0
- data/ext/p7zip/CPP/myWindows/makefile.depend +32 -0
- data/ext/p7zip/CPP/myWindows/makefile.list +28 -0
- data/ext/p7zip/CPP/myWindows/myAddExeFlag.cpp +20 -0
- data/ext/p7zip/CPP/myWindows/myGetTickCount.cpp +8 -0
- data/ext/p7zip/CPP/myWindows/myPrivate.h +17 -0
- data/ext/p7zip/CPP/myWindows/mySplitCommandLine.cpp +82 -0
- data/ext/p7zip/CPP/myWindows/test_emul.cpp +745 -0
- data/ext/p7zip/CPP/myWindows/wine_GetXXXDefaultLangID.cpp +741 -0
- data/ext/p7zip/CPP/myWindows/wine_date_and_time.cpp +434 -0
- data/ext/p7zip/ChangeLog +914 -0
- data/ext/p7zip/DOCS/7zC.txt +194 -0
- data/ext/p7zip/DOCS/7zFormat.txt +469 -0
- data/ext/p7zip/DOCS/License.txt +52 -0
- data/ext/p7zip/DOCS/MANUAL/commands/add.htm +87 -0
- data/ext/p7zip/DOCS/MANUAL/commands/bench.htm +79 -0
- data/ext/p7zip/DOCS/MANUAL/commands/delete.htm +59 -0
- data/ext/p7zip/DOCS/MANUAL/commands/extract.htm +91 -0
- data/ext/p7zip/DOCS/MANUAL/commands/extract_full.htm +68 -0
- data/ext/p7zip/DOCS/MANUAL/commands/index.htm +33 -0
- data/ext/p7zip/DOCS/MANUAL/commands/list.htm +77 -0
- data/ext/p7zip/DOCS/MANUAL/commands/style.css +232 -0
- data/ext/p7zip/DOCS/MANUAL/commands/test.htm +46 -0
- data/ext/p7zip/DOCS/MANUAL/commands/update.htm +66 -0
- data/ext/p7zip/DOCS/MANUAL/exit_codes.htm +27 -0
- data/ext/p7zip/DOCS/MANUAL/index.htm +29 -0
- data/ext/p7zip/DOCS/MANUAL/style.css +232 -0
- data/ext/p7zip/DOCS/MANUAL/switches/ar_exclude.htm +56 -0
- data/ext/p7zip/DOCS/MANUAL/switches/ar_include.htm +83 -0
- data/ext/p7zip/DOCS/MANUAL/switches/ar_no.htm +52 -0
- data/ext/p7zip/DOCS/MANUAL/switches/charset.htm +49 -0
- data/ext/p7zip/DOCS/MANUAL/switches/exclude.htm +60 -0
- data/ext/p7zip/DOCS/MANUAL/switches/include.htm +87 -0
- data/ext/p7zip/DOCS/MANUAL/switches/index.htm +64 -0
- data/ext/p7zip/DOCS/MANUAL/switches/large_pages.htm +50 -0
- data/ext/p7zip/DOCS/MANUAL/switches/list_tech.htm +36 -0
- data/ext/p7zip/DOCS/MANUAL/switches/method.htm +625 -0
- data/ext/p7zip/DOCS/MANUAL/switches/output_dir.htm +53 -0
- data/ext/p7zip/DOCS/MANUAL/switches/overwrite.htm +56 -0
- data/ext/p7zip/DOCS/MANUAL/switches/password.htm +54 -0
- data/ext/p7zip/DOCS/MANUAL/switches/recurse.htm +83 -0
- data/ext/p7zip/DOCS/MANUAL/switches/sfx.htm +156 -0
- data/ext/p7zip/DOCS/MANUAL/switches/ssc.htm +50 -0
- data/ext/p7zip/DOCS/MANUAL/switches/stdin.htm +55 -0
- data/ext/p7zip/DOCS/MANUAL/switches/stdout.htm +50 -0
- data/ext/p7zip/DOCS/MANUAL/switches/stop_switch.htm +31 -0
- data/ext/p7zip/DOCS/MANUAL/switches/style.css +232 -0
- data/ext/p7zip/DOCS/MANUAL/switches/type.htm +83 -0
- data/ext/p7zip/DOCS/MANUAL/switches/update.htm +176 -0
- data/ext/p7zip/DOCS/MANUAL/switches/volume.htm +49 -0
- data/ext/p7zip/DOCS/MANUAL/switches/working_dir.htm +55 -0
- data/ext/p7zip/DOCS/MANUAL/switches/yes.htm +48 -0
- data/ext/p7zip/DOCS/MANUAL/syntax.htm +120 -0
- data/ext/p7zip/DOCS/Methods.txt +152 -0
- data/ext/p7zip/DOCS/copying.txt +504 -0
- data/ext/p7zip/DOCS/history.txt +456 -0
- data/ext/p7zip/DOCS/lzma.txt +598 -0
- data/ext/p7zip/DOCS/readme.txt +181 -0
- data/ext/p7zip/DOCS/unRarLicense.txt +41 -0
- data/ext/p7zip/README +358 -0
- data/ext/p7zip/TODO +39 -0
- data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/ChangeLog +41 -0
- data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/readme +21 -0
- data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/readme.u7z +30 -0
- data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/u7z +133 -0
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/README +21 -0
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/check/check.sh +117 -0
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/check/files.tar +0 -0
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/man1/p7zip.1 +33 -0
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/p7zip +144 -0
- data/ext/p7zip/contrib/qnx630sp3/qnx630sp3-shared +14 -0
- data/ext/p7zip/contrib/qnx630sp3/qnx630sp3-static +10 -0
- data/ext/p7zip/install.sh +206 -0
- data/ext/p7zip/install_local_context_menu.sh +18 -0
- data/ext/p7zip/integration_context_menu.txt +51 -0
- data/ext/p7zip/makefile +181 -0
- data/ext/p7zip/makefile.aix_gcc +22 -0
- data/ext/p7zip/makefile.beos +18 -0
- data/ext/p7zip/makefile.crc32 +8 -0
- data/ext/p7zip/makefile.cygwin +20 -0
- data/ext/p7zip/makefile.cygwin_asm +21 -0
- data/ext/p7zip/makefile.djgpp_old +21 -0
- data/ext/p7zip/makefile.djgpp_watt +47 -0
- data/ext/p7zip/makefile.freebsd5 +20 -0
- data/ext/p7zip/makefile.freebsd6 +20 -0
- data/ext/p7zip/makefile.glb +39 -0
- data/ext/p7zip/makefile.gprof +18 -0
- data/ext/p7zip/makefile.hpux-acc +17 -0
- data/ext/p7zip/makefile.hpux-acc_64 +19 -0
- data/ext/p7zip/makefile.hpux-gcc +21 -0
- data/ext/p7zip/makefile.linux_amd64 +22 -0
- data/ext/p7zip/makefile.linux_amd64_asm +24 -0
- data/ext/p7zip/makefile.linux_amd64_asm_icc +27 -0
- data/ext/p7zip/makefile.linux_any_cpu +22 -0
- data/ext/p7zip/makefile.linux_any_cpu_gcc_4.X +24 -0
- data/ext/p7zip/makefile.linux_clang_amd64 +22 -0
- data/ext/p7zip/makefile.linux_cross_arm +22 -0
- data/ext/p7zip/makefile.linux_gcc_2.95_no_need_for_libstdc +20 -0
- data/ext/p7zip/makefile.linux_other +23 -0
- data/ext/p7zip/makefile.linux_s390x +23 -0
- data/ext/p7zip/makefile.linux_x86_asm_gcc_4.X +26 -0
- data/ext/p7zip/makefile.linux_x86_asm_gcc_4.X_fltk +26 -0
- data/ext/p7zip/makefile.linux_x86_asm_gcc_mudflap_4.X +26 -0
- data/ext/p7zip/makefile.linux_x86_asm_icc +25 -0
- data/ext/p7zip/makefile.linux_x86_icc +24 -0
- data/ext/p7zip/makefile.machine_base +22 -0
- data/ext/p7zip/makefile.macosx_32bits +20 -0
- data/ext/p7zip/makefile.macosx_32bits_asm +23 -0
- data/ext/p7zip/makefile.macosx_32bits_ppc +21 -0
- data/ext/p7zip/makefile.macosx_64bits +20 -0
- data/ext/p7zip/makefile.macosx_llvm_64bits +20 -0
- data/ext/p7zip/makefile.netbsd +21 -0
- data/ext/p7zip/makefile.netware_asm_gcc_3.X +41 -0
- data/ext/p7zip/makefile.oldmake +174 -0
- data/ext/p7zip/makefile.openbsd +20 -0
- data/ext/p7zip/makefile.openbsd_no_port +20 -0
- data/ext/p7zip/makefile.qnx_shared.bin +21 -0
- data/ext/p7zip/makefile.qnx_static +21 -0
- data/ext/p7zip/makefile.rules +661 -0
- data/ext/p7zip/makefile.solaris_sparc_CC_32 +21 -0
- data/ext/p7zip/makefile.solaris_sparc_CC_64 +23 -0
- data/ext/p7zip/makefile.solaris_sparc_gcc +21 -0
- data/ext/p7zip/makefile.solaris_x86 +19 -0
- data/ext/p7zip/makefile.tru64 +22 -0
- data/ext/seven_zip_ruby/depend +5 -0
- data/ext/seven_zip_ruby/extconf.rb +131 -0
- data/ext/seven_zip_ruby/guid_defs.h +29 -0
- data/ext/seven_zip_ruby/mutex.h +10 -0
- data/ext/seven_zip_ruby/posix/mutex.h +94 -0
- data/ext/seven_zip_ruby/seven_zip_archive.cpp +1614 -0
- data/ext/seven_zip_ruby/seven_zip_archive.h +515 -0
- data/ext/seven_zip_ruby/util_common.h +444 -0
- data/ext/seven_zip_ruby/utils.cpp +576 -0
- data/ext/seven_zip_ruby/utils.h +25 -0
- data/ext/seven_zip_ruby/win32/mutex.h +130 -0
- data/lib/seven_zip_ruby.rb +16 -0
- data/lib/seven_zip_ruby/7z.dll +0 -0
- data/lib/seven_zip_ruby/7z64.dll +0 -0
- data/lib/seven_zip_ruby/archive_info.rb +21 -0
- data/lib/seven_zip_ruby/entry_info.rb +45 -0
- data/lib/seven_zip_ruby/exception.rb +7 -0
- data/lib/seven_zip_ruby/seven_zip_reader.rb +180 -0
- data/lib/seven_zip_ruby/seven_zip_writer.rb +143 -0
- data/lib/seven_zip_ruby/update_info.rb +116 -0
- data/lib/seven_zip_ruby/version.rb +3 -0
- data/seven_zip_ruby.gemspec +26 -0
- data/spec/seven_zip_ruby_spec.rb +490 -0
- data/spec/seven_zip_ruby_spec_helper.rb +122 -0
- metadata +820 -0
@@ -0,0 +1,267 @@
|
|
1
|
+
// Rar3Decoder.h
|
2
|
+
// According to unRAR license, this code may not be used to develop
|
3
|
+
// a program that creates RAR archives
|
4
|
+
|
5
|
+
/* This code uses Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
|
6
|
+
|
7
|
+
#ifndef __COMPRESS_RAR3_DECODER_H
|
8
|
+
#define __COMPRESS_RAR3_DECODER_H
|
9
|
+
|
10
|
+
#include "../../../C/Ppmd7.h"
|
11
|
+
|
12
|
+
#include "../../Common/MyCom.h"
|
13
|
+
|
14
|
+
#include "../ICoder.h"
|
15
|
+
|
16
|
+
#include "../Common/InBuffer.h"
|
17
|
+
|
18
|
+
#include "BitmDecoder.h"
|
19
|
+
#include "HuffmanDecoder.h"
|
20
|
+
#include "Rar3Vm.h"
|
21
|
+
|
22
|
+
namespace NCompress {
|
23
|
+
namespace NRar3 {
|
24
|
+
|
25
|
+
const UInt32 kWindowSize = 1 << 22;
|
26
|
+
const UInt32 kWindowMask = (kWindowSize - 1);
|
27
|
+
|
28
|
+
const UInt32 kNumReps = 4;
|
29
|
+
const UInt32 kNumLen2Symbols = 8;
|
30
|
+
const UInt32 kLenTableSize = 28;
|
31
|
+
const UInt32 kMainTableSize = 256 + 1 + 1 + 1 + kNumReps + kNumLen2Symbols + kLenTableSize;
|
32
|
+
const UInt32 kDistTableSize = 60;
|
33
|
+
|
34
|
+
const int kNumAlignBits = 4;
|
35
|
+
const UInt32 kAlignTableSize = (1 << kNumAlignBits) + 1;
|
36
|
+
|
37
|
+
const UInt32 kLevelTableSize = 20;
|
38
|
+
|
39
|
+
const UInt32 kTablesSizesSum = kMainTableSize + kDistTableSize + kAlignTableSize + kLenTableSize;
|
40
|
+
|
41
|
+
class CBitDecoder
|
42
|
+
{
|
43
|
+
UInt32 m_Value;
|
44
|
+
unsigned m_BitPos;
|
45
|
+
public:
|
46
|
+
CInBuffer m_Stream;
|
47
|
+
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
|
48
|
+
void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream);}
|
49
|
+
void ReleaseStream() { m_Stream.ReleaseStream();}
|
50
|
+
|
51
|
+
void Init()
|
52
|
+
{
|
53
|
+
m_Stream.Init();
|
54
|
+
m_BitPos = 0;
|
55
|
+
m_Value = 0;
|
56
|
+
}
|
57
|
+
|
58
|
+
UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() - (m_BitPos) / 8; }
|
59
|
+
UInt32 GetBitPosition() const { return ((8 - m_BitPos) & 7); }
|
60
|
+
|
61
|
+
UInt32 GetValue(unsigned numBits)
|
62
|
+
{
|
63
|
+
if (m_BitPos < numBits)
|
64
|
+
{
|
65
|
+
m_BitPos += 8;
|
66
|
+
m_Value = (m_Value << 8) | m_Stream.ReadByte();
|
67
|
+
if (m_BitPos < numBits)
|
68
|
+
{
|
69
|
+
m_BitPos += 8;
|
70
|
+
m_Value = (m_Value << 8) | m_Stream.ReadByte();
|
71
|
+
}
|
72
|
+
}
|
73
|
+
return m_Value >> (m_BitPos - numBits);
|
74
|
+
}
|
75
|
+
|
76
|
+
void MovePos(unsigned numBits)
|
77
|
+
{
|
78
|
+
m_BitPos -= numBits;
|
79
|
+
m_Value = m_Value & ((1 << m_BitPos) - 1);
|
80
|
+
}
|
81
|
+
|
82
|
+
UInt32 ReadBits(unsigned numBits)
|
83
|
+
{
|
84
|
+
UInt32 res = GetValue(numBits);
|
85
|
+
MovePos(numBits);
|
86
|
+
return res;
|
87
|
+
}
|
88
|
+
};
|
89
|
+
|
90
|
+
const UInt32 kTopValue = (1 << 24);
|
91
|
+
const UInt32 kBot = (1 << 15);
|
92
|
+
|
93
|
+
struct CRangeDecoder
|
94
|
+
{
|
95
|
+
IPpmd7_RangeDec s;
|
96
|
+
UInt32 Range;
|
97
|
+
UInt32 Code;
|
98
|
+
UInt32 Low;
|
99
|
+
CBitDecoder bitDecoder;
|
100
|
+
SRes Res;
|
101
|
+
|
102
|
+
public:
|
103
|
+
void InitRangeCoder()
|
104
|
+
{
|
105
|
+
Code = 0;
|
106
|
+
Low = 0;
|
107
|
+
Range = 0xFFFFFFFF;
|
108
|
+
for (int i = 0; i < 4; i++)
|
109
|
+
Code = (Code << 8) | bitDecoder.ReadBits(8);
|
110
|
+
}
|
111
|
+
|
112
|
+
void Normalize()
|
113
|
+
{
|
114
|
+
while ((Low ^ (Low + Range)) < kTopValue ||
|
115
|
+
Range < kBot && ((Range = (0 - Low) & (kBot - 1)), 1))
|
116
|
+
{
|
117
|
+
Code = (Code << 8) | bitDecoder.m_Stream.ReadByte();
|
118
|
+
Range <<= 8;
|
119
|
+
Low <<= 8;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
CRangeDecoder();
|
124
|
+
};
|
125
|
+
|
126
|
+
struct CFilter: public NVm::CProgram
|
127
|
+
{
|
128
|
+
CRecordVector<Byte> GlobalData;
|
129
|
+
UInt32 BlockStart;
|
130
|
+
UInt32 BlockSize;
|
131
|
+
UInt32 ExecCount;
|
132
|
+
CFilter(): BlockStart(0), BlockSize(0), ExecCount(0) {}
|
133
|
+
};
|
134
|
+
|
135
|
+
struct CTempFilter: public NVm::CProgramInitState
|
136
|
+
{
|
137
|
+
UInt32 BlockStart;
|
138
|
+
UInt32 BlockSize;
|
139
|
+
UInt32 ExecCount;
|
140
|
+
bool NextWindow;
|
141
|
+
|
142
|
+
UInt32 FilterIndex;
|
143
|
+
};
|
144
|
+
|
145
|
+
const int kNumHuffmanBits = 15;
|
146
|
+
|
147
|
+
class CDecoder:
|
148
|
+
public ICompressCoder,
|
149
|
+
public ICompressSetDecoderProperties2,
|
150
|
+
public CMyUnknownImp
|
151
|
+
{
|
152
|
+
CRangeDecoder m_InBitStream;
|
153
|
+
Byte *_window;
|
154
|
+
UInt32 _winPos;
|
155
|
+
UInt32 _wrPtr;
|
156
|
+
UInt64 _lzSize;
|
157
|
+
UInt64 _unpackSize;
|
158
|
+
UInt64 _writtenFileSize; // if it's > _unpackSize, then _unpackSize only written
|
159
|
+
CMyComPtr<ISequentialOutStream> _outStream;
|
160
|
+
NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;
|
161
|
+
NHuffman::CDecoder<kNumHuffmanBits, kDistTableSize> m_DistDecoder;
|
162
|
+
NHuffman::CDecoder<kNumHuffmanBits, kAlignTableSize> m_AlignDecoder;
|
163
|
+
NHuffman::CDecoder<kNumHuffmanBits, kLenTableSize> m_LenDecoder;
|
164
|
+
NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
|
165
|
+
|
166
|
+
UInt32 _reps[kNumReps];
|
167
|
+
UInt32 _lastLength;
|
168
|
+
|
169
|
+
Byte m_LastLevels[kTablesSizesSum];
|
170
|
+
|
171
|
+
Byte *_vmData;
|
172
|
+
Byte *_vmCode;
|
173
|
+
NVm::CVm _vm;
|
174
|
+
CRecordVector<CFilter *> _filters;
|
175
|
+
CRecordVector<CTempFilter *> _tempFilters;
|
176
|
+
UInt32 _lastFilter;
|
177
|
+
|
178
|
+
bool m_IsSolid;
|
179
|
+
|
180
|
+
bool _lzMode;
|
181
|
+
|
182
|
+
UInt32 PrevAlignBits;
|
183
|
+
UInt32 PrevAlignCount;
|
184
|
+
|
185
|
+
bool TablesRead;
|
186
|
+
|
187
|
+
CPpmd7 _ppmd;
|
188
|
+
int PpmEscChar;
|
189
|
+
bool PpmError;
|
190
|
+
|
191
|
+
HRESULT WriteDataToStream(const Byte *data, UInt32 size);
|
192
|
+
HRESULT WriteData(const Byte *data, UInt32 size);
|
193
|
+
HRESULT WriteArea(UInt32 startPtr, UInt32 endPtr);
|
194
|
+
void ExecuteFilter(int tempFilterIndex, NVm::CBlockRef &outBlockRef);
|
195
|
+
HRESULT WriteBuf();
|
196
|
+
|
197
|
+
void InitFilters();
|
198
|
+
bool AddVmCode(UInt32 firstByte, UInt32 codeSize);
|
199
|
+
bool ReadVmCodeLZ();
|
200
|
+
bool ReadVmCodePPM();
|
201
|
+
|
202
|
+
UInt32 ReadBits(int numBits);
|
203
|
+
|
204
|
+
HRESULT InitPPM();
|
205
|
+
int DecodePpmSymbol();
|
206
|
+
HRESULT DecodePPM(Int32 num, bool &keepDecompressing);
|
207
|
+
|
208
|
+
HRESULT ReadTables(bool &keepDecompressing);
|
209
|
+
HRESULT ReadEndOfBlock(bool &keepDecompressing);
|
210
|
+
HRESULT DecodeLZ(bool &keepDecompressing);
|
211
|
+
HRESULT CodeReal(ICompressProgressInfo *progress);
|
212
|
+
public:
|
213
|
+
CDecoder();
|
214
|
+
~CDecoder();
|
215
|
+
|
216
|
+
MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
|
217
|
+
|
218
|
+
void ReleaseStreams()
|
219
|
+
{
|
220
|
+
_outStream.Release();
|
221
|
+
m_InBitStream.bitDecoder.ReleaseStream();
|
222
|
+
}
|
223
|
+
|
224
|
+
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
225
|
+
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
|
226
|
+
|
227
|
+
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
|
228
|
+
|
229
|
+
void CopyBlock(UInt32 distance, UInt32 len)
|
230
|
+
{
|
231
|
+
_lzSize += len;
|
232
|
+
UInt32 pos = (_winPos - distance - 1) & kWindowMask;
|
233
|
+
Byte *window = _window;
|
234
|
+
UInt32 winPos = _winPos;
|
235
|
+
if (kWindowSize - winPos > len && kWindowSize - pos > len)
|
236
|
+
{
|
237
|
+
const Byte *src = window + pos;
|
238
|
+
Byte *dest = window + winPos;
|
239
|
+
_winPos += len;
|
240
|
+
do
|
241
|
+
*dest++ = *src++;
|
242
|
+
while(--len != 0);
|
243
|
+
return;
|
244
|
+
}
|
245
|
+
do
|
246
|
+
{
|
247
|
+
window[winPos] = window[pos];
|
248
|
+
winPos = (winPos + 1) & kWindowMask;
|
249
|
+
pos = (pos + 1) & kWindowMask;
|
250
|
+
}
|
251
|
+
while(--len != 0);
|
252
|
+
_winPos = winPos;
|
253
|
+
}
|
254
|
+
|
255
|
+
void PutByte(Byte b)
|
256
|
+
{
|
257
|
+
_window[_winPos] = b;
|
258
|
+
_winPos = (_winPos + 1) & kWindowMask;
|
259
|
+
_lzSize++;
|
260
|
+
}
|
261
|
+
|
262
|
+
|
263
|
+
};
|
264
|
+
|
265
|
+
}}
|
266
|
+
|
267
|
+
#endif
|
@@ -0,0 +1,1091 @@
|
|
1
|
+
// Rar3Vm.cpp
|
2
|
+
// According to unRAR license, this code may not be used to develop
|
3
|
+
// a program that creates RAR archives
|
4
|
+
|
5
|
+
/*
|
6
|
+
Note:
|
7
|
+
Due to performance considerations Rar VM may set Flags C incorrectly
|
8
|
+
for some operands (SHL x, 0, ... ).
|
9
|
+
Check implementation of concrete VM command
|
10
|
+
to see if it sets flags right.
|
11
|
+
*/
|
12
|
+
|
13
|
+
#include "StdAfx.h"
|
14
|
+
|
15
|
+
#include "../../../C/7zCrc.h"
|
16
|
+
#include "../../../C/Alloc.h"
|
17
|
+
|
18
|
+
#include "Rar3Vm.h"
|
19
|
+
|
20
|
+
namespace NCompress {
|
21
|
+
namespace NRar3 {
|
22
|
+
|
23
|
+
UInt32 CMemBitDecoder::ReadBits(int numBits)
|
24
|
+
{
|
25
|
+
UInt32 res = 0;
|
26
|
+
for (;;)
|
27
|
+
{
|
28
|
+
Byte b = _bitPos < _bitSize ? _data[_bitPos >> 3] : 0;
|
29
|
+
int avail = (int)(8 - (_bitPos & 7));
|
30
|
+
if (numBits <= avail)
|
31
|
+
{
|
32
|
+
_bitPos += numBits;
|
33
|
+
return res | (b >> (avail - numBits)) & ((1 << numBits) - 1);
|
34
|
+
}
|
35
|
+
numBits -= avail;
|
36
|
+
res |= (UInt32)(b & ((1 << avail) - 1)) << numBits;
|
37
|
+
_bitPos += avail;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
UInt32 CMemBitDecoder::ReadBit() { return ReadBits(1); }
|
42
|
+
|
43
|
+
namespace NVm {
|
44
|
+
|
45
|
+
static const UInt32 kStackRegIndex = kNumRegs - 1;
|
46
|
+
|
47
|
+
static const UInt32 FLAG_C = 1;
|
48
|
+
static const UInt32 FLAG_Z = 2;
|
49
|
+
static const UInt32 FLAG_S = 0x80000000;
|
50
|
+
|
51
|
+
static const Byte CF_OP0 = 0;
|
52
|
+
static const Byte CF_OP1 = 1;
|
53
|
+
static const Byte CF_OP2 = 2;
|
54
|
+
static const Byte CF_OPMASK = 3;
|
55
|
+
static const Byte CF_BYTEMODE = 4;
|
56
|
+
static const Byte CF_JUMP = 8;
|
57
|
+
static const Byte CF_PROC = 16;
|
58
|
+
static const Byte CF_USEFLAGS = 32;
|
59
|
+
static const Byte CF_CHFLAGS = 64;
|
60
|
+
|
61
|
+
static Byte kCmdFlags[]=
|
62
|
+
{
|
63
|
+
/* CMD_MOV */ CF_OP2 | CF_BYTEMODE,
|
64
|
+
/* CMD_CMP */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
|
65
|
+
/* CMD_ADD */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
|
66
|
+
/* CMD_SUB */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
|
67
|
+
/* CMD_JZ */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
|
68
|
+
/* CMD_JNZ */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
|
69
|
+
/* CMD_INC */ CF_OP1 | CF_BYTEMODE | CF_CHFLAGS,
|
70
|
+
/* CMD_DEC */ CF_OP1 | CF_BYTEMODE | CF_CHFLAGS,
|
71
|
+
/* CMD_JMP */ CF_OP1 | CF_JUMP,
|
72
|
+
/* CMD_XOR */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
|
73
|
+
/* CMD_AND */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
|
74
|
+
/* CMD_OR */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
|
75
|
+
/* CMD_TEST */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
|
76
|
+
/* CMD_JS */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
|
77
|
+
/* CMD_JNS */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
|
78
|
+
/* CMD_JB */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
|
79
|
+
/* CMD_JBE */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
|
80
|
+
/* CMD_JA */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
|
81
|
+
/* CMD_JAE */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
|
82
|
+
/* CMD_PUSH */ CF_OP1,
|
83
|
+
/* CMD_POP */ CF_OP1,
|
84
|
+
/* CMD_CALL */ CF_OP1 | CF_PROC,
|
85
|
+
/* CMD_RET */ CF_OP0 | CF_PROC,
|
86
|
+
/* CMD_NOT */ CF_OP1 | CF_BYTEMODE,
|
87
|
+
/* CMD_SHL */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
|
88
|
+
/* CMD_SHR */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
|
89
|
+
/* CMD_SAR */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
|
90
|
+
/* CMD_NEG */ CF_OP1 | CF_BYTEMODE | CF_CHFLAGS,
|
91
|
+
/* CMD_PUSHA */ CF_OP0,
|
92
|
+
/* CMD_POPA */ CF_OP0,
|
93
|
+
/* CMD_PUSHF */ CF_OP0 | CF_USEFLAGS,
|
94
|
+
/* CMD_POPF */ CF_OP0 | CF_CHFLAGS,
|
95
|
+
/* CMD_MOVZX */ CF_OP2,
|
96
|
+
/* CMD_MOVSX */ CF_OP2,
|
97
|
+
/* CMD_XCHG */ CF_OP2 | CF_BYTEMODE,
|
98
|
+
/* CMD_MUL */ CF_OP2 | CF_BYTEMODE,
|
99
|
+
/* CMD_DIV */ CF_OP2 | CF_BYTEMODE,
|
100
|
+
/* CMD_ADC */ CF_OP2 | CF_BYTEMODE | CF_USEFLAGS | CF_CHFLAGS ,
|
101
|
+
/* CMD_SBB */ CF_OP2 | CF_BYTEMODE | CF_USEFLAGS | CF_CHFLAGS ,
|
102
|
+
/* CMD_PRINT */ CF_OP0
|
103
|
+
};
|
104
|
+
|
105
|
+
CVm::CVm(): Mem(NULL) {}
|
106
|
+
|
107
|
+
bool CVm::Create()
|
108
|
+
{
|
109
|
+
if (Mem == NULL)
|
110
|
+
Mem = (Byte *)::MyAlloc(kSpaceSize + 4);
|
111
|
+
return (Mem != NULL);
|
112
|
+
}
|
113
|
+
|
114
|
+
CVm::~CVm()
|
115
|
+
{
|
116
|
+
::MyFree(Mem);
|
117
|
+
}
|
118
|
+
|
119
|
+
// CVm::Execute can change CProgram object: it clears progarm if VM returns error.
|
120
|
+
|
121
|
+
bool CVm::Execute(CProgram *prg, const CProgramInitState *initState,
|
122
|
+
CBlockRef &outBlockRef, CRecordVector<Byte> &outGlobalData)
|
123
|
+
{
|
124
|
+
memcpy(R, initState->InitR, sizeof(initState->InitR));
|
125
|
+
R[kStackRegIndex] = kSpaceSize;
|
126
|
+
R[kNumRegs] = 0;
|
127
|
+
Flags = 0;
|
128
|
+
|
129
|
+
UInt32 globalSize = MyMin((UInt32)initState->GlobalData.Size(), kGlobalSize);
|
130
|
+
if (globalSize != 0)
|
131
|
+
memcpy(Mem + kGlobalOffset, &initState->GlobalData[0], globalSize);
|
132
|
+
UInt32 staticSize = MyMin((UInt32)prg->StaticData.Size(), kGlobalSize - globalSize);
|
133
|
+
if (staticSize != 0)
|
134
|
+
memcpy(Mem + kGlobalOffset + globalSize, &prg->StaticData[0], staticSize);
|
135
|
+
|
136
|
+
bool res = true;
|
137
|
+
#ifdef RARVM_STANDARD_FILTERS
|
138
|
+
if (prg->StandardFilterIndex >= 0)
|
139
|
+
ExecuteStandardFilter(prg->StandardFilterIndex);
|
140
|
+
else
|
141
|
+
#endif
|
142
|
+
{
|
143
|
+
res = ExecuteCode(prg);
|
144
|
+
if (!res)
|
145
|
+
prg->Commands[0].OpCode = CMD_RET;
|
146
|
+
}
|
147
|
+
UInt32 newBlockPos = GetFixedGlobalValue32(NGlobalOffset::kBlockPos) & kSpaceMask;
|
148
|
+
UInt32 newBlockSize = GetFixedGlobalValue32(NGlobalOffset::kBlockSize) & kSpaceMask;
|
149
|
+
if (newBlockPos + newBlockSize >= kSpaceSize)
|
150
|
+
newBlockPos = newBlockSize = 0;
|
151
|
+
outBlockRef.Offset = newBlockPos;
|
152
|
+
outBlockRef.Size = newBlockSize;
|
153
|
+
|
154
|
+
outGlobalData.Clear();
|
155
|
+
UInt32 dataSize = GetFixedGlobalValue32(NGlobalOffset::kGlobalMemOutSize);
|
156
|
+
dataSize = MyMin(dataSize, kGlobalSize - kFixedGlobalSize);
|
157
|
+
if (dataSize != 0)
|
158
|
+
{
|
159
|
+
dataSize += kFixedGlobalSize;
|
160
|
+
outGlobalData.Reserve(dataSize);
|
161
|
+
for (UInt32 i = 0; i < dataSize; i++)
|
162
|
+
outGlobalData.Add(Mem[kGlobalOffset + i]);
|
163
|
+
}
|
164
|
+
return res;
|
165
|
+
}
|
166
|
+
|
167
|
+
|
168
|
+
#define SET_IP(IP) \
|
169
|
+
if ((IP) >= numCommands) return true; \
|
170
|
+
if (--maxOpCount <= 0) return false; \
|
171
|
+
cmd = commands + (IP);
|
172
|
+
|
173
|
+
#define GET_FLAG_S_B(res) (((res) & 0x80) ? FLAG_S : 0)
|
174
|
+
#define SET_IP_OP1 { UInt32 val = GetOperand32(&cmd->Op1); SET_IP(val); }
|
175
|
+
#define FLAGS_UPDATE_SZ Flags = res == 0 ? FLAG_Z : res & FLAG_S
|
176
|
+
#define FLAGS_UPDATE_SZ_B Flags = (res & 0xFF) == 0 ? FLAG_Z : GET_FLAG_S_B(res)
|
177
|
+
|
178
|
+
UInt32 CVm::GetOperand32(const COperand *op) const
|
179
|
+
{
|
180
|
+
switch(op->Type)
|
181
|
+
{
|
182
|
+
case OP_TYPE_REG: return R[op->Data];
|
183
|
+
case OP_TYPE_REGMEM: return GetValue32(&Mem[(op->Base + R[op->Data]) & kSpaceMask]);
|
184
|
+
default: return op->Data;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
void CVm::SetOperand32(const COperand *op, UInt32 val)
|
189
|
+
{
|
190
|
+
switch(op->Type)
|
191
|
+
{
|
192
|
+
case OP_TYPE_REG: R[op->Data] = val; return;
|
193
|
+
case OP_TYPE_REGMEM: SetValue32(&Mem[(op->Base + R[op->Data]) & kSpaceMask], val); return;
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
197
|
+
Byte CVm::GetOperand8(const COperand *op) const
|
198
|
+
{
|
199
|
+
switch(op->Type)
|
200
|
+
{
|
201
|
+
case OP_TYPE_REG: return (Byte)R[op->Data];
|
202
|
+
case OP_TYPE_REGMEM: return Mem[(op->Base + R[op->Data]) & kSpaceMask];;
|
203
|
+
default: return (Byte)op->Data;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
void CVm::SetOperand8(const COperand *op, Byte val)
|
208
|
+
{
|
209
|
+
switch(op->Type)
|
210
|
+
{
|
211
|
+
case OP_TYPE_REG: R[op->Data] = (R[op->Data] & 0xFFFFFF00) | val; return;
|
212
|
+
case OP_TYPE_REGMEM: Mem[(op->Base + R[op->Data]) & kSpaceMask] = val; return;
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
UInt32 CVm::GetOperand(bool byteMode, const COperand *op) const
|
217
|
+
{
|
218
|
+
if (byteMode)
|
219
|
+
return GetOperand8(op);
|
220
|
+
return GetOperand32(op);
|
221
|
+
}
|
222
|
+
|
223
|
+
void CVm::SetOperand(bool byteMode, const COperand *op, UInt32 val)
|
224
|
+
{
|
225
|
+
if (byteMode)
|
226
|
+
SetOperand8(op, (Byte)(val & 0xFF));
|
227
|
+
else
|
228
|
+
SetOperand32(op, val);
|
229
|
+
}
|
230
|
+
|
231
|
+
bool CVm::ExecuteCode(const CProgram *prg)
|
232
|
+
{
|
233
|
+
Int32 maxOpCount = 25000000;
|
234
|
+
const CCommand *commands = &prg->Commands[0];
|
235
|
+
const CCommand *cmd = commands;
|
236
|
+
UInt32 numCommands = prg->Commands.Size();
|
237
|
+
for (;;)
|
238
|
+
{
|
239
|
+
switch(cmd->OpCode)
|
240
|
+
{
|
241
|
+
#ifndef RARVM_NO_VM
|
242
|
+
|
243
|
+
case CMD_MOV:
|
244
|
+
SetOperand32(&cmd->Op1, GetOperand32(&cmd->Op2));
|
245
|
+
break;
|
246
|
+
case CMD_MOVB:
|
247
|
+
SetOperand8(&cmd->Op1, GetOperand8(&cmd->Op2));
|
248
|
+
break;
|
249
|
+
case CMD_CMP:
|
250
|
+
{
|
251
|
+
UInt32 v1 = GetOperand32(&cmd->Op1);
|
252
|
+
UInt32 res = v1 - GetOperand32(&cmd->Op2);
|
253
|
+
Flags = res == 0 ? FLAG_Z : (res > v1) | (res & FLAG_S);
|
254
|
+
}
|
255
|
+
break;
|
256
|
+
case CMD_CMPB:
|
257
|
+
{
|
258
|
+
Byte v1 = GetOperand8(&cmd->Op1);
|
259
|
+
Byte res = v1 - GetOperand8(&cmd->Op2);
|
260
|
+
res &= 0xFF;
|
261
|
+
Flags = res == 0 ? FLAG_Z : (res > v1) | GET_FLAG_S_B(res);
|
262
|
+
}
|
263
|
+
break;
|
264
|
+
case CMD_ADD:
|
265
|
+
{
|
266
|
+
UInt32 v1 = GetOperand32(&cmd->Op1);
|
267
|
+
UInt32 res = v1 + GetOperand32(&cmd->Op2);
|
268
|
+
SetOperand32(&cmd->Op1, res);
|
269
|
+
Flags = (res < v1) | (res == 0 ? FLAG_Z : (res & FLAG_S));
|
270
|
+
}
|
271
|
+
break;
|
272
|
+
case CMD_ADDB:
|
273
|
+
{
|
274
|
+
Byte v1 = GetOperand8(&cmd->Op1);
|
275
|
+
Byte res = v1 + GetOperand8(&cmd->Op2);
|
276
|
+
res &= 0xFF;
|
277
|
+
SetOperand8(&cmd->Op1, (Byte)res);
|
278
|
+
Flags = (res < v1) | (res == 0 ? FLAG_Z : GET_FLAG_S_B(res));
|
279
|
+
}
|
280
|
+
break;
|
281
|
+
case CMD_ADC:
|
282
|
+
{
|
283
|
+
UInt32 v1 = GetOperand(cmd->ByteMode, &cmd->Op1);
|
284
|
+
UInt32 FC = (Flags & FLAG_C);
|
285
|
+
UInt32 res = v1 + GetOperand(cmd->ByteMode, &cmd->Op2) + FC;
|
286
|
+
if (cmd->ByteMode)
|
287
|
+
res &= 0xFF;
|
288
|
+
SetOperand(cmd->ByteMode, &cmd->Op1, res);
|
289
|
+
Flags = (res < v1 || res == v1 && FC) | (res == 0 ? FLAG_Z : (res & FLAG_S));
|
290
|
+
}
|
291
|
+
break;
|
292
|
+
case CMD_SUB:
|
293
|
+
{
|
294
|
+
UInt32 v1 = GetOperand32(&cmd->Op1);
|
295
|
+
UInt32 res = v1 - GetOperand32(&cmd->Op2);
|
296
|
+
SetOperand32(&cmd->Op1, res);
|
297
|
+
Flags = res == 0 ? FLAG_Z : (res > v1) | (res & FLAG_S);
|
298
|
+
}
|
299
|
+
break;
|
300
|
+
case CMD_SUBB:
|
301
|
+
{
|
302
|
+
UInt32 v1 = GetOperand8(&cmd->Op1);
|
303
|
+
UInt32 res = v1 - GetOperand8(&cmd->Op2);
|
304
|
+
SetOperand8(&cmd->Op1, (Byte)res);
|
305
|
+
Flags = res == 0 ? FLAG_Z : (res > v1) | (res & FLAG_S);
|
306
|
+
}
|
307
|
+
break;
|
308
|
+
case CMD_SBB:
|
309
|
+
{
|
310
|
+
UInt32 v1 = GetOperand(cmd->ByteMode, &cmd->Op1);
|
311
|
+
UInt32 FC = (Flags & FLAG_C);
|
312
|
+
UInt32 res = v1 - GetOperand(cmd->ByteMode, &cmd->Op2) - FC;
|
313
|
+
// Flags = res == 0 ? FLAG_Z : (res > v1 || res == v1 && FC) | (res & FLAG_S);
|
314
|
+
if (cmd->ByteMode)
|
315
|
+
res &= 0xFF;
|
316
|
+
SetOperand(cmd->ByteMode, &cmd->Op1, res);
|
317
|
+
Flags = (res > v1 || res == v1 && FC) | (res == 0 ? FLAG_Z : (res & FLAG_S));
|
318
|
+
}
|
319
|
+
break;
|
320
|
+
case CMD_INC:
|
321
|
+
{
|
322
|
+
UInt32 res = GetOperand32(&cmd->Op1) + 1;
|
323
|
+
SetOperand32(&cmd->Op1, res);
|
324
|
+
FLAGS_UPDATE_SZ;
|
325
|
+
}
|
326
|
+
break;
|
327
|
+
case CMD_INCB:
|
328
|
+
{
|
329
|
+
Byte res = GetOperand8(&cmd->Op1) + 1;
|
330
|
+
SetOperand8(&cmd->Op1, res);;
|
331
|
+
FLAGS_UPDATE_SZ_B;
|
332
|
+
}
|
333
|
+
break;
|
334
|
+
case CMD_DEC:
|
335
|
+
{
|
336
|
+
UInt32 res = GetOperand32(&cmd->Op1) - 1;
|
337
|
+
SetOperand32(&cmd->Op1, res);
|
338
|
+
FLAGS_UPDATE_SZ;
|
339
|
+
}
|
340
|
+
break;
|
341
|
+
case CMD_DECB:
|
342
|
+
{
|
343
|
+
Byte res = GetOperand8(&cmd->Op1) - 1;
|
344
|
+
SetOperand8(&cmd->Op1, res);;
|
345
|
+
FLAGS_UPDATE_SZ_B;
|
346
|
+
}
|
347
|
+
break;
|
348
|
+
case CMD_XOR:
|
349
|
+
{
|
350
|
+
UInt32 res = GetOperand32(&cmd->Op1) ^ GetOperand32(&cmd->Op2);
|
351
|
+
SetOperand32(&cmd->Op1, res);
|
352
|
+
FLAGS_UPDATE_SZ;
|
353
|
+
}
|
354
|
+
break;
|
355
|
+
case CMD_XORB:
|
356
|
+
{
|
357
|
+
Byte res = GetOperand8(&cmd->Op1) ^ GetOperand8(&cmd->Op2);
|
358
|
+
SetOperand8(&cmd->Op1, res);
|
359
|
+
FLAGS_UPDATE_SZ_B;
|
360
|
+
}
|
361
|
+
break;
|
362
|
+
case CMD_AND:
|
363
|
+
{
|
364
|
+
UInt32 res = GetOperand32(&cmd->Op1) & GetOperand32(&cmd->Op2);
|
365
|
+
SetOperand32(&cmd->Op1, res);
|
366
|
+
FLAGS_UPDATE_SZ;
|
367
|
+
}
|
368
|
+
break;
|
369
|
+
case CMD_ANDB:
|
370
|
+
{
|
371
|
+
Byte res = GetOperand8(&cmd->Op1) & GetOperand8(&cmd->Op2);
|
372
|
+
SetOperand8(&cmd->Op1, res);
|
373
|
+
FLAGS_UPDATE_SZ_B;
|
374
|
+
}
|
375
|
+
break;
|
376
|
+
case CMD_OR:
|
377
|
+
{
|
378
|
+
UInt32 res = GetOperand32(&cmd->Op1) | GetOperand32(&cmd->Op2);
|
379
|
+
SetOperand32(&cmd->Op1, res);
|
380
|
+
FLAGS_UPDATE_SZ;
|
381
|
+
}
|
382
|
+
break;
|
383
|
+
case CMD_ORB:
|
384
|
+
{
|
385
|
+
Byte res = GetOperand8(&cmd->Op1) | GetOperand8(&cmd->Op2);
|
386
|
+
SetOperand8(&cmd->Op1, res);
|
387
|
+
FLAGS_UPDATE_SZ_B;
|
388
|
+
}
|
389
|
+
break;
|
390
|
+
case CMD_TEST:
|
391
|
+
{
|
392
|
+
UInt32 res = GetOperand32(&cmd->Op1) & GetOperand32(&cmd->Op2);
|
393
|
+
FLAGS_UPDATE_SZ;
|
394
|
+
}
|
395
|
+
break;
|
396
|
+
case CMD_TESTB:
|
397
|
+
{
|
398
|
+
Byte res = GetOperand8(&cmd->Op1) & GetOperand8(&cmd->Op2);
|
399
|
+
FLAGS_UPDATE_SZ_B;
|
400
|
+
}
|
401
|
+
break;
|
402
|
+
case CMD_NOT:
|
403
|
+
SetOperand(cmd->ByteMode, &cmd->Op1, ~GetOperand(cmd->ByteMode, &cmd->Op1));
|
404
|
+
break;
|
405
|
+
case CMD_NEG:
|
406
|
+
{
|
407
|
+
UInt32 res = 0 - GetOperand32(&cmd->Op1);
|
408
|
+
SetOperand32(&cmd->Op1, res);
|
409
|
+
Flags = res == 0 ? FLAG_Z : FLAG_C | (res & FLAG_S);
|
410
|
+
}
|
411
|
+
break;
|
412
|
+
case CMD_NEGB:
|
413
|
+
{
|
414
|
+
Byte res = (Byte)(0 - GetOperand8(&cmd->Op1));
|
415
|
+
SetOperand8(&cmd->Op1, res);
|
416
|
+
Flags = res == 0 ? FLAG_Z : FLAG_C | GET_FLAG_S_B(res);
|
417
|
+
}
|
418
|
+
break;
|
419
|
+
|
420
|
+
case CMD_SHL:
|
421
|
+
{
|
422
|
+
UInt32 v1 = GetOperand32(&cmd->Op1);
|
423
|
+
int v2 = (int)GetOperand32(&cmd->Op2);
|
424
|
+
UInt32 res = v1 << v2;
|
425
|
+
SetOperand32(&cmd->Op1, res);
|
426
|
+
Flags = (res == 0 ? FLAG_Z : (res & FLAG_S)) | ((v1 << (v2 - 1)) & 0x80000000 ? FLAG_C : 0);
|
427
|
+
}
|
428
|
+
break;
|
429
|
+
case CMD_SHLB:
|
430
|
+
{
|
431
|
+
Byte v1 = GetOperand8(&cmd->Op1);
|
432
|
+
int v2 = (int)GetOperand8(&cmd->Op2);
|
433
|
+
Byte res = (Byte)(v1 << v2);
|
434
|
+
SetOperand8(&cmd->Op1, res);
|
435
|
+
Flags = (res == 0 ? FLAG_Z : GET_FLAG_S_B(res)) | ((v1 << (v2 - 1)) & 0x80 ? FLAG_C : 0);
|
436
|
+
}
|
437
|
+
break;
|
438
|
+
case CMD_SHR:
|
439
|
+
{
|
440
|
+
UInt32 v1 = GetOperand32(&cmd->Op1);
|
441
|
+
int v2 = (int)GetOperand32(&cmd->Op2);
|
442
|
+
UInt32 res = v1 >> v2;
|
443
|
+
SetOperand32(&cmd->Op1, res);
|
444
|
+
Flags = (res == 0 ? FLAG_Z : (res & FLAG_S)) | ((v1 >> (v2 - 1)) & FLAG_C);
|
445
|
+
}
|
446
|
+
break;
|
447
|
+
case CMD_SHRB:
|
448
|
+
{
|
449
|
+
Byte v1 = GetOperand8(&cmd->Op1);
|
450
|
+
int v2 = (int)GetOperand8(&cmd->Op2);
|
451
|
+
Byte res = (Byte)(v1 >> v2);
|
452
|
+
SetOperand8(&cmd->Op1, res);
|
453
|
+
Flags = (res == 0 ? FLAG_Z : GET_FLAG_S_B(res)) | ((v1 >> (v2 - 1)) & FLAG_C);
|
454
|
+
}
|
455
|
+
break;
|
456
|
+
case CMD_SAR:
|
457
|
+
{
|
458
|
+
UInt32 v1 = GetOperand32(&cmd->Op1);
|
459
|
+
int v2 = (int)GetOperand32(&cmd->Op2);
|
460
|
+
UInt32 res = UInt32(((Int32)v1) >> v2);
|
461
|
+
SetOperand32(&cmd->Op1, res);
|
462
|
+
Flags= (res == 0 ? FLAG_Z : (res & FLAG_S)) | ((v1 >> (v2 - 1)) & FLAG_C);
|
463
|
+
}
|
464
|
+
break;
|
465
|
+
case CMD_SARB:
|
466
|
+
{
|
467
|
+
Byte v1 = GetOperand8(&cmd->Op1);
|
468
|
+
int v2 = (int)GetOperand8(&cmd->Op2);
|
469
|
+
Byte res = (Byte)(((signed char)v1) >> v2);
|
470
|
+
SetOperand8(&cmd->Op1, res);
|
471
|
+
Flags= (res == 0 ? FLAG_Z : GET_FLAG_S_B(res)) | ((v1 >> (v2 - 1)) & FLAG_C);
|
472
|
+
}
|
473
|
+
break;
|
474
|
+
|
475
|
+
case CMD_JMP:
|
476
|
+
SET_IP_OP1;
|
477
|
+
continue;
|
478
|
+
case CMD_JZ:
|
479
|
+
if ((Flags & FLAG_Z) != 0)
|
480
|
+
{
|
481
|
+
SET_IP_OP1;
|
482
|
+
continue;
|
483
|
+
}
|
484
|
+
break;
|
485
|
+
case CMD_JNZ:
|
486
|
+
if ((Flags & FLAG_Z) == 0)
|
487
|
+
{
|
488
|
+
SET_IP_OP1;
|
489
|
+
continue;
|
490
|
+
}
|
491
|
+
break;
|
492
|
+
case CMD_JS:
|
493
|
+
if ((Flags & FLAG_S) != 0)
|
494
|
+
{
|
495
|
+
SET_IP_OP1;
|
496
|
+
continue;
|
497
|
+
}
|
498
|
+
break;
|
499
|
+
case CMD_JNS:
|
500
|
+
if ((Flags & FLAG_S) == 0)
|
501
|
+
{
|
502
|
+
SET_IP_OP1;
|
503
|
+
continue;
|
504
|
+
}
|
505
|
+
break;
|
506
|
+
case CMD_JB:
|
507
|
+
if ((Flags & FLAG_C) != 0)
|
508
|
+
{
|
509
|
+
SET_IP_OP1;
|
510
|
+
continue;
|
511
|
+
}
|
512
|
+
break;
|
513
|
+
case CMD_JBE:
|
514
|
+
if ((Flags & (FLAG_C | FLAG_Z)) != 0)
|
515
|
+
{
|
516
|
+
SET_IP_OP1;
|
517
|
+
continue;
|
518
|
+
}
|
519
|
+
break;
|
520
|
+
case CMD_JA:
|
521
|
+
if ((Flags & (FLAG_C | FLAG_Z)) == 0)
|
522
|
+
{
|
523
|
+
SET_IP_OP1;
|
524
|
+
continue;
|
525
|
+
}
|
526
|
+
break;
|
527
|
+
case CMD_JAE:
|
528
|
+
if ((Flags & FLAG_C) == 0)
|
529
|
+
{
|
530
|
+
SET_IP_OP1;
|
531
|
+
continue;
|
532
|
+
}
|
533
|
+
break;
|
534
|
+
|
535
|
+
case CMD_PUSH:
|
536
|
+
R[kStackRegIndex] -= 4;
|
537
|
+
SetValue32(&Mem[R[kStackRegIndex] & kSpaceMask], GetOperand32(&cmd->Op1));
|
538
|
+
break;
|
539
|
+
case CMD_POP:
|
540
|
+
SetOperand32(&cmd->Op1, GetValue32(&Mem[R[kStackRegIndex] & kSpaceMask]));
|
541
|
+
R[kStackRegIndex] += 4;
|
542
|
+
break;
|
543
|
+
case CMD_CALL:
|
544
|
+
R[kStackRegIndex] -= 4;
|
545
|
+
SetValue32(&Mem[R[kStackRegIndex] & kSpaceMask], (UInt32)(cmd - commands + 1));
|
546
|
+
SET_IP_OP1;
|
547
|
+
continue;
|
548
|
+
|
549
|
+
case CMD_PUSHA:
|
550
|
+
{
|
551
|
+
for (UInt32 i = 0, SP = R[kStackRegIndex] - 4; i < kNumRegs; i++, SP -= 4)
|
552
|
+
SetValue32(&Mem[SP & kSpaceMask], R[i]);
|
553
|
+
R[kStackRegIndex] -= kNumRegs * 4;
|
554
|
+
}
|
555
|
+
break;
|
556
|
+
case CMD_POPA:
|
557
|
+
{
|
558
|
+
for (UInt32 i = 0, SP = R[kStackRegIndex]; i < kNumRegs; i++, SP += 4)
|
559
|
+
R[kStackRegIndex - i] = GetValue32(&Mem[SP & kSpaceMask]);
|
560
|
+
}
|
561
|
+
break;
|
562
|
+
case CMD_PUSHF:
|
563
|
+
R[kStackRegIndex] -= 4;
|
564
|
+
SetValue32(&Mem[R[kStackRegIndex]&kSpaceMask], Flags);
|
565
|
+
break;
|
566
|
+
case CMD_POPF:
|
567
|
+
Flags = GetValue32(&Mem[R[kStackRegIndex] & kSpaceMask]);
|
568
|
+
R[kStackRegIndex] += 4;
|
569
|
+
break;
|
570
|
+
|
571
|
+
case CMD_MOVZX:
|
572
|
+
SetOperand32(&cmd->Op1, GetOperand8(&cmd->Op2));
|
573
|
+
break;
|
574
|
+
case CMD_MOVSX:
|
575
|
+
SetOperand32(&cmd->Op1, (UInt32)(Int32)(signed char)GetOperand8(&cmd->Op2));
|
576
|
+
break;
|
577
|
+
case CMD_XCHG:
|
578
|
+
{
|
579
|
+
UInt32 v1 = GetOperand(cmd->ByteMode, &cmd->Op1);
|
580
|
+
SetOperand(cmd->ByteMode, &cmd->Op1, GetOperand(cmd->ByteMode, &cmd->Op2));
|
581
|
+
SetOperand(cmd->ByteMode, &cmd->Op2, v1);
|
582
|
+
}
|
583
|
+
break;
|
584
|
+
case CMD_MUL:
|
585
|
+
{
|
586
|
+
UInt32 res = GetOperand32(&cmd->Op1) * GetOperand32(&cmd->Op2);
|
587
|
+
SetOperand32(&cmd->Op1, res);
|
588
|
+
}
|
589
|
+
break;
|
590
|
+
case CMD_MULB:
|
591
|
+
{
|
592
|
+
Byte res = GetOperand8(&cmd->Op1) * GetOperand8(&cmd->Op2);
|
593
|
+
SetOperand8(&cmd->Op1, res);
|
594
|
+
}
|
595
|
+
break;
|
596
|
+
case CMD_DIV:
|
597
|
+
{
|
598
|
+
UInt32 divider = GetOperand(cmd->ByteMode, &cmd->Op2);
|
599
|
+
if (divider != 0)
|
600
|
+
{
|
601
|
+
UInt32 res = GetOperand(cmd->ByteMode, &cmd->Op1) / divider;
|
602
|
+
SetOperand(cmd->ByteMode, &cmd->Op1, res);
|
603
|
+
}
|
604
|
+
}
|
605
|
+
break;
|
606
|
+
|
607
|
+
#endif
|
608
|
+
|
609
|
+
case CMD_RET:
|
610
|
+
{
|
611
|
+
if (R[kStackRegIndex] >= kSpaceSize)
|
612
|
+
return true;
|
613
|
+
UInt32 ip = GetValue32(&Mem[R[kStackRegIndex] & kSpaceMask]);
|
614
|
+
SET_IP(ip);
|
615
|
+
R[kStackRegIndex] += 4;
|
616
|
+
continue;
|
617
|
+
}
|
618
|
+
case CMD_PRINT:
|
619
|
+
break;
|
620
|
+
}
|
621
|
+
cmd++;
|
622
|
+
--maxOpCount;
|
623
|
+
}
|
624
|
+
}
|
625
|
+
|
626
|
+
|
627
|
+
//////////////////////////////////////////////////////
|
628
|
+
// Read program
|
629
|
+
|
630
|
+
UInt32 ReadEncodedUInt32(CMemBitDecoder &inp)
|
631
|
+
{
|
632
|
+
switch(inp.ReadBits(2))
|
633
|
+
{
|
634
|
+
case 0:
|
635
|
+
return inp.ReadBits(4);
|
636
|
+
case 1:
|
637
|
+
{
|
638
|
+
UInt32 v = inp.ReadBits(4);
|
639
|
+
if (v == 0)
|
640
|
+
return 0xFFFFFF00 | inp.ReadBits(8);
|
641
|
+
else
|
642
|
+
return (v << 4) | inp.ReadBits(4);
|
643
|
+
}
|
644
|
+
case 2:
|
645
|
+
return inp.ReadBits(16);
|
646
|
+
default:
|
647
|
+
return inp.ReadBits(32);
|
648
|
+
}
|
649
|
+
}
|
650
|
+
|
651
|
+
void CVm::DecodeArg(CMemBitDecoder &inp, COperand &op, bool byteMode)
|
652
|
+
{
|
653
|
+
if (inp.ReadBit())
|
654
|
+
{
|
655
|
+
op.Type = OP_TYPE_REG;
|
656
|
+
op.Data = inp.ReadBits(kNumRegBits);
|
657
|
+
}
|
658
|
+
else if (inp.ReadBit() == 0)
|
659
|
+
{
|
660
|
+
op.Type = OP_TYPE_INT;
|
661
|
+
if (byteMode)
|
662
|
+
op.Data = inp.ReadBits(8);
|
663
|
+
else
|
664
|
+
op.Data = ReadEncodedUInt32(inp);
|
665
|
+
}
|
666
|
+
else
|
667
|
+
{
|
668
|
+
op.Type = OP_TYPE_REGMEM;
|
669
|
+
if (inp.ReadBit() == 0)
|
670
|
+
{
|
671
|
+
op.Data = inp.ReadBits(kNumRegBits);
|
672
|
+
op.Base = 0;
|
673
|
+
}
|
674
|
+
else
|
675
|
+
{
|
676
|
+
if (inp.ReadBit() == 0)
|
677
|
+
op.Data = inp.ReadBits(kNumRegBits);
|
678
|
+
else
|
679
|
+
op.Data = kNumRegs;
|
680
|
+
op.Base = ReadEncodedUInt32(inp);
|
681
|
+
}
|
682
|
+
}
|
683
|
+
}
|
684
|
+
|
685
|
+
void CVm::ReadVmProgram(const Byte *code, UInt32 codeSize, CProgram *prg)
|
686
|
+
{
|
687
|
+
CMemBitDecoder inp;
|
688
|
+
inp.Init(code, codeSize);
|
689
|
+
|
690
|
+
prg->StaticData.Clear();
|
691
|
+
if (inp.ReadBit())
|
692
|
+
{
|
693
|
+
UInt32 dataSize = ReadEncodedUInt32(inp) + 1;
|
694
|
+
for (UInt32 i = 0; inp.Avail() && i < dataSize; i++)
|
695
|
+
prg->StaticData.Add((Byte)inp.ReadBits(8));
|
696
|
+
}
|
697
|
+
while (inp.Avail())
|
698
|
+
{
|
699
|
+
prg->Commands.Add(CCommand());
|
700
|
+
CCommand *cmd = &prg->Commands.Back();
|
701
|
+
if (inp.ReadBit() == 0)
|
702
|
+
cmd->OpCode = (ECommand)inp.ReadBits(3);
|
703
|
+
else
|
704
|
+
cmd->OpCode = (ECommand)(8 + inp.ReadBits(5));
|
705
|
+
if (kCmdFlags[cmd->OpCode] & CF_BYTEMODE)
|
706
|
+
cmd->ByteMode = (inp.ReadBit()) ? true : false;
|
707
|
+
else
|
708
|
+
cmd->ByteMode = 0;
|
709
|
+
int opNum = (kCmdFlags[cmd->OpCode] & CF_OPMASK);
|
710
|
+
if (opNum > 0)
|
711
|
+
{
|
712
|
+
DecodeArg(inp, cmd->Op1, cmd->ByteMode);
|
713
|
+
if (opNum == 2)
|
714
|
+
DecodeArg(inp, cmd->Op2, cmd->ByteMode);
|
715
|
+
else
|
716
|
+
{
|
717
|
+
if (cmd->Op1.Type == OP_TYPE_INT && (kCmdFlags[cmd->OpCode] & (CF_JUMP | CF_PROC)))
|
718
|
+
{
|
719
|
+
int Distance = cmd->Op1.Data;
|
720
|
+
if (Distance >= 256)
|
721
|
+
Distance -= 256;
|
722
|
+
else
|
723
|
+
{
|
724
|
+
if (Distance >= 136)
|
725
|
+
Distance -= 264;
|
726
|
+
else if (Distance >= 16)
|
727
|
+
Distance -= 8;
|
728
|
+
else if (Distance >= 8)
|
729
|
+
Distance -= 16;
|
730
|
+
Distance += prg->Commands.Size() - 1;
|
731
|
+
}
|
732
|
+
cmd->Op1.Data = Distance;
|
733
|
+
}
|
734
|
+
}
|
735
|
+
}
|
736
|
+
if (cmd->ByteMode)
|
737
|
+
{
|
738
|
+
switch (cmd->OpCode)
|
739
|
+
{
|
740
|
+
case CMD_MOV: cmd->OpCode = CMD_MOVB; break;
|
741
|
+
case CMD_CMP: cmd->OpCode = CMD_CMPB; break;
|
742
|
+
case CMD_ADD: cmd->OpCode = CMD_ADDB; break;
|
743
|
+
case CMD_SUB: cmd->OpCode = CMD_SUBB; break;
|
744
|
+
case CMD_INC: cmd->OpCode = CMD_INCB; break;
|
745
|
+
case CMD_DEC: cmd->OpCode = CMD_DECB; break;
|
746
|
+
case CMD_XOR: cmd->OpCode = CMD_XORB; break;
|
747
|
+
case CMD_AND: cmd->OpCode = CMD_ANDB; break;
|
748
|
+
case CMD_OR: cmd->OpCode = CMD_ORB; break;
|
749
|
+
case CMD_TEST: cmd->OpCode = CMD_TESTB; break;
|
750
|
+
case CMD_NEG: cmd->OpCode = CMD_NEGB; break;
|
751
|
+
case CMD_SHL: cmd->OpCode = CMD_SHLB; break;
|
752
|
+
case CMD_SHR: cmd->OpCode = CMD_SHRB; break;
|
753
|
+
case CMD_SAR: cmd->OpCode = CMD_SARB; break;
|
754
|
+
case CMD_MUL: cmd->OpCode = CMD_MULB; break;
|
755
|
+
}
|
756
|
+
}
|
757
|
+
}
|
758
|
+
}
|
759
|
+
|
760
|
+
#ifdef RARVM_STANDARD_FILTERS
|
761
|
+
|
762
|
+
enum EStandardFilter
|
763
|
+
{
|
764
|
+
SF_E8,
|
765
|
+
SF_E8E9,
|
766
|
+
SF_ITANIUM,
|
767
|
+
SF_RGB,
|
768
|
+
SF_AUDIO,
|
769
|
+
SF_DELTA,
|
770
|
+
SF_UPCASE
|
771
|
+
};
|
772
|
+
|
773
|
+
struct StandardFilterSignature
|
774
|
+
{
|
775
|
+
UInt32 Length;
|
776
|
+
UInt32 CRC;
|
777
|
+
EStandardFilter Type;
|
778
|
+
}
|
779
|
+
kStdFilters[]=
|
780
|
+
{
|
781
|
+
{ 53, 0xad576887, SF_E8 },
|
782
|
+
{ 57, 0x3cd7e57e, SF_E8E9 },
|
783
|
+
{ 120, 0x3769893f, SF_ITANIUM },
|
784
|
+
{ 29, 0x0e06077d, SF_DELTA },
|
785
|
+
{ 149, 0x1c2c5dc8, SF_RGB },
|
786
|
+
{ 216, 0xbc85e701, SF_AUDIO },
|
787
|
+
{ 40, 0x46b9c560, SF_UPCASE }
|
788
|
+
};
|
789
|
+
|
790
|
+
static int FindStandardFilter(const Byte *code, UInt32 codeSize)
|
791
|
+
{
|
792
|
+
UInt32 crc = CrcCalc(code, codeSize);
|
793
|
+
for (int i = 0; i < sizeof(kStdFilters) / sizeof(kStdFilters[0]); i++)
|
794
|
+
{
|
795
|
+
StandardFilterSignature &sfs = kStdFilters[i];
|
796
|
+
if (sfs.CRC == crc && sfs.Length == codeSize)
|
797
|
+
return i;
|
798
|
+
}
|
799
|
+
return -1;
|
800
|
+
}
|
801
|
+
|
802
|
+
#endif
|
803
|
+
|
804
|
+
void CVm::PrepareProgram(const Byte *code, UInt32 codeSize, CProgram *prg)
|
805
|
+
{
|
806
|
+
Byte xorSum = 0;
|
807
|
+
for (UInt32 i = 1; i < codeSize; i++)
|
808
|
+
xorSum ^= code[i];
|
809
|
+
|
810
|
+
prg->Commands.Clear();
|
811
|
+
#ifdef RARVM_STANDARD_FILTERS
|
812
|
+
prg->StandardFilterIndex = -1;
|
813
|
+
#endif
|
814
|
+
|
815
|
+
if (xorSum == code[0] && codeSize > 0)
|
816
|
+
{
|
817
|
+
#ifdef RARVM_STANDARD_FILTERS
|
818
|
+
prg->StandardFilterIndex = FindStandardFilter(code, codeSize);
|
819
|
+
if (prg->StandardFilterIndex >= 0)
|
820
|
+
return;
|
821
|
+
#endif
|
822
|
+
// 1 byte for checksum
|
823
|
+
ReadVmProgram(code + 1, codeSize - 1, prg);
|
824
|
+
}
|
825
|
+
prg->Commands.Add(CCommand());
|
826
|
+
CCommand *cmd = &prg->Commands.Back();
|
827
|
+
cmd->OpCode = CMD_RET;
|
828
|
+
}
|
829
|
+
|
830
|
+
void CVm::SetMemory(UInt32 pos, const Byte *data, UInt32 dataSize)
|
831
|
+
{
|
832
|
+
if (pos < kSpaceSize && data != Mem + pos)
|
833
|
+
memmove(Mem + pos, data, MyMin(dataSize, kSpaceSize - pos));
|
834
|
+
}
|
835
|
+
|
836
|
+
#ifdef RARVM_STANDARD_FILTERS
|
837
|
+
|
838
|
+
static void E8E9Decode(Byte *data, UInt32 dataSize, UInt32 fileOffset, bool e9)
|
839
|
+
{
|
840
|
+
if (dataSize <= 4)
|
841
|
+
return;
|
842
|
+
dataSize -= 4;
|
843
|
+
const UInt32 kFileSize = 0x1000000;
|
844
|
+
Byte cmpByte2 = (e9 ? 0xE9 : 0xE8);
|
845
|
+
for (UInt32 curPos = 0; curPos < dataSize;)
|
846
|
+
{
|
847
|
+
Byte curByte = *(data++);
|
848
|
+
curPos++;
|
849
|
+
if (curByte == 0xE8 || curByte == cmpByte2)
|
850
|
+
{
|
851
|
+
UInt32 offset = curPos + fileOffset;
|
852
|
+
UInt32 addr = (Int32)GetValue32(data);
|
853
|
+
if (addr < kFileSize)
|
854
|
+
SetValue32(data, addr - offset);
|
855
|
+
else if ((Int32)addr < 0 && (Int32)(addr + offset) >= 0)
|
856
|
+
SetValue32(data, addr + kFileSize);
|
857
|
+
data += 4;
|
858
|
+
curPos += 4;
|
859
|
+
}
|
860
|
+
}
|
861
|
+
}
|
862
|
+
|
863
|
+
static inline UInt32 ItaniumGetOpType(const Byte *data, int bitPos)
|
864
|
+
{
|
865
|
+
return (data[(unsigned int)bitPos >> 3] >> (bitPos & 7)) & 0xF;
|
866
|
+
}
|
867
|
+
|
868
|
+
|
869
|
+
static void ItaniumDecode(Byte *data, UInt32 dataSize, UInt32 fileOffset)
|
870
|
+
{
|
871
|
+
UInt32 curPos = 0;
|
872
|
+
fileOffset >>= 4;
|
873
|
+
while (curPos < dataSize - 21)
|
874
|
+
{
|
875
|
+
int b = (data[0] & 0x1F) - 0x10;
|
876
|
+
if (b >= 0)
|
877
|
+
{
|
878
|
+
static Byte kCmdMasks[16] = {4,4,6,6,0,0,7,7,4,4,0,0,4,4,0,0};
|
879
|
+
Byte cmdMask = kCmdMasks[b];
|
880
|
+
if (cmdMask != 0)
|
881
|
+
for (int i = 0; i < 3; i++)
|
882
|
+
if (cmdMask & (1 << i))
|
883
|
+
{
|
884
|
+
int startPos = i * 41 + 18;
|
885
|
+
if (ItaniumGetOpType(data, startPos + 24) == 5)
|
886
|
+
{
|
887
|
+
const UInt32 kMask = 0xFFFFF;
|
888
|
+
Byte *p = data + ((unsigned int)startPos >> 3);
|
889
|
+
UInt32 bitField = ((UInt32)p[0]) | ((UInt32)p[1] << 8) | ((UInt32)p[2] << 16);
|
890
|
+
int inBit = (startPos & 7);
|
891
|
+
UInt32 offset = (bitField >> inBit) & kMask;
|
892
|
+
UInt32 andMask = ~(kMask << inBit);
|
893
|
+
bitField = ((offset - fileOffset) & kMask) << inBit;
|
894
|
+
for (int j = 0; j < 3; j++)
|
895
|
+
{
|
896
|
+
p[j] &= andMask;
|
897
|
+
p[j] |= bitField;
|
898
|
+
andMask >>= 8;
|
899
|
+
bitField >>= 8;
|
900
|
+
}
|
901
|
+
}
|
902
|
+
}
|
903
|
+
}
|
904
|
+
data += 16;
|
905
|
+
curPos += 16;
|
906
|
+
fileOffset++;
|
907
|
+
}
|
908
|
+
}
|
909
|
+
|
910
|
+
static void DeltaDecode(Byte *data, UInt32 dataSize, UInt32 numChannels)
|
911
|
+
{
|
912
|
+
UInt32 srcPos = 0;
|
913
|
+
UInt32 border = dataSize * 2;
|
914
|
+
for (UInt32 curChannel = 0; curChannel < numChannels; curChannel++)
|
915
|
+
{
|
916
|
+
Byte prevByte = 0;
|
917
|
+
for (UInt32 destPos = dataSize + curChannel; destPos < border; destPos += numChannels)
|
918
|
+
data[destPos] = (prevByte = prevByte - data[srcPos++]);
|
919
|
+
}
|
920
|
+
}
|
921
|
+
|
922
|
+
static void RgbDecode(Byte *srcData, UInt32 dataSize, UInt32 width, UInt32 posR)
|
923
|
+
{
|
924
|
+
Byte *destData = srcData + dataSize;
|
925
|
+
const UInt32 numChannels = 3;
|
926
|
+
for (UInt32 curChannel = 0; curChannel < numChannels; curChannel++)
|
927
|
+
{
|
928
|
+
Byte prevByte = 0;
|
929
|
+
|
930
|
+
for (UInt32 i = curChannel; i < dataSize; i+= numChannels)
|
931
|
+
{
|
932
|
+
unsigned int predicted;
|
933
|
+
if (i < width)
|
934
|
+
predicted = prevByte;
|
935
|
+
else
|
936
|
+
{
|
937
|
+
unsigned int upperLeftByte = destData[i - width];
|
938
|
+
unsigned int upperByte = destData[i - width + 3];
|
939
|
+
predicted = prevByte + upperByte - upperLeftByte;
|
940
|
+
int pa = abs((int)(predicted - prevByte));
|
941
|
+
int pb = abs((int)(predicted - upperByte));
|
942
|
+
int pc = abs((int)(predicted - upperLeftByte));
|
943
|
+
if (pa <= pb && pa <= pc)
|
944
|
+
predicted = prevByte;
|
945
|
+
else
|
946
|
+
if (pb <= pc)
|
947
|
+
predicted = upperByte;
|
948
|
+
else
|
949
|
+
predicted = upperLeftByte;
|
950
|
+
}
|
951
|
+
destData[i] = prevByte = (Byte)(predicted - *(srcData++));
|
952
|
+
}
|
953
|
+
}
|
954
|
+
if (dataSize < 3)
|
955
|
+
return;
|
956
|
+
for (UInt32 i = posR, border = dataSize - 2; i < border; i += 3)
|
957
|
+
{
|
958
|
+
Byte g = destData[i + 1];
|
959
|
+
destData[i] = destData[i] + g;
|
960
|
+
destData[i + 2] = destData[i + 2] + g;
|
961
|
+
}
|
962
|
+
}
|
963
|
+
|
964
|
+
static void AudioDecode(Byte *srcData, UInt32 dataSize, UInt32 numChannels)
|
965
|
+
{
|
966
|
+
Byte *destData = srcData + dataSize;
|
967
|
+
for (UInt32 curChannel = 0; curChannel < numChannels; curChannel++)
|
968
|
+
{
|
969
|
+
UInt32 prevByte = 0, prevDelta = 0, dif[7];
|
970
|
+
Int32 D1 = 0, D2 = 0, D3;
|
971
|
+
Int32 K1 = 0, K2 = 0, K3 = 0;
|
972
|
+
memset(dif, 0, sizeof(dif));
|
973
|
+
|
974
|
+
for (UInt32 i = curChannel, byteCount = 0; i < dataSize; i += numChannels, byteCount++)
|
975
|
+
{
|
976
|
+
D3 = D2;
|
977
|
+
D2 = prevDelta - D1;
|
978
|
+
D1 = prevDelta;
|
979
|
+
|
980
|
+
UInt32 predicted = 8 * prevByte + K1 * D1 + K2 * D2 + K3 * D3;
|
981
|
+
predicted = (predicted >> 3) & 0xFF;
|
982
|
+
|
983
|
+
UInt32 curByte = *(srcData++);
|
984
|
+
|
985
|
+
predicted -= curByte;
|
986
|
+
destData[i] = (Byte)predicted;
|
987
|
+
prevDelta = (UInt32)(Int32)(signed char)(predicted - prevByte);
|
988
|
+
prevByte = predicted;
|
989
|
+
|
990
|
+
Int32 D = ((Int32)(signed char)curByte) << 3;
|
991
|
+
|
992
|
+
dif[0] += abs(D);
|
993
|
+
dif[1] += abs(D - D1);
|
994
|
+
dif[2] += abs(D + D1);
|
995
|
+
dif[3] += abs(D - D2);
|
996
|
+
dif[4] += abs(D + D2);
|
997
|
+
dif[5] += abs(D - D3);
|
998
|
+
dif[6] += abs(D + D3);
|
999
|
+
|
1000
|
+
if ((byteCount & 0x1F) == 0)
|
1001
|
+
{
|
1002
|
+
UInt32 minDif = dif[0], numMinDif = 0;
|
1003
|
+
dif[0] = 0;
|
1004
|
+
for (int j = 1; j < sizeof(dif) / sizeof(dif[0]); j++)
|
1005
|
+
{
|
1006
|
+
if (dif[j] < minDif)
|
1007
|
+
{
|
1008
|
+
minDif = dif[j];
|
1009
|
+
numMinDif = j;
|
1010
|
+
}
|
1011
|
+
dif[j] = 0;
|
1012
|
+
}
|
1013
|
+
switch (numMinDif)
|
1014
|
+
{
|
1015
|
+
case 1: if (K1 >= -16) K1--; break;
|
1016
|
+
case 2: if (K1 < 16) K1++; break;
|
1017
|
+
case 3: if (K2 >= -16) K2--; break;
|
1018
|
+
case 4: if (K2 < 16) K2++; break;
|
1019
|
+
case 5: if (K3 >= -16) K3--; break;
|
1020
|
+
case 6: if (K3 < 16) K3++; break;
|
1021
|
+
}
|
1022
|
+
}
|
1023
|
+
}
|
1024
|
+
}
|
1025
|
+
}
|
1026
|
+
|
1027
|
+
static UInt32 UpCaseDecode(Byte *data, UInt32 dataSize)
|
1028
|
+
{
|
1029
|
+
UInt32 srcPos = 0, destPos = dataSize;
|
1030
|
+
while (srcPos < dataSize)
|
1031
|
+
{
|
1032
|
+
Byte curByte = data[srcPos++];
|
1033
|
+
if (curByte == 2 && (curByte = data[srcPos++]) != 2)
|
1034
|
+
curByte -= 32;
|
1035
|
+
data[destPos++] = curByte;
|
1036
|
+
}
|
1037
|
+
return destPos - dataSize;
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
void CVm::ExecuteStandardFilter(int filterIndex)
|
1041
|
+
{
|
1042
|
+
UInt32 dataSize = R[4];
|
1043
|
+
if (dataSize >= kGlobalOffset)
|
1044
|
+
return;
|
1045
|
+
EStandardFilter filterType = kStdFilters[filterIndex].Type;
|
1046
|
+
|
1047
|
+
switch (filterType)
|
1048
|
+
{
|
1049
|
+
case SF_E8:
|
1050
|
+
case SF_E8E9:
|
1051
|
+
E8E9Decode(Mem, dataSize, R[6], (filterType == SF_E8E9));
|
1052
|
+
break;
|
1053
|
+
case SF_ITANIUM:
|
1054
|
+
ItaniumDecode(Mem, dataSize, R[6]);
|
1055
|
+
break;
|
1056
|
+
case SF_DELTA:
|
1057
|
+
if (dataSize >= kGlobalOffset / 2)
|
1058
|
+
break;
|
1059
|
+
SetBlockPos(dataSize);
|
1060
|
+
DeltaDecode(Mem, dataSize, R[0]);
|
1061
|
+
break;
|
1062
|
+
case SF_RGB:
|
1063
|
+
if (dataSize >= kGlobalOffset / 2)
|
1064
|
+
break;
|
1065
|
+
{
|
1066
|
+
UInt32 width = R[0];
|
1067
|
+
if (width <= 3)
|
1068
|
+
break;
|
1069
|
+
SetBlockPos(dataSize);
|
1070
|
+
RgbDecode(Mem, dataSize, width, R[1]);
|
1071
|
+
}
|
1072
|
+
break;
|
1073
|
+
case SF_AUDIO:
|
1074
|
+
if (dataSize >= kGlobalOffset / 2)
|
1075
|
+
break;
|
1076
|
+
SetBlockPos(dataSize);
|
1077
|
+
AudioDecode(Mem, dataSize, R[0]);
|
1078
|
+
break;
|
1079
|
+
case SF_UPCASE:
|
1080
|
+
if (dataSize >= kGlobalOffset / 2)
|
1081
|
+
break;
|
1082
|
+
UInt32 destSize = UpCaseDecode(Mem, dataSize);
|
1083
|
+
SetBlockSize(destSize);
|
1084
|
+
SetBlockPos(dataSize);
|
1085
|
+
break;
|
1086
|
+
}
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
#endif
|
1090
|
+
|
1091
|
+
}}}
|