Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
4015e8ba
Commit
4015e8ba
authored
Jun 24, 2017
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PptFormatReader - decrypt ppt images
parent
276af556
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
196 additions
and
174 deletions
+196
-174
ASCOfficeDocFile/DocDocxConverter/EncryptionHeader.cpp
ASCOfficeDocFile/DocDocxConverter/EncryptionHeader.cpp
+2
-1
ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfo.h
ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfo.h
+3
-1
ASCOfficePPTFile/PPTFormatLib/Reader/PPTFileReader.cpp
ASCOfficePPTFile/PPTFormatLib/Reader/PPTFileReader.cpp
+8
-13
ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp
ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp
+23
-12
ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h
ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h
+5
-1
ASCOfficePPTFile/PPTFormatLib/Records/CryptSession10Container.h
...icePPTFile/PPTFormatLib/Records/CryptSession10Container.h
+2
-0
ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp
ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp
+153
-146
No files found.
ASCOfficeDocFile/DocDocxConverter/EncryptionHeader.cpp
View file @
4015e8ba
...
...
@@ -147,10 +147,11 @@ namespace DocFileFormat
if
(
fAES
)
crypt_data_aes
.
cipherAlgorithm
=
CRYPT_METHOD
::
AES_ECB
;
if
(
fCryptoAPI
)
crypt_data_aes
.
cipherAlgorithm
=
CRYPT_METHOD
::
RC4
;
crypt_data_aes
.
keySize
=
KeySize
/
8
;
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
;
...
...
ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfo.h
View file @
4015e8ba
...
...
@@ -96,7 +96,9 @@ public:
if
(
bResult
==
false
)
{
delete
pInfo
;
continue
;
if
(
pInfo
->
m_bEncrypt
)
return
false
;
else
continue
;
}
m_arUsers
.
push_back
(
pInfo
);
...
...
ASCOfficePPTFile/PPTFormatLib/Reader/PPTFileReader.cpp
View file @
4015e8ba
...
...
@@ -224,6 +224,7 @@ void CPPTFileReader::ReadDocumentSummary()
void
CPPTFileReader
::
ReadPictures
()
{
if
(
m_oDocumentInfo
.
m_arUsers
.
empty
())
return
;
CFStreamPtr
pStream
=
GetPictureStream
();
if
(
!
pStream
)
return
;
...
...
@@ -242,28 +243,22 @@ void CPPTFileReader::ReadPictures()
POLE
::
Stream
*
pStreamTmp
=
pStream
->
stream_
;
if
(
pDecryptor
)
{
m_oDocumentInfo
.
m_arUsers
[
0
]
->
DecryptStream
(
pStreamTmp
,
0
);
m_oDocumentInfo
.
m_arUsers
[
0
]
->
DecryptStream
(
pStreamTmp
,
0
);
pStreamTmp
=
m_oDocumentInfo
.
m_arUsers
[
0
]
->
m_arStreamDecrypt
.
back
()
->
stream_
;
}
oHeader
.
ReadFromStream
(
pStreamTmp
);
pStream
->
seekFromBegin
(
pos
+
8
);
CRecordOfficeArtBlip
art_blip
;
art_blip
.
m_strTmpDirectory
=
m_strTmpDirectory
;
art_blip
.
m_oDocumentInfo
=
&
m_oDocumentInfo
;
pStreamTmp
=
pStream
->
stream_
;
if
(
pDecryptor
)
{
m_oDocumentInfo
.
m_arUsers
[
0
]
->
DecryptStream
(
pStreamTmp
,
1
);
pStreamTmp
=
m_oDocumentInfo
.
m_arUsers
[
0
]
->
m_arStreamDecrypt
.
back
()
->
stream_
;
//
pStream
->
seekFromBegin
(
pos
+
8
);
pStreamTmp
=
pStream
->
stream_
;
//каждое поле отдельно нужно
}
art_blip
.
ReadFromStream
(
oHeader
,
pStreamTmp
);
pStream
->
seekFromBegin
(
pos
+
oHeader
.
RecLen
+
8
);
art_blip
.
ReadFromStream
(
oHeader
,
pStreamTmp
);
m_oDocumentInfo
.
m_mapStoreImageFile
[
pos
]
=
art_blip
.
m_sFileName
;
pStream
->
seekFromBegin
(
pos
+
oHeader
.
RecLen
+
8
);
}
}
ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp
View file @
4015e8ba
...
...
@@ -33,8 +33,10 @@
#include "ReadStructures.h"
#include <zlib.h>
#include "../../../ASCOfficeDocFile/DocDocxConverter/MemoryStream.h"
#include "../../../OfficeCryptReader/source/CryptTransform.h"
#include <zlib.h>
using
namespace
NSPresentationEditor
;
...
...
@@ -639,22 +641,31 @@ namespace NSPresentationEditor
}
}
//------------------------------------------------------------------------------------
void
CMetaHeader
::
FromStream
(
POLE
::
Stream
*
pStream
)
void
CMetaHeader
::
FromStream
(
POLE
::
Stream
*
pStream
,
CRYPT
::
ECMADecryptor
*
pDecryptor
)
{
cbSize
=
StreamUtils
::
ReadDWORD
(
pStream
);
int
size
=
34
;
BYTE
*
pData
=
new
BYTE
[
size
];
pStream
->
read
(
pData
,
size
);
if
(
pDecryptor
)
{
pDecryptor
->
Decrypt
((
char
*
)
pData
,
size
,
0
);
}
MemoryStream
memStream
(
pData
,
size
,
false
);
cbSize
=
memStream
.
ReadUInt32
();
rcBounds
.
left
=
StreamUtils
::
ReadLONG
(
pStream
);
rcBounds
.
top
=
StreamUtils
::
ReadLONG
(
pStream
);
rcBounds
.
right
=
StreamUtils
::
ReadLONG
(
pStream
);
rcBounds
.
bottom
=
StreamUtils
::
ReadLONG
(
pStream
);
rcBounds
.
left
=
memStream
.
ReadInt32
(
);
rcBounds
.
top
=
memStream
.
ReadInt32
(
);
rcBounds
.
right
=
memStream
.
ReadInt32
(
);
rcBounds
.
bottom
=
memStream
.
ReadInt32
(
);
ptSize
.
x
=
StreamUtils
::
ReadLONG
(
pStream
);
ptSize
.
y
=
StreamUtils
::
ReadLONG
(
pStream
);
ptSize
.
x
=
memStream
.
ReadInt32
(
);
ptSize
.
y
=
memStream
.
ReadInt32
(
);
cbSave
=
StreamUtils
::
ReadDWORD
(
pStream
);
cbSave
=
memStream
.
ReadUInt32
(
);
compression
=
StreamUtils
::
ReadBYTE
(
pStream
);
filter
=
StreamUtils
::
ReadBYTE
(
pStream
);
compression
=
memStream
.
ReadByte
(
);
filter
=
memStream
.
ReadByte
(
);
}
void
CMetaHeader
::
ToEMFHeader
(
Gdiplus
::
ENHMETAHEADER3
*
pHeader
)
...
...
ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h
View file @
4015e8ba
...
...
@@ -43,6 +43,10 @@ namespace NSZLib
bool
Decompress
(
const
BYTE
*
pSrcBuffer
,
const
ULONG
&
lSrcBufferLen
,
BYTE
*
pDstBuffer
,
ULONG
&
lDstBufferLen
);
}
namespace
CRYPT
{
class
ECMADecryptor
;
}
/**************************************************************
теперь все структуры...
которые участвуют в записях
...
...
@@ -170,7 +174,7 @@ public:
CMetaHeader
()
{
}
void
FromStream
(
POLE
::
Stream
*
pStream
);
void
FromStream
(
POLE
::
Stream
*
pStream
,
CRYPT
::
ECMADecryptor
*
pDecryptor
=
NULL
);
void
ToEMFHeader
(
Gdiplus
::
ENHMETAHEADER3
*
pHeader
);
void
ToWMFHeader
(
Gdiplus
::
WmfPlaceableFileHeader
*
pHeader
);
...
...
ASCOfficePPTFile/PPTFormatLib/Records/CryptSession10Container.h
View file @
4015e8ba
...
...
@@ -165,6 +165,8 @@ public:
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
;
...
...
ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp
View file @
4015e8ba
...
...
@@ -39,191 +39,198 @@
void
CRecordOfficeArtBlip
::
ReadFromStream
(
SRecordHeader
&
oHeader
,
POLE
::
Stream
*
pStream
)
{
CMetaFileBuffer
oMetaFile
;
if
((
oHeader
.
RecVersion
==
PSFLAG_CONTAINER
)
||
((
oHeader
.
RecVersion
&
0x0F
)
==
0x0F
))
return
;
CRYPT
::
ECMADecryptor
*
pDecryptor
=
m_oDocumentInfo
?
m_oDocumentInfo
->
m_arUsers
[
0
]
->
m_pDecryptor
:
NULL
;
CMetaFileBuffer
oMetaFile
;
std
::
wstring
sExt
=
L".jpg"
;
int
lOffset
=
0
;
int
pos
=
pStream
->
tell
();
if
((
oHeader
.
RecVersion
!=
PSFLAG_CONTAINER
)
&&
((
oHeader
.
RecVersion
&
0x0F
)
!=
0x0F
))
switch
(
oHeader
.
RecType
)
{
int
lOffset
=
0
;
switch
(
oHeader
.
RecType
)
case
RECORD_TYPE_ESCHER_BLIP_EMF
:
{
case
RECORD_TYPE_ESCHER_BLIP_EMF
:
{
if
(
0x03D4
==
oHeader
.
RecInstance
)
lOffset
=
16
;
else
if
(
0x03D5
==
oHeader
.
RecInstance
)
lOffset
=
32
;
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
lOffset
+=
34
;
if
(
0x03D4
==
oHeader
.
RecInstance
)
lOffset
=
16
;
else
if
(
0x03D5
==
oHeader
.
RecInstance
)
lOffset
=
32
;
oMetaFile
.
m_bIsValid
=
TRUE
;
oMetaFile
.
m_sExtension
=
L".emf"
;
CMetaHeader
oMetaHeader
;
oMetaHeader
.
FromStream
(
pStream
);
Gdiplus
::
ENHMETAHEADER3
oEmfHeader
;
oMetaHeader
.
ToEMFHeader
(
&
oEmfHeader
);
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
lOffset
+=
34
;
oMetaFile
.
SetHeader
(
NULL
,
0
);
BYTE
*
pData
=
new
BYTE
[
oHeader
.
RecLen
-
lOffset
];
pStream
->
read
(
pData
,
oHeader
.
RecLen
-
lOffset
);
oMetaFile
.
m_bIsValid
=
TRUE
;
oMetaFile
.
m_sExtension
=
L".emf"
;
CMetaHeader
oMetaHeader
;
oMetaHeader
.
FromStream
(
pStream
,
pDecryptor
);
Gdiplus
::
ENHMETAHEADER3
oEmfHeader
;
oMetaHeader
.
ToEMFHeader
(
&
oEmfHeader
);
oMetaFile
.
SetData
(
pData
,
oMetaHeader
.
cbSave
,
oMetaHeader
.
cbSize
,
(
bool
)(
oMetaHeader
.
compression
!=
0xFE
)
);
oMetaFile
.
SetHeader
(
NULL
,
0
);
}
break
;
case
RECORD_TYPE_ESCHER_BLIP_WMF
:
BYTE
*
pData
=
new
BYTE
[
oHeader
.
RecLen
-
lOffset
];
pStream
->
read
(
pData
,
oHeader
.
RecLen
-
lOffset
);
if
(
pDecryptor
)
{
if
(
0x0216
==
oHeader
.
RecInstance
)
lOffset
=
16
;
else
if
(
0x0217
==
oHeader
.
RecInstance
)
lOffset
=
32
;
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
pDecryptor
->
Decrypt
((
char
*
)
pData
,
oHeader
.
RecLen
-
lOffset
,
0
);
}
oMetaFile
.
SetData
(
pData
,
oMetaHeader
.
cbSave
,
oMetaHeader
.
cbSize
,
(
bool
)(
oMetaHeader
.
compression
!=
0xFE
)
);
lOffset
+=
34
;
}
break
;
case
RECORD_TYPE_ESCHER_BLIP_WMF
:
{
if
(
0x0216
==
oHeader
.
RecInstance
)
lOffset
=
16
;
else
if
(
0x0217
==
oHeader
.
RecInstance
)
lOffset
=
32
;
oMetaFile
.
m_bIsValid
=
TRUE
;
oMetaFile
.
m_sExtension
=
L".wmf"
;
CMetaHeader
oMetaHeader
;
oMetaHeader
.
FromStream
(
pStream
);
Gdiplus
::
WmfPlaceableFileHeader
oWmfHeader
;
oMetaHeader
.
ToWMFHeader
(
&
oWmfHeader
);
LONG
lLenHeader
=
22
;
BYTE
*
pMetaHeader
=
new
BYTE
[
lLenHeader
];
// удалится в oMetaFile
memcpy
(
pMetaHeader
,
(
void
*
)(
&
oWmfHeader
),
lLenHeader
);
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
oMetaFile
.
SetHeader
(
pMetaHeader
,
lLenHeader
)
;
lOffset
+=
34
;
BYTE
*
pData
=
new
BYTE
[
oHeader
.
RecLen
-
lOffset
];
pStream
->
read
(
pData
,
oHeader
.
RecLen
-
lOffset
);
oMetaFile
.
m_bIsValid
=
TRUE
;
oMetaFile
.
m_sExtension
=
L".wmf"
;
CMetaHeader
oMetaHeader
;
oMetaHeader
.
FromStream
(
pStream
,
pDecryptor
);
Gdiplus
::
WmfPlaceableFileHeader
oWmfHeader
;
oMetaHeader
.
ToWMFHeader
(
&
oWmfHeader
);
LONG
lLenHeader
=
22
;
BYTE
*
pMetaHeader
=
new
BYTE
[
lLenHeader
];
// удалится в oMetaFile
memcpy
(
pMetaHeader
,
(
void
*
)(
&
oWmfHeader
),
lLenHeader
);
oMetaFile
.
SetData
(
pData
,
oMetaHeader
.
cbSave
,
oMetaHeader
.
cbSize
,
(
bool
)(
oMetaHeader
.
compression
!=
0xFE
)
);
oMetaFile
.
SetHeader
(
pMetaHeader
,
lLenHeader
);
}
break
;
case
RECORD_TYPE_ESCHER_BLIP_PICT
:
//Medwoche.ppt , (483)
BYTE
*
pData
=
new
BYTE
[
oHeader
.
RecLen
-
lOffset
];
pStream
->
read
(
pData
,
oHeader
.
RecLen
-
lOffset
);
if
(
pDecryptor
)
{
if
(
0x0542
==
oHeader
.
RecInstance
)
lOffset
=
16
;
else
if
(
0x0543
==
oHeader
.
RecInstance
)
lOffset
=
32
;
pDecryptor
->
Decrypt
((
char
*
)
pData
,
oHeader
.
RecLen
-
lOffset
,
0
);
}
oMetaFile
.
SetData
(
pData
,
oMetaHeader
.
cbSave
,
oMetaHeader
.
cbSize
,
(
bool
)(
oMetaHeader
.
compression
!=
0xFE
)
);
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
}
break
;
case
RECORD_TYPE_ESCHER_BLIP_PICT
:
//Medwoche.ppt , (483)
{
if
(
0x0542
==
oHeader
.
RecInstance
)
lOffset
=
16
;
else
if
(
0x0543
==
oHeader
.
RecInstance
)
lOffset
=
32
;
lOffset
+=
34
;
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
)
;
oMetaFile
.
m_bIsValid
=
TRUE
;
oMetaFile
.
m_sExtension
=
L".wmf"
;
//L".pct"; - ВРЕМЕННО пока не сделана конвертация pct(pic) хоть во что нито !!!
CMetaHeader
oMetaHeader
;
oMetaHeader
.
FromStream
(
pStream
);
//отдельно вынесенный заголовок.. "форматный" находится в блоке данных
lOffset
+=
34
;
BYTE
*
pData
=
new
BYTE
[
oHeader
.
RecLen
-
lOffset
];
pStream
->
read
(
pData
,
oHeader
.
RecLen
-
lOffset
);
oMetaFile
.
m_bIsValid
=
TRUE
;
oMetaFile
.
m_sExtension
=
L".wmf"
;
//L".pct"; - ВРЕМЕННО пока не сделана конвертация pct(pic) хоть во что нито !!!
CMetaHeader
oMetaHeader
;
oMetaHeader
.
FromStream
(
pStream
,
pDecryptor
);
//отдельно вынесенный заголовок.. "форматный" находится в блоке данных
oMetaFile
.
SetData
(
pData
,
oMetaHeader
.
cbSave
,
oMetaHeader
.
cbSize
,
(
bool
)(
oMetaHeader
.
compression
!=
0xFE
)
)
;
}
break
;
case
RECORD_TYPE_ESCHER_BLIP_JPEG
:
BYTE
*
pData
=
new
BYTE
[
oHeader
.
RecLen
-
lOffset
]
;
pStream
->
read
(
pData
,
oHeader
.
RecLen
-
lOffset
);
if
(
pDecryptor
)
{
if
(
0x046A
==
oHeader
.
RecInstance
||
0x06E2
==
oHeader
.
RecInstance
)
lOffset
=
17
;
else
if
(
0x046B
==
oHeader
.
RecInstance
||
0x06E3
==
oHeader
.
RecInstance
)
lOffset
=
33
;
//StreamUtils::StreamSkip(lOffset, pStream);
std
::
string
str
=
StreamUtils
::
ReadStringA
(
pStream
,
lOffset
);
sExt
=
_T
(
".jpg"
);
break
;
pDecryptor
->
Decrypt
((
char
*
)
pData
,
oHeader
.
RecLen
-
lOffset
,
0
);
}
case
RECORD_TYPE_ESCHER_BLIP_PNG
:
{
if
(
0x06E0
==
oHeader
.
RecInstance
)
lOffset
=
17
;
else
if
(
0x06E1
==
oHeader
.
RecInstance
)
lOffset
=
33
;
oMetaFile
.
SetData
(
pData
,
oMetaHeader
.
cbSave
,
oMetaHeader
.
cbSize
,
(
bool
)(
oMetaHeader
.
compression
!=
0xFE
)
);
}
break
;
case
RECORD_TYPE_ESCHER_BLIP_JPEG
:
{
if
(
0x046A
==
oHeader
.
RecInstance
||
0x06E2
==
oHeader
.
RecInstance
)
lOffset
=
17
;
else
if
(
0x046B
==
oHeader
.
RecInstance
||
0x06E3
==
oHeader
.
RecInstance
)
lOffset
=
33
;
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
sExt
=
_T
(
".jpg"
);
break
;
}
case
RECORD_TYPE_ESCHER_BLIP_PNG
:
{
if
(
0x06E0
==
oHeader
.
RecInstance
)
lOffset
=
17
;
else
if
(
0x06E1
==
oHeader
.
RecInstance
)
lOffset
=
33
;
//StreamUtils::StreamSkip(lOffset, pStream);
std
::
string
str
=
StreamUtils
::
ReadStringA
(
pStream
,
lOffset
);
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
sExt
=
_T
(
".png"
);
break
;
}
case
RECORD_TYPE_ESCHER_BLIP_DIB
:
{
if
(
0x07A8
==
oHeader
.
RecInstance
)
lOffset
=
17
;
else
if
(
0x07A9
==
oHeader
.
RecInstance
)
lOffset
=
33
;
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
sExt
=
_T
(
".png"
);
break
;
}
case
RECORD_TYPE_ESCHER_BLIP_DIB
:
{
if
(
0x07A8
==
oHeader
.
RecInstance
)
lOffset
=
17
;
else
if
(
0x07A9
==
oHeader
.
RecInstance
)
lOffset
=
33
;
sExt
=
_T
(
".bmp"
);
break
;
}
case
RECORD_TYPE_ESCHER_BLIP_TIFF
:
{
if
(
0x06E4
==
oHeader
.
RecInstance
)
lOffset
=
17
;
else
if
(
0x06E5
==
oHeader
.
RecInstance
)
lOffset
=
33
;
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
sExt
=
_T
(
".bmp"
);
break
;
}
case
RECORD_TYPE_ESCHER_BLIP_TIFF
:
{
if
(
0x06E4
==
oHeader
.
RecInstance
)
lOffset
=
17
;
else
if
(
0x06E5
==
oHeader
.
RecInstance
)
lOffset
=
33
;
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
sExt
=
_T
(
".tif"
);
break
;
}
default:
{
break
;
}
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
sExt
=
_T
(
".tif"
);
break
;
}
int
nImagesCount
=
0
;
if
(
m_oDocumentInfo
)
default:
{
nImagesCount
=
m_oDocumentInfo
->
m_mapStoreImageFile
.
size
()
;
break
;
}
//else nImagesCount = generate uniq name
}
int
nImagesCount
=
0
;
if
(
m_oDocumentInfo
)
{
nImagesCount
=
m_oDocumentInfo
->
m_mapStoreImageFile
.
size
();
}
//else nImagesCount = generate uniq name
if
(
oMetaFile
.
m_bIsValid
)
{
std
::
wstring
strFile
=
L"Image "
+
std
::
to_wstring
(
nImagesCount
+
1
)
+
oMetaFile
.
m_sExtension
;
if
(
oMetaFile
.
m_bIsValid
)
CFile
fileMeta
;
HRESULT
hr
=
fileMeta
.
CreateFile
(
m_strTmpDirectory
+
FILE_SEPARATOR_STR
+
strFile
);
if
(
hr
==
S_OK
)
{
std
::
wstring
strFile
=
L"Image "
+
std
::
to_wstring
(
nImagesCount
+
1
)
+
oMetaFile
.
m_sExtension
;
oMetaFile
.
ToFile
(
&
fileMeta
);
fileMeta
.
CloseFile
();
}
m_sFileName
=
strFile
;
}
else
{
BYTE
*
pImage
=
new
BYTE
[
oHeader
.
RecLen
-
lOffset
];
CFile
fileMeta
;
HRESULT
hr
=
fileMeta
.
CreateFile
(
m_strTmpDirectory
+
FILE_SEPARATOR_STR
+
strFile
);
if
(
hr
==
S_OK
)
{
oMetaFile
.
ToFile
(
&
fileMeta
);
fileMeta
.
CloseFile
();
}
m_sFileName
=
strFile
;
pStream
->
read
(
pImage
,
oHeader
.
RecLen
-
lOffset
);
if
(
pDecryptor
)
{
pDecryptor
->
Decrypt
((
char
*
)
pImage
,
oHeader
.
RecLen
-
lOffset
,
0
);
}
else
std
::
wstring
strFile
=
L"Image "
+
std
::
to_wstring
(
nImagesCount
+
1
)
+
sExt
;
CFile
fileImage
;
HRESULT
hr
=
fileImage
.
CreateFile
(
m_strTmpDirectory
+
FILE_SEPARATOR_STR
+
strFile
);
if
(
hr
==
S_OK
)
{
BYTE
*
pImage
=
new
BYTE
[
oHeader
.
RecLen
-
lOffset
];
pStream
->
read
(
pImage
,
oHeader
.
RecLen
-
lOffset
);
std
::
wstring
strFile
=
L"Image "
+
std
::
to_wstring
(
nImagesCount
+
1
)
+
sExt
;
CFile
fileImage
;
HRESULT
hr
=
fileImage
.
CreateFile
(
m_strTmpDirectory
+
FILE_SEPARATOR_STR
+
strFile
);
if
(
hr
==
S_OK
)
if
(
RECORD_TYPE_ESCHER_BLIP_DIB
==
oHeader
.
RecType
)
{
if
(
RECORD_TYPE_ESCHER_BLIP_DIB
==
oHeader
.
RecType
)
{
WORD
vtType
=
0x4D42
;
fileImage
.
WriteFile
((
void
*
)
&
vtType
,
2
);
DWORD
dwLen
=
oHeader
.
RecLen
-
lOffset
;
fileImage
.
WriteFile
((
void
*
)
&
dwLen
,
4
);
DWORD
dwRes
=
0
;
fileImage
.
WriteFile
((
void
*
)
&
dwRes
,
4
);
DWORD
dwOffset
=
2
;
fileImage
.
WriteFile
((
void
*
)
&
dwOffset
,
4
);
}
fileImage
.
WriteFile
((
void
*
)
pImage
,
oHeader
.
RecLen
-
lOffset
);
fileImage
.
CloseFile
();
WORD
vtType
=
0x4D42
;
fileImage
.
WriteFile
((
void
*
)
&
vtType
,
2
);
DWORD
dwLen
=
oHeader
.
RecLen
-
lOffset
;
fileImage
.
WriteFile
((
void
*
)
&
dwLen
,
4
);
DWORD
dwRes
=
0
;
fileImage
.
WriteFile
((
void
*
)
&
dwRes
,
4
);
DWORD
dwOffset
=
2
;
fileImage
.
WriteFile
((
void
*
)
&
dwOffset
,
4
);
}
if
(
pImage
)
delete
[]
pImage
;
pImage
=
NULL
;
m_sFileName
=
strFile
;
fileImage
.
WriteFile
((
void
*
)
pImage
,
oHeader
.
RecLen
-
lOffset
);
fileImage
.
CloseFile
();
}
if
(
pImage
)
delete
[]
pImage
;
pImage
=
NULL
;
m_sFileName
=
strFile
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment