diff options
Diffstat (limited to 'CPP/7zip/Archive/Rar')
-rwxr-xr-x | CPP/7zip/Archive/Rar/DllExports.cpp | 142 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Rar/Rar.dsp | 459 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Rar/Rar.dsw | 29 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Rar/RarHandler.cpp | 104 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Rar/RarHandler.h | 12 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Rar/RarIn.cpp | 41 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Rar/RarRegister.cpp | 13 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Rar/RarVolumeInStream.cpp | 11 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Rar/RarVolumeInStream.h | 3 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Rar/makefile | 90 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Rar/resource.rc | 5 |
11 files changed, 96 insertions, 813 deletions
diff --git a/CPP/7zip/Archive/Rar/DllExports.cpp b/CPP/7zip/Archive/Rar/DllExports.cpp deleted file mode 100755 index 921bffb2..00000000 --- a/CPP/7zip/Archive/Rar/DllExports.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// DLLExports.cpp - -#include "StdAfx.h" - -#include "Common/MyInitGuid.h" -#include "Common/ComTry.h" -#include "Windows/PropVariant.h" -#include "../../ICoder.h" -#include "../../IPassword.h" -#include "../Common/CodecsPath.h" - -// {23170F69-40C1-278B-0601-010000000000} -DEFINE_GUID(CLSID_CCrypto_AES128_Decoder, -0x23170F69, 0x40C1, 0x278B, 0x06, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00); - -#include "RarHandler.h" - -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 - -void GetCryptoFolderPrefix(TCHAR *path) -{ - CSysString s = GetCodecsFolderPrefix(); - lstrcpy(path, s); -} - - -// {23170F69-40C1-278B-0403-010000000000} -DEFINE_GUID(CLSID_CCompressRar15Decoder, -0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00); - -// {23170F69-40C1-278B-0403-020000000000} -DEFINE_GUID(CLSID_CCompressRar20Decoder, -0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00); - -// {23170F69-40C1-278B-0403-030000000000} -DEFINE_GUID(CLSID_CCompressRar29Decoder, -0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00); - -/* -// {23170F69-40C1-278B-06F1-0302000000000} -DEFINE_GUID(CLSID_CCryptoRar20Decoder, -0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00); - -// {23170F69-40C1-278B-06F1-0303000000000} -DEFINE_GUID(CLSID_CCryptoRar29Decoder, -0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00); -*/ - -// {23170F69-40C1-278A-1000-000110030000} -DEFINE_GUID(CLSID_CRarHandler, - 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x03, 0x00, 0x00); - -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_CRarHandler) - return CLASS_E_CLASSNOTAVAILABLE; - int needIn = *interfaceID == IID_IInArchive; - if (needIn) - { - NArchive::NRar::CHandler *temp = new NArchive::NRar::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"Rar"; - break; - case NArchive::kClassID: - { - if ((value->bstrVal = ::SysAllocStringByteLen( - (const char *)&CLSID_CRarHandler, sizeof(GUID))) != 0) - value->vt = VT_BSTR; - return S_OK; - } - case NArchive::kExtension: - propVariant = L"rar"; - break; - case NArchive::kUpdate: - propVariant = false; - break; - case NArchive::kKeepName: - propVariant = false; - break; - case NArchive::kStartSignature: - { - if ((value->bstrVal = ::SysAllocStringByteLen( - (const char *)NArchive::NRar::NHeader::kMarker, - NArchive::NRar::NHeader::kMarkerSize)) != 0) - value->vt = VT_BSTR; - return S_OK; - } - } - propVariant.Detach(value); - return S_OK; -} diff --git a/CPP/7zip/Archive/Rar/Rar.dsp b/CPP/7zip/Archive/Rar/Rar.dsp deleted file mode 100755 index 739024da..00000000 --- a/CPP/7zip/Archive/Rar/Rar.dsp +++ /dev/null @@ -1,459 +0,0 @@ -# Microsoft Developer Studio Project File - Name="Rar" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=Rar - 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 "Rar.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 "Rar.mak" CFG="Rar - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "Rar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "Rar - 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)" == "Rar - 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 "RAR_EXPORTS" /YX /FD /c -# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAR_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\rar.dll" /opt:NOWIN98 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "Rar - 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 "RAR_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 "RAR_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\rar.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "Rar - Win32 Release" -# Name "Rar - 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=.\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\CRC.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\CRC.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\DynamicBuffer.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\Types.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\UTFConvert.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\UTFConvert.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 "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.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\IArchiveHandler.h -# End Source File -# Begin Source File - -SOURCE=..\Common\InStreamWithCRC.cpp -# End Source File -# Begin Source File - -SOURCE=..\Common\InStreamWithCRC.h -# End Source File -# Begin Source File - -SOURCE=..\Common\OutStreamWithCRC.cpp -# End Source File -# Begin Source File - -SOURCE=..\Common\OutStreamWithCRC.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\Handle.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\PropVariant.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\PropVariant.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\Synchronization.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\Synchronization.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\Thread.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=.\RarHandler.cpp -# End Source File -# Begin Source File - -SOURCE=.\RarHandler.h -# End Source File -# Begin Source File - -SOURCE=.\RarHeader.cpp -# End Source File -# Begin Source File - -SOURCE=.\RarHeader.h -# End Source File -# Begin Source File - -SOURCE=.\RarIn.cpp -# End Source File -# Begin Source File - -SOURCE=.\RarIn.h -# End Source File -# Begin Source File - -SOURCE=.\RarItem.cpp -# End Source File -# Begin Source File - -SOURCE=.\RarItem.h -# End Source File -# Begin Source File - -SOURCE=.\RarVolumeInStream.cpp -# End Source File -# Begin Source File - -SOURCE=.\RarVolumeInStream.h -# End Source File -# End Group -# Begin Group "Crypto" - -# PROP Default_Filter "" -# Begin Group "Rar29" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\Crypto\RarAES\RarAES.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Crypto\RarAES\RarAES.h -# End Source File -# End Group -# Begin Group "Rar20" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\Crypto\Rar20\Rar20Cipher.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Crypto\Rar20\Rar20Cipher.h -# End Source File -# Begin Source File - -SOURCE=..\..\Crypto\Rar20\Rar20Crypto.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Crypto\Rar20\Rar20Crypto.h -# End Source File -# End Group -# Begin Group "Hash" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\Crypto\Hash\Sha1.cpp - -!IF "$(CFG)" == "Rar - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "Rar - Win32 Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\Crypto\Hash\Sha1.h -# End Source File -# End Group -# End Group -# Begin Group "7-zip 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 -# Begin Source File - -SOURCE=.\Rar.ico -# End Source File -# End Target -# End Project diff --git a/CPP/7zip/Archive/Rar/Rar.dsw b/CPP/7zip/Archive/Rar/Rar.dsw deleted file mode 100755 index 3dab87aa..00000000 --- a/CPP/7zip/Archive/Rar/Rar.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "Rar"=.\Rar.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/CPP/7zip/Archive/Rar/RarHandler.cpp b/CPP/7zip/Archive/Rar/RarHandler.cpp index 3389f0e2..5cd3c15d 100755 --- a/CPP/7zip/Archive/Rar/RarHandler.cpp +++ b/CPP/7zip/Archive/Rar/RarHandler.cpp @@ -12,37 +12,19 @@ #include "Windows/Time.h" #include "../../IPassword.h" - -#include "../../Common//ProgressUtils.h" +#include "../../Common/ProgressUtils.h" +#include "../../Common/CreateCoder.h" +#include "../../Common/MethodID.h" +#include "../../Common/FilterCoder.h" #include "../../Compress/Copy/CopyCoder.h" - #include "../../Crypto/Rar20/Rar20Cipher.h" #include "../../Crypto/RarAES/RarAES.h" - #include "../Common/OutStreamWithCRC.h" -#include "../Common/CoderLoader.h" -#include "../Common/CodecsPath.h" -#include "../Common/FilterCoder.h" #include "../Common/ItemNameUtils.h" -#include "../7z/7zMethods.h" - using namespace NWindows; using namespace NTime; -// {23170F69-40C1-278B-0403-010000000000} -DEFINE_GUID(CLSID_CCompressRar15Decoder, -0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00); - -// {23170F69-40C1-278B-0403-020000000000} -DEFINE_GUID(CLSID_CCompressRar20Decoder, -0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00); - -// {23170F69-40C1-278B-0403-030000000000} -DEFINE_GUID(CLSID_CCompressRar29Decoder, -0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00); - - namespace NArchive { namespace NRar { @@ -588,32 +570,11 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, UInt64 currentImportantTotalPacked = 0; UInt64 currentUnPackSize, currentPackSize; - /* - CSysString path = GetCodecsFolderPrefix() + TEXT("Rar29.dll"); - TCHAR compressLibPath[MAX_PATH + 64]; - if (!GetCompressFolderPrefix(compressLibPath)) - return ::GetLastError(); - lstrcat(compressLibPath, TEXT("Rar29.dll")); - */ - N7z::LoadMethodMap(); - CCoderLibraries libraries; CObjectVector<CMethodItem> methodItems; - /* - CCoderLibrary compressLib; - CMyComPtr<ICompressCoder> decoder15; - CMyComPtr<ICompressCoder> decoder20; - CMyComPtr<ICompressCoder> decoder29; - */ - NCompress::CCopyCoder *copyCoderSpec = NULL; CMyComPtr<ICompressCoder> copyCoder; - // CCoderMixer *mixerCoderSpec; - // CMyComPtr<ICompressCoder> mixerCoder; - // bool mixerCoderStoreMethod; - // int mixerCryptoVersion; - CFilterCoder *filterStreamSpec = new CFilterCoder; CMyComPtr<ISequentialInStream> filterStream = filterStreamSpec; @@ -625,6 +586,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, CFolderInStream *folderInStreamSpec = NULL; CMyComPtr<ISequentialInStream> folderInStream; + bool solidStart = true; for(int i = 0; i < importantIndexes.Size(); i++, currentImportantTotalUnPacked += currentUnPackSize, currentImportantTotalPacked += currentPackSize) @@ -654,6 +616,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); + if (!IsSolid(index)) + solidStart = true; if(item.IsDirectory()) { RINOK(extractCallback->PrepareOperation(askMode)); @@ -839,25 +803,27 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, { CMethodItem mi; mi.RarUnPackVersion = item.UnPackVersion; - N7z::CMethodID methodID = { { 0x04, 0x03 } , 3 }; - - Byte myID; - if (item.UnPackVersion < 20) - myID = 1; - else if (item.UnPackVersion < 29) - myID = 2; - else - myID = 3; - methodID.ID[2] = myID; - N7z::CMethodInfo methodInfo; - if (!N7z::GetMethodInfo(methodID, methodInfo)) + + mi.Coder.Release(); + if (item.UnPackVersion <= 30) { - RINOK(extractCallback->SetOperationResult( - NArchive::NExtract::NOperationResult::kUnSupportedMethod)); + UInt32 methodID = 0x040300; + if (item.UnPackVersion < 20) + methodID += 1; + else if (item.UnPackVersion < 29) + methodID += 2; + else + methodID += 3; + RINOK(CreateCoder(EXTERNAL_CODECS_VARS methodID, mi.Coder, false)); + } + + if (mi.Coder == 0) + { + outStream.Release(); + RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod)); continue; } - RINOK(libraries.CreateCoder(methodInfo.FilePath, - methodInfo.Decoder, &mi.Coder)); + m = methodItems.Add(mi); } CMyComPtr<ICompressCoder> decoder = methodItems[m].Coder; @@ -867,6 +833,12 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, &compressSetDecoderProperties)); Byte isSolid = (Byte)((IsSolid(index) || item.IsSplitBefore()) ? 1: 0); + if (solidStart) + { + isSolid = false; + solidStart = false; + } + RINOK(compressSetDecoderProperties->SetDecoderProperties2(&isSolid, 1)); @@ -924,18 +896,6 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, COM_TRY_END } -/* -STDMETHODIMP CHandler::ExtractAllItems(Int32 testMode, - IArchiveExtractCallback *extractCallback) -{ - COM_TRY_BEGIN - CRecordVector<UInt32> indices; - indices.Reserve(_refItems.Size()); - for(int i = 0; i < _refItems.Size(); i++) - indices.Add(i); - return Extract(&indices.Front(), _refItems.Size(), testMode, extractCallback); - COM_TRY_END -} -*/ +IMPL_ISetCompressCodecsInfo }} diff --git a/CPP/7zip/Archive/Rar/RarHandler.h b/CPP/7zip/Archive/Rar/RarHandler.h index ea13e01e..d54fd4e5 100755 --- a/CPP/7zip/Archive/Rar/RarHandler.h +++ b/CPP/7zip/Archive/Rar/RarHandler.h @@ -7,15 +7,21 @@ #include "RarIn.h" #include "RarVolumeInStream.h" +#include "../../Common/CreateCoder.h" + namespace NArchive { namespace NRar { class CHandler: public IInArchive, + PUBLIC_ISetCompressCodecsInfo public CMyUnknownImp { public: - MY_UNKNOWN_IMP + MY_QUERYINTERFACE_BEGIN + QUERY_ENTRY_ISetCompressCodecsInfo + MY_QUERYINTERFACE_END + MY_ADDREF_RELEASE STDMETHOD(Open)(IInStream *aStream, const UInt64 *aMaxCheckStartPosition, @@ -36,12 +42,16 @@ public: STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType); + DECL_ISetCompressCodecsInfo + private: CRecordVector<CRefItem> _refItems; CObjectVector<CItemEx> _items; CObjectVector<CInArchive> _archives; NArchive::NRar::CInArchiveInfo _archiveInfo; + DECL_EXTERNAL_CODECS_VARS + UInt64 GetPackSize(int refIndex) const; // NArchive::NRar::CInArchive _archive; diff --git a/CPP/7zip/Archive/Rar/RarIn.cpp b/CPP/7zip/Archive/Rar/RarIn.cpp index 9a88feb7..b87199ce 100755 --- a/CPP/7zip/Archive/Rar/RarIn.cpp +++ b/CPP/7zip/Archive/Rar/RarIn.cpp @@ -3,13 +3,17 @@ #include "StdAfx.h" #include "Common/StringConvert.h" -#include "Common/CRC.h" #include "Common/UTFConvert.h" #include "RarIn.h" #include "../../Common/LimitedStreams.h" #include "../../Common/StreamUtils.h" +extern "C" +{ + #include "../../../../C/7zCrc.h" +} + namespace NArchive { namespace NRar { @@ -137,6 +141,23 @@ HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize) return result; } +static UInt32 CrcUpdateUInt16(UInt32 crc, UInt16 v) +{ + crc = CRC_UPDATE_BYTE(crc, (Byte)(v & 0xFF)); + crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 8) & 0xFF)); + return crc; +} + +static UInt32 CrcUpdateUInt32(UInt32 crc, UInt32 v) +{ + crc = CRC_UPDATE_BYTE(crc, (Byte)(v & 0xFF)); + crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 8) & 0xFF)); + crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 16) & 0xFF)); + crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 24) & 0xFF)); + return crc; +} + + bool CInArchive::ReadMarkerAndArchiveHeader(const UInt64 *searchHeaderSizeLimit) { if (!FindAndReadMarker(searchHeaderSizeLimit)) @@ -159,22 +180,22 @@ bool CInArchive::ReadMarkerAndArchiveHeader(const UInt64 *searchHeaderSizeLimit) m_ArchiveHeader.Reserved2 = ReadUInt32(); m_ArchiveHeader.EncryptVersion = 0; - CCRC crc; - crc.UpdateByte(m_ArchiveHeader.Type); - crc.UpdateUInt16(m_ArchiveHeader.Flags); - crc.UpdateUInt16(m_ArchiveHeader.Size); - crc.UpdateUInt16(m_ArchiveHeader.Reserved1); - crc.UpdateUInt32(m_ArchiveHeader.Reserved2); + UInt32 crc = CRC_INIT_VAL; + crc = CRC_UPDATE_BYTE(crc, m_ArchiveHeader.Type); + crc = CrcUpdateUInt16(crc, m_ArchiveHeader.Flags); + crc = CrcUpdateUInt16(crc, m_ArchiveHeader.Size); + crc = CrcUpdateUInt16(crc, m_ArchiveHeader.Reserved1); + crc = CrcUpdateUInt32(crc, m_ArchiveHeader.Reserved2); if (m_ArchiveHeader.IsThereEncryptVer() && m_ArchiveHeader.Size > NHeader::NArchive::kArchiveHeaderSize) { ReadBytes(&m_ArchiveHeader.EncryptVersion, 1, &processedSize); if (processedSize != 1) return false; - crc.UpdateByte(m_ArchiveHeader.EncryptVersion); + crc = CRC_UPDATE_BYTE(crc, m_ArchiveHeader.EncryptVersion); } - if(m_ArchiveHeader.CRC != (crc.GetDigest() & 0xFFFF)) + if(m_ArchiveHeader.CRC != (CRC_GET_DIGEST(crc) & 0xFFFF)) ThrowExceptionWithCode(CInArchiveException::kArchiveHeaderCRCError); if (m_ArchiveHeader.Type != NHeader::NBlockType::kArchiveHeader) return false; @@ -478,7 +499,7 @@ HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPa m_PosLimit = m_BlockHeader.HeadSize; ReadBytesAndTestResult(m_CurData + m_CurPos, m_BlockHeader.HeadSize - 7); ReadHeaderReal(item); - if ((CCRC::CalculateDigest(m_CurData + 2, + if ((CrcCalc(m_CurData + 2, m_BlockHeader.HeadSize - item.CommentSize - 2) & 0xFFFF) != m_BlockHeader.CRC) ThrowExceptionWithCode(CInArchiveException::kFileHeaderCRCError); diff --git a/CPP/7zip/Archive/Rar/RarRegister.cpp b/CPP/7zip/Archive/Rar/RarRegister.cpp new file mode 100755 index 00000000..def6e480 --- /dev/null +++ b/CPP/7zip/Archive/Rar/RarRegister.cpp @@ -0,0 +1,13 @@ +// RarRegister.cpp + +#include "StdAfx.h" + +#include "../../Common/RegisterArc.h" + +#include "RarHandler.h" +static IInArchive *CreateArc() { return new NArchive::NRar::CHandler; } + +static CArcInfo g_ArcInfo = + { L"Rar", L"rar", 0, 3, {0x52 , 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00}, 7, false, CreateArc, 0, }; + +REGISTER_ARC(Rar) diff --git a/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp b/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp index 32078e6d..aeb52ecc 100755 --- a/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp +++ b/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp @@ -7,6 +7,11 @@ #include "Windows/Defs.h" #include "Common/Defs.h" +extern "C" +{ + #include "../../../../C/7zCrc.h" +} + namespace NArchive { namespace NRar { @@ -32,7 +37,7 @@ HRESULT CFolderInStream::OpenStream() CreateLimitedStream(item.GetDataPosition(), item.PackSize)); _curIndex++; _fileIsOpen = true; - _crc.Init(); + _crc = CRC_INIT_VAL; return S_OK; } return S_OK; @@ -40,7 +45,7 @@ HRESULT CFolderInStream::OpenStream() HRESULT CFolderInStream::CloseStream() { - CRCs.Add(_crc.GetDigest()); + CRCs.Add(CRC_GET_DIGEST(_crc)); _stream.Release(); _fileIsOpen = false; return S_OK; @@ -56,7 +61,7 @@ STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSiz UInt32 localProcessedSize; RINOK(_stream->Read( ((Byte *)data) + realProcessedSize, size, &localProcessedSize)); - _crc.Update(((Byte *)data) + realProcessedSize, localProcessedSize); + _crc = CrcUpdate(_crc, ((Byte *)data) + realProcessedSize, localProcessedSize); if (localProcessedSize == 0) { RINOK(CloseStream()); diff --git a/CPP/7zip/Archive/Rar/RarVolumeInStream.h b/CPP/7zip/Archive/Rar/RarVolumeInStream.h index 4c9a9e96..7c5902b5 100755 --- a/CPP/7zip/Archive/Rar/RarVolumeInStream.h +++ b/CPP/7zip/Archive/Rar/RarVolumeInStream.h @@ -4,7 +4,6 @@ #define __RAR_VOLUME_IN_STREAM_H #include "../../IStream.h" -#include "Common/CRC.h" #include "RarIn.h" namespace NArchive { @@ -31,7 +30,7 @@ private: const CObjectVector<CItemEx> *_items; CRefItem _refItem; int _curIndex; - CCRC _crc; + UInt32 _crc; bool _fileIsOpen; CMyComPtr<ISequentialInStream> _stream; diff --git a/CPP/7zip/Archive/Rar/makefile b/CPP/7zip/Archive/Rar/makefile deleted file mode 100755 index 678dd412..00000000 --- a/CPP/7zip/Archive/Rar/makefile +++ /dev/null @@ -1,90 +0,0 @@ -PROG = rar.dll -DEF_FILE = ../Archive.def -CFLAGS = $(CFLAGS) -I ../../../ -LIBS = $(LIBS) oleaut32.lib user32.lib - -RAR_OBJS = \ - $O\DllExports.obj \ - $O\RarHandler.obj \ - $O\RarHeader.obj \ - $O\RarIn.obj \ - $O\RarItem.obj \ - $O\RarVolumeInStream.obj \ - -COMMON_OBJS = \ - $O\Alloc.obj \ - $O\CRC.obj \ - $O\IntToString.obj \ - $O\NewHandler.obj \ - $O\String.obj \ - $O\StringConvert.obj \ - $O\UTFConvert.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\StreamObjects.obj \ - $O\StreamUtils.obj \ - -AR_COMMON_OBJS = \ - $O\CodecsPath.obj \ - $O\FilterCoder.obj \ - $O\InStreamWithCRC.obj \ - $O\OutStreamWithCRC.obj \ - -7Z_OBJS = \ - $O\7zMethodID.obj \ - $O\7zMethods.obj \ - -CRYPTO_HASH_OBJS = \ - $O\Sha1.obj \ - -CRYPTO_RAR20_OBJS = \ - $O\Rar20Cipher.obj \ - $O\Rar20Crypto.obj \ - -CRYPTO_RARAES_OBJS = \ - $O\RarAES.obj \ - -OBJS = \ - $O\StdAfx.obj \ - $(RAR_OBJS) \ - $(COMMON_OBJS) \ - $(WIN_OBJS) \ - $(7ZIP_COMMON_OBJS) \ - $(AR_COMMON_OBJS) \ - $(7Z_OBJS) \ - $(CRYPTO_HASH_OBJS) \ - $(CRYPTO_RAR20_OBJS) \ - $(CRYPTO_RARAES_OBJS) \ - $O\CopyCoder.obj \ - $O\resource.res - -!include "../../../Build.mak" - -$(RAR_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) -$(CRYPTO_HASH_OBJS): ../../Crypto/Hash/$(*B).cpp - $(COMPL_O2) -$(CRYPTO_RAR20_OBJS): ../../Crypto/Rar20/$(*B).cpp - $(COMPL) -$(CRYPTO_RARAES_OBJS): ../../Crypto/RarAES/$(*B).cpp - $(COMPL) -$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp - $(COMPL) diff --git a/CPP/7zip/Archive/Rar/resource.rc b/CPP/7zip/Archive/Rar/resource.rc deleted file mode 100755 index 94b4198b..00000000 --- a/CPP/7zip/Archive/Rar/resource.rc +++ /dev/null @@ -1,5 +0,0 @@ -#include "../../MyVersionInfo.rc" - -MY_VERSION_INFO_DLL("Rar Plugin", "rar") - -101 ICON "rar.ico" |