This commit is contained in:
Igor Pavlov
2009-02-03 00:00:00 +00:00
committed by Kornel Lesiński
parent 1dc92281fa
commit 8874e4fbc9
34 changed files with 216 additions and 148 deletions

View File

@@ -1,7 +1,7 @@
#define MY_VER_MAJOR 4 #define MY_VER_MAJOR 4
#define MY_VER_MINOR 64 #define MY_VER_MINOR 65
#define MY_VER_BUILD 0 #define MY_VER_BUILD 0
#define MY_VERSION "4.64" #define MY_VERSION "4.65"
#define MY_DATE "2009-01-03" #define MY_DATE "2009-02-03"
#define MY_COPYRIGHT ": Igor Pavlov : Public domain" #define MY_COPYRIGHT ": Igor Pavlov : Public domain"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE

View File

@@ -1,5 +1,5 @@
/* LzmaEnc.c -- LZMA Encoder /* LzmaEnc.c -- LZMA Encoder
2008-10-04 : Igor Pavlov : Public domain */ 2009-02-02 : Igor Pavlov : Public domain */
#include <string.h> #include <string.h>
@@ -64,7 +64,13 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p)
if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1); if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1);
if (p->numHashBytes < 0) p->numHashBytes = 4; if (p->numHashBytes < 0) p->numHashBytes = 4;
if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1); if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1);
if (p->numThreads < 0) p->numThreads = ((p->btMode && p->algo) ? 2 : 1); if (p->numThreads < 0)
p->numThreads =
#ifdef COMPRESS_MF_MT
((p->btMode && p->algo) ? 2 : 1);
#else
1;
#endif
} }
UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2) UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)

View File

@@ -586,7 +586,7 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
if (number <= mainDicMethodIndex) if (number <= mainDicMethodIndex)
mainDicSize = dicSize; mainDicSize = dicSize;
} }
else if (realName.Left(1).CompareNoCase(L"B") == 0) else if (realName.Left(1).CompareNoCase(L"C") == 0)
{ {
UInt32 blockSize; UInt32 blockSize;
RINOK(ParsePropDictionaryValue(realName.Mid(1), value, blockSize)); RINOK(ParsePropDictionaryValue(realName.Mid(1), value, blockSize));

View File

@@ -198,7 +198,7 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
RINOK(GetNextItemReal(filled, item)); RINOK(GetNextItemReal(filled, item));
if (!filled) if (!filled)
return S_OK; return S_OK;
if (item.Name.CompareNoCase("debian-binary") != 0) if (item.Name.Compare("debian-binary") != 0)
return S_OK; return S_OK;
if (item.Size != 4) if (item.Size != 4)
return S_OK; return S_OK;

View File

@@ -308,11 +308,9 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
static AString GetName(const char *name) static AString GetName(const char *name)
{ {
AString res; char res[kNameSize + 1];
char *p = res.GetBuffer(kNameSize); memcpy(res, name, kNameSize);
strncpy(p, name, kNameSize); res[kNameSize] = 0;
p[kNameSize] = 0;
res.ReleaseBuffer();
return res; return res;
} }

View File

@@ -2,19 +2,19 @@
#include "StdAfx.h" #include "StdAfx.h"
#include "NsisHandler.h" #include "../../../../C/CpuArch.h"
#include "Common/StringConvert.h" #include "Common/ComTry.h"
#include "Common/IntToString.h" #include "Common/IntToString.h"
#include "Common/NewHandler.h" #include "Common/NewHandler.h"
#include "Common/ComTry.h"
#include "Windows/PropVariant.h" #include "Windows/PropVariant.h"
#include "../Common/ItemNameUtils.h"
#include "../../Common/StreamUtils.h" #include "../../Common/StreamUtils.h"
#include "../../../../C/CpuArch.h" #include "../Common/ItemNameUtils.h"
#include "NsisHandler.h"
#define Get32(p) GetUi32(p) #define Get32(p) GetUi32(p)
@@ -228,12 +228,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
{ {
case kpidPath: case kpidPath:
{ {
UString s; UString s = NItemName::WinNameToOSName(item.GetReducedName(_archive.IsUnicode));
if (_archive.IsUnicode)
s = item.GetReducedNameU();
else
s = MultiByteToUnicodeString(item.GetReducedNameA(), CP_ACP);
s = NItemName::WinNameToOSName(s);
if (!s.IsEmpty()) if (!s.IsEmpty())
prop = (const wchar_t *)s; prop = (const wchar_t *)s;
break; break;
@@ -320,6 +315,11 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
_inStream, _archive.Method, _archive.FilterFlag, useFilter)); _inStream, _archive.Method, _archive.FilterFlag, useFilter));
} }
CByteBuffer byteBuf;
const UInt32 kBufferLength = 1 << 16;
byteBuf.SetCapacity(kBufferLength);
Byte *buffer = byteBuf;
bool dataError = false; bool dataError = false;
for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize) for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
{ {
@@ -363,9 +363,6 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
bool sizeIsKnown = false; bool sizeIsKnown = false;
UInt32 fullSize = 0; UInt32 fullSize = 0;
const UInt32 kBufferLength = 1 << 11;
Byte buffer[kBufferLength];
if (_archive.IsSolid) if (_archive.IsSolid)
{ {
UInt64 pos = _archive.GetPosOfSolidItem(index); UInt64 pos = _archive.GetPosOfSolidItem(index);
@@ -389,12 +386,13 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
} }
if (streamPos == pos) if (streamPos == pos)
{ {
Byte buffer2[4];
size_t processedSize = 4; size_t processedSize = 4;
RINOK(_archive.Decoder.Read(buffer, &processedSize)); RINOK(_archive.Decoder.Read(buffer2, &processedSize));
if (processedSize != 4) if (processedSize != 4)
return E_FAIL; return E_FAIL;
streamPos += processedSize; streamPos += processedSize;
fullSize = Get32(buffer); fullSize = Get32(buffer2);
sizeIsKnown = true; sizeIsKnown = true;
needDecompress = true; needDecompress = true;
} }
@@ -409,7 +407,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(_archive.Decoder.Init( RINOK(_archive.Decoder.Init(
EXTERNAL_CODECS_VARS EXTERNAL_CODECS_VARS
_inStream, _archive.Method, _archive.FilterFlag, useFilter)); _inStream, _archive.Method, _archive.FilterFlag, useFilter));
fullSize = Get32(buffer); // fullSize = Get32(buffer); // It's bug !!!
// Test it: what is exact fullSize?
fullSize = 0xFFFFFFFF;
} }
else else
fullSize = item.Size; fullSize = item.Size;

View File

@@ -3,16 +3,17 @@
#ifndef __ARCHIVE_NSIS_IN_H #ifndef __ARCHIVE_NSIS_IN_H
#define __ARCHIVE_NSIS_IN_H #define __ARCHIVE_NSIS_IN_H
#include "Common/MyCom.h"
#include "Common/IntToString.h"
#include "Common/Buffer.h" #include "Common/Buffer.h"
#include "Common/IntToString.h"
#include "Common/MyCom.h"
#include "Common/StringConvert.h"
#include "../../Common/CreateCoder.h"
#include "../../IStream.h" #include "../../IStream.h"
#include "NsisDecode.h" #include "NsisDecode.h"
#include "../../Common/CreateCoder.h"
// #define NSIS_SCRIPT // #define NSIS_SCRIPT
namespace NArchive { namespace NArchive {
@@ -81,32 +82,25 @@ struct CItem
return (PrefixA.Length() >= 3 || PrefixU.Length() >= 3); return (PrefixA.Length() >= 3 || PrefixU.Length() >= 3);
} }
AString GetReducedNameA() const UString GetReducedName(bool unicode) const
{ {
AString prefix = PrefixA; UString s;
if (prefix.Length() > 0) if (unicode)
if (prefix[prefix.Length() - 1] != '\\') s = PrefixU;
prefix += '\\'; else
AString s2 = prefix + NameA; s = MultiByteToUnicodeString(PrefixA);
if (s.Length() > 0)
if (s[s.Length() - 1] != L'\\')
s += L'\\';
if (unicode)
s += NameU;
else
s += MultiByteToUnicodeString(NameA);
const int len = 9; const int len = 9;
if (s2.Left(len).CompareNoCase("$INSTDIR\\") == 0) if (s.Left(len).CompareNoCase(L"$INSTDIR\\") == 0)
s2 = s2.Mid(len); s = s.Mid(len);
return s2; return s;
} }
UString GetReducedNameU() const
{
UString prefix = PrefixU;
if (prefix.Length() > 0)
if (prefix[prefix.Length() - 1] != L'\\')
prefix += L'\\';
UString s2 = prefix + NameU;
const int len = 9;
if (s2.Left(len).CompareNoCase(L"$INSTDIR\\") == 0)
s2 = s2.Mid(len);
return s2;
}
}; };
class CInArchive class CInArchive

View File

@@ -55,6 +55,7 @@ private:
UInt32 m_NumMatchFinderCycles; UInt32 m_NumMatchFinderCycles;
bool m_NumMatchFinderCyclesDefined; bool m_NumMatchFinderCyclesDefined;
bool m_ForceAesMode;
bool m_IsAesMode; bool m_IsAesMode;
Byte m_AesKeyMode; Byte m_AesKeyMode;
@@ -78,6 +79,7 @@ private:
m_NumFastBytes = m_NumFastBytes =
m_NumMatchFinderCycles = 0xFFFFFFFF; m_NumMatchFinderCycles = 0xFFFFFFFF;
m_NumMatchFinderCyclesDefined = false; m_NumMatchFinderCyclesDefined = false;
m_ForceAesMode = false;
m_IsAesMode = false; m_IsAesMode = false;
m_AesKeyMode = 3; // aes-256 m_AesKeyMode = 3; // aes-256
m_WriteNtfsTimeExtra = false; m_WriteNtfsTimeExtra = false;

View File

@@ -98,6 +98,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
{ {
COM_TRY_BEGIN2 COM_TRY_BEGIN2
CObjectVector<CUpdateItem> updateItems; CObjectVector<CUpdateItem> updateItems;
bool thereAreAesUpdates = false;
for (UInt32 i = 0; i < numItems; i++) for (UInt32 i = 0; i < numItems; i++)
{ {
CUpdateItem ui; CUpdateItem ui;
@@ -111,7 +112,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
ui.NewData = IntToBool(newData); ui.NewData = IntToBool(newData);
ui.IndexInArchive = indexInArchive; ui.IndexInArchive = indexInArchive;
ui.IndexInClient = i; ui.IndexInClient = i;
// bool existInArchive = (indexInArchive != UInt32(-1)); bool existInArchive = (indexInArchive != UInt32(-1));
if (existInArchive && newData)
if (m_Items[indexInArchive].IsAesEncrypted())
thereAreAesUpdates = true;
if (IntToBool(newProperties)) if (IntToBool(newProperties))
{ {
UString name; UString name;
@@ -237,7 +242,6 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
} }
CMyComPtr<ICryptoGetTextPassword2> getTextPassword; CMyComPtr<ICryptoGetTextPassword2> getTextPassword;
if (!getTextPassword)
{ {
CMyComPtr<IArchiveUpdateCallback> udateCallBack2(callback); CMyComPtr<IArchiveUpdateCallback> udateCallBack2(callback);
udateCallBack2.QueryInterface(IID_ICryptoGetTextPassword2, &getTextPassword); udateCallBack2.QueryInterface(IID_ICryptoGetTextPassword2, &getTextPassword);
@@ -252,16 +256,17 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
options.PasswordIsDefined = IntToBool(passwordIsDefined); options.PasswordIsDefined = IntToBool(passwordIsDefined);
if (options.PasswordIsDefined) if (options.PasswordIsDefined)
{ {
options.IsAesMode = (m_ForceAesMode ? m_IsAesMode : thereAreAesUpdates);
options.AesKeyMode = m_AesKeyMode;
if (!IsAsciiString((const wchar_t *)password)) if (!IsAsciiString((const wchar_t *)password))
return E_INVALIDARG; return E_INVALIDARG;
if (m_IsAesMode) if (options.IsAesMode)
{ {
if (options.Password.Length() > NCrypto::NWzAes::kPasswordSizeMax) if (options.Password.Length() > NCrypto::NWzAes::kPasswordSizeMax)
return E_INVALIDARG; return E_INVALIDARG;
} }
options.Password = UnicodeStringToMultiByte((const wchar_t *)password, CP_OEMCP); options.Password = UnicodeStringToMultiByte((const wchar_t *)password, CP_OEMCP);
options.IsAesMode = m_IsAesMode;
options.AesKeyMode = m_AesKeyMode;
} }
} }
else else
@@ -422,9 +427,13 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
else else
return E_INVALIDARG; return E_INVALIDARG;
m_IsAesMode = true; m_IsAesMode = true;
m_ForceAesMode = true;
} }
else if (valueString == L"ZIPCRYPTO") else if (valueString == L"ZIPCRYPTO")
{
m_IsAesMode = false; m_IsAesMode = false;
m_ForceAesMode = true;
}
else else
return E_INVALIDARG; return E_INVALIDARG;
} }

View File

@@ -187,6 +187,7 @@ public:
bool IsEncrypted() const { return (Flags & NFileHeader::NFlags::kEncrypted) != 0; } bool IsEncrypted() const { return (Flags & NFileHeader::NFlags::kEncrypted) != 0; }
bool IsStrongEncrypted() const { return IsEncrypted() && (Flags & NFileHeader::NFlags::kStrongEncrypted) != 0; }; bool IsStrongEncrypted() const { return IsEncrypted() && (Flags & NFileHeader::NFlags::kStrongEncrypted) != 0; };
bool IsAesEncrypted() const { return IsEncrypted() && (IsStrongEncrypted() || CompressionMethod == NFileHeader::NCompressionMethod::kWzAES); };
bool IsLzmaEOS() const { return (Flags & NFileHeader::NFlags::kLzmaEOS) != 0; } bool IsLzmaEOS() const { return (Flags & NFileHeader::NFlags::kLzmaEOS) != 0; }

View File

@@ -1,8 +1,8 @@
#define MY_VER_MAJOR 4 #define MY_VER_MAJOR 4
#define MY_VER_MINOR 64 #define MY_VER_MINOR 65
#define MY_VER_BUILD 0 #define MY_VER_BUILD 0
#define MY_VERSION "4.64" #define MY_VERSION "4.65"
#define MY_7ZIP_VERSION "7-Zip 4.64" #define MY_7ZIP_VERSION "7-Zip 4.65"
#define MY_DATE "2009-01-03" #define MY_DATE "2009-02-03"
#define MY_COPYRIGHT "Copyright (c) 1999-2009 Igor Pavlov" #define MY_COPYRIGHT "Copyright (c) 1999-2009 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE

View File

@@ -2,23 +2,25 @@
#include "StdAfx.h" #include "StdAfx.h"
#include "Common/IntToString.h"
#include "Common/MyInitGuid.h" #include "Common/MyInitGuid.h"
#include "Common/StringConvert.h" #include "Common/StringConvert.h"
#include "Common/IntToString.h"
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
#include "Windows/DLL.h" #include "Windows/DLL.h"
#include "Windows/FileDir.h" #include "Windows/FileDir.h"
#include "Windows/FileName.h"
#include "Windows/FileFind.h" #include "Windows/FileFind.h"
#include "Windows/FileName.h"
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
#include "../../Common/FileStreams.h" #include "../../Common/FileStreams.h"
#include "../../Archive/IArchive.h" #include "../../Archive/IArchive.h"
#include "../../IPassword.h" #include "../../IPassword.h"
#include "../../MyVersion.h" #include "../../MyVersion.h"
// use another CLSIDs, if you want to support other formats (zip, rar, ...).
// {23170F69-40C1-278A-1000-000110070000} // {23170F69-40C1-278A-1000-000110070000}
DEFINE_GUID(CLSID_CFormat7z, DEFINE_GUID(CLSID_CFormat7z,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00); 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00);
@@ -687,8 +689,9 @@ int MY_CDECL main(int argc, char* argv[])
} }
AString command = argv[1]; AString command = argv[1];
command.MakeLower();
UString archiveName = GetUnicodeString(argv[2], CP_OEMCP); UString archiveName = GetUnicodeString(argv[2], CP_OEMCP);
if (command.CompareNoCase("a") == 0) if (command.Compare("a") == 0)
{ {
// create archive command // create archive command
if (argc < 4) if (argc < 4)
@@ -764,9 +767,9 @@ int MY_CDECL main(int argc, char* argv[])
} }
bool listCommand; bool listCommand;
if (command.CompareNoCase("l") == 0) if (command.Compare("l") == 0)
listCommand = true; listCommand = true;
else if (command.CompareNoCase("x") == 0) else if (command.Compare("x") == 0)
listCommand = false; listCommand = false;
else else
{ {

View File

@@ -531,8 +531,11 @@ HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
CArcItem ai; CArcItem ai;
RINOK(GetArchiveItemPath(archive, i, ai.Name)); RINOK(GetArchiveItemPath(archive, i, ai.Name));
// check it: defaultItemName !!!
if (ai.Name.IsEmpty())
ai.Name = defaultItemName;
RINOK(IsArchiveItemFolder(archive, i, ai.IsDir)); RINOK(IsArchiveItemFolder(archive, i, ai.IsDir));
ai.Censored = censor.CheckPath(ai.Name.IsEmpty() ? defaultItemName : ai.Name, !ai.IsDir); ai.Censored = censor.CheckPath(ai.Name, !ai.IsDir);
RINOK(GetArchiveItemFileTime(archive, i, archiveFileInfo.MTime, ai.MTime)); RINOK(GetArchiveItemFileTime(archive, i, archiveFileInfo.MTime, ai.MTime));
{ {

View File

@@ -77,7 +77,7 @@ STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
case NUserAnswerMode::kNoAll: *answer = NOverwriteAnswer::kNoToAll; break; case NUserAnswerMode::kNoAll: *answer = NOverwriteAnswer::kNoToAll; break;
case NUserAnswerMode::kYesAll: *answer = NOverwriteAnswer::kYesToAll; break; case NUserAnswerMode::kYesAll: *answer = NOverwriteAnswer::kYesToAll; break;
case NUserAnswerMode::kYes: *answer = NOverwriteAnswer::kYes; break; case NUserAnswerMode::kYes: *answer = NOverwriteAnswer::kYes; break;
case NUserAnswerMode::kAutoRename: *answer = NOverwriteAnswer::kAutoRename; break; case NUserAnswerMode::kAutoRenameAll: *answer = NOverwriteAnswer::kAutoRename; break;
default: return E_FAIL; default: return E_FAIL;
} }
return S_OK; return S_OK;

View File

@@ -11,16 +11,14 @@ static const char kYes = 'Y';
static const char kNo = 'N'; static const char kNo = 'N';
static const char kYesAll = 'A'; static const char kYesAll = 'A';
static const char kNoAll = 'S'; static const char kNoAll = 'S';
static const char kAutoRename = 'U'; static const char kAutoRenameAll = 'U';
static const char kQuit = 'Q'; static const char kQuit = 'Q';
static const char *kFirstQuestionMessage = "?\n"; static const char *kFirstQuestionMessage = "?\n";
static const char *kHelpQuestionMessage = static const char *kHelpQuestionMessage =
"(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename / (Q)uit? "; "(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? ";
// return true if pressed Quite; // return true if pressed Quite;
// in: anAll
// out: anAll, anYes;
NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream) NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
{ {
@@ -41,8 +39,8 @@ NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
return NUserAnswerMode::kYesAll; return NUserAnswerMode::kYesAll;
case kNoAll: case kNoAll:
return NUserAnswerMode::kNoAll; return NUserAnswerMode::kNoAll;
case kAutoRename: case kAutoRenameAll:
return NUserAnswerMode::kAutoRename; return NUserAnswerMode::kAutoRenameAll;
case kQuit: case kQuit:
return NUserAnswerMode::kQuit; return NUserAnswerMode::kQuit;
} }

View File

@@ -13,7 +13,7 @@ enum EEnum
kNo, kNo,
kYesAll, kYesAll,
kNoAll, kNoAll,
kAutoRename, kAutoRenameAll,
kQuit kQuit
}; };
} }

View File

@@ -35,38 +35,27 @@ static CSysString GetFullContextMenuKeyName(const CSysString &keyName)
static CSysString GetFullDragDropMenuKeyName(const CSysString &keyName) static CSysString GetFullDragDropMenuKeyName(const CSysString &keyName)
{ return (keyName + kDragDropMenuKeyName); } { return (keyName + kDragDropMenuKeyName); }
static bool CheckContextMenuHandlerCommon(const CSysString &keyName) static bool CheckHandlerCommon(const CSysString &keyName)
{ {
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
CKey key; CKey key;
if (key.Open(HKEY_CLASSES_ROOT, GetFullContextMenuKeyName(keyName), KEY_READ) if (key.Open(HKEY_CLASSES_ROOT, keyName, KEY_READ) != ERROR_SUCCESS)
!= ERROR_SUCCESS)
return false; return false;
CSysString value; CSysString value;
if (key.QueryValue(NULL, value) != ERROR_SUCCESS) if (key.QueryValue(NULL, value) != ERROR_SUCCESS)
return false; return false;
return (value.CompareNoCase(kExtensionCLSID) == 0); value.MakeUpper();
} return (value.Compare(kExtensionCLSID) == 0);
static bool CheckDragDropMenuHandlerCommon(const CSysString &keyName)
{
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
CKey key;
if (key.Open(HKEY_CLASSES_ROOT, GetFullDragDropMenuKeyName(keyName), KEY_READ) != ERROR_SUCCESS)
return false;
CSysString value;
if (key.QueryValue(NULL, value) != ERROR_SUCCESS)
return false;
return (value.CompareNoCase(kExtensionCLSID) == 0);
} }
bool CheckContextMenuHandler() bool CheckContextMenuHandler()
{ {
return CheckContextMenuHandlerCommon(kRootKeyNameForFile) && return
// CheckContextMenuHandlerCommon(kRootKeyNameForFolder) && // CheckHandlerCommon(GetFullContextMenuKeyName(kRootKeyNameForFolder)) &&
CheckContextMenuHandlerCommon(kRootKeyNameForDirectory) && CheckHandlerCommon(GetFullContextMenuKeyName(kRootKeyNameForDirectory)) &&
CheckDragDropMenuHandlerCommon(kRootKeyNameForDirectory) && CheckHandlerCommon(GetFullContextMenuKeyName(kRootKeyNameForFile)) &&
CheckDragDropMenuHandlerCommon(kRootKeyNameForDrive); CheckHandlerCommon(GetFullDragDropMenuKeyName(kRootKeyNameForDirectory)) &&
CheckHandlerCommon(GetFullDragDropMenuKeyName(kRootKeyNameForDrive));
} }
static void DeleteContextMenuHandlerCommon(const CSysString &keyName) static void DeleteContextMenuHandlerCommon(const CSysString &keyName)

View File

@@ -151,7 +151,7 @@ static void CreateToolbar(
imageList.Create( imageList.Create(
LargeButtons ? 48: 24, LargeButtons ? 48: 24,
LargeButtons ? 36: 24, LargeButtons ? 36: 24,
ILC_MASK, 0, 0); ILC_MASK | ILC_COLOR32, 0, 0);
toolBar.SetImageList(0, imageList); toolBar.SetImageList(0, imageList);
} }

View File

@@ -657,6 +657,34 @@ SOURCE=..\..\..\..\C\Alloc.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\..\..\C\Sha256.c
!IF "$(CFG)" == "FM - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "FM - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU"
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "FM - Win32 DebugU"
# SUBTRACT CPP /YX /Yc /Yu
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Sha256.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Sort.c SOURCE=..\..\..\..\C\Sort.c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
# End Source File # End Source File

View File

@@ -2,30 +2,31 @@
#include "StdAfx.h" #include "StdAfx.h"
#include "resource.h"
extern "C" extern "C"
{ {
#include "../../../../C/Alloc.h" #include "../../../../C/Alloc.h"
#include "../../../../C/7zCrc.h" #include "../../../../C/7zCrc.h"
#include "../../../../C/Sha256.h"
} }
#include "Common/IntToString.h" #include "Common/IntToString.h"
#include "Common/StringConvert.h" #include "Common/StringConvert.h"
#include "Windows/FileIO.h" #include "Windows/Error.h"
#include "Windows/FileFind.h" #include "Windows/FileFind.h"
#include "Windows/FileIO.h"
#include "Windows/FileName.h" #include "Windows/FileName.h"
#include "Windows/Thread.h" #include "Windows/Thread.h"
#include "Windows/Error.h"
#include "ProgressDialog2.h"
#include "OverwriteDialogRes.h" #include "OverwriteDialogRes.h"
#include "ProgressDialog2.h"
#include "App.h" #include "App.h"
#include "FormatUtils.h" #include "FormatUtils.h"
#include "LangUtils.h" #include "LangUtils.h"
#include "resource.h"
using namespace NWindows; using namespace NWindows;
using namespace NFile; using namespace NFile;
using namespace NName; using namespace NName;
@@ -125,10 +126,12 @@ struct CThreadCrc
CDirEnumerator DirEnumerator; CDirEnumerator DirEnumerator;
UInt64 NumFilesScan;
UInt64 NumFiles; UInt64 NumFiles;
UInt64 NumFolders; UInt64 NumFolders;
UInt64 DataSize; UInt64 DataSize;
UInt32 DataCrcSum; UInt32 DataCrcSum;
Byte Sha256Sum[SHA256_DIGEST_SIZE];
UInt32 DataNameCrcSum; UInt32 DataNameCrcSum;
HRESULT Result; HRESULT Result;
@@ -139,7 +142,8 @@ struct CThreadCrc
void Process2() void Process2()
{ {
DataSize = NumFolders = NumFiles = DataCrcSum = DataNameCrcSum = 0; DataSize = NumFolders = NumFiles = NumFilesScan = DataCrcSum = DataNameCrcSum = 0;
memset(Sha256Sum, 0, SHA256_DIGEST_SIZE);
ProgressDialog->WaitCreating(); ProgressDialog->WaitCreating();
CMyBuffer bufferObject; CMyBuffer bufferObject;
@@ -172,14 +176,17 @@ struct CThreadCrc
if (!filled) if (!filled)
break; break;
if (!fileInfo.IsDir()) if (!fileInfo.IsDir())
{
totalSize += fileInfo.Size; totalSize += fileInfo.Size;
NumFilesScan++;
}
ProgressDialog->ProgressSynch.SetCurrentFileName(scanningStr + resPath); ProgressDialog->ProgressSynch.SetCurrentFileName(scanningStr + resPath);
ProgressDialog->ProgressSynch.SetProgress(totalSize, 0); ProgressDialog->ProgressSynch.SetProgress(totalSize, 0);
Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(0); Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(0);
if (Result != S_OK) if (Result != S_OK)
return; return;
} }
ProgressDialog->ProgressSynch.SetNumFilesTotal(NumFilesScan);
ProgressDialog->ProgressSynch.SetProgress(totalSize, 0); ProgressDialog->ProgressSynch.SetProgress(totalSize, 0);
DirEnumerator.Init(); DirEnumerator.Init();
@@ -199,6 +206,9 @@ struct CThreadCrc
break; break;
UInt32 crc = CRC_INIT_VAL; UInt32 crc = CRC_INIT_VAL;
CSha256 sha256;
Sha256_Init(&sha256);
if (fileInfo.IsDir()) if (fileInfo.IsDir())
NumFolders++; NumFolders++;
else else
@@ -211,8 +221,9 @@ struct CThreadCrc
ErrorPath = resPath; ErrorPath = resPath;
return; return;
} }
NumFiles++;
ProgressDialog->ProgressSynch.SetCurrentFileName(resPath); ProgressDialog->ProgressSynch.SetCurrentFileName(resPath);
ProgressDialog->ProgressSynch.SetNumFilesCur(NumFiles);
NumFiles++;
for (;;) for (;;)
{ {
UInt32 processedSize; UInt32 processedSize;
@@ -226,12 +237,17 @@ struct CThreadCrc
if (processedSize == 0) if (processedSize == 0)
break; break;
crc = CrcUpdate(crc, buffer, processedSize); crc = CrcUpdate(crc, buffer, processedSize);
if (NumFilesScan == 1)
Sha256_Update(&sha256, buffer, processedSize);
DataSize += processedSize; DataSize += processedSize;
Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize); Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize);
if (Result != S_OK) if (Result != S_OK)
return; return;
} }
DataCrcSum += CRC_GET_DIGEST(crc); DataCrcSum += CRC_GET_DIGEST(crc);
if (NumFilesScan == 1)
Sha256_Final(&sha256, Sha256Sum);
} }
for (int i = 0; i < resPath.Length(); i++) for (int i = 0; i < resPath.Length(); i++)
{ {
@@ -259,13 +275,22 @@ struct CThreadCrc
} }
}; };
static void ConvertByteToHex(unsigned value, wchar_t *s)
{
for (int i = 0; i < 2; i++)
{
unsigned t = value & 0xF;
value >>= 4;
s[1 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10)));
}
}
static void ConvertUInt32ToHex(UInt32 value, wchar_t *s) static void ConvertUInt32ToHex(UInt32 value, wchar_t *s)
{ {
for (int i = 0; i < 8; i++) for (int i = 6; i >= 0; i -= 2)
{ {
int t = value & 0xF; ConvertByteToHex(value & 0xFF, s + i);
value >>= 4; value >>= 8;
s[7 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10)));
} }
s[8] = L'\0'; s[8] = L'\0';
} }
@@ -360,6 +385,19 @@ void CApp::CalculateCrc()
s += L" "; s += L" ";
ConvertUInt32ToHex(combiner.DataNameCrcSum, sz); ConvertUInt32ToHex(combiner.DataNameCrcSum, sz);
s += sz; s += sz;
s += L"\n";
if (combiner.NumFiles == 1 && combiner.NumFilesScan == 1)
{
s += L"SHA-256: ";
for (int i = 0; i < SHA256_DIGEST_SIZE; i++)
{
wchar_t s2[4];
ConvertByteToHex(combiner.Sha256Sum[i], s2);
s2[2] = 0;
s += s2;
}
}
} }
srcPanel.MessageBoxInfo(s, LangString(IDS_CHECKSUM_INFORMATION, 0x03020720)); srcPanel.MessageBoxInfo(s, LangString(IDS_CHECKSUM_INFORMATION, 0x03020720));
} }

View File

@@ -126,7 +126,8 @@ static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconP
if (extKey.QueryValue(NULL, programNameValue) != ERROR_SUCCESS) if (extKey.QueryValue(NULL, programNameValue) != ERROR_SUCCESS)
return false; return false;
CSysString extProgramKeyName = GetExtProgramKeyName(extension); CSysString extProgramKeyName = GetExtProgramKeyName(extension);
if (programNameValue.CompareNoCase(extProgramKeyName) != 0) UString programNameValueU = GetUnicodeString(programNameValue);
if (programNameValueU.CompareNoCase(GetUnicodeString(extProgramKeyName)) != 0)
return false; return false;
CKey iconKey; CKey iconKey;
if (extKey.Open(HKEY_CLASSES_ROOT, extProgramKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS) if (extKey.Open(HKEY_CLASSES_ROOT, extProgramKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS)

View File

@@ -149,6 +149,7 @@ AGENT_OBJS = \
C_OBJS = \ C_OBJS = \
$O\Alloc.obj \ $O\Alloc.obj \
$O\Sha256.obj \
$O\Sort.obj \ $O\Sort.obj \
$O\Threads.obj \ $O\Threads.obj \

View File

@@ -73,7 +73,7 @@ using namespace NFile;
using namespace NName; using namespace NName;
using namespace NDirectory; using namespace NDirectory;
static const int kHistorySize = 8; static const int kHistorySize = 20;
static LPCWSTR kExeExt = L".exe"; static LPCWSTR kExeExt = L".exe";
static LPCWSTR k7zFormat = L"7z"; static LPCWSTR k7zFormat = L"7z";
@@ -1315,7 +1315,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemo
UInt64 size1 = (UInt64)hs * 4; UInt64 size1 = (UInt64)hs * 4;
size1 += (UInt64)dictionary * 11 / 2; size1 += (UInt64)dictionary * 11 / 2;
if (level >= 5) if (level >= 5)
size1 += dictionary * 4; size1 += (UInt64)dictionary * 4;
size1 += (2 << 20); size1 += (2 << 20);
UInt32 numThreads1 = 1; UInt32 numThreads1 = 1;

View File

@@ -2,12 +2,14 @@
#include "StdAfx.h" #include "StdAfx.h"
#ifdef _WIN32 #ifndef _WIN32
#include "StringConvert.h"
#else
#include <ctype.h> #include <ctype.h>
#endif #endif
#ifndef _UNICODE
#include "StringConvert.h"
#endif
#include "MyString.h" #include "MyString.h"
@@ -190,9 +192,9 @@ int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2)
} }
} }
#ifdef _WIN32 /*
int MyStringCompareNoCase(const char *s1, const char *s2) int MyStringCompareNoCase(const char *s1, const char *s2)
{ {
return MyStringCompareNoCase(MultiByteToUnicodeString(s1), MultiByteToUnicodeString(s2)); return MyStringCompareNoCase(MultiByteToUnicodeString(s1), MultiByteToUnicodeString(s2));
} }
#endif */

View File

@@ -100,10 +100,7 @@ int MyStringCollateNoCase(const wchar_t *s1, const wchar_t *s2);
int MyStringCompare(const char *s1, const char *s2); int MyStringCompare(const char *s1, const char *s2);
int MyStringCompare(const wchar_t *s1, const wchar_t *s2); int MyStringCompare(const wchar_t *s1, const wchar_t *s2);
#ifdef _WIN32 // int MyStringCompareNoCase(const char *s1, const char *s2);
int MyStringCompareNoCase(const char *s1, const char *s2);
#endif
int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2); int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2);
template <class T> template <class T>

View File

@@ -20,7 +20,7 @@ public:
{ SendMessage(TBM_SETTICFREQ, freq); } { SendMessage(TBM_SETTICFREQ, freq); }
int GetPos() int GetPos()
{ return SendMessage(TBM_GETPOS); } { return (int)SendMessage(TBM_GETPOS); }
}; };
}} }}

View File

@@ -1,12 +1,8 @@
// Windows/Security.h // Windows/Security.cpp
#include "StdAfx.h" #include "StdAfx.h"
#include "Windows/Security.h" #include "Security.h"
#include "Windows/Defs.h"
#include "Common/StringConvert.h"
#include "Defs.h"
namespace NWindows { namespace NWindows {
namespace NSecurity { namespace NSecurity {
@@ -105,6 +101,8 @@ static PSID GetSid(LPWSTR accountName)
return NULL; return NULL;
} }
#define MY__SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
bool AddLockMemoryPrivilege() bool AddLockMemoryPrivilege()
{ {
CPolicy policy; CPolicy policy;
@@ -123,8 +121,9 @@ bool AddLockMemoryPrivilege()
!= 0) != 0)
return false; return false;
LSA_UNICODE_STRING userRights; LSA_UNICODE_STRING userRights;
UString s = GetUnicodeString(SE_LOCK_MEMORY_NAME); wchar_t s[128];
SetLsaString((LPWSTR)(LPCWSTR)s, &userRights); wcscpy(s, MY__SE_LOCK_MEMORY_NAME);
SetLsaString(s, &userRights);
WCHAR userName[256 + 2]; WCHAR userName[256 + 2];
DWORD size = 256; DWORD size = 256;
if (!GetUserNameW(userName, &size)) if (!GetUserNameW(userName, &size))

View File

@@ -3,7 +3,7 @@
#ifndef __WINDOWS_SECURITY_H #ifndef __WINDOWS_SECURITY_H
#define __WINDOWS_SECURITY_H #define __WINDOWS_SECURITY_H
#include "Windows/Defs.h" #include "Defs.h"
#include <NTSecAPI.h> #include <NTSecAPI.h>

View File

@@ -25,6 +25,9 @@ public:
WRes Wait() { return Thread_Wait(&thread); } WRes Wait() { return Thread_Wait(&thread); }
#ifdef _WIN32 #ifdef _WIN32
operator HANDLE() { return thread.handle; }
void Attach(HANDLE handle) { thread.handle = handle; }
HANDLE Detach() { HANDLE h = thread.handle; thread.handle = NULL; return h; }
DWORD Resume() { return ::ResumeThread(thread.handle); } DWORD Resume() { return ::ResumeThread(thread.handle); }
DWORD Suspend() { return ::SuspendThread(thread.handle); } DWORD Suspend() { return ::SuspendThread(thread.handle); }
bool Terminate(DWORD exitCode) { return BOOLToBool(::TerminateThread(thread.handle, exitCode)); } bool Terminate(DWORD exitCode) { return BOOLToBool(::TerminateThread(thread.handle, exitCode)); }

View File

@@ -2,7 +2,7 @@
;Defines ;Defines
!define VERSION_MAJOR 4 !define VERSION_MAJOR 4
!define VERSION_MINOR 64 !define VERSION_MINOR 65
!define VERSION_POSTFIX_FULL "" !define VERSION_POSTFIX_FULL ""
!ifdef WIN64 !ifdef WIN64
!ifdef IA64 !ifdef IA64

View File

@@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<?define VerMajor = "4" ?> <?define VerMajor = "4" ?>
<?define VerMinor = "64" ?> <?define VerMinor = "65" ?>
<?define VerBuild = "00" ?> <?define VerBuild = "00" ?>
<?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?> <?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?>
<?define MmHex = "0$(var.VerMajor)$(var.VerMinor)" ?> <?define MmHex = "0$(var.VerMajor)$(var.VerMinor)" ?>

View File

@@ -1,4 +1,4 @@
7-Zip method IDs (4.61) 7-Zip method IDs (4.65)
----------------------- -----------------------
Each compression or crypto method in 7z has unique binary value (ID). Each compression or crypto method in 7z has unique binary value (ID).
@@ -24,12 +24,11 @@ List of defined IDs
------------------- -------------------
00 - Copy 00 - Copy
01 - Reserved
02 - Common 02 - Common
03 Swap 03 Swap
- 2 Swap2 - 2 Swap2
- 4 Swap4 - 4 Swap4
04 Delta (subject to change)
03 - 7z 03 - 7z
01 - LZMA 01 - LZMA
@@ -60,9 +59,6 @@ List of defined IDs
7F - 7F -
01 - experimental methods. 01 - experimental methods.
80 - reserved for independent developers
E0 - Random IDs
04 - Misc 04 - Misc
00 - Reserved 00 - Reserved

View File

@@ -1,4 +1,4 @@
LZMA SDK 4.63 LZMA SDK 4.65
------------- -------------
LZMA SDK provides the documentation, samples, header files, libraries, LZMA SDK provides the documentation, samples, header files, libraries,

View File

@@ -1,4 +1,4 @@
7-Zip 4.64 Sources 7-Zip 4.65 Sources
------------------ ------------------
7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP/Vista. 7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP/Vista.