3 #ifndef __ARCHIVE_NSIS_IN_H
\r
4 #define __ARCHIVE_NSIS_IN_H
\r
6 #include "Common/Buffer.h"
\r
7 #include "Common/MyCom.h"
\r
8 #include "Common/StringConvert.h"
\r
10 #include "NsisDecode.h"
\r
12 // #define NSIS_SCRIPT
\r
14 namespace NArchive {
\r
17 const int kSignatureSize = 16;
\r
18 #define NSIS_SIGNATURE { 0xEF, 0xBE, 0xAD, 0xDE, 0x4E, 0x75, 0x6C, 0x6C, 0x73, 0x6F, 0x66, 0x74, 0x49, 0x6E, 0x73, 0x74}
\r
20 extern Byte kSignature[kSignatureSize];
\r
22 const UInt32 kFlagsMask = 0xF;
\r
25 const UInt32 kUninstall = 1;
\r
26 const UInt32 kSilent = 2;
\r
27 const UInt32 kNoCrc = 4;
\r
28 const UInt32 kForceCrc = 8;
\r
34 UInt32 HeaderLength;
\r
38 bool ThereIsCrc() const
\r
40 if ((Flags & NFlags::kForceCrc ) != 0)
\r
42 return ((Flags & NFlags::kNoCrc) == 0);
\r
45 UInt32 GetDataSize() const { return ArchiveSize - (ThereIsCrc() ? 4 : 0); }
\r
66 bool CompressedSizeIsDefined;
\r
67 bool EstimatedSizeIsDefined;
\r
70 UInt32 CompressedSize;
\r
71 UInt32 EstimatedSize;
\r
72 UInt32 DictionarySize;
\r
74 CItem(): IsUnicode(false), UseFilter(false), IsCompressed(true), SizeIsDefined(false),
\r
75 CompressedSizeIsDefined(false), EstimatedSizeIsDefined(false), Size(0), DictionarySize(1) {}
\r
77 bool IsINSTDIR() const
\r
79 return (PrefixA.Length() >= 3 || PrefixU.Length() >= 3);
\r
82 UString GetReducedName(bool unicode) const
\r
88 s = MultiByteToUnicodeString(PrefixA);
\r
90 if (s[s.Length() - 1] != L'\\')
\r
95 s += MultiByteToUnicodeString(NameA);
\r
97 if (s.Left(len).CompareNoCase(L"$INSTDIR\\") == 0)
\r
105 UInt64 _archiveSize;
\r
106 CMyComPtr<IInStream> _stream;
\r
109 UInt32 ReadUInt32();
\r
111 DECL_EXTERNAL_CODECS_LOC_VARS2
\r
113 void ReadBlockHeader(CBlockHeader &bh);
\r
114 AString ReadStringA(UInt32 pos) const;
\r
115 UString ReadStringU(UInt32 pos) const;
\r
116 AString ReadString2A(UInt32 pos) const;
\r
117 UString ReadString2U(UInt32 pos) const;
\r
118 AString ReadString2(UInt32 pos) const;
\r
119 AString ReadString2Qw(UInt32 pos) const;
\r
120 HRESULT ReadEntries(const CBlockHeader &bh);
\r
128 UInt32 _stringsPos;
\r
131 bool _headerIsCompressed;
\r
132 UInt32 _nonSolidStartOffset;
\r
135 DECL_EXTERNAL_CODECS_LOC_VARS
\r
136 IInStream *inStream, const UInt64 *maxCheckStartPosition);
\r
139 UInt64 StreamOffset;
\r
141 CObjectVector<CItem> Items;
\r
142 CFirstHeader FirstHeader;
\r
143 NMethodType::EEnum Method;
\r
144 UInt32 DictionarySize;
\r
153 UInt32 GetOffset() const { return IsSolid ? 4 : 0; }
\r
154 UInt64 GetDataPos(int index)
\r
156 const CItem &item = Items[index];
\r
157 return GetOffset() + FirstHeader.HeaderLength + item.Pos;
\r
160 UInt64 GetPosOfSolidItem(int index) const
\r
162 const CItem &item = Items[index];
\r
163 return 4 + FirstHeader.HeaderLength + item.Pos;
\r
166 UInt64 GetPosOfNonSolidItem(int index) const
\r
168 const CItem &item = Items[index];
\r
169 return StreamOffset + _nonSolidStartOffset + 4 + item.Pos;
\r