-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
itouch5000
committed
Apr 8, 2016
1 parent
d52edb2
commit 5ea5ee4
Showing
156 changed files
with
33,377 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
ACKNOWLEDGMENTS | ||
|
||
* We used "Screaming Fast Galois Field Arithmetic Using Intel | ||
SIMD Instructions" paper by James S. Plank, Kevin M. Greenan | ||
and Ethan L. Miller to improve Reed-Solomon coding performance. | ||
Also we are grateful to Artem Drobanov and Bulat Ziganshin | ||
for samples and ideas allowed to make Reed-Solomon coding | ||
more efficient. | ||
|
||
* RAR text compression algorithm is based on Dmitry Shkarin PPMII | ||
and Dmitry Subbotin carryless rangecoder public domain source code. | ||
You may find it in ftp.elf.stuba.sk/pub/pc/pack. | ||
|
||
* RAR encryption includes parts of code from Szymon Stefanek | ||
and Brian Gladman AES implementations also as Steve Reid SHA-1 source. | ||
|
||
--------------------------------------------------------------------------- | ||
Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK. | ||
All rights reserved. | ||
|
||
LICENSE TERMS | ||
|
||
The free distribution and use of this software in both source and binary | ||
form is allowed (with or without changes) provided that: | ||
|
||
1. distributions of this source code include the above copyright | ||
notice, this list of conditions and the following disclaimer; | ||
|
||
2. distributions in binary form include the above copyright | ||
notice, this list of conditions and the following disclaimer | ||
in the documentation and/or other associated materials; | ||
|
||
3. the copyright holder's name is not used to endorse products | ||
built using this software without specific written permission. | ||
|
||
ALTERNATIVELY, provided that this notice is retained in full, this product | ||
may be distributed under the terms of the GNU General Public License (GPL), | ||
in which case the provisions of the GPL apply INSTEAD OF those given above. | ||
|
||
DISCLAIMER | ||
|
||
This software is provided 'as is' with no explicit or implied warranties | ||
in respect of its properties, including, but not limited to, correctness | ||
and/or fitness for purpose. | ||
--------------------------------------------------------------------------- | ||
|
||
Source code of this package also as other cryptographic technology | ||
and computing project related links are available on Brian Gladman's | ||
web site: http://www.gladman.me.uk | ||
|
||
* RAR uses CRC32 function based on Intel Slicing-by-8 algorithm. | ||
Original Intel Slicing-by-8 code is available here: | ||
|
||
http://sourceforge.net/projects/slicing-by-8/ | ||
|
||
Original Intel Slicing-by-8 code is licensed under BSD License | ||
available at http://www.opensource.org/licenses/bsd-license.html | ||
|
||
Copyright (c) 2004-2006 Intel Corporation. | ||
All Rights Reserved | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
|
||
Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer | ||
in the documentation and/or other materials provided with | ||
the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
SUCH DAMAGE. | ||
|
||
* RAR archives may optionally include BLAKE2sp hash ( https://blake2.net ), | ||
designed by Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn | ||
and Christian Winnerlein. | ||
|
||
* Useful hints provided by Alexander Khoroshev and Bulat Ziganshin allowed | ||
to significantly improve RAR compression and speed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
static bool IsAnsiEscComment(const wchar *Data,size_t Size); | ||
|
||
bool Archive::GetComment(Array<wchar> *CmtData) | ||
{ | ||
if (!MainComment) | ||
return false; | ||
SaveFilePos SavePos(*this); | ||
|
||
#ifndef SFX_MODULE | ||
ushort CmtLength; | ||
if (Format==RARFMT14) | ||
{ | ||
Seek(SFXSize+SIZEOF_MAINHEAD14,SEEK_SET); | ||
CmtLength=GetByte(); | ||
CmtLength+=(GetByte()<<8); | ||
} | ||
else | ||
#endif | ||
{ | ||
if (MainHead.CommentInHeader) | ||
{ | ||
// Old style (RAR 2.9) archive comment embedded into the main | ||
// archive header. | ||
Seek(SFXSize+SIZEOF_MARKHEAD3+SIZEOF_MAINHEAD3,SEEK_SET); | ||
ReadHeader(); | ||
} | ||
else | ||
{ | ||
// Current (RAR 3.0+) version of archive comment. | ||
Seek(GetStartPos(),SEEK_SET); | ||
return SearchSubBlock(SUBHEAD_TYPE_CMT)!=0 && ReadCommentData(CmtData); | ||
} | ||
#ifndef SFX_MODULE | ||
// Old style (RAR 2.9) comment header embedded into the main | ||
// archive header. | ||
if (BrokenHeader) | ||
{ | ||
uiMsg(UIERROR_CMTBROKEN,FileName); | ||
return false; | ||
} | ||
CmtLength=CommHead.HeadSize-SIZEOF_COMMHEAD; | ||
#endif | ||
} | ||
#ifndef SFX_MODULE | ||
if (Format==RARFMT14 && MainHead.PackComment || Format!=RARFMT14 && CommHead.Method!=0x30) | ||
{ | ||
if (Format!=RARFMT14 && (CommHead.UnpVer < 15 || CommHead.UnpVer > VER_UNPACK || CommHead.Method > 0x35)) | ||
return(false); | ||
ComprDataIO DataIO; | ||
DataIO.SetTestMode(true); | ||
uint UnpCmtLength; | ||
if (Format==RARFMT14) | ||
{ | ||
#ifdef RAR_NOCRYPT | ||
return(false); | ||
#else | ||
UnpCmtLength=GetByte(); | ||
UnpCmtLength+=(GetByte()<<8); | ||
CmtLength-=2; | ||
DataIO.SetCmt13Encryption(); | ||
CommHead.UnpVer=15; | ||
#endif | ||
} | ||
else | ||
UnpCmtLength=CommHead.UnpSize; | ||
DataIO.SetFiles(this,NULL); | ||
DataIO.EnableShowProgress(false); | ||
DataIO.SetPackedSizeToRead(CmtLength); | ||
DataIO.UnpHash.Init(HASH_CRC32,1); | ||
|
||
Unpack CmtUnpack(&DataIO); | ||
CmtUnpack.Init(0x10000,false); | ||
CmtUnpack.SetDestSize(UnpCmtLength); | ||
CmtUnpack.DoUnpack(CommHead.UnpVer,false); | ||
|
||
if (Format!=RARFMT14 && (DataIO.UnpHash.GetCRC32()&0xffff)!=CommHead.CommCRC) | ||
{ | ||
uiMsg(UIERROR_CMTBROKEN,FileName); | ||
return false; | ||
} | ||
else | ||
{ | ||
byte *UnpData; | ||
size_t UnpDataSize; | ||
DataIO.GetUnpackedData(&UnpData,&UnpDataSize); | ||
#ifdef _WIN_ALL | ||
OemToCharBuffA((char *)UnpData,(char *)UnpData,(DWORD)UnpDataSize); | ||
#endif | ||
CmtData->Alloc(UnpDataSize+1); | ||
memset(CmtData->Addr(0),0,CmtData->Size()*sizeof(wchar)); | ||
CharToWide((char *)UnpData,CmtData->Addr(0),UnpDataSize); | ||
CmtData->Alloc(wcslen(CmtData->Addr(0))); | ||
} | ||
} | ||
else | ||
{ | ||
Array<byte> CmtRaw(CmtLength); | ||
Read(&CmtRaw[0],CmtLength); | ||
|
||
if (Format!=RARFMT14 && CommHead.CommCRC!=(~CRC32(0xffffffff,&CmtRaw[0],CmtLength)&0xffff)) | ||
{ | ||
uiMsg(UIERROR_CMTBROKEN,FileName); | ||
return false; | ||
} | ||
CmtData->Alloc(CmtLength+1); | ||
CmtRaw.Push(0); | ||
#ifdef _WIN_ALL | ||
OemToCharA((char *)&CmtRaw[0],(char *)&CmtRaw[0]); | ||
#endif | ||
CharToWide((char *)&CmtRaw[0],CmtData->Addr(0),CmtLength); | ||
CmtData->Alloc(wcslen(CmtData->Addr(0))); | ||
} | ||
#endif | ||
return CmtData->Size() > 0; | ||
} | ||
|
||
|
||
bool Archive::ReadCommentData(Array<wchar> *CmtData) | ||
{ | ||
Array<byte> CmtRaw; | ||
if (!ReadSubData(&CmtRaw,NULL)) | ||
return false; | ||
size_t CmtSize=CmtRaw.Size(); | ||
CmtRaw.Push(0); | ||
CmtData->Alloc(CmtSize+1); | ||
if (Format==RARFMT50) | ||
UtfToWide((char *)&CmtRaw[0],CmtData->Addr(0),CmtData->Size()); | ||
else | ||
if ((SubHead.SubFlags & SUBHEAD_FLAGS_CMT_UNICODE)!=0) | ||
{ | ||
RawToWide(&CmtRaw[0],CmtData->Addr(0),CmtSize/2); | ||
(*CmtData)[CmtSize/2]=0; | ||
|
||
} | ||
else | ||
{ | ||
CharToWide((char *)&CmtRaw[0],CmtData->Addr(0),CmtData->Size()); | ||
} | ||
CmtData->Alloc(wcslen(CmtData->Addr(0))); // Set buffer size to actual comment length. | ||
return true; | ||
} | ||
|
||
|
||
void Archive::ViewComment() | ||
{ | ||
#ifndef GUI | ||
if (Cmd->DisableComment) | ||
return; | ||
Array<wchar> CmtBuf; | ||
if (GetComment(&CmtBuf)) | ||
{ | ||
size_t CmtSize=CmtBuf.Size(); | ||
wchar *ChPtr=wcschr(&CmtBuf[0],0x1A); | ||
if (ChPtr!=NULL) | ||
CmtSize=ChPtr-&CmtBuf[0]; | ||
mprintf(L"\n"); | ||
OutComment(&CmtBuf[0],CmtSize); | ||
} | ||
#endif | ||
} | ||
|
||
|
Oops, something went wrong.