mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-12 16:11:35 -06:00
9.34
This commit is contained in:
committed by
Kornel Lesiński
parent
83f8ddcc5b
commit
f08f4dcc3c
56
CPP/7zip/Compress/Lzx86Converter.cpp
Executable file → Normal file
56
CPP/7zip/Compress/Lzx86Converter.cpp
Executable file → Normal file
@@ -9,31 +9,31 @@
|
||||
namespace NCompress {
|
||||
namespace NLzx {
|
||||
|
||||
static const int kResidue = 6 + 4;
|
||||
static const UInt32 kResidue = 6 + 4;
|
||||
|
||||
void Cx86ConvertOutStream::MakeTranslation()
|
||||
{
|
||||
if (m_Pos <= kResidue)
|
||||
if (_pos <= kResidue)
|
||||
return;
|
||||
UInt32 numBytes = m_Pos - kResidue;
|
||||
Byte *buffer = m_Buffer;
|
||||
UInt32 numBytes = _pos - kResidue;
|
||||
Byte *buf = _buf;
|
||||
for (UInt32 i = 0; i < numBytes;)
|
||||
{
|
||||
if (buffer[i++] == 0xE8)
|
||||
if (buf[i++] == 0xE8)
|
||||
{
|
||||
Int32 absValue = 0;
|
||||
int j;
|
||||
for(j = 0; j < 4; j++)
|
||||
absValue += (UInt32)buffer[i + j] << (j * 8);
|
||||
Int32 pos = (Int32)(m_ProcessedSize + i - 1);
|
||||
if (absValue >= -pos && absValue < (Int32)m_TranslationSize)
|
||||
unsigned j;
|
||||
for (j = 0; j < 4; j++)
|
||||
absValue += (UInt32)buf[i + j] << (j * 8);
|
||||
Int32 pos = (Int32)(_processedSize + i - 1);
|
||||
if (absValue >= -pos && absValue < (Int32)_translationSize)
|
||||
{
|
||||
UInt32 offset = (absValue >= 0) ?
|
||||
absValue - pos :
|
||||
absValue + m_TranslationSize;
|
||||
for(j = 0; j < 4; j++)
|
||||
absValue + _translationSize;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
buffer[i + j] = (Byte)(offset & 0xFF);
|
||||
buf[i + j] = (Byte)(offset & 0xFF);
|
||||
offset >>= 8;
|
||||
}
|
||||
}
|
||||
@@ -44,46 +44,46 @@ void Cx86ConvertOutStream::MakeTranslation()
|
||||
|
||||
STDMETHODIMP Cx86ConvertOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
if (processedSize != NULL)
|
||||
if (processedSize)
|
||||
*processedSize = 0;
|
||||
if (!m_TranslationMode)
|
||||
return m_Stream->Write(data, size, processedSize);
|
||||
if (!_translationMode)
|
||||
return _stream->Write(data, size, processedSize);
|
||||
UInt32 realProcessedSize = 0;
|
||||
while (realProcessedSize < size)
|
||||
{
|
||||
UInt32 writeSize = MyMin(size - realProcessedSize, kUncompressedBlockSize - m_Pos);
|
||||
memmove(m_Buffer + m_Pos, (const Byte *)data + realProcessedSize, writeSize);
|
||||
m_Pos += writeSize;
|
||||
UInt32 writeSize = MyMin(size - realProcessedSize, kUncompressedBlockSize - _pos);
|
||||
memcpy(_buf + _pos, (const Byte *)data + realProcessedSize, writeSize);
|
||||
_pos += writeSize;
|
||||
realProcessedSize += writeSize;
|
||||
if (m_Pos == kUncompressedBlockSize)
|
||||
if (_pos == kUncompressedBlockSize)
|
||||
{
|
||||
RINOK(Flush());
|
||||
}
|
||||
}
|
||||
if (processedSize != NULL)
|
||||
if (processedSize)
|
||||
*processedSize = realProcessedSize;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Cx86ConvertOutStream::Flush()
|
||||
{
|
||||
if (m_Pos == 0)
|
||||
if (_pos == 0)
|
||||
return S_OK;
|
||||
if (m_TranslationMode)
|
||||
if (_translationMode)
|
||||
MakeTranslation();
|
||||
UInt32 pos = 0;
|
||||
do
|
||||
{
|
||||
UInt32 processed;
|
||||
RINOK(m_Stream->Write(m_Buffer + pos, m_Pos - pos, &processed));
|
||||
RINOK(_stream->Write(_buf + pos, _pos - pos, &processed));
|
||||
if (processed == 0)
|
||||
return E_FAIL;
|
||||
pos += processed;
|
||||
}
|
||||
while(pos < m_Pos);
|
||||
m_ProcessedSize += m_Pos;
|
||||
m_Pos = 0;
|
||||
m_TranslationMode = (m_TranslationMode && (m_ProcessedSize < (1 << 30)));
|
||||
while (pos < _pos);
|
||||
_processedSize += _pos;
|
||||
_pos = 0;
|
||||
_translationMode = (_translationMode && (_processedSize < ((UInt32)1 << 30)));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user