diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2010-09-08 04:00:00 +0400 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:03 +0300 |
commit | 044e4bb7413beb329edfa3ad27b492d819cdc811 (patch) | |
tree | 9da146355814669c1c9331c596edce0acd21c490 /CPP/7zip | |
parent | e279500d76f1944ba26526f085030909a2c7ef49 (diff) |
9.169.16
Diffstat (limited to 'CPP/7zip')
-rwxr-xr-x | CPP/7zip/Archive/FatHandler.cpp | 9 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Nsis/NsisDecode.cpp | 27 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Nsis/NsisHandler.cpp | 43 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Nsis/NsisIn.cpp | 31 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Tar/TarHandlerOut.cpp | 3 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Tar/TarIn.cpp | 13 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Tar/TarOut.cpp | 27 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Wim/WimIn.cpp | 67 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Wim/WimIn.h | 1 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Zip/ZipHeader.h | 2 | ||||
-rwxr-xr-x | CPP/7zip/Bundles/Fm/makefile | 1 | ||||
-rwxr-xr-x | CPP/7zip/Bundles/Format7zF/Format7z.dsp | 4 | ||||
-rwxr-xr-x | CPP/7zip/Bundles/Format7zF/makefile | 1 | ||||
-rwxr-xr-x | CPP/7zip/Bundles/Format7zF/resource.rc | 2 | ||||
-rwxr-xr-x | CPP/7zip/Common/CWrappers.cpp | 4 | ||||
-rwxr-xr-x | CPP/7zip/Compress/BZip2Decoder.cpp | 184 | ||||
-rwxr-xr-x | CPP/7zip/Compress/BZip2Decoder.h | 36 | ||||
-rwxr-xr-x | CPP/7zip/Compress/DeflateNsisRegister.cpp | 14 | ||||
-rwxr-xr-x | CPP/7zip/Compress/Rar3Decoder.cpp | 6 | ||||
-rwxr-xr-x | CPP/7zip/Crypto/ZipStrong.cpp | 6 | ||||
-rwxr-xr-x | CPP/7zip/MyVersion.h | 8 | ||||
-rwxr-xr-x | CPP/7zip/UI/FileManager/PanelItemOpen.cpp | 2 |
22 files changed, 365 insertions, 126 deletions
diff --git a/CPP/7zip/Archive/FatHandler.cpp b/CPP/7zip/Archive/FatHandler.cpp index 22a61f88..1c374a44 100755 --- a/CPP/7zip/Archive/FatHandler.cpp +++ b/CPP/7zip/Archive/FatHandler.cpp @@ -526,7 +526,14 @@ HRESULT CDatabase::ReadDir(Int32 parent, UInt32 cluster, int level) item.Attrib = attrib; item.Flags = p[12]; item.Size = Get32(p + 28); - item.Cluster = Get16(p + 26) | ((UInt32)Get16(p + 20) << 16); + item.Cluster = Get16(p + 26); + if (Header.NumFatBits > 16) + item.Cluster |= ((UInt32)Get16(p + 20) << 16); + else + { + // OS/2 and WinNT probably can store EA (extended atributes) in that field. + } + item.CTime = Get32(p + 14); item.CTime2 = p[13]; item.ADate = Get16(p + 18); diff --git a/CPP/7zip/Archive/Nsis/NsisDecode.cpp b/CPP/7zip/Archive/Nsis/NsisDecode.cpp index 7e126bd4..0845f965 100755 --- a/CPP/7zip/Archive/Nsis/NsisDecode.cpp +++ b/CPP/7zip/Archive/Nsis/NsisDecode.cpp @@ -7,15 +7,14 @@ #include "../../Common/StreamUtils.h" #include "../../Common/MethodId.h" -#include "../../Common/CreateCoder.h" + +#include "../../Compress/BZip2Decoder.h" +#include "../../Compress/DeflateDecoder.h" +#include "../../Compress/LzmaDecoder.h" namespace NArchive { namespace NNsis { -static const CMethodId k_Copy = 0x0; -static const CMethodId k_Deflate = 0x040901; -static const CMethodId k_BZip2 = 0x040902; -static const CMethodId k_LZMA = 0x030101; static const CMethodId k_BCJ_X86 = 0x03030103; HRESULT CDecoder::Init( @@ -31,24 +30,14 @@ HRESULT CDecoder::Init( _method = method; if (!_codecInStream) { - CMethodId methodID; switch (method) { - case NMethodType::kCopy: methodID = k_Copy; break; - case NMethodType::kDeflate: methodID = k_Deflate; break; - case NMethodType::kBZip2: methodID = k_BZip2; break; - case NMethodType::kLZMA: methodID = k_LZMA; break; + // case NMethodType::kCopy: return E_NOTIMPL; + case NMethodType::kDeflate: _codecInStream = new NCompress::NDeflate::NDecoder::CNsisCOMCoder(); break; + case NMethodType::kBZip2: _codecInStream = new NCompress::NBZip2::CNsisDecoder(); break; + case NMethodType::kLZMA: _codecInStream = new NCompress::NLzma::CDecoder(); break; default: return E_NOTIMPL; } - CMyComPtr<ICompressCoder> coder; - RINOK(CreateCoder( - EXTERNAL_CODECS_LOC_VARS - methodID, coder, false)); - if (!coder) - return E_NOTIMPL; - coder.QueryInterface(IID_ISequentialInStream, &_codecInStream); - if (!_codecInStream) - return E_NOTIMPL; } if (thereIsFilterFlag) diff --git a/CPP/7zip/Archive/Nsis/NsisHandler.cpp b/CPP/7zip/Archive/Nsis/NsisHandler.cpp index 818b0a88..4058bd2a 100755 --- a/CPP/7zip/Archive/Nsis/NsisHandler.cpp +++ b/CPP/7zip/Archive/Nsis/NsisHandler.cpp @@ -87,7 +87,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 * maxCheckStartPosit COM_TRY_BEGIN Close(); { - if(_archive.Open( + if (_archive.Open( EXTERNAL_CODECS_VARS stream, maxCheckStartPosition) != S_OK) return S_FALSE; @@ -264,12 +264,12 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) GetNumberOfItems(&numItems); - if(numItems == 0) + if (numItems == 0) return S_OK; UInt64 totalSize = 0; UInt32 i; - for(i = 0; i < numItems; i++) + for (i = 0; i < numItems; i++) { UInt32 index = (allFilesMode ? i : indices[i]); #ifdef NSIS_SCRIPT @@ -313,6 +313,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, byteBuf.SetCapacity(kBufferLength); Byte *buffer = byteBuf; + CByteBuffer tempBuf; + bool dataError = false; for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize) { @@ -330,7 +332,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, if (index >= (UInt32)_archive.Items.Size()) { currentItemSize = _archive.Script.Length(); - if(!testMode && !realOutStream) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); if (!testMode) @@ -346,7 +348,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, else GetCompressedSize(index, currentItemSize); - if(!testMode && !realOutStream) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); @@ -357,10 +359,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, bool sizeIsKnown = false; UInt32 fullSize = 0; + bool writeToTemp = false; + bool readFromTemp = false; + if (_archive.IsSolid) { UInt64 pos = _archive.GetPosOfSolidItem(index); - while(streamPos < pos) + while (streamPos < pos) { size_t processedSize = (UInt32)MyMin(pos - streamPos, (UInt64)kBufferLength); HRESULT res = _archive.Decoder.Read(buffer, &processedSize); @@ -389,7 +394,20 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, fullSize = Get32(buffer2); sizeIsKnown = true; needDecompress = true; + + if (!testMode && i + 1 < numItems) + { + UInt64 nextPos = _archive.GetPosOfSolidItem(allFilesMode ? i : indices[i + 1]); + if (nextPos < streamPos + fullSize) + { + tempBuf.Free(); + tempBuf.SetCapacity(fullSize); + writeToTemp = true; + } + } } + else + readFromTemp = true; } else { @@ -413,7 +431,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, if (needDecompress) { UInt64 offset = 0; - while(!sizeIsKnown || fullSize > 0) + while (!sizeIsKnown || fullSize > 0) { UInt32 curSize = kBufferLength; if (sizeIsKnown && curSize > fullSize) @@ -433,6 +451,9 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, dataError = true; break; } + + if (writeToTemp) + memcpy((Byte *)tempBuf + (size_t)offset, buffer, processedSize); fullSize -= (UInt32)processedSize; streamPos += processedSize; @@ -450,7 +471,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, } else { - while(fullSize > 0) + if (readFromTemp) + { + if (!testMode) + RINOK(WriteStream(realOutStream, tempBuf, tempBuf.GetCapacity())); + } + else + while (fullSize > 0) { UInt32 curSize = MyMin(fullSize, kBufferLength); UInt32 processedSize; diff --git a/CPP/7zip/Archive/Nsis/NsisIn.cpp b/CPP/7zip/Archive/Nsis/NsisIn.cpp index 290349aa..40756008 100755 --- a/CPP/7zip/Archive/Nsis/NsisIn.cpp +++ b/CPP/7zip/Archive/Nsis/NsisIn.cpp @@ -1151,16 +1151,25 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh) bool sameName = IsUnicode ? (Items[i].NameU == Items[i + 1].NameU) : (Items[i].NameA == Items[i + 1].NameA); - if (Items[i].Pos == Items[i + 1].Pos && (IsSolid || sameName)) + if (Items[i].Pos == Items[i + 1].Pos && sameName) Items.Delete(i + 1); else i++; } - for (i = 0; i + 1 < Items.Size(); i++) + for (i = 0; i < Items.Size(); i++) { CItem &item = Items[i]; - item.EstimatedSizeIsDefined = true; - item.EstimatedSize = Items[i + 1].Pos - item.Pos - 4; + UInt32 curPos = item.Pos + 4; + for (int nextIndex = i + 1; nextIndex < Items.Size(); nextIndex++) + { + UInt32 nextPos = Items[nextIndex].Pos; + if (curPos <= nextPos) + { + item.EstimatedSizeIsDefined = true; + item.EstimatedSize = nextPos - curPos; + break; + } + } } if (!IsSolid) { @@ -1275,6 +1284,11 @@ static bool IsLZMA(const Byte *p, UInt32 &dictionary, bool &thereIsFlag) return false; } +static bool IsBZip2(const Byte *p) +{ + return (p[0] == 0x31 && p[1] < 14); +} + HRESULT CInArchive::Open2( DECL_EXTERNAL_CODECS_LOC_VARS2 ) @@ -1312,7 +1326,14 @@ HRESULT CInArchive::Open2( else if (sig[3] == 0x80) { IsSolid = false; - Method = NMethodType::kDeflate; + if (IsBZip2(sig + 4)) + Method = NMethodType::kBZip2; + else + Method = NMethodType::kDeflate; + } + else if (IsBZip2(sig)) + { + Method = NMethodType::kBZip2; } else { diff --git a/CPP/7zip/Archive/Tar/TarHandlerOut.cpp b/CPP/7zip/Archive/Tar/TarHandlerOut.cpp index 92b8abdc..a999f838 100755 --- a/CPP/7zip/Archive/Tar/TarHandlerOut.cpp +++ b/CPP/7zip/Archive/Tar/TarHandlerOut.cpp @@ -107,8 +107,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt if (prop.vt != VT_UI8) return E_INVALIDARG; ui.Size = prop.uhVal.QuadPart; + /* + // now we support GNU extension for big files if (ui.Size >= ((UInt64)1 << 33)) return E_INVALIDARG; + */ } updateItems.Add(ui); } diff --git a/CPP/7zip/Archive/Tar/TarIn.cpp b/CPP/7zip/Archive/Tar/TarIn.cpp index 939c6c0a..c9c3c422 100755 --- a/CPP/7zip/Archive/Tar/TarIn.cpp +++ b/CPP/7zip/Archive/Tar/TarIn.cpp @@ -2,6 +2,8 @@ #include "StdAfx.h" +#include "../../../../C/CpuArch.h" + #include "Common/StringToInt.h" #include "../../Common/StreamUtils.h" @@ -92,7 +94,16 @@ static HRESULT GetNextItemReal(ISequentialInStream *stream, bool &filled, CItemE if (!OctalToNumber32(p, 8, item.UID)) item.UID = 0; p += 8; if (!OctalToNumber32(p, 8, item.GID)) item.GID = 0; p += 8; - RIF(OctalToNumber(p, 12, item.Size)); p += 12; + if (GetBe32(p) == (UInt32)1 << 31) + { + // GNU extension + item.Size = GetBe64(p + 4); + } + else + { + RIF(OctalToNumber(p, 12, item.Size)); + } + p += 12; RIF(OctalToNumber32(p, 12, item.MTime)); p += 12; UInt32 checkSum; diff --git a/CPP/7zip/Archive/Tar/TarOut.cpp b/CPP/7zip/Archive/Tar/TarOut.cpp index 1ec314c7..e542a3b2 100755 --- a/CPP/7zip/Archive/Tar/TarOut.cpp +++ b/CPP/7zip/Archive/Tar/TarOut.cpp @@ -53,17 +53,23 @@ static bool MakeOctalString8(char *s, UInt32 value) return true; } -static bool MakeOctalString12(char *s, UInt64 value) +static void MakeOctalString12(char *s, UInt64 value) { AString tempString = MakeOctalString(value); const int kMaxSize = 12; if (tempString.Length() > kMaxSize) - return false; + { + // GNU extension; + s[0] = (char)(Byte)0x80; + s[1] = s[2] = s[3] = 0; + for (int i = 0; i < 8; i++, value <<= 8) + s[4 + i] = (char)(value >> 56); + return; + } int numSpaces = kMaxSize - tempString.Length(); for(int i = 0; i < numSpaces; i++) s[i] = ' '; memmove(s + numSpaces, (const char *)tempString, tempString.Length()); - return true; } static bool CopyString(char *dest, const AString &src, int maxSize) @@ -90,17 +96,12 @@ HRESULT COutArchive::WriteHeaderReal(const CItem &item) MyStrNCpy(cur, item.Name, NFileHeader::kNameSize); cur += NFileHeader::kNameSize; - RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.Mode)); - cur += 8; - RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.UID)); - cur += 8; - RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.GID)); - cur += 8; + RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.Mode)); cur += 8; + RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.UID)); cur += 8; + RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.GID)); cur += 8; - RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.Size)); - cur += 12; - RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.MTime)); - cur += 12; + MakeOctalString12(cur, item.Size); cur += 12; + MakeOctalString12(cur, item.MTime); cur += 12; memmove(cur, NFileHeader::kCheckSumBlanks, 8); cur += 8; diff --git a/CPP/7zip/Archive/Wim/WimIn.cpp b/CPP/7zip/Archive/Wim/WimIn.cpp index 4ea028af..c2e8df69 100755 --- a/CPP/7zip/Archive/Wim/WimIn.cpp +++ b/CPP/7zip/Archive/Wim/WimIn.cpp @@ -258,12 +258,23 @@ void CResource::Parse(const Byte *p) #define GetResource(p, res) res.Parse(p) -static void GetStream(const Byte *p, CStreamInfo &s) +static void GetStream(bool oldVersion, const Byte *p, CStreamInfo &s) { s.Resource.Parse(p); - s.PartNumber = Get16(p + 24); - s.RefCount = Get32(p + 26); - memcpy(s.Hash, p + 30, kHashSize); + if (oldVersion) + { + s.PartNumber = 1; + s.RefCount = 1; + // UInt32 id = Get32(p + 24); + // UInt32 unknown = Get32(p + 28); + memcpy(s.Hash, p + 32, kHashSize); + } + else + { + s.PartNumber = Get16(p + 24); + s.RefCount = Get32(p + 26); + memcpy(s.Hash, p + 30, kHashSize); + } } static const wchar_t *kLongPath = L"[LongPath]"; @@ -386,7 +397,7 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent) UInt32 fileNameLen = Get16(p + 0x24); if ((fileNameLen & 1) != 0) return S_FALSE; - /* Probably different versions of ImageX can use different number of + /* Probably different versions of ImageX can use different number of additional ZEROs. So we don't use exact check. */ UInt32 fileNameLen2 = (fileNameLen == 0 ? fileNameLen : fileNameLen + 2); if (((0x26 + fileNameLen2 + 6) & ~7) > len) @@ -527,9 +538,7 @@ HRESULT CDatabase::ParseImageDirs(const CByteBuffer &buf, int parent) HRESULT CHeader::Parse(const Byte *p) { - UInt32 haderSize = Get32(p + 8); - if (haderSize < 0x74) - return S_FALSE; + UInt32 headerSize = Get32(p + 8); Version = Get32(p + 0x0C); Flags = Get32(p + 0x10); if (!IsSupported()) @@ -537,25 +546,42 @@ HRESULT CHeader::Parse(const Byte *p) ChunkSize = Get32(p + 0x14); if (ChunkSize != kChunkSize && ChunkSize != 0) return S_FALSE; - memcpy(Guid, p + 0x18, 16); - PartNumber = Get16(p + 0x28); - NumParts = Get16(p + 0x2A); - int offset = 0x2C; - if (IsNewVersion()) + int offset; + if (IsOldVersion()) { - NumImages = Get32(p + offset); - offset += 4; + if (headerSize != 0x60) + return S_FALSE; + memset(Guid, 0, 16); + offset = 0x18; + PartNumber = 1; + NumParts = 1; + } + else + { + if (headerSize < 0x74) + return S_FALSE; + memcpy(Guid, p + 0x18, 16); + PartNumber = Get16(p + 0x28); + NumParts = Get16(p + 0x2A); + offset = 0x2C; + if (IsNewVersion()) + { + NumImages = Get32(p + offset); + offset += 4; + } } GetResource(p + offset, OffsetResource); GetResource(p + offset + 0x18, XmlResource); GetResource(p + offset + 0x30, MetadataResource); if (IsNewVersion()) { - if (haderSize < 0xD0) + if (headerSize < 0xD0) return S_FALSE; BootIndex = Get32(p + 0x48); IntegrityResource.Parse(p + offset + 0x4C); } + if (IsOldVersion()) + return S_FALSE; return S_OK; } @@ -570,15 +596,16 @@ HRESULT ReadHeader(IInStream *inStream, CHeader &h) return h.Parse(p); } -static HRESULT ReadStreams(IInStream *inStream, const CHeader &h, CDatabase &db) +static HRESULT ReadStreams(bool oldVersion, IInStream *inStream, const CHeader &h, CDatabase &db) { CByteBuffer offsetBuf; RINOK(UnpackData(inStream, h.OffsetResource, h.IsLzxMode(), offsetBuf, NULL)); size_t i; - for (i = 0; offsetBuf.GetCapacity() - i >= kStreamInfoSize; i += kStreamInfoSize) + size_t streamInfoSize = oldVersion ? kStreamInfoSize + 2 : kStreamInfoSize; + for (i = 0; offsetBuf.GetCapacity() - i >= streamInfoSize; i += streamInfoSize) { CStreamInfo s; - GetStream((const Byte *)offsetBuf + i, s); + GetStream(oldVersion, (const Byte *)offsetBuf + i, s); if (s.PartNumber == h.PartNumber) db.Streams.Add(s); } @@ -589,7 +616,7 @@ HRESULT CDatabase::Open(IInStream *inStream, const CHeader &h, CByteBuffer &xml, { OpenCallback = openCallback; RINOK(UnpackData(inStream, h.XmlResource, h.IsLzxMode(), xml, NULL)); - RINOK(ReadStreams(inStream, h, *this)); + RINOK(ReadStreams(h.IsOldVersion(), inStream, h, *this)); bool needBootMetadata = !h.MetadataResource.IsEmpty(); Order = 0; if (h.PartNumber == 1) diff --git a/CPP/7zip/Archive/Wim/WimIn.h b/CPP/7zip/Archive/Wim/WimIn.h index 5bca71db..2a40adb3 100755 --- a/CPP/7zip/Archive/Wim/WimIn.h +++ b/CPP/7zip/Archive/Wim/WimIn.h @@ -155,6 +155,7 @@ struct CHeader bool IsSupported() const { return (!IsCompressed() || (Flags & NHeaderFlags::kLZX) != 0 || (Flags & NHeaderFlags::kXPRESS) != 0 ) ; } bool IsLzxMode() const { return (Flags & NHeaderFlags::kLZX) != 0; } bool IsSpanned() const { return (!IsCompressed() || (Flags & NHeaderFlags::kSpanned) != 0); } + bool IsOldVersion() const { return (Version == 0x010A00); } bool IsNewVersion()const { return (Version > 0x010C00); } bool AreFromOnArchive(const CHeader &h) diff --git a/CPP/7zip/Archive/Zip/ZipHeader.h b/CPP/7zip/Archive/Zip/ZipHeader.h index eeff5980..ce8c1e4f 100755 --- a/CPP/7zip/Archive/Zip/ZipHeader.h +++ b/CPP/7zip/Archive/Zip/ZipHeader.h @@ -78,7 +78,7 @@ namespace NFileHeader kWzAES = 0x63 }; const int kNumCompressionMethods = 11; - const Byte kMadeByProgramVersion = 20; + const Byte kMadeByProgramVersion = 63; const Byte kExtractVersion_Default = 10; const Byte kExtractVersion_Dir = 20; diff --git a/CPP/7zip/Bundles/Fm/makefile b/CPP/7zip/Bundles/Fm/makefile index 74703a99..e9e30d6f 100755 --- a/CPP/7zip/Bundles/Fm/makefile +++ b/CPP/7zip/Bundles/Fm/makefile @@ -358,7 +358,6 @@ COMPRESS_OBJS = \ $O\Deflate64Register.obj \ $O\DeflateDecoder.obj \ $O\DeflateEncoder.obj \ - $O\DeflateNsisRegister.obj \ $O\DeflateRegister.obj \ $O\DeltaFilter.obj \ $O\ImplodeDecoder.obj \ diff --git a/CPP/7zip/Bundles/Format7zF/Format7z.dsp b/CPP/7zip/Bundles/Format7zF/Format7z.dsp index 4b24d0b9..52edc93f 100755 --- a/CPP/7zip/Bundles/Format7zF/Format7z.dsp +++ b/CPP/7zip/Bundles/Format7zF/Format7z.dsp @@ -539,10 +539,6 @@ SOURCE=..\..\Compress\DeflateEncoder.h # End Source File # Begin Source File -SOURCE=..\..\Compress\DeflateNsisRegister.cpp -# End Source File -# Begin Source File - SOURCE=..\..\Compress\DeflateRegister.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/Bundles/Format7zF/makefile b/CPP/7zip/Bundles/Format7zF/makefile index 5afa115e..8199dd79 100755 --- a/CPP/7zip/Bundles/Format7zF/makefile +++ b/CPP/7zip/Bundles/Format7zF/makefile @@ -210,7 +210,6 @@ COMPRESS_OBJS = \ $O\Deflate64Register.obj \ $O\DeflateDecoder.obj \ $O\DeflateEncoder.obj \ - $O\DeflateNsisRegister.obj \ $O\DeflateRegister.obj \ $O\DeltaFilter.obj \ $O\ImplodeDecoder.obj \ diff --git a/CPP/7zip/Bundles/Format7zF/resource.rc b/CPP/7zip/Bundles/Format7zF/resource.rc index 60c1f732..c6edfecc 100755 --- a/CPP/7zip/Bundles/Format7zF/resource.rc +++ b/CPP/7zip/Bundles/Format7zF/resource.rc @@ -32,5 +32,5 @@ MY_VERSION_INFO_DLL("7z Standalone Plugin", "7za") STRINGTABLE BEGIN - 100 "7z:0 zip:1 bz2:2 bzip2:2 tbz2:2 tbz:2 rar:3 arj:4 z:5 taz:5 lzh:6 lha:6 cab:7 iso:8 001:9 rpm:10 deb:11 cpio:12 tar:13 gz:14 gzip:14 tgz:14 tpz:14 wim:15 swm:15 lzma:16 dmg:17 hfs:18 xar:19 vhd:20 fat:21 ntfs:22 xz:23" + 100 "7z:0 zip:1 bz2:2 bzip2:2 tbz2:2 tbz:2 rar:3 arj:4 z:5 taz:5 lzh:6 lha:6 cab:7 iso:8 001:9 rpm:10 deb:11 cpio:12 tar:13 gz:14 gzip:14 tgz:14 tpz:14 wim:15 swm:15 lzma:16 dmg:17 hfs:18 xar:19 vhd:20 fat:21 ntfs:22 xz:23 txz:23" END diff --git a/CPP/7zip/Common/CWrappers.cpp b/CPP/7zip/Common/CWrappers.cpp index 41537e97..358f0b50 100755 --- a/CPP/7zip/Common/CWrappers.cpp +++ b/CPP/7zip/Common/CWrappers.cpp @@ -164,7 +164,7 @@ Byte CByteInBufWrap::ReadByteFromNewBlock() return 0; } -extern "C" static Byte Wrap_ReadByte(void *pp) +static Byte Wrap_ReadByte(void *pp) { CByteInBufWrap *p = (CByteInBufWrap *)pp; if (p->Cur != p->Lim) @@ -210,7 +210,7 @@ HRESULT CByteOutBufWrap::Flush() return Res; } -extern "C" static void Wrap_WriteByte(void *pp, Byte b) +static void Wrap_WriteByte(void *pp, Byte b) { CByteOutBufWrap *p = (CByteOutBufWrap *)pp; Byte *dest = p->Cur; diff --git a/CPP/7zip/Compress/BZip2Decoder.cpp b/CPP/7zip/Compress/BZip2Decoder.cpp index 96ecf4b5..bc252d09 100755 --- a/CPP/7zip/Compress/BZip2Decoder.cpp +++ b/CPP/7zip/Compress/BZip2Decoder.cpp @@ -4,9 +4,6 @@ #include "../../../C/Alloc.h" -#include "../../Common/Defs.h" - -#include "BZip2Crc.h" #include "BZip2Decoder.h" #include "Mtf8.h" @@ -15,11 +12,11 @@ namespace NBZip2 { #define NO_INLINE MY_FAST_CALL -const UInt32 kNumThreadsMax = 4; +static const UInt32 kNumThreadsMax = 4; static const UInt32 kBufferSize = (1 << 17); -static Int16 kRandNums[512] = { +static const UInt16 kRandNums[512] = { 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, @@ -76,8 +73,8 @@ static Int16 kRandNums[512] = { bool CState::Alloc() { - if (Counters == 0) - Counters = (UInt32 *)BigAlloc((256 + kBlockSizeMax) * sizeof(UInt32)); + if (!Counters) + Counters = (UInt32 *)::BigAlloc((256 + kBlockSizeMax) * sizeof(UInt32)); return (Counters != 0); } @@ -87,7 +84,7 @@ void CState::Free() Counters = 0; } -UInt32 CDecoder::ReadBits(int numBits) { return m_InStream.ReadBits(numBits); } +UInt32 CDecoder::ReadBits(unsigned numBits) { return m_InStream.ReadBits(numBits); } Byte CDecoder::ReadByte() {return (Byte)ReadBits(8); } bool CDecoder::ReadBit() { return ReadBits(1) != 0; } @@ -102,21 +99,22 @@ UInt32 CDecoder::ReadCrc() return crc; } -UInt32 NO_INLINE ReadBits(NBitm::CDecoder<CInBuffer> *m_InStream, int num) +static UInt32 NO_INLINE ReadBits(NBitm::CDecoder<CInBuffer> *m_InStream, unsigned num) { return m_InStream->ReadBits(num); } -UInt32 NO_INLINE ReadBit(NBitm::CDecoder<CInBuffer> *m_InStream) +static UInt32 NO_INLINE ReadBit(NBitm::CDecoder<CInBuffer> *m_InStream) { return m_InStream->ReadBits(1); } static HRESULT NO_INLINE ReadBlock(NBitm::CDecoder<CInBuffer> *m_InStream, - UInt32 *CharCounters, UInt32 blockSizeMax, Byte *m_Selectors, CHuffmanDecoder *m_HuffmanDecoders, - UInt32 *blockSizeRes, UInt32 *origPtrRes, bool *randRes) + UInt32 *CharCounters, UInt32 blockSizeMax, Byte *m_Selectors, CHuffmanDecoder *m_HuffmanDecoders, + UInt32 *blockSizeRes, UInt32 *origPtrRes, bool *randRes) { - *randRes = ReadBit(m_InStream) ? true : false; + if (randRes) + *randRes = ReadBit(m_InStream) ? true : false; *origPtrRes = ReadBits(m_InStream, kNumOrigBits); // in original code it compares OrigPtr to (UInt32)(10 + blockSizeMax)) : why ? @@ -258,7 +256,7 @@ static HRESULT NO_INLINE ReadBlock(NBitm::CDecoder<CInBuffer> *m_InStream, return (*origPtrRes < blockSize) ? S_OK : S_FALSE; } -void NO_INLINE DecodeBlock1(UInt32 *charCounters, UInt32 blockSize) +static void NO_INLINE DecodeBlock1(UInt32 *charCounters, UInt32 blockSize) { { UInt32 sum = 0; @@ -283,13 +281,13 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32 // it's for speed optimization: prefetch & prevByte_init; UInt32 tPos = tt[tt[OrigPtr] >> 8]; - unsigned int prevByte = (unsigned int)(tPos & 0xFF); + unsigned prevByte = (unsigned)(tPos & 0xFF); - int numReps = 0; + unsigned numReps = 0; do { - unsigned int b = (unsigned int)(tPos & 0xFF); + unsigned b = (unsigned)(tPos & 0xFF); tPos = tt[tPos >> 8]; if (numReps == kRleModeRepSize) @@ -315,7 +313,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32 m_OutStream.WriteByte((Byte)b); for (; --blockSize != 0;) { - b = (unsigned int)(tPos & 0xFF); + b = (unsigned)(tPos & 0xFF); tPos = tt[tPos >> 8]; crc.UpdateByte(b); m_OutStream.WriteByte((Byte)b); @@ -327,7 +325,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32 if (--blockSize == 0) break; - b = (unsigned int)(tPos & 0xFF); + b = (unsigned)(tPos & 0xFF); tPos = tt[tPos >> 8]; crc.UpdateByte(b); m_OutStream.WriteByte((Byte)b); @@ -339,7 +337,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32 if (--blockSize == 0) break; - b = (unsigned int)(tPos & 0xFF); + b = (unsigned)(tPos & 0xFF); tPos = tt[tPos >> 8]; crc.UpdateByte(b); m_OutStream.WriteByte((Byte)b); @@ -354,7 +352,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32 if (blockSize == 0) break; - b = (unsigned int)(tPos & 0xFF); + b = (unsigned)(tPos & 0xFF); tPos = tt[tPos >> 8]; for (; b > 0; b--) @@ -375,15 +373,15 @@ static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UIn UInt32 randIndex = 1; UInt32 randToGo = kRandNums[0] - 2; - int numReps = 0; + unsigned numReps = 0; // it's for speed optimization: prefetch & prevByte_init; UInt32 tPos = tt[tt[OrigPtr] >> 8]; - unsigned int prevByte = (unsigned int)(tPos & 0xFF); + unsigned prevByte = (unsigned)(tPos & 0xFF); do { - unsigned int b = (unsigned int)(tPos & 0xFF); + unsigned b = (unsigned)(tPos & 0xFF); tPos = tt[tPos >> 8]; { @@ -449,7 +447,7 @@ HRESULT CDecoder::Create() try { m_States = new CState[NumThreads]; - if (m_States == 0) + if (!m_States) return E_OUTOFMEMORY; } catch(...) { return E_OUTOFMEMORY; } @@ -487,6 +485,7 @@ void CDecoder::Free() delete []m_States; m_States = 0; } + #endif HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc) @@ -794,6 +793,7 @@ STDMETHODIMP CDecoder::SetNumberOfThreads(UInt32 numThreads) NumThreads = kNumThreadsMax; return S_OK; } + #endif HRESULT CDecoder::SetRatioProgress(UInt64 packSize) @@ -805,4 +805,138 @@ HRESULT CDecoder::SetRatioProgress(UInt64 packSize) return Progress->SetRatioInfo(&packSize, &unpackSize); } + +// ---------- NSIS ---------- + +enum +{ + NSIS_STATE_INIT, + NSIS_STATE_NEW_BLOCK, + NSIS_STATE_DATA, + NSIS_STATE_FINISHED, + NSIS_STATE_ERROR +}; + +STDMETHODIMP CNsisDecoder::SetInStream(ISequentialInStream *inStream) { m_InStream.SetStream(inStream); return S_OK; } +STDMETHODIMP CNsisDecoder::ReleaseInStream() { m_InStream.ReleaseStream(); return S_OK; } + +STDMETHODIMP CNsisDecoder::SetOutStreamSize(const UInt64 * /* outSize */) +{ + _nsisState = NSIS_STATE_INIT; + return S_OK; +} + +STDMETHODIMP CNsisDecoder::Read(void *data, UInt32 size, UInt32 *processedSize) +{ + try { + + *processedSize = 0; + if (_nsisState == NSIS_STATE_FINISHED) + return S_OK; + if (_nsisState == NSIS_STATE_ERROR) + return S_FALSE; + if (size == 0) + return S_OK; + + CState &state = m_State; + + if (_nsisState == NSIS_STATE_INIT) + { + if (!m_InStream.Create(kBufferSize)) + return E_OUTOFMEMORY; + if (!state.Alloc()) + return E_OUTOFMEMORY; + m_InStream.Init(); + _nsisState = NSIS_STATE_NEW_BLOCK; + } + + if (_nsisState == NSIS_STATE_NEW_BLOCK) + { + Byte b = (Byte)m_InStream.ReadBits(8); + if (b == kFinSig0) + { + _nsisState = NSIS_STATE_FINISHED; + return S_OK; + } + if (b != kBlockSig0) + { + _nsisState = NSIS_STATE_ERROR; + return S_FALSE; + } + UInt32 origPtr; + RINOK(ReadBlock(&m_InStream, state.Counters, 9 * kBlockSizeStep, + m_Selectors, m_HuffmanDecoders, &_blockSize, &origPtr, NULL)); + DecodeBlock1(state.Counters, _blockSize); + const UInt32 *tt = state.Counters + 256; + _tPos = tt[tt[origPtr] >> 8]; + _prevByte = (unsigned)(_tPos & 0xFF); + _numReps = 0; + _repRem = 0; + _nsisState = NSIS_STATE_DATA; + } + + UInt32 tPos = _tPos; + unsigned prevByte = _prevByte; + unsigned numReps = _numReps; + UInt32 blockSize = _blockSize; + const UInt32 *tt = state.Counters + 256; + + while (_repRem) + { + _repRem--; + *(Byte *)data = (Byte)prevByte; + data = (Byte *)data + 1; + (*processedSize)++; + if (--size == 0) + return S_OK; + } + + if (blockSize == 0) + { + _nsisState = NSIS_STATE_NEW_BLOCK; + return S_OK; + } + + do + { + unsigned b = (unsigned)(tPos & 0xFF); + tPos = tt[tPos >> 8]; + blockSize--; + + if (numReps == kRleModeRepSize) + { + numReps = 0; + while (b) + { + b--; + *(Byte *)data = (Byte)prevByte; + data = (Byte *)data + 1; + (*processedSize)++; + if (--size == 0) + break; + } + _repRem = b; + continue; + } + if (b != prevByte) + numReps = 0; + numReps++; + prevByte = b; + *(Byte *)data = (Byte)b; + data = (Byte *)data + 1; + (*processedSize)++; + size--; + } + while (size && blockSize); + _tPos = tPos; + _prevByte = prevByte; + _numReps = numReps; + _blockSize = blockSize; + return S_OK; + + } + catch(const CInBufferException &e) { return e.ErrorCode; } + catch(...) { return S_FALSE; } +} + }} diff --git a/CPP/7zip/Compress/BZip2Decoder.h b/CPP/7zip/Compress/BZip2Decoder.h index d02b70a8..e6dec1ea 100755 --- a/CPP/7zip/Compress/BZip2Decoder.h +++ b/CPP/7zip/Compress/BZip2Decoder.h @@ -76,11 +76,10 @@ private: bool _needInStreamInit; - UInt32 ReadBits(int numBits); + UInt32 ReadBits(unsigned numBits); Byte ReadByte(); bool ReadBit(); UInt32 ReadCrc(); - HRESULT PrepareBlock(CState &state); HRESULT DecodeFile(bool &isBZ, ICompressProgressInfo *progress); HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, bool &isBZ, ICompressProgressInfo *progress); @@ -168,6 +167,39 @@ public: #endif }; + +class CNsisDecoder : + public ISequentialInStream, + public ICompressSetInStream, + public ICompressSetOutStreamSize, + public CMyUnknownImp +{ + NBitm::CDecoder<CInBuffer> m_InStream; + Byte m_Selectors[kNumSelectorsMax]; + CHuffmanDecoder m_HuffmanDecoders[kNumTablesMax]; + CState m_State; + + int _nsisState; + UInt32 _tPos; + unsigned _prevByte; + unsigned _repRem; + unsigned _numReps; + UInt32 _blockSize; + +public: + + MY_QUERYINTERFACE_BEGIN2(ISequentialInStream) + MY_QUERYINTERFACE_ENTRY(ICompressSetInStream) + MY_QUERYINTERFACE_ENTRY(ICompressSetOutStreamSize) + MY_QUERYINTERFACE_END + MY_ADDREF_RELEASE + + STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); + STDMETHOD(SetInStream)(ISequentialInStream *inStream); + STDMETHOD(ReleaseInStream)(); + STDMETHOD(SetOutStreamSize)(const UInt64 *outSize); +}; + }} #endif diff --git a/CPP/7zip/Compress/DeflateNsisRegister.cpp b/CPP/7zip/Compress/DeflateNsisRegister.cpp deleted file mode 100755 index ffad96c2..00000000 --- a/CPP/7zip/Compress/DeflateNsisRegister.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// DeflateNsisRegister.cpp - -#include "StdAfx.h" - -#include "../Common/RegisterCodec.h" - -#include "DeflateDecoder.h" - -static void *CreateCodecDeflateNsis() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NDecoder::CNsisCOMCoder); } - -static CCodecInfo g_CodecInfo = - { CreateCodecDeflateNsis, 0, 0x040901, L"DeflateNSIS", 1, false }; - -REGISTER_CODEC(DeflateNsis) diff --git a/CPP/7zip/Compress/Rar3Decoder.cpp b/CPP/7zip/Compress/Rar3Decoder.cpp index af5cef1a..dde7c6de 100755 --- a/CPP/7zip/Compress/Rar3Decoder.cpp +++ b/CPP/7zip/Compress/Rar3Decoder.cpp @@ -627,7 +627,6 @@ public: CCoderReleaser(CDecoder *coder): m_Coder(coder) {} ~CCoderReleaser() { - // m_Coder->m_OutWindowStream.Flush(); m_Coder->ReleaseStreams(); } }; @@ -821,7 +820,7 @@ HRESULT CDecoder::CodeReal(ICompressProgressInfo *progress) return S_OK; } - for(;;) + for (;;) { bool keepDecompressing; if (_lzMode) @@ -838,9 +837,10 @@ HRESULT CDecoder::CodeReal(ICompressProgressInfo *progress) break; } RINOK(WriteBuf()); + UInt64 packSize = m_InBitStream.bitDecoder.GetProcessedSize(); + RINOK(progress->SetRatioInfo(&packSize, &_writtenFileSize)); if (_writtenFileSize < _unpackSize) return S_FALSE; - // return m_OutWindowStream.Flush(); return S_OK; } diff --git a/CPP/7zip/Crypto/ZipStrong.cpp b/CPP/7zip/Crypto/ZipStrong.cpp index d635fee1..1554b348 100755 --- a/CPP/7zip/Crypto/ZipStrong.cpp +++ b/CPP/7zip/Crypto/ZipStrong.cpp @@ -114,6 +114,12 @@ HRESULT CDecoder::CheckPassword(bool &passwOK) _key.KeySize = 16 + algId * 8; if ((flags & 1) == 0) return E_NOTIMPL; + if ((flags & 0x4000) != 0) + { + // Use 3DES + return E_NOTIMPL; + } + UInt32 rdSize = GetUi16(p + 8); if ((rdSize & 0xF) != 0 || rdSize + 16 > _remSize) return E_NOTIMPL; diff --git a/CPP/7zip/MyVersion.h b/CPP/7zip/MyVersion.h index acfcc6b4..baa722df 100755 --- a/CPP/7zip/MyVersion.h +++ b/CPP/7zip/MyVersion.h @@ -1,8 +1,8 @@ #define MY_VER_MAJOR 9 -#define MY_VER_MINOR 15 +#define MY_VER_MINOR 16 #define MY_VER_BUILD 0 -#define MY_VERSION "9.15 beta" -#define MY_7ZIP_VERSION "7-Zip 9.15 beta" -#define MY_DATE "2010-06-20" +#define MY_VERSION "9.16" +#define MY_7ZIP_VERSION "7-Zip 9.16 beta" +#define MY_DATE "2010-09-08" #define MY_COPYRIGHT "Copyright (c) 1999-2010 Igor Pavlov" #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp index 12206786..8dcc60d5 100755 --- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp +++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp @@ -169,7 +169,7 @@ static const char *kStartExtensions = #endif " exe bat com" " chm" - " msi doc xls ppt pps wps wpt wks xlr wdb" + " msi doc xls ppt pps wps wpt wks xlr wdb vsd" " docx docm dotx dotm xlsx xlsm xltx xltm xlsb" " xlam pptx pptm potx potm ppam ppsx ppsm xsn" |