OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
9 #include "../../include/javascript/JS_GlobalData.h" | 9 #include "../../include/javascript/JS_GlobalData.h" |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 delete array.GetAt(i); | 98 delete array.GetAt(i); |
99 array.RemoveAll(); | 99 array.RemoveAll(); |
100 } | 100 } |
101 | 101 |
102 /* -------------------------- CJS_GlobalData -------------------------- */ | 102 /* -------------------------- CJS_GlobalData -------------------------- */ |
103 | 103 |
104 #define READER_JS_GLOBALDATA_FILENAME L"Reader_JsGloba
l.Data" | 104 #define READER_JS_GLOBALDATA_FILENAME L"Reader_JsGloba
l.Data" |
105 #define PHANTOM_JS_GLOBALDATA_FILENAME L"Phantom_JsGlob
al.Data" | 105 #define PHANTOM_JS_GLOBALDATA_FILENAME L"Phantom_JsGlob
al.Data" |
106 #define SDK_JS_GLOBALDATA_FILENAME L"SDK_Js
Global.Data" | 106 #define SDK_JS_GLOBALDATA_FILENAME L"SDK_Js
Global.Data" |
107 | 107 |
108 static const FX_BYTE JS_RC4KEY[] = {0x19,0xa8,0xe8,0x01,0xf6,0xa8,0xb6,0x4d,0x82
,0x04, | 108 static const uint8_t JS_RC4KEY[] = {0x19,0xa8,0xe8,0x01,0xf6,0xa8,0xb6,0x4d,0x82
,0x04, |
109 0x45,0x6d,0xb4,0xcf,0xd7
,0x77,0x67,0xf9,0x75,0x9f, | 109 0x45,0x6d,0xb4,0xcf,0xd7
,0x77,0x67,0xf9,0x75,0x9f, |
110 0xf0,0xe0,0x1e,0x51,0xee
,0x46,0xfd,0x0b,0xc9,0x93, | 110 0xf0,0xe0,0x1e,0x51,0xee
,0x46,0xfd,0x0b,0xc9,0x93, |
111 0x25,0x55,0x4a,0xee,0xe0
,0x16,0xd0,0xdf,0x8c,0xfa, | 111 0x25,0x55,0x4a,0xee,0xe0
,0x16,0xd0,0xdf,0x8c,0xfa, |
112 0x2a,0xa9,0x49,0xfd,0x97
,0x1c,0x0e,0x22,0x13,0x28, | 112 0x2a,0xa9,0x49,0xfd,0x97
,0x1c,0x0e,0x22,0x13,0x28, |
113 0x7c,0xaf,0xc4,0xfc,0x9c
,0x12,0x65,0x8c,0x4e,0x5b, | 113 0x7c,0xaf,0xc4,0xfc,0x9c
,0x12,0x65,0x8c,0x4e,0x5b, |
114 0x04,0x75,0x89,0xc9,0xb1
,0xed,0x50,0xca,0x96,0x6f, | 114 0x04,0x75,0x89,0xc9,0xb1
,0xed,0x50,0xca,0x96,0x6f, |
115 0x1a,0x7a,0xfe,0x58,0x5d
,0xec,0x19,0x4a,0xf6,0x35, | 115 0x1a,0x7a,0xfe,0x58,0x5d
,0xec,0x19,0x4a,0xf6,0x35, |
116 0x6a,0x97,0x14,0x00,0x0e
,0xd0,0x6b,0xbb,0xd5,0x75, | 116 0x6a,0x97,0x14,0x00,0x0e
,0xd0,0x6b,0xbb,0xd5,0x75, |
117 0x55,0x8b,0x6e,0x6b,0x19
,0xa0,0xf8,0x77,0xd5,0xa3 | 117 0x55,0x8b,0x6e,0x6b,0x19
,0xa0,0xf8,0x77,0xd5,0xa3 |
118 }; | 118 }; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 if (nFind >= 0) | 331 if (nFind >= 0) |
332 { | 332 { |
333 delete m_arrayGlobalData.GetAt(nFind); | 333 delete m_arrayGlobalData.GetAt(nFind); |
334 m_arrayGlobalData.RemoveAt(nFind); | 334 m_arrayGlobalData.RemoveAt(nFind); |
335 return TRUE; | 335 return TRUE; |
336 } | 336 } |
337 | 337 |
338 return FALSE; | 338 return FALSE; |
339 } | 339 } |
340 | 340 |
341 FX_INT32 CJS_GlobalData::GetSize() const | 341 int32_t CJS_GlobalData::GetSize() const |
342 { | 342 { |
343 return m_arrayGlobalData.GetSize(); | 343 return m_arrayGlobalData.GetSize(); |
344 } | 344 } |
345 | 345 |
346 CJS_GlobalData_Element* CJS_GlobalData::GetAt(int index) const | 346 CJS_GlobalData_Element* CJS_GlobalData::GetAt(int index) const |
347 { | 347 { |
348 return m_arrayGlobalData.GetAt(index); | 348 return m_arrayGlobalData.GetAt(index); |
349 } | 349 } |
350 | 350 |
351 void CJS_GlobalData::LoadGlobalPersistentVariables() | 351 void CJS_GlobalData::LoadGlobalPersistentVariables() |
352 { | 352 { |
353 FX_LPBYTE pBuffer = NULL; | 353 FX_LPBYTE pBuffer = NULL; |
354 » FX_INT32 nLength = 0; | 354 » int32_t nLength = 0; |
355 | 355 |
356 LoadFileBuffer(m_sFilePath.c_str(), pBuffer, nLength); | 356 LoadFileBuffer(m_sFilePath.c_str(), pBuffer, nLength); |
357 CRYPT_ArcFourCryptBlock(pBuffer, nLength, JS_RC4KEY, sizeof(JS_RC4KEY)); | 357 CRYPT_ArcFourCryptBlock(pBuffer, nLength, JS_RC4KEY, sizeof(JS_RC4KEY)); |
358 | 358 |
359 if (pBuffer) | 359 if (pBuffer) |
360 { | 360 { |
361 FX_LPBYTE p = pBuffer; | 361 FX_LPBYTE p = pBuffer; |
362 FX_WORD wType = *((FX_WORD*)p); | 362 FX_WORD wType = *((FX_WORD*)p); |
363 p += sizeof(FX_WORD); | 363 p += sizeof(FX_WORD); |
364 | 364 |
365 //FX_WORD wTemp = (FX_WORD)(('X' << 8) | 'F'); | 365 //FX_WORD wTemp = (FX_WORD)(('X' << 8) | 'F'); |
366 | 366 |
367 if (wType == (FX_WORD)(('X' << 8) | 'F')) | 367 if (wType == (FX_WORD)(('X' << 8) | 'F')) |
368 { | 368 { |
369 FX_WORD wVersion = *((FX_WORD*)p); | 369 FX_WORD wVersion = *((FX_WORD*)p); |
370 p += sizeof(FX_WORD); | 370 p += sizeof(FX_WORD); |
371 | 371 |
372 ASSERT(wVersion <= 2); | 372 ASSERT(wVersion <= 2); |
373 | 373 |
374 FX_DWORD dwCount = *((FX_DWORD*)p); | 374 FX_DWORD dwCount = *((FX_DWORD*)p); |
375 p += sizeof(FX_DWORD); | 375 p += sizeof(FX_DWORD); |
376 | 376 |
377 FX_DWORD dwSize = *((FX_DWORD*)p); | 377 FX_DWORD dwSize = *((FX_DWORD*)p); |
378 p += sizeof(FX_DWORD); | 378 p += sizeof(FX_DWORD); |
379 | 379 |
380 if (dwSize == nLength - sizeof(FX_WORD) * 2 - sizeof(FX_
DWORD)* 2) | 380 if (dwSize == nLength - sizeof(FX_WORD) * 2 - sizeof(FX_
DWORD)* 2) |
381 { | 381 { |
382 » » » » for (FX_INT32 i=0,sz=dwCount; i<sz; i++) | 382 » » » » for (int32_t i=0,sz=dwCount; i<sz; i++) |
383 { | 383 { |
384 if (p > pBuffer + nLength) | 384 if (p > pBuffer + nLength) |
385 break; | 385 break; |
386 | 386 |
387 FX_DWORD dwNameLen = *((FX_DWORD*)p); | 387 FX_DWORD dwNameLen = *((FX_DWORD*)p); |
388 p += sizeof(FX_DWORD); | 388 p += sizeof(FX_DWORD); |
389 | 389 |
390 if (p + dwNameLen > pBuffer + nLength) | 390 if (p + dwNameLen > pBuffer + nLength) |
391 break; | 391 break; |
392 | 392 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 sFile.AppendBlock(&nCount, sizeof(FX_DWORD)); | 504 sFile.AppendBlock(&nCount, sizeof(FX_DWORD)); |
505 FX_DWORD dwSize = sData.GetSize(); | 505 FX_DWORD dwSize = sData.GetSize(); |
506 sFile.AppendBlock(&dwSize, sizeof(FX_DWORD)); | 506 sFile.AppendBlock(&dwSize, sizeof(FX_DWORD)); |
507 | 507 |
508 sFile.AppendBlock(sData.GetBuffer(), sData.GetSize()); | 508 sFile.AppendBlock(sData.GetBuffer(), sData.GetSize()); |
509 | 509 |
510 CRYPT_ArcFourCryptBlock(sFile.GetBuffer(), sFile.GetSize(), JS_RC4KEY, s
izeof(JS_RC4KEY)); | 510 CRYPT_ArcFourCryptBlock(sFile.GetBuffer(), sFile.GetSize(), JS_RC4KEY, s
izeof(JS_RC4KEY)); |
511 WriteFileBuffer(m_sFilePath.c_str(), (FX_LPCSTR)sFile.GetBuffer(), sFile
.GetSize()); | 511 WriteFileBuffer(m_sFilePath.c_str(), (FX_LPCSTR)sFile.GetBuffer(), sFile
.GetSize()); |
512 } | 512 } |
513 | 513 |
514 void CJS_GlobalData::LoadFileBuffer(FX_LPCWSTR sFilePath, FX_LPBYTE& pBuffer, FX
_INT32& nLength) | 514 void CJS_GlobalData::LoadFileBuffer(FX_LPCWSTR sFilePath, FX_LPBYTE& pBuffer, in
t32_t& nLength) |
515 { | 515 { |
516 //UnSupport. | 516 //UnSupport. |
517 } | 517 } |
518 | 518 |
519 void CJS_GlobalData::WriteFileBuffer(FX_LPCWSTR sFilePath, FX_LPCSTR pBuffer, FX
_INT32 nLength) | 519 void CJS_GlobalData::WriteFileBuffer(FX_LPCWSTR sFilePath, FX_LPCSTR pBuffer, in
t32_t nLength) |
520 { | 520 { |
521 //UnSupport. | 521 //UnSupport. |
522 } | 522 } |
523 | 523 |
524 void CJS_GlobalData::MakeByteString(const CFX_ByteString& name, CJS_KeyValue* pD
ata, CFX_BinaryBuf& sData) | 524 void CJS_GlobalData::MakeByteString(const CFX_ByteString& name, CJS_KeyValue* pD
ata, CFX_BinaryBuf& sData) |
525 { | 525 { |
526 ASSERT(pData != NULL); | 526 ASSERT(pData != NULL); |
527 | 527 |
528 FX_WORD wType = (FX_WORD)pData->nType; | 528 FX_WORD wType = (FX_WORD)pData->nType; |
529 | 529 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 sData.AppendString(name); | 571 sData.AppendString(name); |
572 | 572 |
573 sData.AppendBlock(&wType, sizeof(FX_DWORD)); | 573 sData.AppendBlock(&wType, sizeof(FX_DWORD)); |
574 } | 574 } |
575 break; | 575 break; |
576 default: | 576 default: |
577 break; | 577 break; |
578 } | 578 } |
579 } | 579 } |
580 | 580 |
OLD | NEW |