Compare commits

..

4 Commits

Author SHA1 Message Date
7e52ebca48 . 2017-06-26 11:39:52 +03:00
4925b47002 x2t version up 2.4.466 2017-06-26 10:50:00 +03:00
afdaacb226 XlsFormat - external data records 2017-06-25 15:56:46 +03:00
9f98f07f23 Decryptors ... small refactoring 2017-06-25 14:20:14 +03:00
75 changed files with 411 additions and 404 deletions

View File

@ -963,4 +963,3 @@ namespace DocFormatUtils
};
}
using namespace DocFormatUtils;

View File

@ -32,6 +32,8 @@
#include "AnnotationReferenceDescriptor.h"
using namespace DocFormatUtils;
namespace DocFileFormat
{
ByteStructure* AnnotationReferenceDescriptor::ConstructObject(VirtualStreamReader* reader, int length)
@ -76,4 +78,4 @@ namespace DocFileFormat
return static_cast<ByteStructure*>(newObject);
}
}
}

View File

@ -34,6 +34,8 @@
#include "IVisitable.h"
#include "Global.h"
using namespace DocFormatUtils;
namespace DocFileFormat
{
typedef enum _BorderType

View File

@ -33,6 +33,8 @@
#include "../Common/FormatUtils.h"
using namespace DocFormatUtils;
namespace DocFileFormat
{
class DateAndTime

View File

@ -33,6 +33,7 @@
#include "DrawingPrimitives.h"
#include "VirtualStreamReader.h"
using namespace DocFormatUtils;
namespace DocFileFormat
{

View File

@ -34,6 +34,8 @@
#include "VirtualStreamReader.h"
#include "../../ASCOfficeXlsFile2/source/XlsFormat/Crypt/Decryptor.h"
using namespace DocFormatUtils;
namespace DocFileFormat
{
typedef enum FibVersion
@ -1189,9 +1191,9 @@ namespace DocFileFormat
m_FibBase.fDot = FormatUtils::BitmaskToBool((int)flag16, 0x0001);
m_FibBase.fGlsy = FormatUtils::BitmaskToBool((int)flag16, 0x0002);
m_FibBase.fComplex = FormatUtils::BitmaskToBool((int)flag16, 0x0002);
m_FibBase.fHasPic = FormatUtils::BitmaskToBool((int)flag16, 0x0008);
m_FibBase.cQuickSaves = (WORD)(((int)flag16 & 0x00F0) >> 4);
m_FibBase.fEncrypted = FormatUtils::BitmaskToBool((int)flag16, 0x0100);
m_FibBase.fHasPic = FormatUtils::BitmaskToBool((int)flag16, 0x0008);
m_FibBase.cQuickSaves = (WORD)(((int)flag16 & 0x00F0) >> 4);
m_FibBase.fEncrypted = FormatUtils::BitmaskToBool((int)flag16, 0x0100);
m_FibBase.fWhichTblStm = FormatUtils::BitmaskToBool((int)flag16, 0x0200);
m_FibBase.fReadOnlyRecommended = FormatUtils::BitmaskToBool((int)flag16, 0x0400);
m_FibBase.fWriteReservation = FormatUtils::BitmaskToBool((int)flag16, 0x0800);

View File

@ -72,7 +72,7 @@ public:
if (m_Data)
{
rdUShort = FormatUtils::BytesToUInt16 (m_Data, m_Position, m_Size);
rdUShort = DocFormatUtils::FormatUtils::BytesToUInt16 (m_Data, m_Position, m_Size);
m_Position += sizeof(rdUShort);
}
@ -85,7 +85,7 @@ public:
if (m_Data)
{
rdShort = FormatUtils::BytesToInt16 (m_Data, m_Position, m_Size);
rdShort = DocFormatUtils::FormatUtils::BytesToInt16 (m_Data, m_Position, m_Size);
m_Position += sizeof(rdShort);
}
@ -98,7 +98,7 @@ public:
if (m_Data)
{
rdInt = FormatUtils::BytesToInt32 (m_Data, m_Position, m_Size);
rdInt = DocFormatUtils::FormatUtils::BytesToInt32 (m_Data, m_Position, m_Size);
m_Position += sizeof(rdInt);
}
@ -111,7 +111,7 @@ public:
if (m_Data )
{
rdUInt = FormatUtils::BytesToUInt32 (m_Data, m_Position, m_Size);
rdUInt = DocFormatUtils::FormatUtils::BytesToUInt32 (m_Data, m_Position, m_Size);
m_Position += sizeof(rdUInt);
}

View File

@ -32,6 +32,8 @@
#include "Spa.h"
#include "VirtualStreamReader.h"
using namespace DocFormatUtils;
namespace DocFileFormat
{

View File

@ -197,20 +197,20 @@ public:
int cchSize = 1;
cch = ReadBytes( cchSize, true );
int xstzSize = FormatUtils::BytesToUChar( cch, 0, cchSize ) * 1;
int xstzSize = DocFormatUtils::FormatUtils::BytesToUChar( cch, 0, cchSize ) * 1;
xstz = ReadBytes(xstzSize, true);
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &wstrResult, xstz, xstzSize, ENCODING_WINDOWS_1250 );
DocFormatUtils::FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &wstrResult, xstz, xstzSize, ENCODING_WINDOWS_1250 );
}
else
{
int cchSize = 2;
cch = ReadBytes( cchSize, true );
int xstzSize = FormatUtils::BytesToInt16( cch, 0, cchSize ) * 2;
int xstzSize = DocFormatUtils::FormatUtils::BytesToInt16( cch, 0, cchSize ) * 2;
xstz = ReadBytes(xstzSize, true);
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &wstrResult, xstz, xstzSize, ENCODING_UTF16 );
DocFormatUtils::FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &wstrResult, xstz, xstzSize, ENCODING_UTF16 );
}
RELEASEARRAYOBJECTS(xstz);
@ -234,7 +234,7 @@ public:
//dont read the terminating zero
unsigned char* stringBytes = ReadBytes( ( cch * 2 ), true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &result, stringBytes, ( ( cch * 2 ) - 2 ), ENCODING_UTF16 );
DocFormatUtils::FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &result, stringBytes, ( ( cch * 2 ) - 2 ), ENCODING_UTF16 );
RELEASEARRAYOBJECTS( stringBytes );
}
@ -278,7 +278,7 @@ public:
//dont read the terminating zero
stringBytes = ReadBytes( cch, true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &result, stringBytes, ( cch - 1 ), ENCODING_WINDOWS_1250);
DocFormatUtils::FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &result, stringBytes, ( cch - 1 ), ENCODING_WINDOWS_1250);
}
RELEASEARRAYOBJECTS( stringBytes );

View File

@ -139,7 +139,7 @@ namespace DocFileFormat
if (encryptionHeader->bStandard)
{
CRYPT::RC4Decryptor Decryptor(encryptionHeader->crypt_data_rc4, m_sPassword, 1);
CRYPT::RC4Decryptor Decryptor(encryptionHeader->crypt_data_rc4, m_sPassword);
if (Decryptor.IsVerify() == false)
{
@ -153,24 +153,6 @@ namespace DocFileFormat
}
else
{
//POLE::Stream * pStream = NULL;
//if (m_pStorage->GetStream ("EncryptedSummaryInformation", &pStream))
//{
// VirtualStreamReader tStream( pStream, 0, FIB->m_bOlderVersion);
// _UINT32 StreamDescriptorArrayOffset = tStream.ReadUInt32();
// _UINT32 StreamDescriptorArraySize = tStream.ReadUInt32();
// for (int i = 0; i < StreamDescriptorArraySize; i++)
// {
// }
// _UINT32 EncryptedStreamDescriptorCount = tStream.ReadUInt32();
// for (int i = 0; i < EncryptedStreamDescriptorCount; i++)
// {
// }
// RELEASEOBJECT(pStream);
//}
CRYPT::ECMADecryptor Decryptor;
Decryptor.SetCryptData(encryptionHeader->crypt_data_aes);

View File

@ -3867,9 +3867,11 @@ public:
pMoveFromRangeStart->m_oColLast->SetValue(m_oBufferedStream.GetLong());
}
else if (c_oSerMoveRange::Date == type)
{
{
std::wstring strValue = m_oBufferedStream.GetString3(length);
pMoveFromRangeStart->m_oDate.Init();
pMoveFromRangeStart->m_oDate->SetValue(m_oBufferedStream.GetString3(length));
pMoveFromRangeStart->m_oDate->SetValue(strValue);
}
else if (c_oSerMoveRange::DisplacedByCustomXml == type)
{
@ -3915,9 +3917,11 @@ public:
pMoveToRangeStart->m_oColLast->SetValue(m_oBufferedStream.GetLong());
}
else if (c_oSerMoveRange::Date == type)
{
{
std::wstring strValue = m_oBufferedStream.GetString3(length);
pMoveToRangeStart->m_oDate.Init();
pMoveToRangeStart->m_oDate->SetValue(m_oBufferedStream.GetString3(length));
pMoveToRangeStart->m_oDate->SetValue(strValue);
}
else if (c_oSerMoveRange::DisplacedByCustomXml == type)
{

View File

@ -94,11 +94,11 @@ struct SFileIdCluster
}
};
#if !defined(_WIN32) && !defined (_WIN64)
typedef struct tagPOINT
{
long x;
long y;
} POINT;
typedef struct tagPOINT
{
long x;
long y;
} POINT;
typedef struct tagSIZE
{

View File

@ -70,10 +70,10 @@ CFRecord::CFRecord(CFStreamPtr stream, GlobalWorkbookInfoPtr global_info)
case rt_RRDHead:
break;
case rt_BoundSheet8:
global_info->decryptor->Decrypt(data_ + sizeof(unsigned int), size_ - sizeof(unsigned int), rec_data_pos + sizeof(unsigned int));
global_info->decryptor->Decrypt(data_ + sizeof(unsigned int), size_ - sizeof(unsigned int), rec_data_pos + sizeof(unsigned int), 1024);
break;
default:
global_info->decryptor->Decrypt(data_, size_, rec_data_pos);
global_info->decryptor->Decrypt(data_, size_, rec_data_pos, 1024);
break;
}
}

View File

@ -34,10 +34,8 @@
namespace CRYPT
{
BiffDecoderBase::BiffDecoderBase(int BLOCKSIZE) : mbValid(false)
BiffDecoderBase::BiffDecoderBase() : mbValid(false)
{
RCF_BLOCKSIZE = BLOCKSIZE;
}
@ -51,34 +49,29 @@ bool BiffDecoderBase::verifyPassword(const std::wstring& rPassword)
mbValid = implVerify(rPassword);
return mbValid;
}
void BiffDecoderBase::decode(unsigned char* pnDestData, const unsigned char* pnSrcData, const long nStreamPos, const unsigned short nBytes)
void BiffDecoderBase::decode(unsigned char* pnDestData, const unsigned char* pnSrcData, const unsigned short nBytes, const long block_index)
{
if(pnDestData && pnSrcData && (nBytes> 0))
{
if(mbValid)
implDecode(pnDestData, pnSrcData, nStreamPos, nBytes);
implDecode(pnDestData, pnSrcData, nBytes, block_index);
else
memcpy(pnDestData, pnSrcData, nBytes);
}}
void BiffDecoderBase::decode(unsigned char* pnDestData, const unsigned char* pnSrcData, const unsigned short nBytes, const long nStreamPos, const unsigned short block_size)
{
if(pnDestData && pnSrcData && (nBytes> 0))
{
if(mbValid)
implDecode(pnDestData, pnSrcData, nBytes, nStreamPos, block_size);
else
memcpy(pnDestData, pnSrcData, nBytes);
}
}
/** Returns the block index of the passed stream position for RCF decryption. */
int BiffDecoderBase::lclGetRcfBlock(long nStreamPos)
{
return static_cast<int>(nStreamPos / RCF_BLOCKSIZE);
}
/** Returns the offset of the passed stream position in a block for RCF decryption. */
int BiffDecoderBase::lclGetRcfOffset(long nStreamPos)
{
return static_cast<int>(nStreamPos % RCF_BLOCKSIZE);
}
BiffDecoder_RCF::BiffDecoder_RCF(unsigned char pnSalt[16], unsigned char pnVerifier[16], unsigned char pnVerifierHash[16], int BlockSize)
: BiffDecoderBase(BlockSize),
BiffDecoder_RCF::BiffDecoder_RCF(unsigned char pnSalt[16], unsigned char pnVerifier[16], unsigned char pnVerifierHash[16])
:
maPassword(16, 0),
maSalt(pnSalt, pnSalt + 16),
maVerifier(pnVerifier, pnVerifier + 16),
@ -107,28 +100,37 @@ bool BiffDecoder_RCF::implVerify(const std::wstring& rPassword)
}
return false;
}
void BiffDecoder_RCF::implDecode(unsigned char* pnDestData, const unsigned char* pnSrcData, const long nStreamPos, const unsigned short nBytes)
void BiffDecoder_RCF::implDecode(unsigned char* pnDestData, const unsigned char* pnSrcData, const unsigned short nBytes, const long block_index)
{
unsigned char* pnCurrDest = pnDestData;
const unsigned char* pnCurrSrc = pnSrcData;
long nCurrPos = nStreamPos;
unsigned short nBytesLeft = nBytes;
while(nBytesLeft> 0)
maCodec.startBlock(block_index);
maCodec.decode(pnDestData, pnSrcData, static_cast<int>(nBytes));
}
void BiffDecoder_RCF::implDecode(unsigned char* pnDestData, const unsigned char* pnSrcData, const unsigned short nBytes, const long nStreamPos, const unsigned short block_size)
{
unsigned char* pnCurrDest = pnDestData;
const unsigned char* pnCurrSrc = pnSrcData;
long nCurrPos = nStreamPos;
unsigned short nBytesLeft = nBytes;
while(nBytesLeft > 0)
{
// initialize codec for current stream position
maCodec.startBlock(lclGetRcfBlock(nCurrPos));
maCodec.skip(lclGetRcfOffset(nCurrPos));
maCodec.startBlock (nCurrPos / block_size);
const long offset = nCurrPos % block_size;
maCodec.skip (offset);
// decode the block
unsigned short nBlockLeft = static_cast<unsigned short>(get_BLOCKSIZE() - lclGetRcfOffset(nCurrPos));
unsigned short nBlockLeft = static_cast<unsigned short>(block_size - offset);
unsigned short nDecBytes = nBytesLeft < nBlockLeft ? nBytesLeft : nBlockLeft;
maCodec.decode(pnCurrDest, pnCurrSrc, static_cast<int>(nDecBytes));
// prepare for next block
pnCurrDest += nDecBytes;
pnCurrSrc += nDecBytes;
nCurrPos += nDecBytes;
pnCurrDest += nDecBytes;
pnCurrSrc += nDecBytes;
nCurrPos += nDecBytes;
nBytesLeft = nBytesLeft - nDecBytes;
}
}

View File

@ -44,12 +44,10 @@ namespace CRYPT
class BiffDecoderBase
{
public:
explicit BiffDecoderBase(int BLOCKSIZE);
explicit BiffDecoderBase();
virtual ~BiffDecoderBase();
int get_BLOCKSIZE(){return RCF_BLOCKSIZE;}
/** Implementation of the ::comphelper::IDocPasswordVerifier interface,
/** Implementation of the ::comphelper::IDocPasswordVerifier interface,
calls the new virtual function implVerify(). */
virtual bool verifyPassword( const std::wstring& rPassword );
@ -57,21 +55,18 @@ public:
inline bool isValid() const { return mbValid; }
/** Decodes nBytes unsigned chars and writes encrypted data into the buffer pnDestData. */
void decode(unsigned char* pnDestData, const unsigned char* pnSrcData, const long nStreamPos, const unsigned short nBytes);
int lclGetRcfBlock(long nStreamPos);
int lclGetRcfOffset(long nStreamPos);
virtual void decode(unsigned char* pnDestData, const unsigned char* pnSrcData, const unsigned short nBytes, const long nStreamPos, const unsigned short block_size);
virtual void decode(unsigned char* pnDestData, const unsigned char* pnSrcData, const unsigned short nBytes, const long block_index);
private:
int RCF_BLOCKSIZE;
/** Derived classes implement password verification and initialization of
the decoder. */
virtual bool implVerify(const std::wstring& rPassword) = 0;
/** Implementation of decryption of a memory block. */
virtual void implDecode(unsigned char* pnDestData, const unsigned char* pnSrcData, const long nStreamPos, const unsigned short nBytes) = 0;
virtual void implDecode(unsigned char* pnDestData, const unsigned char* pnSrcData, const unsigned short nBytes, const long nStreamPos, const unsigned short block_size) = 0;
virtual void implDecode(unsigned char* pnDestData, const unsigned char* pnSrcData, const unsigned short nBytes, const long block_index) = 0;
private:
bool mbValid; /// True = decoder is correctly initialized.
@ -83,7 +78,7 @@ typedef ::boost::shared_ptr<BiffDecoderBase> BiffDecoderRef;
class BiffDecoder_RCF : public BiffDecoderBase
{
public:
explicit BiffDecoder_RCF(unsigned char pnSalt[ 16 ], unsigned char pnVerifier[ 16 ], unsigned char pnVerifierHash[ 16 ], int BlockSize);
explicit BiffDecoder_RCF(unsigned char pnSalt[ 16 ], unsigned char pnVerifier[ 16 ], unsigned char pnVerifierHash[ 16 ]);
private:
@ -91,14 +86,14 @@ private:
virtual bool implVerify(const std::wstring& rPassword);
/** Implementation of decryption of a memory block. */
virtual void implDecode(unsigned char* pnDestData, const unsigned char* pnSrcData, const long nStreamPos, const unsigned short nBytes);
virtual void implDecode(unsigned char* pnDestData, const unsigned char* pnSrcData, const unsigned short nBytes, const long nStreamPos, const unsigned short block_size);
virtual void implDecode(unsigned char* pnDestData, const unsigned char* pnSrcData, const unsigned short nBytes, const long block_index);
private:
BinaryCodec_RCF maCodec; /// Cipher algorithm implementation.
BinaryCodec_RCF maCodec; /// Cipher algorithm implementation.
std::vector<unsigned short> maPassword;
std::vector<unsigned char> maSalt;
std::vector<unsigned char> maVerifier;
std::vector<unsigned char> maVerifierHash;
std::vector<unsigned char> maSalt;
std::vector<unsigned char> maVerifier;
std::vector<unsigned char> maVerifierHash;
};

View File

@ -143,7 +143,7 @@ public:
private:
CipherARCFOUR mhCipher;
DigestMD5 mhDigest;
unsigned char mpnDigestValue[DigestMD5::RTL_DIGEST_LENGTH_MD5];
unsigned char mpnDigestValue[DigestMD5::RTL_DIGEST_LENGTH_MD5];
};

View File

@ -68,8 +68,8 @@ namespace CRYPT
{
public:
virtual void Encrypt(char* data, const size_t size) = 0;
virtual void Decrypt(char* data, const size_t size, const unsigned long stream_pos) = 0;
virtual void Decrypt(char* data, const size_t size, const unsigned long stream_pos, const size_t block_size) = 0;
virtual void Decrypt(char* data, const size_t size, const unsigned long block_index) = 0;
typedef enum
{

View File

@ -37,18 +37,20 @@
namespace CRYPT
{
RC4Decryptor::RC4Decryptor(_rc4CryptData & header, std::wstring _password, int _type) :
crypt(new RC4Crypt(header, _password, _type))
RC4Decryptor::RC4Decryptor(_rc4CryptData & header, std::wstring _password) :
crypt(new RC4Crypt(header, _password))
{
crypt_data = header;
type = _type;
}
void RC4Decryptor::Decrypt(char* data, const size_t size, const unsigned long stream_pos)
void RC4Decryptor::Decrypt(char* data, const size_t size, const unsigned long stream_pos, const size_t block_size)
{
crypt->Decrypt(data, size, stream_pos);
crypt->Decrypt(data, size, stream_pos, block_size);
}
void RC4Decryptor::Decrypt(char* data, const size_t size, const unsigned long block_index)
{
crypt->Decrypt(data, size, block_index);
}
bool RC4Decryptor::IsVerify()
{
return crypt->IsVerify();
@ -57,7 +59,7 @@ namespace CRYPT
bool RC4Decryptor::SetPassword(std::wstring password)
{
crypt.reset();
crypt = CryptPtr(new RC4Crypt(crypt_data, password, type));
crypt = CryptPtr(new RC4Crypt(crypt_data, password));
if (crypt) return crypt->IsVerify();
else return false;

View File

@ -40,15 +40,16 @@ namespace CRYPT
class RC4Decryptor : public Decryptor
{
public:
RC4Decryptor(_rc4CryptData & header, std::wstring password, int type);
RC4Decryptor(_rc4CryptData & header, std::wstring password);
virtual void Decrypt(char* data, const size_t size, const unsigned long stream_pos);
virtual void Decrypt(char* data, const size_t size, const unsigned long stream_pos, const size_t block_size);
virtual void Decrypt(char* data, const size_t size, const unsigned long block_index);
virtual bool SetPassword(std::wstring password);
virtual bool IsVerify();
private:
int type;
CryptPtr crypt;
_rc4CryptData crypt_data;
};

View File

@ -38,7 +38,7 @@
namespace CRYPT
{
RC4Crypt::RC4Crypt(CRYPT::_rc4CryptData & data, std::wstring password, int type)
RC4Crypt::RC4Crypt(CRYPT::_rc4CryptData & data, std::wstring password)
{
m_VerifyPassword = false;
@ -46,18 +46,11 @@ RC4Crypt::RC4Crypt(CRYPT::_rc4CryptData & data, std::wstring password, int type)
CopyDWORDs2Bytes(data.EncryptedVerifier.b1 , data.EncryptedVerifier.b2, data.EncryptedVerifier.b3, data.EncryptedVerifier.b4, pnVerifier);
CopyDWORDs2Bytes(data.EncryptedVerifierHash.b1, data.EncryptedVerifierHash.b2, data.EncryptedVerifierHash.b3, data.EncryptedVerifierHash.b4, pnVerifierHash);
int BlockSize = 1024;
if (type == 1) BlockSize = 512;
mxDecoder.reset(new BiffDecoder_RCF(pnSalt, pnVerifier, pnVerifierHash, BlockSize));
mxDecoder.reset(new BiffDecoder_RCF(pnSalt, pnVerifier, pnVerifierHash));
m_VerifyPassword = mxDecoder->verifyPassword(password);
}
void RC4Crypt::Encrypt(char* data, const size_t size)
{
}
bool RC4Crypt::IsVerify()
{
@ -87,18 +80,33 @@ void RC4Crypt::CopyDWORDs2Bytes(const unsigned int b1, const unsigned int b2, co
byte_array[15] = static_cast<unsigned char>((b4 & 0xff000000) >> 24);
}
void RC4Crypt::Decrypt(char* data, const size_t size, const unsigned long stream_pos)
void RC4Crypt::Decrypt(char* data, const size_t size, const unsigned long block_index)
{
static unsigned char quick_buf[256];
if(size <= 256)
{
mxDecoder->decode( quick_buf, reinterpret_cast<unsigned char*>(data), stream_pos, size );
static unsigned char quick_buf[256];
mxDecoder->decode( quick_buf, reinterpret_cast<unsigned char*>(data), size, block_index );
memcpy(data, quick_buf, size);
}
else
{
boost::scoped_array<unsigned char> out_data(new unsigned char[size]);
mxDecoder->decode( out_data.get(), reinterpret_cast<unsigned char*>(data), stream_pos, size );
mxDecoder->decode( out_data.get(), reinterpret_cast<unsigned char*>(data), size, block_index );
memcpy(data, out_data.get(), size);
}
}
void RC4Crypt::Decrypt(char* data, const size_t size, const unsigned long stream_pos, const size_t block_size)
{
if(size <= 256)
{
static unsigned char quick_buf[256];
mxDecoder->decode( quick_buf, reinterpret_cast<unsigned char*>(data), size, stream_pos, block_size );
memcpy(data, quick_buf, size);
}
else
{
boost::scoped_array<unsigned char> out_data(new unsigned char[size]);
mxDecoder->decode( out_data.get(), reinterpret_cast<unsigned char*>(data), size, stream_pos, block_size );
memcpy(data, out_data.get(), size);
}
}

View File

@ -41,10 +41,10 @@ namespace CRYPT
class RC4Crypt : public Crypt
{
public:
RC4Crypt(CRYPT::_rc4CryptData & data, std::wstring password, int type);
RC4Crypt(CRYPT::_rc4CryptData & data, std::wstring password);
virtual void Encrypt(char* data, const size_t size);
virtual void Decrypt(char* data, const size_t size, const unsigned long stream_pos);
virtual void Decrypt(char* data, const size_t size, const unsigned long stream_pos, const size_t block_size);
virtual void Decrypt(char* data, const size_t size, const unsigned long block_index);
virtual bool IsVerify();

View File

@ -52,9 +52,9 @@ BaseObjectPtr ExtString::clone()
void ExtString::readFields(CFRecord& record)
{
#pragma message("####################### ExtString record is not implemented")
Log::error("ExtString record is not implemented.");
//record >> some_value;
record >> frtHeaderOld >> string;
record.skipNunBytes(record.getDataSize() - record.getRdPtr());
}
} // namespace XLS

View File

@ -32,12 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include "../Biff_structures/FrtHeaderOld.h"
#include "../Biff_structures/BiffString.h"
namespace XLS
{
// Logical representation of ExtString record in BIFF8
class ExtString: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(ExtString)
@ -47,12 +47,13 @@ public:
~ExtString();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeExtString;
static const ElementType type = typeExtString;
FrtHeaderOld frtHeaderOld;
XLUnicodeString string;
};

View File

@ -55,13 +55,14 @@ void ExternName::readFields(CFRecord& record)
{
unsigned short flags;
record >> flags;
fBuiltIn = GETBIT(flags, 0);
fBuiltIn = GETBIT(flags, 0);
fWantAdvise = GETBIT(flags, 1);
fWantPict = GETBIT(flags, 2);
fOle = GETBIT(flags, 3);
fOleLink = GETBIT(flags, 4);
cf = GETBITS(flags, 5, 14);
fIcon = GETBIT(flags, 15);
fWantPict = GETBIT(flags, 2);
fOle = GETBIT(flags, 3);
fOleLink = GETBIT(flags, 4);
cf = GETBITS(flags, 5, 14);
fIcon = GETBIT(flags, 15);
if(0x3A01 == supbook_cch) // UDF reference on a XLL or COM add-in.
{
@ -69,9 +70,6 @@ void ExternName::readFields(CFRecord& record)
}
else
{
#pragma message("####################### ExternName record is not implemented")
Log::error("ExternName record is not implemented.");
if(fOle && !fOleLink) // DDE data item
{
body = BiffStructurePtr(new ExternDdeLinkNoOper);

View File

@ -79,7 +79,7 @@ void FilePass::readFields(CFRecord& record)
if (cryptHeaderPtr->bStandard)
{
record.getGlobalWorkbookInfo()->decryptor =
CRYPT::DecryptorPtr(new CRYPT::RC4Decryptor(cryptHeaderPtr->crypt_data_rc4, record.getGlobalWorkbookInfo()->password, 2));
CRYPT::DecryptorPtr(new CRYPT::RC4Decryptor(cryptHeaderPtr->crypt_data_rc4, record.getGlobalWorkbookInfo()->password));
}
else
{

View File

@ -52,9 +52,7 @@ BaseObjectPtr FnGrp12::clone()
void FnGrp12::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
record >> astFnGrp;
record >> frtHeader >> astFnGrp;
}
} // namespace XLS

View File

@ -32,13 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/BiffString.h>
#include "../Biff_structures/BiffString.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of FnGrp12 record in BIFF8
class FnGrp12: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(FnGrp12)
@ -48,14 +47,14 @@ public:
~FnGrp12();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeFnGrp12;
static const ElementType type = typeFnGrp12;
//-----------------------------
XLUnicodeString astFnGrp;
FrtHeader frtHeader;
};

View File

@ -52,11 +52,8 @@ BaseObjectPtr ForceFullCalculation::clone()
void ForceFullCalculation::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
_UINT32 temp;
record >> temp;
record >> frtHeader >> temp;
fNoDeps = temp;
}

View File

@ -32,12 +32,11 @@
#pragma once
#include "BiffRecord.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of ForceFullCalculation record in BIFF8
class ForceFullCalculation: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(ForceFullCalculation)
@ -51,10 +50,11 @@ public:
void readFields(CFRecord& record);
static const ElementType type = typeForceFullCalculation;
static const ElementType type = typeForceFullCalculation;
//-----------------------------
bool fNoDeps;
bool fNoDeps;
FrtHeader frtHeader;
};

View File

@ -52,10 +52,9 @@ BaseObjectPtr GUIDTypeLib::clone()
void GUIDTypeLib::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
_GUID_ guid_num;
record >> guid_num;
record >> frtHeader >> guid_num;
guid = STR::guid2bstr(guid_num);
}

View File

@ -32,12 +32,11 @@
#pragma once
#include "BiffRecord.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of GUIDTypeLib record in BIFF8
class GUIDTypeLib: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(GUIDTypeLib)
@ -47,16 +46,14 @@ public:
~GUIDTypeLib();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeGUIDTypeLib;
static const ElementType type = typeGUIDTypeLib;
//-----------------------------
std::wstring guid;
std::wstring guid;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -52,8 +52,8 @@ BaseObjectPtr MDB::clone()
void MDB::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
record >> frtHeader;
while(!record.isEOF())
{
MDirPtr element(new MDir);

View File

@ -32,13 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/MDir.h>
#include "../Biff_structures/MDir.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of MDB record in BIFF8
class MDB: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(MDB)
@ -48,11 +47,11 @@ public:
~MDB();
BaseObjectPtr clone();
void readFields(CFRecord& record);
//-----------------------------
BiffStructurePtrVector rgmdir;
BiffStructurePtrVector rgmdir;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -52,11 +52,9 @@ BaseObjectPtr MDTInfo::clone()
void MDTInfo::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
_UINT32 flags;
record >> flags;
record >> frtHeader >> flags;
fGhostRow = GETBIT(flags, 0);
fGhostCol = GETBIT(flags, 1);

View File

@ -32,13 +32,13 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/BiffString.h>
#include "../Biff_structures/BiffString.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of MDTInfo record in BIFF8
class MDTInfo: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(MDTInfo)
@ -48,7 +48,6 @@ public:
~MDTInfo();
BaseObjectPtr clone();
void readFields(CFRecord& record);
//-----------------------------
@ -79,7 +78,8 @@ public:
bool fAdjust;
bool fCellMeta;
LPWideString stName;
LPWideString stName;
FrtHeader frtHeader;
};

View File

@ -52,9 +52,7 @@ BaseObjectPtr MDXKPI::clone()
void MDXKPI::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
record >> istrConnName >> tfnSrc >> kpiprop >> istrKPIName >> istrMbrKPI;
record >> frtHeader >> istrConnName >> tfnSrc >> kpiprop >> istrKPIName >> istrMbrKPI;
}
} // namespace XLS

View File

@ -32,12 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of MDXKPI record in BIFF8
class MDXKPI: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(MDXKPI)
@ -47,7 +47,6 @@ public:
~MDXKPI();
BaseObjectPtr clone();
void readFields(CFRecord& record);
//-----------------------------
@ -56,6 +55,7 @@ public:
unsigned char kpiprop;
_INT32 istrKPIName;
_INT32 istrMbrKPI;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -50,12 +50,9 @@ BaseObjectPtr MDXProp::clone()
return BaseObjectPtr(new MDXProp(*this));
}
void MDXProp::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
record >> istrConnName >> tfnSrc >> istrMbr >> istrProp;
record >> frtHeader >> istrConnName >> tfnSrc >> istrMbr >> istrProp;
}
} // namespace XLS

View File

@ -32,12 +32,11 @@
#pragma once
#include "BiffRecord.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of MDXProp record in BIFF8
class MDXProp: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(MDXProp)
@ -47,14 +46,14 @@ public:
~MDXProp();
BaseObjectPtr clone();
void readFields(CFRecord& record);
//-----------------------------
_INT32 istrConnName;
_INT32 istrConnName;
unsigned char tfnSrc;
_UINT32 istrMbr;
_UINT32 istrProp;
_UINT32 istrMbr;
_UINT32 istrProp;
FrtHeader frtHeader;
};

View File

@ -50,12 +50,10 @@ BaseObjectPtr MDXSet::clone()
return BaseObjectPtr(new MDXSet(*this));
}
void MDXSet::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
record >> istrConnName >> tfnSrc >> sso >> istrSetDef >> cistr;
record >> frtHeader >> istrConnName >> tfnSrc >> sso >> istrSetDef >> cistr;
while(!record.isEOF())
{
MDXStrIndexPtr element(new MDXStrIndex);

View File

@ -32,13 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/MDXStrIndex.h>
#include "../Biff_structures/MDXStrIndex.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of MDXSet record in BIFF8
class MDXSet: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(MDXSet)
@ -48,16 +47,16 @@ public:
~MDXSet();
BaseObjectPtr clone();
void readFields(CFRecord& record);
//-----------------------------
_INT32 istrConnName;
unsigned char tfnSrc;
unsigned char sso;
_UINT32 istrSetDef;
_INT32 cistr;
BiffStructurePtrVector rgistr;
_INT32 istrConnName;
unsigned char tfnSrc;
unsigned char sso;
_UINT32 istrSetDef;
_INT32 cistr;
BiffStructurePtrVector rgistr;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -50,12 +50,9 @@ BaseObjectPtr MDXStr::clone()
return BaseObjectPtr(new MDXStr(*this));
}
void MDXStr::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
record >> st;
record >> frtHeader >> st;
}
} // namespace XLS

View File

@ -32,13 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/BiffString.h>
#include "../Biff_structures/BiffString.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of MDXStr record in BIFF8
class MDXStr: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(MDXStr)
@ -52,7 +51,8 @@ public:
void readFields(CFRecord& record);
//-----------------------------
LPWideString st;
LPWideString st;
FrtHeader frtHeader;
};

View File

@ -50,12 +50,10 @@ BaseObjectPtr MDXTuple::clone()
return BaseObjectPtr(new MDXTuple(*this));
}
void MDXTuple::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
record >> istrConnName >> tfnSrc >> cistr;
record >> frtHeader >> istrConnName >> tfnSrc >> cistr;
while(!record.isEOF())
{
MDXStrIndexPtr element(new MDXStrIndex);

View File

@ -32,13 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/MDXStrIndex.h>
#include "../Biff_structures/MDXStrIndex.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of MDXTuple record in BIFF8
class MDXTuple: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(MDXTuple)
@ -48,18 +47,17 @@ public:
~MDXTuple();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeMDXTuple;
//-----------------------------
_INT32 istrConnName;
unsigned char tfnSrc;
_INT32 cistr;
BiffStructurePtrVector rgistr;
_INT32 istrConnName;
unsigned char tfnSrc;
_INT32 cistr;
BiffStructurePtrVector rgistr;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -44,7 +44,6 @@ NameFnGrp12::~NameFnGrp12()
{
}
BaseObjectPtr NameFnGrp12::clone()
{
return BaseObjectPtr(new NameFnGrp12(*this));
@ -52,9 +51,7 @@ BaseObjectPtr NameFnGrp12::clone()
void NameFnGrp12::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
record >> cachName >> fgrp >> rgach;
record >> frtHeader >> cachName >> fgrp >> rgach;
}
} // namespace XLS

View File

@ -32,13 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/BiffString.h>
#include "../Biff_structures/BiffString.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of NameFnGrp12 record in BIFF8
class NameFnGrp12: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(NameFnGrp12)
@ -48,15 +47,14 @@ public:
~NameFnGrp12();
BaseObjectPtr clone();
void readFields(CFRecord& record);
//-----------------------------
_UINT16 cachName;
_UINT16 fgrp;
_UINT16 cachName;
_UINT16 fgrp;
XLUnicodeString rgach;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -44,7 +44,6 @@ NamePublish::~NamePublish()
{
}
BaseObjectPtr NamePublish::clone()
{
return BaseObjectPtr(new NamePublish(*this));
@ -52,10 +51,10 @@ BaseObjectPtr NamePublish::clone()
void NamePublish::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
unsigned short flags;
record >> flags >> strName;
record >> frtHeader >> flags >> strName;
fPublished = GETBIT(flags, 0);
fWorkbookParam = GETBIT(flags, 0);
}

View File

@ -32,13 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/BiffString.h>
#include "../Biff_structures/BiffString.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of NamePublish record in BIFF8
class NamePublish: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(NamePublish)
@ -48,17 +47,17 @@ public:
~NamePublish();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeNamePublish;
//-----------------------------
bool fPublished;
bool fWorkbookParam;
bool fPublished;
bool fWorkbookParam;
XLUnicodeString strName;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -39,7 +39,6 @@ SortData::SortData()
{
}
SortData::~SortData()
{
}
@ -51,11 +50,9 @@ BaseObjectPtr SortData::clone()
void SortData::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
unsigned short flags;
record >> flags;
record >> frtHeader >> flags;
fCol = GETBIT(flags, 0);
fCaseSensitive = GETBIT(flags, 1);

View File

@ -32,8 +32,9 @@
#pragma once
#include "BiffRecordContinued.h"
#include <Logic/Biff_structures/CellRangeRef.h>
#include <Logic/Biff_structures/SortCond12.h>
#include "../Biff_structures/CellRangeRef.h"
#include "../Biff_structures/SortCond12.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
@ -60,7 +61,8 @@ public:
BIFF_DWORD cconditions;
BIFF_DWORD idParent;
BiffStructurePtrVector sortCond12Array;
BiffStructurePtrVector sortCond12Array;
FrtHeader frtHeader;
//-----------------------------
std::wstring rfx;

View File

@ -52,15 +52,14 @@ BaseObjectPtr StyleExt::clone()
void StyleExt::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
unsigned char flags;
record >> flags;
record >> frtHeader >> flags;
fBuiltIn = GETBIT(flags, 0);
fHidden = GETBIT(flags, 1);
fCustom = GETBIT(flags, 2);
stName.setSize(0xff); //max size
record >> iCategory>> builtInData >> stName >> xfProps;
}

View File

@ -32,9 +32,11 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/BuiltInStyle.h>
#include <Logic/Biff_structures/BiffString.h>
#include <Logic/Biff_structures/XFProps.h>
#include "../Biff_structures/BuiltInStyle.h"
#include "../Biff_structures/XFProps.h"
#include "../Biff_structures/BiffString.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
@ -67,6 +69,8 @@ public:
BuiltInStyle builtInData;
LPWideString stName;
XFProps xfProps;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -52,12 +52,13 @@ BaseObjectPtr TableStyle::clone()
void TableStyle::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
unsigned short flags;
record >> flags;
record >> frtHeader >> flags;
fIsPivot = GETBIT(flags, 1);
fIsTable = GETBIT(flags, 2);
unsigned short cchName;
record >> ctse >> cchName;
rgchName.setSize(cchName);

View File

@ -32,13 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/BiffString.h>
#include "../Biff_structures/BiffString.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of TableStyle record in BIFF8
class TableStyle: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(TableStyle)
@ -49,18 +48,16 @@ public:
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeTableStyle;
//-----------------------------
bool fIsPivot;
bool fIsTable;
_UINT32 ctse;
LPWideStringNoCch rgchName;
bool fIsPivot;
bool fIsTable;
_UINT32 ctse;
LPWideStringNoCch rgchName;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -39,23 +39,18 @@ TableStyleElement::TableStyleElement()
{
}
TableStyleElement::~TableStyleElement()
{
}
BaseObjectPtr TableStyleElement::clone()
{
return BaseObjectPtr(new TableStyleElement(*this));
}
void TableStyleElement::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
record >> tseType >> size >> index;
record >> frtHeader >> tseType >> size >> index;
}
} // namespace XLS

View File

@ -32,12 +32,11 @@
#pragma once
#include "BiffRecord.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of TableStyleElement record in BIFF8
class TableStyleElement: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(TableStyleElement)
@ -47,17 +46,16 @@ public:
~TableStyleElement();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeTableStyleElement;
//-----------------------------
_UINT32 tseType;
_UINT32 size;
_UINT32 index;
_UINT32 tseType;
_UINT32 size;
_UINT32 index;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -39,12 +39,10 @@ TableStyles::TableStyles()
{
}
TableStyles::~TableStyles()
{
}
BaseObjectPtr TableStyles::clone()
{
return BaseObjectPtr(new TableStyles(*this));
@ -52,12 +50,9 @@ BaseObjectPtr TableStyles::clone()
void TableStyles::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
unsigned short cchDefTableStyle;
unsigned short cchDefPivotStyle;
record >> cts >> cchDefTableStyle >> cchDefPivotStyle;
record >> frtHeader >> cts >> cchDefTableStyle >> cchDefPivotStyle;
rgchDefTableStyle.setSize(cchDefTableStyle);
rgchDefPivotStyle.setSize(cchDefPivotStyle);

View File

@ -32,12 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/BiffString.h>
#include "../Biff_structures/BiffString.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of TableStyles record in BIFF8
class TableStyles: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(TableStyles)
@ -50,13 +50,13 @@ public:
void readFields(CFRecord& record);
static const ElementType type = typeTableStyles;
static const ElementType type = typeTableStyles;
//-----------------------------
_UINT32 cts;
LPWideStringNoCch rgchDefTableStyle;
LPWideStringNoCch rgchDefPivotStyle;
_UINT32 cts;
LPWideStringNoCch rgchDefTableStyle;
LPWideStringNoCch rgchDefPivotStyle;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -41,12 +41,10 @@ Theme::Theme()
{
}
Theme::~Theme()
{
}
BaseObjectPtr Theme::clone()
{
return BaseObjectPtr(new Theme(*this));
@ -54,9 +52,7 @@ BaseObjectPtr Theme::clone()
void Theme::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
record >> dwThemeVersion;
record >> frtHeader >> dwThemeVersion;
if(!dwThemeVersion)
{

View File

@ -32,12 +32,11 @@
#pragma once
#include "BiffRecord.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of Theme record in BIFF8
class Theme: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(Theme)
@ -53,9 +52,8 @@ public:
static const ElementType type = typeTheme;
//-----------------------------
_UINT32 dwThemeVersion;
//std::wstring rgb;
_UINT32 dwThemeVersion;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -39,12 +39,10 @@ XFCRC::XFCRC()
{
}
XFCRC::~XFCRC()
{
}
BaseObjectPtr XFCRC::clone()
{
return BaseObjectPtr(new XFCRC(*this));
@ -52,8 +50,7 @@ BaseObjectPtr XFCRC::clone()
void XFCRC::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
record >> frtHeader;
record.skipNunBytes(2); // reserved
record >> cxfs >> crc;
}

View File

@ -32,12 +32,11 @@
#pragma once
#include "BiffRecord.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of XFCRC record in BIFF8
class XFCRC: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(XFCRC)
@ -50,12 +49,12 @@ public:
void readFields(CFRecord& record);
static const ElementType type = typeXFCRC;
static const ElementType type = typeXFCRC;
//-----------------------------
_UINT16 cxfs;
_UINT32 crc;
_UINT16 cxfs;
_UINT32 crc;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -39,12 +39,10 @@ XFExt::XFExt()
{
}
XFExt::~XFExt()
{
}
BaseObjectPtr XFExt::clone()
{
return BaseObjectPtr(new XFExt(*this));
@ -52,8 +50,7 @@ BaseObjectPtr XFExt::clone()
void XFExt::readFields(CFRecord& record)
{
record.skipNunBytes(12);
#pragma message(">>>>>>>>>>> frtHeader skipped here")
record >> frtHeader;
record.skipNunBytes(2); // reserved
record >> ixfe;
record.skipNunBytes(2); // reserved

View File

@ -32,13 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/ExtProp.h>
#include "../Biff_structures/ExtProp.h"
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{
// Logical representation of XFExt record in BIFF8
class XFExt: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(XFExt)
@ -51,13 +50,13 @@ public:
void readFields(CFRecord& record);
static const ElementType type = typeXFExt;
static const ElementType type = typeXFExt;
//-----------------------------
_UINT16 ixfe;
_UINT16 cexts;
BiffStructurePtrVector rgExt;
FrtHeader frtHeader;
};
} // namespace XLS

View File

@ -49,8 +49,6 @@ public:
virtual void load(CFRecord& record);
unsigned char fDefault;
unsigned char fHelp;
unsigned char fCancel;

View File

@ -125,33 +125,34 @@ void RC4EncryptionHeader::load(XLS::CFRecord& record)
pos = record.getRdPtr();
//------------------------------------------------------------------------------------------
crypt_data_aes.hashAlgorithm = CRYPT_METHOD::SHA1; //by AlgIDHash -> 0x0000(reserved ??) || 0x8004(sha1)
crypt_data_aes.spinCount = 50000;
switch(AlgIDHash)
{
case 0x8003: crypt_data_aes.hashAlgorithm = CRYPT_METHOD::MD5; break;
case 0x0000:
case 0x8004: crypt_data_aes.hashAlgorithm = CRYPT_METHOD::SHA1; break;
}
crypt_data_aes.spinCount = 0;
switch(AlgID)
{
case 0x6801:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4;
crypt_data_aes.keySize = KeySize / 8;
break;
case 0x660E:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
crypt_data_aes.keySize = 128 /8;
break;
case 0x660F:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
crypt_data_aes.keySize = 192 /8;
break;
case 0x6610:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
crypt_data_aes.keySize = 256 /8;
break;
}
switch(ProviderType)
{
case 0x0001: crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4; break;
case 0x0018: crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB; break;
case 0x6801:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4;
crypt_data_aes.keySize = KeySize / 8;
if (crypt_data_aes.keySize == 0)crypt_data_aes.keySize = 5; // 40 bit
break;
case 0x660E:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
crypt_data_aes.keySize = 128 /8;
break;
case 0x660F:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
crypt_data_aes.keySize = 192 /8;
break;
case 0x6610:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
crypt_data_aes.keySize = 256 /8;
break;
}
}
}

View File

@ -33,7 +33,7 @@
#include "BiffStructure.h"
#include <Logic/Biff_structures/BitMarkedStructs.h>
#include "../../Crypt/Crypt.h"
#include "../../Crypt/RC4Crypt.h"
namespace CRYPTO
{

View File

@ -134,7 +134,10 @@ void XFProp::load(CFRecord& record)
// EXCEPT::RT::WrongBiffRecord("Unsupported type of XFProp.", record.getTypeString());
break;
}
record >> *xfPropDataBlob;
if (xfPropDataBlob)
{
record >> *xfPropDataBlob;
}
}
static void serialize_color_prop(std::wostream & stream, const std::wstring & name, BiffStructurePtr & val)
{

View File

@ -530,7 +530,11 @@ void XlsConverter::convert(XLS::FORMATTING* formating)
CP_XML_NODE(L"styleSheet")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_ATTR(L"mc:Ignorable", L"x14ac x16r2");
CP_XML_ATTR(L"xmlns:x14ac", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac");
CP_XML_ATTR(L"xmlns:x16r2", L"http://schemas.microsoft.com/office/spreadsheetml/2015/02/main");
formating->serialize1(CP_XML_STREAM()); //важен порядок в styles
CP_XML_NODE(L"fills")

View File

@ -6202,10 +6202,6 @@
RelativePath="..\XlsFormat\Crypt\BinaryCodec_RCF.h"
>
</File>
<File
RelativePath="..\XlsFormat\Crypt\Crypt.h"
>
</File>
<File
RelativePath="..\XlsFormat\Crypt\Decryptor.cpp"
>

View File

@ -513,16 +513,75 @@ void ECMADecryptor::SetCryptData(_ecmaCryptData & data)
}
void ECMADecryptor::Decrypt(char* data , const size_t size, const unsigned long start_iv_block)
{
if (bVerify)
if (!bVerify) return;
unsigned char* data_out = NULL;
Decrypt((unsigned char*)data, size, data_out, start_iv_block);
if (data_out)
{
unsigned char* data_out = NULL;
Decrypt((unsigned char*)data, size, data_out, start_iv_block);
if (data_out)
memcpy(data, data_out, size);
delete []data_out;
}
}
void ECMADecryptor::Decrypt(char* data , const size_t size, const unsigned long stream_pos, const size_t block_size)
{
if (!bVerify) return;
//rc4 only
if (cryptData.cipherAlgorithm != CRYPT_METHOD::RC4) return;
unsigned char* data_out = new unsigned char[size];
unsigned char* pnCurrDest = data_out;
const unsigned char* pnCurrSrc = (unsigned char* )data;
long nCurrPos = stream_pos;
unsigned short nBytesLeft = size;
while(nBytesLeft > 0)
{
// initialize codec for current stream position
int block_index = (nCurrPos / block_size);
{
memcpy(data, data_out, size);
delete []data_out;
_buf pPassword (password);
_buf pSalt (cryptData.saltValue);
_buf hashKey = GenerateHashKey(pSalt, pPassword, cryptData.hashSize, cryptData.spinCount, cryptData.hashAlgorithm, block_index);
CorrectHashSize(hashKey, cryptData.keySize, 0);
if (cryptData.keySize == 5) CorrectHashSize(hashKey, 16, 0); //40-bit crypt key !!!
rc4Decryption.SetKey(hashKey.ptr, hashKey.size);
}
const long offset = nCurrPos % block_size;
{//skip
unsigned char pnDummy[ 1024 ];
size_t nBytesLeft = offset;
bool bResult = true;
while(bResult && (nBytesLeft > 0))
{
size_t nBlockLen = nBytesLeft < sizeof(pnDummy) ? nBytesLeft : sizeof(pnDummy);
rc4Decryption.ProcessData(pnDummy, pnDummy, nBlockLen);
nBytesLeft -= nBlockLen;
}
}
unsigned short nBlockLeft = static_cast<unsigned short>(block_size - offset);
unsigned short nDecBytes = nBytesLeft < nBlockLeft ? nBytesLeft : nBlockLeft;
rc4Decryption.ProcessData(pnCurrDest, pnCurrSrc, static_cast<int>(nDecBytes));
pnCurrDest += nDecBytes;
pnCurrSrc += nDecBytes;
nCurrPos += nDecBytes;
nBytesLeft = nBytesLeft - nDecBytes;
}
if (data_out)
{
memcpy(data, data_out, size);
delete []data_out;
}
}
bool ECMADecryptor::CheckDataIntegrity(unsigned char* data, int size)
@ -564,7 +623,8 @@ bool ECMADecryptor::CheckDataIntegrity(unsigned char* data, int size)
return (hmac == expected);
}
void ECMADecryptor::Decrypt(unsigned char* data_inp, int size, unsigned char*& data_out, int start_iv_block)
void ECMADecryptor::Decrypt(unsigned char* data_inp, int size, unsigned char*& data_out, unsigned long start_iv_block)
{
data_out = new unsigned char[size];

View File

@ -62,7 +62,8 @@ namespace CRYPT
class Decryptor
{
public:
virtual void Decrypt(char* data, const size_t size, const unsigned long stream_pos) = 0;
virtual void Decrypt(char* data, const size_t size, const unsigned long stream_pos, const size_t block_size) = 0;
virtual void Decrypt(char* data, const size_t size, const unsigned long block_index) = 0;
virtual bool SetPassword(std::wstring password) = 0;
virtual bool IsVerify() = 0;
@ -128,9 +129,10 @@ public:
ECMADecryptor();
virtual ~ECMADecryptor();
void Decrypt (unsigned char* data, int size, unsigned char*& data_out, int start_iv_block = 0);
virtual void Decrypt (char* data, const size_t size, const unsigned long stream_pos, const size_t block_size);
virtual void Decrypt (char* data, const size_t size, const unsigned long start_iv_block);
virtual bool SetPassword (std::wstring password);
virtual bool IsVerify();
@ -138,6 +140,8 @@ public:
void SetCryptData(_ecmaCryptData &data);
void Decrypt (unsigned char* data, int size, unsigned char*& data_out, unsigned long start_iv_block);
private:
std::wstring password;

View File

@ -565,26 +565,26 @@ bool ECMACryptFile::EncryptOfficeFile(std::wstring file_name_inp, std::wstring f
pStorage->close();
delete pStorage;
//test back---------------------------------------------------------------------------------test back
ECMADecryptor decryptor;
decryptor.SetCryptData(cryptData);
if (decryptor.SetPassword(password))
{
unsigned char* data_out2 = NULL;
decryptor.Decrypt(data_out, lengthData, data_out2);
bool bDataIntegrity = decryptor.CheckDataIntegrity(data_out, lengthData);
NSFile::CFileBinary test;
test.CreateFileW(file_name_out + L"-back.oox");
test.WriteFile(data_out2, lengthFileSize);
test.CloseFile();
}
//test back---------------------------------------------------------------------------------test back
//
////test back---------------------------------------------------------------------------------test back
// ECMADecryptor decryptor;
//
// decryptor.SetCryptData(cryptData);
//
// if (decryptor.SetPassword(password))
// {
// unsigned char* data_out2 = NULL;
// decryptor.Decrypt(data_out, lengthData, data_out2, 0);
//
// bool bDataIntegrity = decryptor.CheckDataIntegrity(data_out, lengthData);
//
// NSFile::CFileBinary test;
//
// test.CreateFileW(file_name_out + L"-back.oox");
// test.WriteFile(data_out2, lengthFileSize);
// test.CloseFile();
// }
////test back---------------------------------------------------------------------------------test back
return true;
}
@ -717,7 +717,7 @@ bool ECMACryptFile::DecryptOfficeFile(std::wstring file_name_inp, std::wstring f
lengthData = *((_UINT64*)data);
decryptor.Decrypt(data + 8, readData, data_out);//todoo сделать покусочное чтение декриптование
decryptor.Decrypt(data + 8, readData, data_out, 0);//todoo сделать покусочное чтение декриптование
if (data_out)
{

View File

@ -7,7 +7,7 @@
QT -= core
QT -= gui
VERSION = 2.4.465.0
VERSION = 2.4.466.0
DEFINES += INTVER=$$VERSION
TARGET = x2t