mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 16:07:09 -06:00
4.40 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
3415684502
commit
bd9a40b0ed
@@ -52,7 +52,6 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
bool testMode = (testModeSpec != 0);
|
||||
CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
|
||||
UInt64 importantTotalUnPacked = 0;
|
||||
UInt64 censoredTotalUnPacked = 0, censoredTotalPacked = 0;
|
||||
|
||||
bool allFilesMode = (numItems == UInt32(-1));
|
||||
if (allFilesMode)
|
||||
|
||||
@@ -540,7 +540,6 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
// CMyComPtr<IUpdateCallback2> updateCallback2;
|
||||
// updateCallback->QueryInterface(&updateCallback2);
|
||||
|
||||
int index = 0;
|
||||
for(UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
Int32 newData;
|
||||
|
||||
@@ -97,7 +97,6 @@ struct CArchiveDatabaseEx: public CArchiveDatabase
|
||||
CNum folderIndex = FileIndexToFolderIndexMap[fileIndex];
|
||||
if (folderIndex >= 0)
|
||||
{
|
||||
const CFolder &folderInfo = Folders[folderIndex];
|
||||
if (FolderStartFileIndex[folderIndex] == fileIndex)
|
||||
return GetFolderFullPackSize(folderIndex);
|
||||
}
|
||||
|
||||
@@ -119,17 +119,15 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath:
|
||||
{
|
||||
UString unicodeName;
|
||||
if (item.IsNameUTF())
|
||||
{
|
||||
UString unicodeName;
|
||||
if (!ConvertUTF8ToUnicode(item.Name, unicodeName))
|
||||
propVariant = L"";
|
||||
else
|
||||
propVariant = (const wchar_t *)NItemName::WinNameToOSName(unicodeName);
|
||||
}
|
||||
ConvertUTF8ToUnicode(item.Name, unicodeName);
|
||||
else
|
||||
propVariant = MultiByteToUnicodeString(item.Name, CP_ACP);
|
||||
unicodeName = MultiByteToUnicodeString(item.Name, CP_ACP);
|
||||
propVariant = (const wchar_t *)NItemName::WinNameToOSName(unicodeName);
|
||||
break;
|
||||
}
|
||||
case kpidIsFolder:
|
||||
propVariant = item.IsDirectory();
|
||||
break;
|
||||
|
||||
@@ -229,7 +229,6 @@ STDMETHODIMP CCoderMixer2MT::Init(ISequentialInStream **inStreams,
|
||||
{
|
||||
if (_coderInfoVector.Size() != _bindInfo.Coders.Size())
|
||||
throw 0;
|
||||
UInt32 numInStreams = 0, numOutStreams = 0;
|
||||
int i;
|
||||
for(i = 0; i < _coderInfoVector.Size(); i++)
|
||||
{
|
||||
|
||||
@@ -140,9 +140,13 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
{
|
||||
case kpidPath:
|
||||
{
|
||||
const UString s = NItemName::WinNameToOSName(MultiByteToUnicodeString(item.GetName(), CP_OEMCP));
|
||||
UString s = NItemName::WinNameToOSName(MultiByteToUnicodeString(item.GetName(), CP_OEMCP));
|
||||
if (!s.IsEmpty())
|
||||
{
|
||||
if (s[s.Length() - 1] == WCHAR_PATH_SEPARATOR)
|
||||
s.Delete(s.Length() - 1);
|
||||
propVariant = s;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kpidIsFolder:
|
||||
|
||||
110
7zip/Archive/Nsis/DllExports.cpp
Executable file
110
7zip/Archive/Nsis/DllExports.cpp
Executable file
@@ -0,0 +1,110 @@
|
||||
// DLLExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/ComTry.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "../../ICoder.h"
|
||||
#include "NsisHandler.h"
|
||||
|
||||
// {23170F69-40C1-278A-1000-000110090000}
|
||||
DEFINE_GUID(CLSID_CNsisHandler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x09, 0x00, 0x00);
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI CreateObject(
|
||||
const GUID *classID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
if (*classID != CLSID_CNsisHandler)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
int needIn = *interfaceID == IID_IInArchive;
|
||||
// int needOut = *interfaceID == IID_IOutArchive;
|
||||
if (needIn /*|| needOut */)
|
||||
{
|
||||
NArchive::NNsis::CHandler *temp = new NArchive::NNsis::CHandler;
|
||||
if (needIn)
|
||||
{
|
||||
CMyComPtr<IInArchive> inArchive = (IInArchive *)temp;
|
||||
*outObject = inArchive.Detach();
|
||||
}
|
||||
/*
|
||||
else
|
||||
{
|
||||
CMyComPtr<IOutArchive> outArchive = (IOutArchive *)temp;
|
||||
*outObject = outArchive.Detach();
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
return E_NOINTERFACE;
|
||||
COM_TRY_END
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
switch(propID)
|
||||
{
|
||||
case NArchive::kName:
|
||||
propVariant = L"Nsis";
|
||||
break;
|
||||
case NArchive::kClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&CLSID_CNsisHandler, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"exe";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = false;
|
||||
break;
|
||||
case NArchive::kStartSignature:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen((const char *)NArchive::NNsis::kSignature,
|
||||
NArchive::NNsis::kSignatureSize)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kAssociate:
|
||||
{
|
||||
propVariant = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
337
7zip/Archive/Nsis/Nsis.dsp
Executable file
337
7zip/Archive/Nsis/Nsis.dsp
Executable file
@@ -0,0 +1,337 @@
|
||||
# Microsoft Developer Studio Project File - Name="Nsis" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=Nsis - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Nsis.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Nsis.mak" CFG="Nsis - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Nsis - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "Nsis - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Nsis - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-Zip\Formats\nsis.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Nsis - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-Zip\Formats\nsis.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Nsis - Win32 Release"
|
||||
# Name "Nsis - Win32 Debug"
|
||||
# Begin Group "Spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Archive.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DllExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Nsis.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"StdAfx.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Buffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileFind.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileFind.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Engine"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\NsisDecode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\NsisDecode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\NsisHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\NsisHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\NsisIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\NsisIn.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Archive Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CodecsPath.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CodecsPath.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CoderLoader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CoderLoader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\FilterCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\FilterCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ItemNameUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ItemNameUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7zip Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LimitedStreams.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LimitedStreams.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamObjects.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamObjects.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7z"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\7z\7zMethodID.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\7z\7zMethodID.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\7z\7zMethods.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\7z\7zMethods.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
29
7zip/Archive/Nsis/Nsis.dsw
Executable file
29
7zip/Archive/Nsis/Nsis.dsw
Executable file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Nsis"=.\Nsis.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
150
7zip/Archive/Nsis/NsisDecode.cpp
Executable file
150
7zip/Archive/Nsis/NsisDecode.cpp
Executable file
@@ -0,0 +1,150 @@
|
||||
// NsisDecode.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "NsisDecode.h"
|
||||
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "../7z/7zMethods.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
static const N7z::CMethodID k_Copy = { { 0x0 }, 1 };
|
||||
static const N7z::CMethodID k_Deflate = { { 0x4, 0x9, 0x1 }, 3 };
|
||||
static const N7z::CMethodID k_BZip2 = { { 0x4, 0x9, 0x2 }, 3 };
|
||||
static const N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
static const N7z::CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
|
||||
|
||||
CDecoder::CDecoder()
|
||||
{
|
||||
N7z::LoadMethodMap();
|
||||
}
|
||||
|
||||
HRESULT CDecoder::Init(IInStream *inStream, NMethodType::EEnum method, bool thereIsFilterFlag, bool &useFilter)
|
||||
{
|
||||
useFilter = false;
|
||||
CObjectVector< CMyComPtr<ISequentialInStream> > inStreams;
|
||||
|
||||
if (_decoderInStream)
|
||||
if (method != _method)
|
||||
Release();
|
||||
_method = method;
|
||||
if (!_codecInStream)
|
||||
{
|
||||
const NArchive::N7z::CMethodID *methodID = 0;
|
||||
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;
|
||||
default:
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
N7z::CMethodInfo methodInfo;
|
||||
if (!N7z::GetMethodInfo(*methodID, methodInfo))
|
||||
return E_NOTIMPL;
|
||||
CMyComPtr<ICompressCoder> coder;
|
||||
RINOK(_libraries.CreateCoder(methodInfo.FilePath, methodInfo.Decoder, &coder));
|
||||
coder.QueryInterface(IID_ISequentialInStream, &_codecInStream);
|
||||
if (!_codecInStream)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
if (thereIsFilterFlag)
|
||||
{
|
||||
UInt32 processedSize;
|
||||
BYTE flag;
|
||||
RINOK(inStream->Read(&flag, 1, &processedSize));
|
||||
if (processedSize != 1)
|
||||
return E_FAIL;
|
||||
if (flag > 1)
|
||||
return E_NOTIMPL;
|
||||
useFilter = (flag != 0);
|
||||
}
|
||||
|
||||
if (useFilter)
|
||||
{
|
||||
if (!_filterInStream)
|
||||
{
|
||||
N7z::CMethodInfo methodInfo;
|
||||
if (!N7z::GetMethodInfo(k_BCJ_X86, methodInfo))
|
||||
return E_NOTIMPL;
|
||||
CMyComPtr<ICompressCoder> coder;
|
||||
RINOK(_libraries.CreateCoderSpec(methodInfo.FilePath, methodInfo.Decoder, &coder));
|
||||
coder.QueryInterface(IID_ISequentialInStream, &_filterInStream);
|
||||
if (!_filterInStream)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
CMyComPtr<ICompressSetInStream> setInStream;
|
||||
_filterInStream.QueryInterface(IID_ICompressSetInStream, &setInStream);
|
||||
if (!setInStream)
|
||||
return E_NOTIMPL;
|
||||
RINOK(setInStream->SetInStream(_codecInStream));
|
||||
_decoderInStream = _filterInStream;
|
||||
}
|
||||
else
|
||||
_decoderInStream = _codecInStream;
|
||||
|
||||
if (method == NMethodType::kLZMA)
|
||||
{
|
||||
CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
|
||||
_codecInStream.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
|
||||
if (setDecoderProperties)
|
||||
{
|
||||
static const UInt32 kPropertiesSize = 5;
|
||||
BYTE properties[kPropertiesSize];
|
||||
UInt32 processedSize;
|
||||
RINOK(inStream->Read(properties, kPropertiesSize, &processedSize));
|
||||
if (processedSize != kPropertiesSize)
|
||||
return E_FAIL;
|
||||
RINOK(setDecoderProperties->SetDecoderProperties2((const Byte *)properties, kPropertiesSize));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
CMyComPtr<ICompressSetInStream> setInStream;
|
||||
_codecInStream.QueryInterface(IID_ICompressSetInStream, &setInStream);
|
||||
if (!setInStream)
|
||||
return E_NOTIMPL;
|
||||
RINOK(setInStream->SetInStream(inStream));
|
||||
}
|
||||
|
||||
{
|
||||
CMyComPtr<ICompressSetOutStreamSize> setOutStreamSize;
|
||||
_codecInStream.QueryInterface(IID_ICompressSetOutStreamSize, &setOutStreamSize);
|
||||
if (!setOutStreamSize)
|
||||
return E_NOTIMPL;
|
||||
RINOK(setOutStreamSize->SetOutStreamSize(NULL));
|
||||
}
|
||||
|
||||
if (useFilter)
|
||||
{
|
||||
/*
|
||||
CMyComPtr<ICompressSetOutStreamSize> setOutStreamSize;
|
||||
_filterInStream.QueryInterface(IID_ICompressSetOutStreamSize, &setOutStreamSize);
|
||||
if (!setOutStreamSize)
|
||||
return E_NOTIMPL;
|
||||
RINOK(setOutStreamSize->SetOutStreamSize(NULL));
|
||||
*/
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
return ReadStream(_decoderInStream, data, size, processedSize);;
|
||||
}
|
||||
|
||||
}}
|
||||
47
7zip/Archive/Nsis/NsisDecode.h
Executable file
47
7zip/Archive/Nsis/NsisDecode.h
Executable file
@@ -0,0 +1,47 @@
|
||||
// NsisDecode.h
|
||||
|
||||
#ifndef __NSIS_DECODE_H
|
||||
#define __NSIS_DECODE_H
|
||||
|
||||
#include "../../IStream.h"
|
||||
|
||||
#include "../Common/CoderLoader.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
namespace NMethodType
|
||||
{
|
||||
enum EEnum
|
||||
{
|
||||
kCopy,
|
||||
kDeflate,
|
||||
kBZip2,
|
||||
kLZMA
|
||||
};
|
||||
}
|
||||
|
||||
class CDecoder
|
||||
{
|
||||
NMethodType::EEnum _method;
|
||||
CCoderLibraries _libraries;
|
||||
|
||||
CMyComPtr<ISequentialInStream> _filterInStream;
|
||||
CMyComPtr<ISequentialInStream> _codecInStream;
|
||||
CMyComPtr<ISequentialInStream> _decoderInStream;
|
||||
|
||||
public:
|
||||
CDecoder();
|
||||
void Release()
|
||||
{
|
||||
_filterInStream.Release();
|
||||
_codecInStream.Release();
|
||||
_decoderInStream.Release();
|
||||
}
|
||||
HRESULT Init(IInStream *inStream, NMethodType::EEnum method, bool thereIsFilterFlag, bool &useFilter);
|
||||
HRESULT Read(void *data, UInt32 size, UInt32 *processedSize);
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
474
7zip/Archive/Nsis/NsisHandler.cpp
Executable file
474
7zip/Archive/Nsis/NsisHandler.cpp
Executable file
@@ -0,0 +1,474 @@
|
||||
// NSisHandler.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "NsisHandler.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/NewHandler.h"
|
||||
#include "Common/ComTry.h"
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../Common/ItemNameUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
static const wchar_t *kBcjMethod = L"BCJ";
|
||||
static const wchar_t *kUnknownMethod = L"Unknown";
|
||||
|
||||
static const wchar_t *kMethods[] =
|
||||
{
|
||||
L"Copy",
|
||||
L"Deflate",
|
||||
L"BZip2",
|
||||
L"LZMA"
|
||||
};
|
||||
|
||||
static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
|
||||
|
||||
STATPROPSTG kProperties[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidIsFolder, VT_BOOL},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidPackedSize, VT_UI8},
|
||||
{ NULL, kpidLastWriteTime, VT_FILETIME},
|
||||
{ NULL, kpidMethod, VT_BSTR},
|
||||
{ NULL, kpidSolid, VT_BOOL}
|
||||
};
|
||||
|
||||
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
value->vt = VT_EMPTY;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
if(index >= sizeof(kProperties) / sizeof(kProperties[0]))
|
||||
return E_INVALIDARG;
|
||||
const STATPROPSTG &srcItem = kProperties[index];
|
||||
*propID = srcItem.propid;
|
||||
*varType = srcItem.vt;
|
||||
*name = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openArchiveCallback)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
bool mustBeClosed = true;
|
||||
Close();
|
||||
{
|
||||
if(_archive.Open(stream, maxCheckStartPosition) != S_OK)
|
||||
return S_FALSE;
|
||||
_inStream = stream;
|
||||
}
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_archive.Clear();
|
||||
_archive.Release();
|
||||
_inStream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
*numItems = _archive.Items.Size() + 1;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static UString ConvertUInt32ToString(UInt32 value)
|
||||
{
|
||||
wchar_t buffer[32];
|
||||
ConvertUInt64ToString(value, buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static UString GetStringForSizeValue(UInt32 value)
|
||||
{
|
||||
for (int i = 31; i >= 0; i--)
|
||||
if ((UInt32(1) << i) == value)
|
||||
return ConvertUInt32ToString(i);
|
||||
UString result;
|
||||
if (value % (1 << 20) == 0)
|
||||
{
|
||||
result += ConvertUInt32ToString(value >> 20);
|
||||
result += L"m";
|
||||
}
|
||||
else if (value % (1 << 10) == 0)
|
||||
{
|
||||
result += ConvertUInt32ToString(value >> 10);
|
||||
result += L"k";
|
||||
}
|
||||
else
|
||||
{
|
||||
result += ConvertUInt32ToString(value);
|
||||
result += L"b";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CHandler::GetUncompressedSize(int index, UInt32 &size)
|
||||
{
|
||||
size = 0;
|
||||
const CItem &item = _archive.Items[index];
|
||||
if (item.SizeIsDefined)
|
||||
size = item.Size;
|
||||
else if (_archive.IsSolid && item.EstimatedSizeIsDefined)
|
||||
size = item.EstimatedSize;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHandler::GetCompressedSize(int index, UInt32 &size)
|
||||
{
|
||||
size = 0;
|
||||
const CItem &item = _archive.Items[index];
|
||||
if (item.CompressedSizeIsDefined)
|
||||
size = item.CompressedSize;
|
||||
else
|
||||
{
|
||||
if (_archive.IsSolid)
|
||||
{
|
||||
if (index == 0)
|
||||
size = _archive.FirstHeader.GetDataSize();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!item.IsCompressed)
|
||||
size = item.Size;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
if (index >= (UInt32)_archive.Items.Size())
|
||||
{
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath:
|
||||
propVariant = L"[NSIS].nsi";
|
||||
break;
|
||||
case kpidIsFolder:
|
||||
propVariant = false;
|
||||
break;
|
||||
case kpidSize:
|
||||
case kpidPackedSize:
|
||||
propVariant = (UInt64)_archive.Script.Length();
|
||||
break;
|
||||
case kpidSolid:
|
||||
propVariant = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const CItem &item = _archive.Items[index];
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath:
|
||||
{
|
||||
const UString s = NItemName::WinNameToOSName(MultiByteToUnicodeString(item.GetReducedName(), CP_ACP));
|
||||
propVariant = (const wchar_t *)s;
|
||||
break;
|
||||
}
|
||||
case kpidIsFolder:
|
||||
propVariant = false;
|
||||
break;
|
||||
case kpidSize:
|
||||
{
|
||||
UInt32 size;
|
||||
if (GetUncompressedSize(index, size))
|
||||
propVariant = (UInt64)size;
|
||||
break;
|
||||
}
|
||||
case kpidPackedSize:
|
||||
{
|
||||
UInt32 size;
|
||||
if (GetCompressedSize(index, size))
|
||||
propVariant = (UInt64)size;
|
||||
break;
|
||||
}
|
||||
case kpidLastWriteTime:
|
||||
{
|
||||
if (item.DateTime.dwHighDateTime > 0x01000000 &&
|
||||
item.DateTime.dwHighDateTime < 0xFF000000)
|
||||
propVariant = item.DateTime;
|
||||
break;
|
||||
}
|
||||
case kpidMethod:
|
||||
{
|
||||
NMethodType::EEnum methodIndex = _archive.Method;
|
||||
UString method;
|
||||
if (_archive.IsSolid && _archive.UseFilter || !_archive.IsSolid && item.UseFilter)
|
||||
{
|
||||
method += kBcjMethod;
|
||||
method += L" ";
|
||||
}
|
||||
method += (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
|
||||
if (methodIndex == NMethodType::kLZMA)
|
||||
{
|
||||
method += L":";
|
||||
method += GetStringForSizeValue(_archive.IsSolid ? _archive.DictionarySize: item.DictionarySize);
|
||||
}
|
||||
propVariant = method;
|
||||
break;
|
||||
}
|
||||
case kpidSolid:
|
||||
propVariant = _archive.IsSolid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
bool testMode = (_aTestMode != 0);
|
||||
bool allFilesMode = (numItems == UInt32(-1));
|
||||
if (allFilesMode)
|
||||
GetNumberOfItems(&numItems);
|
||||
if(numItems == 0)
|
||||
return S_OK;
|
||||
UInt64 totalSize = 0;
|
||||
|
||||
UInt32 i;
|
||||
for(i = 0; i < numItems; i++)
|
||||
{
|
||||
UInt32 index = (allFilesMode ? i : indices[i]);
|
||||
if (index >= (UInt32)_archive.Items.Size())
|
||||
totalSize += _archive.Script.Length();
|
||||
else
|
||||
{
|
||||
UInt32 size;
|
||||
if (_archive.IsSolid)
|
||||
{
|
||||
GetUncompressedSize(index, size);
|
||||
UInt64 pos = _archive.GetPosOfSolidItem(index);
|
||||
if (pos > totalSize)
|
||||
totalSize = pos + size;
|
||||
}
|
||||
else
|
||||
{
|
||||
GetCompressedSize(index, size);
|
||||
totalSize += size;
|
||||
}
|
||||
}
|
||||
}
|
||||
extractCallback->SetTotal(totalSize);
|
||||
|
||||
UInt64 currentTotalSize = 0;
|
||||
UInt32 currentItemSize = 0;
|
||||
|
||||
UInt64 streamPos = 0;
|
||||
if (_archive.IsSolid)
|
||||
{
|
||||
RINOK(_inStream->Seek(_archive.StreamOffset, STREAM_SEEK_SET, NULL));
|
||||
bool useFilter;
|
||||
RINOK(_archive.Decoder.Init(_inStream, _archive.Method, _archive.FilterFlag, useFilter));
|
||||
}
|
||||
|
||||
bool dataError = false;
|
||||
for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
|
||||
{
|
||||
currentItemSize = 0;
|
||||
RINOK(extractCallback->SetCompleted(¤tTotalSize));
|
||||
CMyComPtr<ISequentialOutStream> realOutStream;
|
||||
Int32 askMode;
|
||||
askMode = testMode ? NArchive::NExtract::NAskMode::kTest : NArchive::NExtract::NAskMode::kExtract;
|
||||
UInt32 index = allFilesMode ? i : indices[i];
|
||||
|
||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
|
||||
|
||||
if (index >= (UInt32)_archive.Items.Size())
|
||||
{
|
||||
currentItemSize = _archive.Script.Length();
|
||||
if(!testMode && (!realOutStream))
|
||||
continue;
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
if (!testMode)
|
||||
RINOK(realOutStream->Write((const char *)_archive.Script, (UInt32)_archive.Script.Length(), NULL));
|
||||
}
|
||||
else
|
||||
{
|
||||
const CItem &item = _archive.Items[index];
|
||||
|
||||
if (_archive.IsSolid)
|
||||
GetUncompressedSize(index, currentItemSize);
|
||||
else
|
||||
GetCompressedSize(index, currentItemSize);
|
||||
|
||||
if(!testMode && (!realOutStream))
|
||||
continue;
|
||||
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
|
||||
if (!dataError)
|
||||
{
|
||||
bool needDecompress = false;
|
||||
bool sizeIsKnown = false;
|
||||
UInt32 fullSize = 0;
|
||||
|
||||
const UInt32 kBufferLength = 1 << 11;
|
||||
Byte buffer[kBufferLength];
|
||||
|
||||
if (_archive.IsSolid)
|
||||
{
|
||||
UInt64 pos = _archive.GetPosOfSolidItem(index);
|
||||
while(streamPos < pos)
|
||||
{
|
||||
UInt32 curSize = (UInt32)MyMin(pos - streamPos, (UInt64)kBufferLength);
|
||||
UInt32 processedSize;
|
||||
HRESULT res = _archive.Decoder.Read(buffer, curSize, &processedSize);
|
||||
if (res != S_OK)
|
||||
{
|
||||
if (res != S_FALSE)
|
||||
return res;
|
||||
dataError = true;
|
||||
break;
|
||||
}
|
||||
if (processedSize == 0)
|
||||
{
|
||||
dataError = true;
|
||||
break;
|
||||
}
|
||||
streamPos += processedSize;
|
||||
}
|
||||
if (streamPos == pos)
|
||||
{
|
||||
UInt32 processedSize;
|
||||
RINOK(_archive.Decoder.Read(buffer, 4, &processedSize));
|
||||
if (processedSize != 4)
|
||||
return E_FAIL;
|
||||
streamPos += processedSize;
|
||||
fullSize = GetUInt32FromMemLE(buffer);
|
||||
sizeIsKnown = true;
|
||||
needDecompress = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(_inStream->Seek(_archive.GetPosOfNonSolidItem(index) + 4, STREAM_SEEK_SET, NULL));
|
||||
if (item.IsCompressed)
|
||||
{
|
||||
needDecompress = true;
|
||||
bool useFilter;
|
||||
RINOK(_archive.Decoder.Init(_inStream, _archive.Method, _archive.FilterFlag, useFilter));
|
||||
fullSize = GetUInt32FromMemLE(buffer);
|
||||
}
|
||||
else
|
||||
fullSize = item.Size;
|
||||
}
|
||||
if (!dataError)
|
||||
{
|
||||
if (needDecompress)
|
||||
{
|
||||
UInt64 offset = 0;
|
||||
while(!sizeIsKnown || fullSize > 0)
|
||||
{
|
||||
UInt32 curSize = kBufferLength;
|
||||
if (sizeIsKnown && curSize > fullSize)
|
||||
curSize = fullSize;
|
||||
UInt32 processedSize;
|
||||
HRESULT res = _archive.Decoder.Read(buffer, curSize, &processedSize);
|
||||
if (res != S_OK)
|
||||
{
|
||||
if (res != S_FALSE)
|
||||
return res;
|
||||
dataError = true;
|
||||
break;
|
||||
}
|
||||
if (processedSize == 0)
|
||||
{
|
||||
if (sizeIsKnown)
|
||||
dataError = true;
|
||||
break;
|
||||
}
|
||||
|
||||
fullSize -= processedSize;
|
||||
streamPos += processedSize;
|
||||
offset += processedSize;
|
||||
|
||||
UInt64 completed;
|
||||
if (_archive.IsSolid)
|
||||
completed = streamPos;
|
||||
else
|
||||
completed = currentTotalSize + offset;
|
||||
RINOK(extractCallback->SetCompleted(&completed));
|
||||
if (!testMode)
|
||||
RINOK(realOutStream->Write(buffer, processedSize, NULL));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(fullSize > 0)
|
||||
{
|
||||
UInt32 curSize = MyMin(fullSize, kBufferLength);
|
||||
UInt32 processedSize;
|
||||
RINOK(_inStream->Read(buffer, curSize, &processedSize));
|
||||
if (processedSize == 0)
|
||||
{
|
||||
dataError = true;
|
||||
break;
|
||||
}
|
||||
fullSize -= processedSize;
|
||||
streamPos += processedSize;
|
||||
if (!testMode)
|
||||
RINOK(realOutStream->Write(buffer, processedSize, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!testMode)
|
||||
realOutStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(dataError ?
|
||||
NArchive::NExtract::NOperationResult::kDataError :
|
||||
NArchive::NExtract::NOperationResult::kOK));
|
||||
}
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
}}
|
||||
41
7zip/Archive/Nsis/NsisHandler.h
Executable file
41
7zip/Archive/Nsis/NsisHandler.h
Executable file
@@ -0,0 +1,41 @@
|
||||
// NSisHandler.h
|
||||
|
||||
#ifndef __NSIS_HANDLER_H
|
||||
#define __NSIS_HANDLER_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "../IArchive.h"
|
||||
|
||||
#include "NsisIn.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
class CHandler:
|
||||
public IInArchive,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CMyComPtr<IInStream> _inStream;
|
||||
CInArchive _archive;
|
||||
|
||||
bool GetUncompressedSize(int index, UInt32 &size);
|
||||
bool GetCompressedSize(int index, UInt32 &size);
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
1145
7zip/Archive/Nsis/NsisIn.cpp
Executable file
1145
7zip/Archive/Nsis/NsisIn.cpp
Executable file
File diff suppressed because it is too large
Load Diff
162
7zip/Archive/Nsis/NsisIn.h
Executable file
162
7zip/Archive/Nsis/NsisIn.h
Executable file
@@ -0,0 +1,162 @@
|
||||
// Archive/NsisIn.h
|
||||
|
||||
#ifndef __ARCHIVE_ISO_IN_H
|
||||
#define __ARCHIVE_ISO_IN_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/Buffer.h"
|
||||
|
||||
#include "../../IStream.h"
|
||||
|
||||
#include "NsisDecode.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
const int kSignatureSize = 16;
|
||||
extern Byte kSignature[kSignatureSize];
|
||||
|
||||
const UInt32 kFlagsMask = 0xF;
|
||||
namespace NFlags
|
||||
{
|
||||
const UInt32 kUninstall = 1;
|
||||
const UInt32 kSilent = 2;
|
||||
const UInt32 kNoCrc = 4;
|
||||
const UInt32 kForceCrc = 8;
|
||||
}
|
||||
|
||||
struct CFirstHeader
|
||||
{
|
||||
UInt32 Flags;
|
||||
UInt32 HeaderLength;
|
||||
|
||||
UInt32 ArchiveSize;
|
||||
|
||||
bool ThereIsCrc() const
|
||||
{
|
||||
if ((Flags & NFlags::kForceCrc ) != 0)
|
||||
return true;
|
||||
return ((Flags & NFlags::kNoCrc) == 0);
|
||||
}
|
||||
|
||||
UInt32 GetDataSize() const { return ArchiveSize - (ThereIsCrc() ? 4 : 0); }
|
||||
};
|
||||
|
||||
|
||||
struct CBlockHeader
|
||||
{
|
||||
UInt32 Offset;
|
||||
UInt32 Num;
|
||||
};
|
||||
|
||||
struct CItem
|
||||
{
|
||||
AString Prefix;
|
||||
AString Name;
|
||||
UInt32 Pos;
|
||||
bool SizeIsDefined;
|
||||
bool CompressedSizeIsDefined;
|
||||
bool EstimatedSizeIsDefined;
|
||||
UInt32 Size;
|
||||
UInt32 CompressedSize;
|
||||
UInt32 EstimatedSize;
|
||||
FILETIME DateTime;
|
||||
UInt32 DictionarySize;
|
||||
bool IsCompressed;
|
||||
bool UseFilter;
|
||||
CItem(): UseFilter(false), SizeIsDefined(false), EstimatedSizeIsDefined(false),
|
||||
IsCompressed(true), CompressedSizeIsDefined(false), Size(0) {}
|
||||
|
||||
bool IsINSTDIR() const
|
||||
{
|
||||
if (Prefix.Length() < 3)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
AString GetReducedName() const
|
||||
{
|
||||
AString prefix = Prefix;
|
||||
if (prefix.Length() > 0)
|
||||
if (prefix[prefix.Length() - 1] != '\\')
|
||||
prefix += '\\';
|
||||
AString s2 = prefix + Name;
|
||||
const int len = 9;
|
||||
if (s2.Left(len).CompareNoCase("$INSTDIR\\") == 0)
|
||||
s2 = s2.Mid(len);
|
||||
return s2;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CInArchive
|
||||
{
|
||||
UInt64 _archiveSize;
|
||||
CMyComPtr<IInStream> _stream;
|
||||
|
||||
Byte ReadByte();
|
||||
UInt32 ReadUInt32();
|
||||
HRESULT Open2();
|
||||
void ReadBlockHeader(CBlockHeader &bh);
|
||||
AString ReadString(UInt32 pos);
|
||||
AString ReadString2(UInt32 pos);
|
||||
HRESULT ReadEntries(const CBlockHeader &bh);
|
||||
HRESULT Parse();
|
||||
|
||||
CByteBuffer _data;
|
||||
UInt64 _size;
|
||||
|
||||
size_t _posInData;
|
||||
|
||||
UInt32 _stringsPos;
|
||||
|
||||
|
||||
bool _headerIsCompressed;
|
||||
UInt32 _nonSolidStartOffset;
|
||||
public:
|
||||
HRESULT Open(IInStream *inStream, const UInt64 *maxCheckStartPosition);
|
||||
void Clear();
|
||||
|
||||
UInt64 StreamOffset;
|
||||
CDecoder Decoder;
|
||||
CObjectVector<CItem> Items;
|
||||
bool IsSolid;
|
||||
CFirstHeader FirstHeader;
|
||||
NMethodType::EEnum Method;
|
||||
bool UseFilter;
|
||||
UInt32 DictionarySize;
|
||||
bool FilterFlag;
|
||||
|
||||
AString Script;
|
||||
UInt32 GetOffset() const { return IsSolid ? 4 : 0; }
|
||||
UInt64 GetDataPos(int index)
|
||||
{
|
||||
const CItem &item = Items[index];
|
||||
return GetOffset() + FirstHeader.HeaderLength + item.Pos;
|
||||
}
|
||||
|
||||
UInt64 GetPosOfSolidItem(int index) const
|
||||
{
|
||||
const CItem &item = Items[index];
|
||||
return 4 + FirstHeader.HeaderLength + item.Pos;
|
||||
}
|
||||
|
||||
UInt64 GetPosOfNonSolidItem(int index) const
|
||||
{
|
||||
const CItem &item = Items[index];
|
||||
return StreamOffset + _nonSolidStartOffset + 4 + item.Pos;
|
||||
}
|
||||
|
||||
void Release()
|
||||
{
|
||||
Decoder.Release();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
UInt32 GetUInt32FromMemLE(const Byte *p);
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
3
7zip/Archive/Nsis/StdAfx.cpp
Executable file
3
7zip/Archive/Nsis/StdAfx.cpp
Executable file
@@ -0,0 +1,3 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
9
7zip/Archive/Nsis/StdAfx.h
Executable file
9
7zip/Archive/Nsis/StdAfx.h
Executable file
@@ -0,0 +1,9 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
#include "../../../Common/NewHandler.h"
|
||||
|
||||
#endif
|
||||
67
7zip/Archive/Nsis/makefile
Executable file
67
7zip/Archive/Nsis/makefile
Executable file
@@ -0,0 +1,67 @@
|
||||
PROG = nsis.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
TAR_OBJS = \
|
||||
$O\DllExports.obj \
|
||||
$O\NsisDecode.obj \
|
||||
$O\NsisHandler.obj \
|
||||
$O\NsisIn.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\IntToString.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\String.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\Vector.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\DLL.obj \
|
||||
$O\FileFind.obj \
|
||||
$O\PropVariant.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\LimitedStreams.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CodecsPath.obj \
|
||||
$O\CoderLoader.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\FilterCoder.obj \
|
||||
|
||||
7Z_OBJS = \
|
||||
$O\7zMethodID.obj \
|
||||
$O\7zMethods.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(TAR_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(AR_COMMON_OBJS) \
|
||||
$(7Z_OBJS) \
|
||||
$(COMPRESS_TAR_OBJS) \
|
||||
$O\CopyCoder.obj \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
$(TAR_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(WIN_OBJS): ../../../Windows/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(AR_COMMON_OBJS): ../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7Z_OBJS): ../7z/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(COMPL)
|
||||
3
7zip/Archive/Nsis/resource.rc
Executable file
3
7zip/Archive/Nsis/resource.rc
Executable file
@@ -0,0 +1,3 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("Nsis Plugin", "nsis")
|
||||
@@ -149,7 +149,6 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
Close();
|
||||
if (openArchiveCallback == 0)
|
||||
return S_FALSE;
|
||||
bool mustBeClosed = true;
|
||||
// try
|
||||
{
|
||||
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
|
||||
|
||||
@@ -77,7 +77,6 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
IArchiveOpenCallback *openArchiveCallback)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
bool mustBeClosed = true;
|
||||
// try
|
||||
{
|
||||
CInArchive archive;
|
||||
|
||||
@@ -140,7 +140,6 @@ HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
|
||||
cur += 8;
|
||||
|
||||
item.LinkFlag = *cur++;
|
||||
Byte linkFlag = item.LinkFlag;
|
||||
|
||||
ReadString(cur, NFileHeader::kNameSize, item.LinkName);
|
||||
cur += NFileHeader::kNameSize;
|
||||
|
||||
@@ -66,7 +66,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
updateItem.NewData = IntToBool(newData);
|
||||
updateItem.IndexInArchive = indexInArchive;
|
||||
updateItem.IndexInClient = i;
|
||||
bool existInArchive = (indexInArchive != UInt32(-1));
|
||||
// bool existInArchive = (indexInArchive != UInt32(-1));
|
||||
if (IntToBool(newProperties))
|
||||
{
|
||||
FILETIME utcFileTime;
|
||||
|
||||
@@ -9,6 +9,7 @@ DIRS = \
|
||||
GZip\~ \
|
||||
Iso\~ \
|
||||
Lzh\~ \
|
||||
Nsis\~ \
|
||||
Rar\~ \
|
||||
RPM\~ \
|
||||
Split\~ \
|
||||
|
||||
Reference in New Issue
Block a user