4.50 beta

This commit is contained in:
Igor Pavlov
2007-07-24 00:00:00 +00:00
committed by Kornel Lesiński
parent 7038848692
commit 980e181dcc
104 changed files with 1419 additions and 4952 deletions

View File

@@ -25,17 +25,6 @@ struct CRef
int ItemIndex;
};
/*
struct CRef2
{
CRecordVector<CRef> Refs;
UInt64 UnPackSize;
UInt64 PackSize;
UInt64 StartPos;
CRef2(): UnPackSize(0), PackSize(0), StartPos(0) {}
};
*/
struct CVolume
{
int StartRef2Index;
@@ -44,10 +33,6 @@ struct CVolume
};
#endif
// {23170F69-40C1-278A-1000-000110070000}
DEFINE_GUID(CLSID_CFormat7z,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00);
#ifndef __7Z_SET_PROPERTIES
#ifdef EXTRACT_ONLY
@@ -93,26 +78,7 @@ public:
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
#ifdef _7Z_VOL
STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
@@ -123,14 +89,7 @@ public:
#endif
#ifndef EXTRACT_ONLY
// IOutArchiveHandler
STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems,
IArchiveUpdateCallback *updateCallback);
STDMETHOD(GetFileTimeType)(UInt32 *type);
// ISetProperties
INTERFACE_IOutArchive(;)
#endif
DECL_ISetCompressCodecsInfo

View File

File diff suppressed because it is too large Load Diff

View File

@@ -3,32 +3,17 @@
#ifndef __7Z_IN_H
#define __7Z_IN_H
#include "../../../Common/MyCom.h"
#include "../../IStream.h"
#include "../../IPassword.h"
#include "../../Common/CreateCoder.h"
#include "../../../Common/MyCom.h"
#include "../../Common/InBuffer.h"
#include "7zHeader.h"
#include "7zItem.h"
namespace NArchive {
namespace N7z {
class CInArchiveException
{
public:
enum CCauseType
{
kUnsupportedVersion = 0,
kUnexpectedEndOfArchive = 0,
kIncorrectHeader,
} Cause;
CInArchiveException(CCauseType cause);
};
struct CInArchiveInfo
{
CArchiveVersion Version;
@@ -43,7 +28,6 @@ struct CInArchiveInfo
}
};
struct CArchiveDatabaseEx: public CArchiveDatabase
{
CInArchiveInfo ArchiveInfo;
@@ -76,8 +60,7 @@ struct CArchiveDatabaseEx: public CArchiveDatabase
UInt64 GetFolderStreamPos(int folderIndex, int indexInFolder) const
{
return ArchiveInfo.DataStartPosition +
PackStreamStartPositions[FolderStartPackStreamIndex[folderIndex] +
indexInFolder];
PackStreamStartPositions[FolderStartPackStreamIndex[folderIndex] + indexInFolder];
}
UInt64 GetFolderFullPackSize(int folderIndex) const
@@ -117,44 +100,33 @@ public:
_size = size;
_pos = 0;
}
bool ReadByte(Byte &b)
{
if(_pos >= _size)
return false;
b = _buffer[_pos++];
return true;
}
void ReadBytes(void *data, size_t size, size_t &processedSize)
{
for(processedSize = 0; processedSize < size && _pos < _size; processedSize++)
((Byte *)data)[processedSize] = _buffer[_pos++];
}
bool ReadBytes(void *data, size_t size)
{
size_t processedSize;
ReadBytes(data, size, processedSize);
return (processedSize == size);
}
size_t GetProcessedSize() const { return _pos; }
Byte ReadByte();
void ReadBytes(Byte *data, size_t size);
void SkeepData(UInt64 size);
void SkeepData();
UInt64 ReadNumber();
CNum ReadNum();
UInt32 ReadUInt32();
UInt64 ReadUInt64();
void ReadString(UString &s);
};
class CStreamSwitch;
const UInt32 kHeaderSize = 32;
class CInArchive
{
friend class CStreamSwitch;
CMyComPtr<IInStream> _stream;
#ifdef _7Z_VOL
bool _finishSignature;
#endif
CObjectVector<CInByte2> _inByteVector;
CInByte2 *_inByteBack;
UInt64 _arhiveBeginStreamPosition;
UInt64 _position;
Byte _header[kHeaderSize];
void AddByteStream(const Byte *buffer, size_t size)
{
@@ -171,80 +143,42 @@ class CInArchive
}
private:
HRESULT FindAndReadSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit); // S_FALSE means is not archive
#ifdef _7Z_VOL
HRESULT FindFinishSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit); // S_FALSE means is not archive
#endif
HRESULT FindAndReadSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
HRESULT ReadFileNames(CObjectVector<CFileItem> &files);
HRESULT ReadDirect(IInStream *stream, void *data, UInt32 size,
UInt32 *processedSize);
HRESULT ReadDirect(void *data, UInt32 size, UInt32 *processedSize);
HRESULT SafeReadDirect(void *data, UInt32 size);
HRESULT SafeReadDirectByte(Byte &b);
HRESULT SafeReadDirectUInt32(UInt32 &value, UInt32 &crc);
HRESULT SafeReadDirectUInt64(UInt64 &value, UInt32 &crc);
void ReadBytes(Byte *data, size_t size) { _inByteBack->ReadBytes(data, size); }
Byte ReadByte() { return _inByteBack->ReadByte(); }
UInt64 ReadNumber() { return _inByteBack->ReadNumber(); }
CNum ReadNum() { return _inByteBack->ReadNum(); }
UInt64 ReadID() { return _inByteBack->ReadNumber(); }
UInt32 ReadUInt32() { return _inByteBack->ReadUInt32(); }
UInt64 ReadUInt64() { return _inByteBack->ReadUInt64(); }
void SkeepData(UInt64 size) { _inByteBack->SkeepData(size); }
void SkeepData() { _inByteBack->SkeepData(); }
void WaitAttribute(UInt64 attribute);
HRESULT ReadBytes(void *data, size_t size)
{
if (!_inByteBack->ReadBytes(data, size))
return E_FAIL;
return S_OK;
}
HRESULT ReadByte(Byte &b)
{
if (!_inByteBack->ReadByte(b))
return E_FAIL;
return S_OK;
}
HRESULT ReadWideCharLE(wchar_t &c)
{
Byte b1 = 0;
if (!_inByteBack->ReadByte(b1))
return E_FAIL;
Byte b2 = 0;
if (!_inByteBack->ReadByte(b2))
return E_FAIL;
c = (wchar_t)(((wchar_t)(b2) << 8) + b1);
return S_OK;
}
HRESULT ReadNumber(UInt64 &value);
HRESULT ReadNum(CNum &value);
HRESULT ReadID(UInt64 &value) { return ReadNumber(value); }
HRESULT ReadUInt32(UInt32 &value);
HRESULT ReadUInt64(UInt64 &value);
HRESULT SkeepData(UInt64 size);
HRESULT SkeepData();
HRESULT WaitAttribute(UInt64 attribute);
HRESULT ReadArchiveProperties(CInArchiveInfo &archiveInfo);
HRESULT GetNextFolderItem(CFolder &itemInfo);
HRESULT ReadHashDigests(int numItems,
void ReadArchiveProperties(CInArchiveInfo &archiveInfo);
void GetNextFolderItem(CFolder &itemInfo);
void ReadHashDigests(int numItems,
CRecordVector<bool> &digestsDefined, CRecordVector<UInt32> &digests);
HRESULT ReadPackInfo(
void ReadPackInfo(
UInt64 &dataOffset,
CRecordVector<UInt64> &packSizes,
CRecordVector<bool> &packCRCsDefined,
CRecordVector<UInt32> &packCRCs);
HRESULT ReadUnPackInfo(
void ReadUnPackInfo(
const CObjectVector<CByteBuffer> *dataVector,
CObjectVector<CFolder> &folders);
HRESULT ReadSubStreamsInfo(
void ReadSubStreamsInfo(
const CObjectVector<CFolder> &folders,
CRecordVector<CNum> &numUnPackStreamsInFolders,
CRecordVector<UInt64> &unPackSizes,
CRecordVector<bool> &digestsDefined,
CRecordVector<UInt32> &digests);
HRESULT ReadStreamsInfo(
void ReadStreamsInfo(
const CObjectVector<CByteBuffer> *dataVector,
UInt64 &dataOffset,
CRecordVector<UInt64> &packSizes,
@@ -257,10 +191,9 @@ private:
CRecordVector<UInt32> &digests);
HRESULT GetNextFileItem(CFileItem &itemInfo);
HRESULT ReadBoolVector(int numItems, CBoolVector &v);
HRESULT ReadBoolVector2(int numItems, CBoolVector &v);
HRESULT ReadTime(const CObjectVector<CByteBuffer> &dataVector,
void ReadBoolVector(int numItems, CBoolVector &v);
void ReadBoolVector2(int numItems, CBoolVector &v);
void ReadTime(const CObjectVector<CByteBuffer> &dataVector,
CObjectVector<CFileItem> &files, UInt64 type);
HRESULT ReadAndDecodePackedStreams(
DECL_EXTERNAL_CODECS_LOC_VARS
@@ -277,6 +210,13 @@ private:
,ICryptoGetTextPassword *getTextPassword
#endif
);
HRESULT ReadDatabase2(
DECL_EXTERNAL_CODECS_LOC_VARS
CArchiveDatabaseEx &database
#ifndef _NO_CRYPTO
,ICryptoGetTextPassword *getTextPassword
#endif
);
public:
HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit); // S_FALSE means is not archive
void Close();

View File

@@ -17,24 +17,7 @@ class CHandler:
public:
MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *inStream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *callback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *anExtractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
CHandler();
private:

View File

@@ -53,32 +53,9 @@ public:
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
INTERFACE_IInArchive(;)
INTERFACE_IOutArchive(;)
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
// IOutArchiveHandler
STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems,
IArchiveUpdateCallback *updateCallback);
STDMETHOD(GetFileTimeType)(UInt32 *type);
// ISetProperties
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
DECL_ISetCompressCodecsInfo

View File

@@ -17,24 +17,7 @@ class CHandler:
public:
MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
private:
CMvDatabaseEx m_Database;

View File

@@ -17,24 +17,7 @@ class CHandler:
public:
MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
private:
CFilesDatabase m_Database;

View File

@@ -26,13 +26,13 @@ void CCoder2::Code(ICompressProgressInfo *progress)
{
if (InSizePointers[i] != NULL)
InSizePointers[i] = &InSizes[i];
InStreamPointers.Add(InStreams[i]);
InStreamPointers.Add((ISequentialInStream *)InStreams[i]);
}
for (i = 0; i < NumOutStreams; i++)
{
if (OutSizePointers[i] != NULL)
OutSizePointers[i] = &OutSizes[i];
OutStreamPointers.Add(OutStreams[i]);
OutStreamPointers.Add((ISequentialOutStream *)OutStreams[i]);
}
if (Coder)
Result = Coder->Code(InStreamPointers[0], OutStreamPointers[0],

View File

@@ -18,24 +18,7 @@ class CHandler:
public:
MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
private:
CObjectVector<CItemEx> m_Items;

View File

@@ -18,24 +18,7 @@ class CHandler:
public:
MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
private:
CObjectVector<CItemEx> _items;

View File

@@ -30,34 +30,9 @@ public:
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
STDMETHOD(Open)(IInStream *inStream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
INTERFACE_IInArchive(;)
INTERFACE_IOutArchive(;)
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
// IOutArchive
STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems,
IArchiveUpdateCallback *updateCallback);
STDMETHOD(GetFileTimeType)(UInt32 *timeType);
// ISetProperties
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
DECL_ISetCompressCodecsInfo

View File

@@ -111,28 +111,28 @@ ARCHIVE_INTERFACE(IArchiveOpenSetSubArchiveName, 0x50)
};
/*
IInArchive::Extract:
indices must be sorted
numItems = 0xFFFFFFFF means "all files"
testMode != 0 means "test files without writing to outStream"
*/
#define INTERFACE_IInArchive(x) \
STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openArchiveCallback) x; \
STDMETHOD(Close)() x; \
STDMETHOD(GetNumberOfItems)(UInt32 *numItems) x; \
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) x; \
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback) x; \
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) x; \
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties) x; \
STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x;
ARCHIVE_INTERFACE(IInArchive, 0x60)
{
STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback) PURE;
STDMETHOD(Close)() PURE;
STDMETHOD(GetNumberOfItems)(UInt32 *numItems) PURE;
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) PURE;
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback) PURE;
// indices must be sorted
// numItems = 0xFFFFFFFF means all files
// testMode != 0 means "test files operation"
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) PURE;
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) PURE;
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType) PURE;
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties) PURE;
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType) PURE;
INTERFACE_IInArchive(PURE)
};
@@ -156,11 +156,13 @@ ARCHIVE_INTERFACE_SUB(IArchiveUpdateCallback2, IArchiveUpdateCallback, 0x82)
};
#define INTERFACE_IOutArchive(x) \
STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems, IArchiveUpdateCallback *updateCallback) x; \
STDMETHOD(GetFileTimeType)(UInt32 *type) x;
ARCHIVE_INTERFACE(IOutArchive, 0xA0)
{
STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems,
IArchiveUpdateCallback *updateCallback) PURE;
STDMETHOD(GetFileTimeType)(UInt32 *type) PURE;
INTERFACE_IOutArchive(PURE)
};

View File

@@ -14,40 +14,14 @@ namespace NIso {
class CHandler:
public IInArchive,
// public IOutArchive,
public CMyUnknownImp
{
public:
MY_UNKNOWN_IMP1(
IInArchive
// IOutArchive
)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
/*
// IOutArchive
STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems,
IArchiveUpdateCallback *updateCallback);
STDMETHOD(GetFileTimeType)(UInt32 *type);
*/
INTERFACE_IInArchive(;)
private:
CMyComPtr<IInStream> _inStream;

View File

@@ -17,24 +17,7 @@ class CHandler:
public:
MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *inStream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *callback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *anExtractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
CHandler();
private:

View File

@@ -32,16 +32,7 @@ public:
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
DECL_ISetCompressCodecsInfo
};

View File

@@ -57,9 +57,11 @@ void CInArchive::ReadBlockHeader(CBlockHeader &bh)
static int CompareItems(void *const *p1, void *const *p2, void * /* param */)
{
RINOZ(MyCompare(
(**(const CItem **)p1).Pos,
(**(const CItem **)p2).Pos));
const CItem &i1 = **(CItem **)p1;
const CItem &i2 = **(CItem **)p2;
RINOZ(MyCompare(i1.Pos, i2.Pos));
RINOZ(i1.Prefix.Compare(i2.Prefix));
RINOZ(i1.Name.Compare(i2.Name));
return 0;
}
@@ -903,6 +905,7 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
{
Items.Sort(CompareItems, 0);
int i;
if (IsSolid)
for (i = 0; i + 1 < Items.Size();)
{
if (Items[i].Pos == Items[i + 1].Pos)

View File

@@ -16,24 +16,7 @@ class CHandler:
public:
MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
private:
CMyComPtr<IInStream> m_InStream;

View File

@@ -23,24 +23,7 @@ public:
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
STDMETHOD(Open)(IInStream *aStream,
const UInt64 *aMaxCheckStartPosition,
IArchiveOpenCallback *anOpenArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *anExtractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
DECL_ISetCompressCodecsInfo

View File

@@ -19,35 +19,10 @@ class CHandler:
public:
MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
// IOutArchiveHandler
/*
STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems,
IArchiveUpdateCallback *updateCallback);
STDMETHOD(GetFileTimeType)(UInt32 *type);
*/
private:
UString _subName;
UString _name;

View File

@@ -22,29 +22,8 @@ public:
IOutArchive
)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
// IOutArchive
STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems,
IArchiveUpdateCallback *updateCallback);
STDMETHOD(GetFileTimeType)(UInt32 *type);
INTERFACE_IInArchive(;)
INTERFACE_IOutArchive(;)
private:
CObjectVector<CItemEx> _items;

View File

@@ -28,25 +28,7 @@ class CHandler:
{
public:
MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
private:
CDatabase m_Database;

View File

@@ -11,6 +11,8 @@
#include "../Common/OutStreamWithSha1.h"
#include "../../../../C/CpuArch.h"
#include "WimIn.h"
namespace NArchive{
@@ -26,11 +28,7 @@ static HRESULT ReadBytes(ISequentialInStream *inStream, void *data, UInt32 size)
return (realProcessedSize == size) ? S_OK : S_FALSE;
}
#if defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || defined(__i386__) || defined(__x86_64__)
#define WIM_LITTLE_ENDIAN_UNALIGN
#endif
#ifdef WIM_LITTLE_ENDIAN_UNALIGN
#ifdef LITTLE_ENDIAN_UNALIGN
static inline UInt16 GetUInt16FromMem(const Byte *p) { return *(const UInt16 *)p; }
static inline UInt32 GetUInt32FromMem(const Byte *p) { return *(const UInt32 *)p; }
static inline UInt64 GetUInt64FromMem(const Byte *p) { return *(const UInt64 *)p; }

View File

@@ -15,25 +15,7 @@ class CHandler:
{
public:
MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
INTERFACE_IInArchive(;)
private:
CMyComPtr<IInStream> _stream;

View File

@@ -31,6 +31,10 @@
#include "../../Crypto/Zip/ZipCipher.h"
#include "../../Crypto/WzAES/WzAES.h"
#ifdef ZIP_STRONG_SUPORT
#include "../../Crypto/ZipStrong/ZipStrong.h"
#endif
using namespace NWindows;
using namespace NTime;
@@ -47,22 +51,22 @@ const wchar_t *kHostOS[] =
L"AMIGA",
L"VMS",
L"Unix",
L"VM_CMS",
L"Atari", // what if it's a minix filesystem? [cjh]
L"HPFS", // filesystem used by OS/2 (and NT 3.x)
L"Mac",
L"Z_System",
L"CPM",
L"TOPS20", // pkzip 2.50 NTFS
L"NTFS", // filesystem used by Windows NT
L"QDOS ", // SMS/QDOS
L"Acorn", // Archimedes Acorn RISC OS
L"VFAT", // filesystem used by Windows 95, NT
L"VM/CMS",
L"Atari",
L"HPFS",
L"Macintosh",
L"Z-System",
L"CP/M",
L"TOPS-20",
L"NTFS",
L"SMS/QDOS",
L"Acorn",
L"VFAT",
L"MVS",
L"BeOS", // hybrid POSIX/database filesystem
// BeBOX or PowerMac
L"BeOS",
L"Tandem",
L"THEOS"
L"OS/400",
L"OS/X"
};
@@ -120,6 +124,33 @@ const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
const wchar_t *kPPMdMethod = L"PPMd";
const wchar_t *kAESMethod = L"AES";
const wchar_t *kZipCryptoMethod = L"ZipCrypto";
const wchar_t *kStrongCryptoMethod = L"StrongCrypto";
struct CStrongCryptoPair
{
UInt16 Id;
const wchar_t *Name;
};
CStrongCryptoPair g_StrongCryptoPairs[] =
{
{ NStrongCryptoFlags::kDES, L"DES" },
{ NStrongCryptoFlags::kRC2old, L"RC2a" },
{ NStrongCryptoFlags::k3DES168, L"3DES-168" },
{ NStrongCryptoFlags::k3DES112, L"3DES-112" },
{ NStrongCryptoFlags::kAES128, L"pkAES-128" },
{ NStrongCryptoFlags::kAES192, L"pkAES-192" },
{ NStrongCryptoFlags::kAES256, L"pkAES-256" },
{ NStrongCryptoFlags::kRC2, L"RC2" },
{ NStrongCryptoFlags::kBlowfish, L"Blowfish" },
{ NStrongCryptoFlags::kTwofish, L"Twofish" },
{ NStrongCryptoFlags::kRC4, L"RC4" }
};
STATPROPSTG kArcProperties[] =
{
{ NULL, kpidComment, VT_BSTR}
};
CHandler::CHandler():
m_ArchiveIsOpen(false)
@@ -127,9 +158,33 @@ CHandler::CHandler():
InitMethodProperties();
}
STDMETHODIMP CHandler::GetArchiveProperty(PROPID /* propID */, PROPVARIANT *value)
static void StringToProp(const CByteBuffer &data, UINT codePage, NWindows::NCOM::CPropVariant &propVariant)
{
value->vt = VT_EMPTY;
int size = (int)data.GetCapacity();
if (size <= 0)
return;
AString s;
char *p = s.GetBuffer(size + 1);
memcpy(p, (const Byte *)data, size);
p[size] = '\0';
s.ReleaseBuffer();
propVariant = MultiByteToUnicodeString(s, codePage);
}
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
NWindows::NCOM::CPropVariant propVariant;
switch(propID)
{
case kpidComment:
{
StringToProp(m_Archive.m_ArchiveInfo.Comment, CP_ACP, propVariant);
break;
}
}
propVariant.Detach(value);
COM_TRY_END
return S_OK;
}
@@ -142,7 +197,7 @@ STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if(index >= sizeof(kProperties) / sizeof(kProperties[0]))
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
return E_INVALIDARG;
const STATPROPSTG &srcItem = kProperties[index];
*propID = srcItem.propid;
@@ -153,14 +208,20 @@ STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index,
STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties)
{
*numProperties = 0;
*numProperties = sizeof(kArcProperties) / sizeof(kArcProperties[0]);
return S_OK;
}
STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 /* index */,
BSTR * /* name */, PROPID * /* propID */, VARTYPE * /* varType */)
STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 index,
BSTR * name, PROPID * propID, VARTYPE *varType)
{
return E_NOTIMPL;
if (index >= sizeof(kArcProperties) / sizeof(kArcProperties[0]))
return E_INVALIDARG;
const STATPROPSTG &srcItem = kArcProperties[index];
*propID = srcItem.propid;
*varType = srcItem.vt;
*name = 0;
return S_OK;
}
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
@@ -169,23 +230,12 @@ STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
return S_OK;
}
static void MyStrNCpy(char *dest, const char *src, int size)
{
for (int i = 0; i < size; i++)
{
char c = src[i];
dest[i] = c;
if (c == 0)
break;
}
}
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID aPropID, PROPVARIANT *aValue)
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
NWindows::NCOM::CPropVariant propVariant;
const CItemEx &item = m_Items[index];
switch(aPropID)
switch(propID)
{
case kpidPath:
propVariant = NItemName::GetOSName2(
@@ -202,15 +252,15 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID aPropID, PROPVARIANT *a
break;
case kpidLastWriteTime:
{
FILETIME aLocalFileTime, anUTCFileTime;
if (DosTimeToFileTime(item.Time, aLocalFileTime))
FILETIME localFileTime, utcFileTime;
if (DosTimeToFileTime(item.Time, localFileTime))
{
if (!LocalFileTimeToFileTime(&aLocalFileTime, &anUTCFileTime))
anUTCFileTime.dwHighDateTime = anUTCFileTime.dwLowDateTime = 0;
if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime))
utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
}
else
anUTCFileTime.dwHighDateTime = anUTCFileTime.dwLowDateTime = 0;
propVariant = anUTCFileTime;
utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
propVariant = utcFileTime;
break;
}
case kpidAttributes:
@@ -221,16 +271,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID aPropID, PROPVARIANT *a
break;
case kpidComment:
{
int size = (int)item.Comment.GetCapacity();
if (size > 0)
{
AString s;
char *p = s.GetBuffer(size + 1);
MyStrNCpy(p, (const char *)(const Byte *)item.Comment, size);
p[size] = '\0';
s.ReleaseBuffer();
propVariant = MultiByteToUnicodeString(s, item.GetCodePage());
}
StringToProp(item.Comment, item.GetCodePage(), propVariant);
break;
}
case kpidCRC:
@@ -259,7 +300,28 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID aPropID, PROPVARIANT *a
}
else
{
method += kZipCryptoMethod;
if (item.IsStrongEncrypted())
{
CStrongCryptoField f;
bool finded = false;
if (item.CentralExtra.GetStrongCryptoField(f))
{
for (int i = 0; i < sizeof(g_StrongCryptoPairs) / sizeof(g_StrongCryptoPairs[0]); i++)
{
const CStrongCryptoPair &pair = g_StrongCryptoPairs[i];
if (f.AlgId == pair.Id)
{
method += pair.Name;
finded = true;
break;
}
}
}
if (!finded)
method += kStrongCryptoMethod;
}
else
method += kZipCryptoMethod;
method += L" ";
}
}
@@ -281,7 +343,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID aPropID, PROPVARIANT *a
(kHostOS[item.MadeByVersion.HostOS]) : kUnknownOS;
break;
}
propVariant.Detach(aValue);
propVariant.Detach(value);
return S_OK;
COM_TRY_END
}
@@ -353,6 +415,10 @@ class CZipDecoder
NCrypto::NWzAES::CDecoder *_aesDecoderSpec;
CMyComPtr<ICompressFilter> _zipCryptoDecoder;
CMyComPtr<ICompressFilter> _aesDecoder;
#ifdef ZIP_STRONG_SUPORT
NCrypto::NZipStrong::CDecoder *_zsDecoderSpec;
CMyComPtr<ICompressFilter> _zsDecoder;
#endif
CFilterCoder *filterStreamSpec;
CMyComPtr<ISequentialInStream> filterStream;
CMyComPtr<ICryptoGetTextPassword> getTextPassword;
@@ -383,8 +449,27 @@ HRESULT CZipDecoder::Decode(
bool needCRC = true;
bool aesMode = false;
#ifdef ZIP_STRONG_SUPORT
bool pkAesMode = false;
#endif
UInt16 methodId = item.CompressionMethod;
if (item.IsEncrypted())
{
if (item.IsStrongEncrypted())
{
#ifdef ZIP_STRONG_SUPORT
CStrongCryptoField f;
if (item.CentralExtra.GetStrongCryptoField(f))
{
pkAesMode = true;
}
if (!pkAesMode)
#endif
{
res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
return S_OK;
}
}
if (methodId == NFileHeader::NCompressionMethod::kWzAES)
{
CWzAesExtraField aesField;
@@ -394,8 +479,9 @@ HRESULT CZipDecoder::Decode(
needCRC = aesField.NeedCrc();
}
}
}
COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;;
COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
outStreamSpec->SetStream(realOutStream);
outStreamSpec->Init(needCRC);
@@ -434,6 +520,17 @@ HRESULT CZipDecoder::Decode(
Byte properties = aesField.Strength;
RINOK(_aesDecoderSpec->SetDecoderProperties2(&properties, 1));
}
#ifdef ZIP_STRONG_SUPORT
else if (pkAesMode)
{
if (!_zsDecoder)
{
_zsDecoderSpec = new NCrypto::NZipStrong::CDecoder;
_zsDecoder = _zsDecoderSpec;
}
cryptoFilter = _zsDecoder;
}
#endif
else
{
if (!_zipCryptoDecoder)
@@ -454,7 +551,11 @@ HRESULT CZipDecoder::Decode(
CMyComBSTR password;
RINOK(getTextPassword->CryptoGetTextPassword(&password));
AString charPassword;
if (aesMode)
if (aesMode
#ifdef ZIP_STRONG_SUPORT
|| pkAesMode
#endif
)
{
charPassword = UnicodeStringToMultiByte((const wchar_t *)password, CP_ACP);
/*
@@ -566,6 +667,12 @@ HRESULT CZipDecoder::Decode(
{
RINOK(_aesDecoderSpec->ReadHeader(inStream));
}
#ifdef ZIP_STRONG_SUPORT
else if (pkAesMode)
{
RINOK(_zsDecoderSpec->ReadHeader(inStream));
}
#endif
else
{
RINOK(_zipCryptoDecoderSpec->ReadHeader(inStream));

View File

@@ -34,31 +34,9 @@ public:
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
STDMETHOD(Open)(IInStream *aStream,
const UInt64 *aMaxCheckStartPosition,
IArchiveOpenCallback *anOpenArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *anExtractCallback);
INTERFACE_IInArchive(;)
INTERFACE_IOutArchive(;)
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
// IOutArchive
STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems,
IArchiveUpdateCallback *updateCallback);
STDMETHOD(GetFileTimeType)(UInt32 *timeType);
// ISetProperties
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
DECL_ISetCompressCodecsInfo

View File

@@ -86,6 +86,7 @@ namespace NFileHeader
enum
{
kZip64 = 0x01,
kStrongEncrypt = 0x17,
kWzAES = 0x9901
};
}
@@ -157,8 +158,9 @@ namespace NFileHeader
const int kNumUsedBits = 4;
const int kUsedBitsMask = (1 << kNumUsedBits) - 1;
const int kEncryptedMask = 1 << 0;
const int kDescriptorUsedMask = 1 << 3;
const int kEncrypted = 1 << 0;
const int kDescriptorUsedMask = 1 << 3;
const int kStrongEncrypted = 1 << 6;
const int kImplodeDictionarySizeMask = 1 << 1;
const int kImplodeLiteralsOnMask = 1 << 2;
@@ -173,8 +175,7 @@ namespace NFileHeader
{
enum EEnum
{
kFAT = 0, // filesystem used by MS-DOS, OS/2, Win32
// pkzip 2.50 (FAT / VFAT / FAT32 file systems)
kFAT = 0,
kAMIGA = 1,
kVMS = 2, // VAX/VMS
kUnix = 3,
@@ -191,11 +192,10 @@ namespace NFileHeader
kVFAT = 14, // filesystem used by Windows 95, NT
kMVS = 15,
kBeOS = 16, // hybrid POSIX/database filesystem
// BeBOX or PowerMac
kTandem = 17,
kTHEOS = 18
kOS400 = 18,
kOSX = 19
};
// const int kNumHostSystems = 19;
}
namespace NUnixAttribute
{

View File

@@ -64,7 +64,6 @@ class CInArchive
UInt32 m_Signature;
UInt64 m_StreamStartPosition;
UInt64 m_Position;
CInArchiveInfo m_ArchiveInfo;
AString m_NameBuffer;
HRESULT Seek(UInt64 offset);
@@ -95,6 +94,8 @@ class CInArchive
HRESULT ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize);
HRESULT ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset);
public:
CInArchiveInfo m_ArchiveInfo;
HRESULT ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress);
HRESULT ReadLocalItemAfterCdItem(CItemEx &item);
HRESULT ReadLocalItemAfterCdItemFull(CItemEx &item);

View File

@@ -19,14 +19,9 @@ bool operator!=(const CVersion &v1, const CVersion &v2)
return !(v1 == v2);
}
bool CLocalItem::IsEncrypted() const
{ return (Flags & NFileHeader::NFlags::kEncryptedMask) != 0; }
bool CLocalItem::HasDescriptor() const
{ return (Flags & NFileHeader::NFlags::kDescriptorUsedMask) != 0; }
bool CLocalItem::IsImplodeBigDictionary() const
{
if (CompressionMethod != NFileHeader::NCompressionMethod::kImploded)
if (CompressionMethod != NFileHeader::NCompressionMethod::kImploded)
throw 12312212;
return (Flags & NFileHeader::NFlags::kImplodeDictionarySizeMask) != 0;
}
@@ -130,6 +125,6 @@ void CLocalItem::SetBitMask(int bitMask, bool enable)
}
void CLocalItem::SetEncrypted(bool encrypted)
{ SetBitMask(NFileHeader::NFlags::kEncryptedMask, encrypted); }
{ SetBitMask(NFileHeader::NFlags::kEncrypted, encrypted); }
}}

View File

@@ -67,6 +67,43 @@ struct CWzAesExtraField
}
};
namespace NStrongCryptoFlags
{
const UInt16 kDES = 0x6601;
const UInt16 kRC2old = 0x6602;
const UInt16 k3DES168 = 0x6603;
const UInt16 k3DES112 = 0x6609;
const UInt16 kAES128 = 0x660E;
const UInt16 kAES192 = 0x660F;
const UInt16 kAES256 = 0x6610;
const UInt16 kRC2 = 0x6702;
const UInt16 kBlowfish = 0x6720;
const UInt16 kTwofish = 0x6721;
const UInt16 kRC4 = 0x6801;
}
struct CStrongCryptoField
{
UInt16 Format;
UInt16 AlgId;
UInt16 BitLen;
UInt16 Flags;
bool ParseFromSubBlock(const CExtraSubBlock &sb)
{
if (sb.ID != NFileHeader::NExtraID::kStrongEncrypt)
return false;
const Byte *p = (const Byte *)sb.Data;
if (sb.Data.GetCapacity() < 8)
return false;
Format = (((UInt16)p[1]) << 8) | p[0];
AlgId = (((UInt16)p[3]) << 8) | p[2];
BitLen = (((UInt16)p[5]) << 8) | p[4];
Flags = (((UInt16)p[7]) << 8) | p[6];
return (Format == 2);
}
};
struct CExtraBlock
{
CObjectVector<CExtraSubBlock> SubBlocks;
@@ -80,19 +117,34 @@ struct CExtraBlock
}
bool GetWzAesField(CWzAesExtraField &aesField) const
{
// size_t res = 0;
for (int i = 0; i < SubBlocks.Size(); i++)
if (aesField.ParseFromSubBlock(SubBlocks[i]))
return true;
return false;
}
bool GetStrongCryptoField(CStrongCryptoField &f) const
{
for (int i = 0; i < SubBlocks.Size(); i++)
if (f.ParseFromSubBlock(SubBlocks[i]))
return true;
return false;
}
bool HasWzAesField() const
{
CWzAesExtraField aesField;
return GetWzAesField(aesField);
}
/*
bool HasStrongCryptoField() const
{
CStrongCryptoField f;
return GetStrongCryptoField(f);
}
*/
void RemoveUnknownSubBlocks()
{
for (int i = SubBlocks.Size() - 1; i >= 0;)
@@ -122,7 +174,8 @@ public:
CExtraBlock LocalExtra;
bool IsEncrypted() const;
bool IsEncrypted() const { return (Flags & NFileHeader::NFlags::kEncrypted) != 0; }
bool IsStrongEncrypted() const { return IsEncrypted() && (Flags & NFileHeader::NFlags::kStrongEncrypted) != 0; };
bool IsImplodeBigDictionary() const;
bool IsImplodeLiteralsOn() const;
@@ -131,7 +184,8 @@ public:
bool IgnoreItem() const { return false; }
UInt32 GetWinAttributes() const;
bool HasDescriptor() const;
bool HasDescriptor() const { return (Flags & NFileHeader::NFlags::kDescriptorUsedMask) != 0; }
private:
void SetFlagBits(int startBitNumber, int numBits, int value);