mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 02:07:07 -06:00
4.59 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
3901bf0ab8
commit
173c07e166
@@ -14,6 +14,10 @@
|
||||
#include "../Common/ItemNameUtils.h"
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "../../../../C/CpuArch.h"
|
||||
|
||||
#define Get32(p) GetUi32(p)
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NArchive {
|
||||
@@ -22,7 +26,7 @@ namespace NNsis {
|
||||
static const wchar_t *kBcjMethod = L"BCJ";
|
||||
static const wchar_t *kUnknownMethod = L"Unknown";
|
||||
|
||||
static const wchar_t *kMethods[] =
|
||||
static const wchar_t *kMethods[] =
|
||||
{
|
||||
L"Copy",
|
||||
L"Deflate",
|
||||
@@ -32,18 +36,17 @@ static const wchar_t *kMethods[] =
|
||||
|
||||
static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
|
||||
|
||||
STATPROPSTG kProps[] =
|
||||
STATPROPSTG kProps[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidIsFolder, VT_BOOL},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidPackedSize, VT_UI8},
|
||||
{ NULL, kpidLastWriteTime, VT_FILETIME},
|
||||
{ NULL, kpidPackSize, VT_UI8},
|
||||
{ NULL, kpidMTime, VT_FILETIME},
|
||||
{ NULL, kpidMethod, VT_BSTR},
|
||||
{ NULL, kpidSolid, VT_BOOL}
|
||||
};
|
||||
|
||||
STATPROPSTG kArcProps[] =
|
||||
STATPROPSTG kArcProps[] =
|
||||
{
|
||||
{ NULL, kpidMethod, VT_BSTR},
|
||||
{ NULL, kpidSolid, VT_BOOL}
|
||||
@@ -69,7 +72,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
if (item.DictionarySize > dict)
|
||||
dict = item.DictionarySize;
|
||||
}
|
||||
prop = GetMethod(filter, dict);
|
||||
prop = GetMethod(filter, dict);
|
||||
break;
|
||||
}
|
||||
case kpidSolid: prop = _archive.IsSolid; break;
|
||||
@@ -211,19 +214,10 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
{
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath:
|
||||
prop = L"[NSIS].nsi";
|
||||
break;
|
||||
case kpidIsFolder:
|
||||
prop = false;
|
||||
break;
|
||||
case kpidPath: prop = L"[NSIS].nsi"; break;
|
||||
case kpidSize:
|
||||
case kpidPackedSize:
|
||||
prop = (UInt64)_archive.Script.Length();
|
||||
break;
|
||||
case kpidSolid:
|
||||
prop = false;
|
||||
break;
|
||||
case kpidPackSize: prop = (UInt64)_archive.Script.Length(); break;
|
||||
case kpidSolid: prop = false; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -244,9 +238,6 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
prop = (const wchar_t *)s;
|
||||
break;
|
||||
}
|
||||
case kpidIsFolder:
|
||||
prop = false;
|
||||
break;
|
||||
case kpidSize:
|
||||
{
|
||||
UInt32 size;
|
||||
@@ -254,28 +245,22 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
prop = (UInt64)size;
|
||||
break;
|
||||
}
|
||||
case kpidPackedSize:
|
||||
case kpidPackSize:
|
||||
{
|
||||
UInt32 size;
|
||||
if (GetCompressedSize(index, size))
|
||||
prop = (UInt64)size;
|
||||
break;
|
||||
}
|
||||
case kpidLastWriteTime:
|
||||
case kpidMTime:
|
||||
{
|
||||
if (item.DateTime.dwHighDateTime > 0x01000000 &&
|
||||
item.DateTime.dwHighDateTime < 0xFF000000)
|
||||
prop = item.DateTime;
|
||||
if (item.MTime.dwHighDateTime > 0x01000000 &&
|
||||
item.MTime.dwHighDateTime < 0xFF000000)
|
||||
prop = item.MTime;
|
||||
break;
|
||||
}
|
||||
case kpidMethod:
|
||||
{
|
||||
prop = GetMethod(item.UseFilter, item.DictionarySize);
|
||||
break;
|
||||
}
|
||||
case kpidSolid:
|
||||
prop = _archive.IsSolid;
|
||||
break;
|
||||
case kpidMethod: prop = GetMethod(item.UseFilter, item.DictionarySize); break;
|
||||
case kpidSolid: prop = _archive.IsSolid; break;
|
||||
}
|
||||
}
|
||||
prop.Detach(value);
|
||||
@@ -409,7 +394,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
if (processedSize != 4)
|
||||
return E_FAIL;
|
||||
streamPos += processedSize;
|
||||
fullSize = GetUInt32FromMemLE(buffer);
|
||||
fullSize = Get32(buffer);
|
||||
sizeIsKnown = true;
|
||||
needDecompress = true;
|
||||
}
|
||||
@@ -424,7 +409,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
RINOK(_archive.Decoder.Init(
|
||||
EXTERNAL_CODECS_VARS
|
||||
_inStream, _archive.Method, _archive.FilterFlag, useFilter));
|
||||
fullSize = GetUInt32FromMemLE(buffer);
|
||||
fullSize = Get32(buffer);
|
||||
}
|
||||
else
|
||||
fullSize = item.Size;
|
||||
@@ -461,9 +446,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
|
||||
UInt64 completed;
|
||||
if (_archive.IsSolid)
|
||||
completed = streamPos;
|
||||
else
|
||||
completed = currentTotalSize + offset;
|
||||
else
|
||||
completed = streamPos;
|
||||
RINOK(extractCallback->SetCompleted(&completed));
|
||||
if (!testMode)
|
||||
RINOK(WriteStream(realOutStream, buffer, processedSize));
|
||||
@@ -491,7 +476,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
}
|
||||
}
|
||||
realOutStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(dataError ?
|
||||
RINOK(extractCallback->SetOperationResult(dataError ?
|
||||
NArchive::NExtract::NOperationResult::kDataError :
|
||||
NArchive::NExtract::NOperationResult::kOK));
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
class CHandler:
|
||||
class CHandler:
|
||||
public IInArchive,
|
||||
PUBLIC_ISetCompressCodecsInfo
|
||||
public CMyUnknownImp
|
||||
|
||||
@@ -14,17 +14,17 @@
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/IntToString.h"
|
||||
|
||||
#include "../../../../C/CpuArch.h"
|
||||
|
||||
#define Get32(p) GetUi32(p)
|
||||
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
Byte kSignature[kSignatureSize] = { 0xEF + 1, 0xBE, 0xAD, 0xDE,
|
||||
Byte kSignature[kSignatureSize] = { 0xEF + 1, 0xBE, 0xAD, 0xDE,
|
||||
0x4E, 0x75, 0x6C, 0x6C, 0x73, 0x6F, 0x66, 0x74, 0x49, 0x6E, 0x73, 0x74};
|
||||
|
||||
class SignatureInitializer
|
||||
{
|
||||
public:
|
||||
SignatureInitializer() { kSignature[0]--; };
|
||||
} g_SignatureInitializer;
|
||||
struct CSignatureInit { CSignatureInit() { kSignature[0]--; } } g_SignatureInit;
|
||||
|
||||
#ifdef NSIS_SCRIPT
|
||||
static const char *kCrLf = "\x0D\x0A";
|
||||
@@ -35,13 +35,7 @@ static const char *kCrLf = "\x0D\x0A";
|
||||
#define NS_UN_SHELL_CODE 0xE002
|
||||
#define NS_UN_LANG_CODE 0xE003
|
||||
#define NS_UN_CODES_START NS_UN_SKIP_CODE
|
||||
#define NS_UN_CODES_END NS_UN_LANG_CODE
|
||||
|
||||
|
||||
UInt32 GetUInt32FromMemLE(const Byte *p)
|
||||
{
|
||||
return p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24);
|
||||
}
|
||||
#define NS_UN_CODES_END NS_UN_LANG_CODE
|
||||
|
||||
Byte CInArchive::ReadByte()
|
||||
{
|
||||
@@ -84,14 +78,30 @@ static int CompareItems(void *const *p1, void *const *p2, void * /* param */)
|
||||
return 0;
|
||||
}
|
||||
|
||||
AString CInArchive::ReadStringA(UInt32 pos)
|
||||
static AString UIntToString(UInt32 v)
|
||||
{
|
||||
char sz[32];
|
||||
ConvertUInt64ToString(v, sz);
|
||||
return sz;
|
||||
}
|
||||
|
||||
static AString IntToString(Int32 v)
|
||||
{
|
||||
char sz[32];
|
||||
ConvertInt64ToString(v, sz);
|
||||
return sz;
|
||||
}
|
||||
|
||||
AString CInArchive::ReadStringA(UInt32 pos) const
|
||||
{
|
||||
AString s;
|
||||
if (pos >= _size)
|
||||
return IntToString((Int32)pos);
|
||||
UInt32 offset = GetOffset() + _stringsPos + pos;
|
||||
for (;;)
|
||||
{
|
||||
if (offset >= _size)
|
||||
throw 1;
|
||||
break; // throw 1;
|
||||
char c = _data[offset++];
|
||||
if (c == 0)
|
||||
break;
|
||||
@@ -100,14 +110,14 @@ AString CInArchive::ReadStringA(UInt32 pos)
|
||||
return s;
|
||||
}
|
||||
|
||||
UString CInArchive::ReadStringU(UInt32 pos)
|
||||
UString CInArchive::ReadStringU(UInt32 pos) const
|
||||
{
|
||||
UString s;
|
||||
UInt32 offset = GetOffset() + _stringsPos + (pos * 2);
|
||||
for (;;)
|
||||
{
|
||||
if (offset >= _size || offset + 1 >= _size)
|
||||
throw 1;
|
||||
return s; // throw 1;
|
||||
char c0 = _data[offset++];
|
||||
char c1 = _data[offset++];
|
||||
wchar_t c = (c0 | ((wchar_t)c1 << 8));
|
||||
@@ -287,7 +297,7 @@ enum
|
||||
};
|
||||
|
||||
#ifdef NSIS_SCRIPT
|
||||
static CCommandPair kCommandPairs[] =
|
||||
static CCommandPair kCommandPairs[] =
|
||||
{
|
||||
{ 0, "Invalid" },
|
||||
{ 0, "Return" },
|
||||
@@ -315,7 +325,7 @@ static CCommandPair kCommandPairs[] =
|
||||
{ 2, "Delete" },
|
||||
{ 5, "MessageBox" },
|
||||
{ 2, "RMDir" },
|
||||
{ 2, "Assign" },
|
||||
{ 2, "StrLen" },
|
||||
{ 4, "StrCpy" },
|
||||
{ 5, "StrCmp" },
|
||||
{ 3, "ReadEnvStr" },
|
||||
@@ -368,7 +378,7 @@ static CCommandPair kCommandPairs[] =
|
||||
|
||||
#endif
|
||||
|
||||
static const char *kShellStrings[] =
|
||||
static const char *kShellStrings[] =
|
||||
{
|
||||
"",
|
||||
"",
|
||||
@@ -451,7 +461,7 @@ static const int kNumShellStrings = sizeof(kShellStrings) / sizeof(kShellStrings
|
||||
# define _OUTDIR 29
|
||||
*/
|
||||
|
||||
static const char *kVarStrings[] =
|
||||
static const char *kVarStrings[] =
|
||||
{
|
||||
"CMDLINE",
|
||||
"INSTDIR",
|
||||
@@ -460,6 +470,8 @@ static const char *kVarStrings[] =
|
||||
"LANGUAGE",
|
||||
"TEMP",
|
||||
"PLUGINSDIR",
|
||||
"EXEPATH", // test it
|
||||
"EXEFILE", // test it
|
||||
"HWNDPARENT",
|
||||
"_CLICK",
|
||||
"_OUTDIR"
|
||||
@@ -468,20 +480,6 @@ static const char *kVarStrings[] =
|
||||
static const int kNumVarStrings = sizeof(kVarStrings) / sizeof(kVarStrings[0]);
|
||||
|
||||
|
||||
static AString UIntToString(UInt32 v)
|
||||
{
|
||||
char sz[32];
|
||||
ConvertUInt64ToString(v, sz);
|
||||
return sz;
|
||||
}
|
||||
|
||||
static AString IntToString(Int32 v)
|
||||
{
|
||||
char sz[32];
|
||||
ConvertInt64ToString(v, sz);
|
||||
return sz;
|
||||
}
|
||||
|
||||
static AString GetVar(UInt32 index)
|
||||
{
|
||||
AString res = "$";
|
||||
@@ -586,17 +584,17 @@ UString GetNsisString(const UString &s)
|
||||
return res;
|
||||
}
|
||||
|
||||
AString CInArchive::ReadString2A(UInt32 pos)
|
||||
AString CInArchive::ReadString2A(UInt32 pos) const
|
||||
{
|
||||
return GetNsisString(ReadStringA(pos));
|
||||
}
|
||||
|
||||
UString CInArchive::ReadString2U(UInt32 pos)
|
||||
UString CInArchive::ReadString2U(UInt32 pos) const
|
||||
{
|
||||
return GetNsisString(ReadStringU(pos));
|
||||
}
|
||||
|
||||
AString CInArchive::ReadString2(UInt32 pos)
|
||||
AString CInArchive::ReadString2(UInt32 pos) const
|
||||
{
|
||||
if (IsUnicode)
|
||||
return UnicodeStringToMultiByte(ReadString2U(pos));
|
||||
@@ -604,6 +602,11 @@ AString CInArchive::ReadString2(UInt32 pos)
|
||||
return ReadString2A(pos);
|
||||
}
|
||||
|
||||
AString CInArchive::ReadString2Qw(UInt32 pos) const
|
||||
{
|
||||
return "\"" + ReadString2(pos) + "\"";
|
||||
}
|
||||
|
||||
#define DEL_DIR 1
|
||||
#define DEL_RECURSE 2
|
||||
#define DEL_REBOOT 4
|
||||
@@ -639,6 +642,31 @@ AString CEntry::GetParamsString(int numParams)
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifdef NSIS_SCRIPT
|
||||
|
||||
static AString GetRegRootID(UInt32 val)
|
||||
{
|
||||
const char *s;
|
||||
switch(val)
|
||||
{
|
||||
case 0: s = "SHCTX"; break;
|
||||
case 0x80000000: s = "HKCR"; break;
|
||||
case 0x80000001: s = "HKCU"; break;
|
||||
case 0x80000002: s = "HKLM"; break;
|
||||
case 0x80000003: s = "HKU"; break;
|
||||
case 0x80000004: s = "HKPD"; break;
|
||||
case 0x80000005: s = "HKCC"; break;
|
||||
case 0x80000006: s = "HKDD"; break;
|
||||
case 0x80000050: s = "HKPT"; break;
|
||||
case 0x80000060: s = "HKPN"; break;
|
||||
default:
|
||||
return UIntToString(val); break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
{
|
||||
_posInData = bh.Offset + GetOffset();
|
||||
@@ -698,8 +726,8 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
}
|
||||
/* UInt32 overwriteFlag = e.Params[0]; */
|
||||
item.Pos = e.Params[2];
|
||||
item.DateTime.dwLowDateTime = e.Params[3];
|
||||
item.DateTime.dwHighDateTime = e.Params[4];
|
||||
item.MTime.dwLowDateTime = e.Params[3];
|
||||
item.MTime.dwHighDateTime = e.Params[4];
|
||||
/* UInt32 allowIgnore = e.Params[5]; */
|
||||
if (Items.Size() > 0)
|
||||
{
|
||||
@@ -815,18 +843,25 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
Script += ReadString2(e.Params[0]);
|
||||
break;
|
||||
}
|
||||
case EW_STRLEN:
|
||||
{
|
||||
Script += " ";
|
||||
Script += GetVar(e.Params[0]);;
|
||||
Script += " ";
|
||||
Script += ReadString2Qw(e.Params[1]);
|
||||
break;
|
||||
}
|
||||
case EW_ASSIGNVAR:
|
||||
{
|
||||
Script += " ";
|
||||
Script += GetVar(e.Params[0]);;
|
||||
Script += " \"";
|
||||
Script += " ";
|
||||
Script += ReadString2Qw(e.Params[1]);
|
||||
AString maxLen, startOffset;
|
||||
Script += ReadString2(e.Params[1]);
|
||||
Script += "\"";
|
||||
if (e.Params[2] != 0)
|
||||
maxLen = ReadString(e.Params[2]);
|
||||
maxLen = ReadString2(e.Params[2]);
|
||||
if (e.Params[3] != 0)
|
||||
startOffset = ReadString(e.Params[3]);
|
||||
startOffset = ReadString2(e.Params[3]);
|
||||
if (!maxLen.IsEmpty() || !startOffset.IsEmpty())
|
||||
{
|
||||
Script += " ";
|
||||
@@ -846,13 +881,11 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
{
|
||||
Script += " ";
|
||||
|
||||
Script += " \"";
|
||||
Script += ReadString2(e.Params[0]);
|
||||
Script += "\"";
|
||||
Script += " ";
|
||||
Script += ReadString2Qw(e.Params[0]);
|
||||
|
||||
Script += " \"";
|
||||
Script += ReadString2(e.Params[1]);
|
||||
Script += "\"";
|
||||
Script += " ";
|
||||
Script += ReadString2Qw(e.Params[1]);
|
||||
|
||||
for (int j = 2; j < 5; j++)
|
||||
{
|
||||
@@ -861,6 +894,62 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EW_INTCMP:
|
||||
{
|
||||
if (e.Params[5] != 0)
|
||||
Script += "U";
|
||||
|
||||
Script += " ";
|
||||
Script += ReadString2(e.Params[0]);
|
||||
Script += " ";
|
||||
Script += ReadString2(e.Params[1]);
|
||||
|
||||
for (int i = 2; i < 5; i++)
|
||||
{
|
||||
Script += " ";
|
||||
Script += UIntToString(e.Params[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EW_INTOP:
|
||||
{
|
||||
Script += " ";
|
||||
Script += GetVar(e.Params[0]);
|
||||
Script += " ";
|
||||
int numOps = 2;
|
||||
AString op;
|
||||
switch (e.Params[3])
|
||||
{
|
||||
case 0: op = '+'; break;
|
||||
case 1: op = '-'; break;
|
||||
case 2: op = '*'; break;
|
||||
case 3: op = '/'; break;
|
||||
case 4: op = '|'; break;
|
||||
case 5: op = '&'; break;
|
||||
case 6: op = '^'; break;
|
||||
case 7: op = '~'; numOps = 1; break;
|
||||
case 8: op = '!'; numOps = 1; break;
|
||||
case 9: op = "||"; break;
|
||||
case 10: op = "&&"; break;
|
||||
case 11: op = '%'; break;
|
||||
default: op = UIntToString(e.Params[3]);
|
||||
}
|
||||
AString p1 = ReadString2(e.Params[1]);
|
||||
if (numOps == 1)
|
||||
{
|
||||
Script += op;
|
||||
Script += p1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Script += p1;
|
||||
Script += " ";
|
||||
Script += op;
|
||||
Script += " ";
|
||||
Script += ReadString2(e.Params[2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case EW_PUSHPOP:
|
||||
{
|
||||
@@ -888,24 +977,55 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
case EW_SENDMESSAGE:
|
||||
{
|
||||
// SendMessage: 6 [output, hwnd, msg, wparam, lparam, [wparamstring?1:0 | lparamstring?2:0 | timeout<<2]
|
||||
Script += " ";
|
||||
Script += IntToString(e.Params[0]);
|
||||
Script += " ";
|
||||
Script += GetVar(e.Params[1]);
|
||||
// Script += ReadString2(e.Params[0]);
|
||||
// Script += " ";
|
||||
Script += ReadString2(e.Params[1]);
|
||||
Script += " ";
|
||||
Script += ReadString2(e.Params[2]);
|
||||
|
||||
Script += " ";
|
||||
Script += UIntToString(e.Params[3]);
|
||||
UInt32 spec = e.Params[5];
|
||||
// if (spec & 1)
|
||||
Script += IntToString(e.Params[3]);
|
||||
// else
|
||||
// Script += ReadString2(e.Params[3]);
|
||||
|
||||
Script += " ";
|
||||
Script += IntToString(e.Params[4]);
|
||||
Script += " ";
|
||||
Script += UIntToString(e.Params[5]);
|
||||
// if (spec & 2)
|
||||
Script += IntToString(e.Params[4]);
|
||||
// else
|
||||
// Script += ReadString2(e.Params[4]);
|
||||
|
||||
if ((Int32)e.Params[0] >= 0)
|
||||
{
|
||||
Script += " ";
|
||||
Script += GetVar(e.Params[1]);
|
||||
}
|
||||
|
||||
spec >>= 2;
|
||||
if (spec != 0)
|
||||
{
|
||||
Script += " /TIMEOUT=";
|
||||
Script += IntToString(spec);
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
case EW_GETDLGITEM:
|
||||
{
|
||||
Script += " ";
|
||||
Script += GetVar(e.Params[0]);;
|
||||
Script += " ";
|
||||
Script += ReadString2(e.Params[1]);
|
||||
Script += " ";
|
||||
Script += ReadString2(e.Params[2]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case EW_REGISTERDLL:
|
||||
{
|
||||
@@ -923,14 +1043,10 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
AString s;
|
||||
|
||||
Script += " ";
|
||||
Script += " \"";
|
||||
Script += ReadString2(e.Params[0]);
|
||||
Script += " \"";
|
||||
Script += ReadString2Qw(e.Params[0]);
|
||||
|
||||
Script += " ";
|
||||
Script += " \"";
|
||||
Script += ReadString2(e.Params[1]);
|
||||
Script += " \"";
|
||||
Script += ReadString2Qw(e.Params[1]);
|
||||
|
||||
for (int j = 2; j < 5; j++)
|
||||
{
|
||||
@@ -968,6 +1084,38 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
}
|
||||
*/
|
||||
|
||||
case EW_WRITEREG:
|
||||
{
|
||||
AString s;
|
||||
switch(e.Params[4])
|
||||
{
|
||||
case 1: s = "Str"; break;
|
||||
case 2: s = "ExpandStr"; break;
|
||||
case 3: s = "Bin"; break;
|
||||
case 4: s = "DWORD"; break;
|
||||
default: s = "?" + UIntToString(e.Params[4]); break;
|
||||
}
|
||||
Script += s;
|
||||
Script += " ";
|
||||
Script += GetRegRootID(e.Params[0]);
|
||||
Script += " ";
|
||||
|
||||
AString keyName, valueName;
|
||||
keyName = ReadString2Qw(e.Params[1]);
|
||||
Script += keyName;
|
||||
Script += " ";
|
||||
|
||||
valueName = ReadString2Qw(e.Params[2]);
|
||||
Script += valueName;
|
||||
Script += " ";
|
||||
|
||||
valueName = ReadString2Qw(e.Params[3]);
|
||||
Script += valueName;
|
||||
Script += " ";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case EW_WRITEUNINSTALLER:
|
||||
{
|
||||
Script += " ";
|
||||
@@ -1006,7 +1154,7 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
{
|
||||
Items.Sort(CompareItems, 0);
|
||||
int i;
|
||||
// if (IsSolid)
|
||||
// if (IsSolid)
|
||||
for (i = 0; i + 1 < Items.Size();)
|
||||
{
|
||||
bool sameName = IsUnicode ?
|
||||
@@ -1035,7 +1183,7 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
RINOK(ReadStream(_stream, sig, &processedSize));
|
||||
if (processedSize < 4)
|
||||
return S_FALSE;
|
||||
UInt32 size = GetUInt32FromMemLE(sig);
|
||||
UInt32 size = Get32(sig);
|
||||
if ((size & 0x80000000) != 0)
|
||||
{
|
||||
item.IsCompressed = true;
|
||||
@@ -1047,7 +1195,7 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
return S_FALSE;
|
||||
if (FilterFlag)
|
||||
item.UseFilter = (sig[4] != 0);
|
||||
item.DictionarySize = GetUInt32FromMemLE(sig + 5 + (FilterFlag ? 1 : 0));
|
||||
item.DictionarySize = Get32(sig + 5 + (FilterFlag ? 1 : 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1085,7 +1233,7 @@ HRESULT CInArchive::Parse()
|
||||
int numZeros0 = 0;
|
||||
int numZeros1 = 0;
|
||||
int i;
|
||||
const kBlockSize = 256;
|
||||
const int kBlockSize = 256;
|
||||
for (i = 0; i < kBlockSize; i++)
|
||||
{
|
||||
if (pos >= _size || pos + 1 >= _size)
|
||||
@@ -1117,7 +1265,7 @@ HRESULT CInArchive::Parse()
|
||||
|
||||
static bool IsLZMA(const Byte *p, UInt32 &dictionary)
|
||||
{
|
||||
dictionary = GetUInt32FromMemLE(p + 1);
|
||||
dictionary = Get32(p + 1);
|
||||
return (p[0] == 0x5D && p[1] == 0x00 && p[2] == 0x00 && p[5] == 0x00);
|
||||
}
|
||||
|
||||
@@ -1152,7 +1300,7 @@ HRESULT CInArchive::Open2(
|
||||
IsSolid = true;
|
||||
FilterFlag = false;
|
||||
|
||||
UInt32 compressedHeaderSize = GetUInt32FromMemLE(sig);
|
||||
UInt32 compressedHeaderSize = Get32(sig);
|
||||
|
||||
if (compressedHeaderSize == FirstHeader.HeaderLength)
|
||||
{
|
||||
@@ -1218,7 +1366,7 @@ HRESULT CInArchive::Open2(
|
||||
}
|
||||
|
||||
/*
|
||||
NsisExe =
|
||||
NsisExe =
|
||||
{
|
||||
ExeStub
|
||||
Archive // must start from 512 * N
|
||||
@@ -1253,51 +1401,39 @@ HRESULT CInArchive::Open(
|
||||
IInStream *inStream, const UInt64 *maxCheckStartPosition)
|
||||
{
|
||||
Clear();
|
||||
UInt64 pos;
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &pos));
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_END, &_archiveSize));
|
||||
UInt64 position;
|
||||
RINOK(inStream->Seek(pos, STREAM_SEEK_SET, &position));
|
||||
UInt64 maxSize = (maxCheckStartPosition != 0) ? *maxCheckStartPosition : (1 << 20);
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
UInt64 maxSize = ((maxCheckStartPosition != 0) ? *maxCheckStartPosition : 0);
|
||||
const UInt32 kStep = 512;
|
||||
const UInt32 kStartHeaderSize = 4 * 7;
|
||||
Byte buffer[kStep];
|
||||
bool found = false;
|
||||
|
||||
UInt64 headerPosition = 0;
|
||||
while (position <= maxSize)
|
||||
UInt64 position = 0;
|
||||
for (; position <= maxSize; position += kStep)
|
||||
{
|
||||
RINOK(ReadStream_FALSE(inStream, buffer, kStartHeaderSize));
|
||||
headerPosition = position;
|
||||
position += kStartHeaderSize;
|
||||
if(memcmp(buffer + 4, kSignature, kSignatureSize) == 0)
|
||||
{
|
||||
found = true;
|
||||
RINOK(ReadStream_FALSE(inStream, buffer, kStep));
|
||||
if (memcmp(buffer + 4, kSignature, kSignatureSize) == 0)
|
||||
break;
|
||||
}
|
||||
const UInt32 kRem = kStep - kStartHeaderSize;
|
||||
RINOK(ReadStream_FALSE(inStream, buffer + kStartHeaderSize, kRem));
|
||||
position += kRem;
|
||||
}
|
||||
if (!found)
|
||||
if (position > maxSize)
|
||||
return S_FALSE;
|
||||
FirstHeader.Flags = GetUInt32FromMemLE(buffer);
|
||||
FirstHeader.HeaderLength = GetUInt32FromMemLE(buffer + kSignatureSize + 4);
|
||||
FirstHeader.ArchiveSize = GetUInt32FromMemLE(buffer + kSignatureSize + 8);
|
||||
if (_archiveSize - headerPosition < FirstHeader.ArchiveSize)
|
||||
const UInt32 kStartHeaderSize = 4 * 7;
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_END, &_archiveSize));
|
||||
RINOK(inStream->Seek(position + kStartHeaderSize, STREAM_SEEK_SET, 0));
|
||||
FirstHeader.Flags = Get32(buffer);
|
||||
FirstHeader.HeaderLength = Get32(buffer + kSignatureSize + 4);
|
||||
FirstHeader.ArchiveSize = Get32(buffer + kSignatureSize + 8);
|
||||
if (_archiveSize - position < FirstHeader.ArchiveSize)
|
||||
return S_FALSE;
|
||||
|
||||
_stream = inStream;
|
||||
HRESULT res = S_FALSE;
|
||||
try
|
||||
{
|
||||
res = Open2(
|
||||
EXTERNAL_CODECS_LOC_VARS2
|
||||
);
|
||||
try
|
||||
{
|
||||
_stream = inStream;
|
||||
HRESULT res = Open2(EXTERNAL_CODECS_LOC_VARS2);
|
||||
if (res != S_OK)
|
||||
Clear();
|
||||
_stream.Release();
|
||||
return res;
|
||||
}
|
||||
catch(...) { Clear(); res = S_FALSE; }
|
||||
_stream.Release();
|
||||
return res;
|
||||
catch(...) { Clear(); return S_FALSE; }
|
||||
}
|
||||
|
||||
void CInArchive::Clear()
|
||||
@@ -1306,6 +1442,7 @@ void CInArchive::Clear()
|
||||
Script.Empty();
|
||||
#endif
|
||||
Items.Clear();
|
||||
_stream.Release();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -37,7 +37,7 @@ struct CFirstHeader
|
||||
|
||||
UInt32 ArchiveSize;
|
||||
|
||||
bool ThereIsCrc() const
|
||||
bool ThereIsCrc() const
|
||||
{
|
||||
if ((Flags & NFlags::kForceCrc ) != 0)
|
||||
return true;
|
||||
@@ -60,7 +60,7 @@ struct CItem
|
||||
UString PrefixU;
|
||||
AString NameA;
|
||||
UString NameU;
|
||||
FILETIME DateTime;
|
||||
FILETIME MTime;
|
||||
bool IsUnicode;
|
||||
bool UseFilter;
|
||||
bool IsCompressed;
|
||||
@@ -73,7 +73,7 @@ struct CItem
|
||||
UInt32 EstimatedSize;
|
||||
UInt32 DictionarySize;
|
||||
|
||||
CItem(): IsUnicode(false), UseFilter(false), IsCompressed(true), SizeIsDefined(false),
|
||||
CItem(): IsUnicode(false), UseFilter(false), IsCompressed(true), SizeIsDefined(false),
|
||||
CompressedSizeIsDefined(false), EstimatedSizeIsDefined(false), Size(0) {}
|
||||
|
||||
bool IsINSTDIR() const
|
||||
@@ -81,7 +81,7 @@ struct CItem
|
||||
return (PrefixA.Length() >= 3 || PrefixU.Length() >= 3);
|
||||
}
|
||||
|
||||
AString GetReducedNameA() const
|
||||
AString GetReducedNameA() const
|
||||
{
|
||||
AString prefix = PrefixA;
|
||||
if (prefix.Length() > 0)
|
||||
@@ -94,7 +94,7 @@ struct CItem
|
||||
return s2;
|
||||
}
|
||||
|
||||
UString GetReducedNameU() const
|
||||
UString GetReducedNameU() const
|
||||
{
|
||||
UString prefix = PrefixU;
|
||||
if (prefix.Length() > 0)
|
||||
@@ -120,11 +120,12 @@ class CInArchive
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS2
|
||||
);
|
||||
void ReadBlockHeader(CBlockHeader &bh);
|
||||
AString ReadStringA(UInt32 pos);
|
||||
UString ReadStringU(UInt32 pos);
|
||||
AString ReadString2A(UInt32 pos);
|
||||
UString ReadString2U(UInt32 pos);
|
||||
AString ReadString2(UInt32 pos);
|
||||
AString ReadStringA(UInt32 pos) const;
|
||||
UString ReadStringU(UInt32 pos) const;
|
||||
AString ReadString2A(UInt32 pos) const;
|
||||
UString ReadString2U(UInt32 pos) const;
|
||||
AString ReadString2(UInt32 pos) const;
|
||||
AString ReadString2Qw(UInt32 pos) const;
|
||||
HRESULT ReadEntries(const CBlockHeader &bh);
|
||||
HRESULT Parse();
|
||||
|
||||
@@ -165,14 +166,14 @@ public:
|
||||
return GetOffset() + FirstHeader.HeaderLength + item.Pos;
|
||||
}
|
||||
|
||||
UInt64 GetPosOfSolidItem(int index) const
|
||||
{
|
||||
UInt64 GetPosOfSolidItem(int index) const
|
||||
{
|
||||
const CItem &item = Items[index];
|
||||
return 4 + FirstHeader.HeaderLength + item.Pos;
|
||||
}
|
||||
|
||||
UInt64 GetPosOfNonSolidItem(int index) const
|
||||
{
|
||||
UInt64 GetPosOfNonSolidItem(int index) const
|
||||
{
|
||||
const CItem &item = Items[index];
|
||||
return StreamOffset + _nonSolidStartOffset + 4 + item.Pos;
|
||||
}
|
||||
@@ -184,8 +185,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
UInt32 GetUInt32FromMemLE(const Byte *p);
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
static IInArchive *CreateArc() { return new NArchive::NNsis::CHandler; }
|
||||
|
||||
static CArcInfo g_ArcInfo =
|
||||
{ L"Nsis", 0, 0, 0x9, { 0xEF, 0xBE, 0xAD, 0xDE,
|
||||
{ L"Nsis", 0, 0, 0x9, { 0xEF, 0xBE, 0xAD, 0xDE,
|
||||
0x4E, 0x75, 0x6C, 0x6C, 0x73, 0x6F, 0x66, 0x74, 0x49, 0x6E, 0x73, 0x74}, 16, false, CreateArc, 0 };
|
||||
|
||||
REGISTER_ARC(Nsis)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
Reference in New Issue
Block a user