static FX_BOOL _JpegEmbedIccProfile(j_compress_ptr cinfo, FX_LPCBYTE icc_buf_ptr, FX_DWORD icc_length) { if(icc_buf_ptr == NULL || icc_length == 0) { return FALSE; } FX_DWORD icc_segment_size = (JPEG_MARKER_MAXSIZE - 2 - JPEG_OVERHEAD_LEN); FX_DWORD icc_segment_num = (icc_length / icc_segment_size) + 1; if (icc_segment_num > 255) { return FALSE; } FX_DWORD icc_data_length = JPEG_OVERHEAD_LEN + (icc_segment_num > 1 ? icc_segment_size : icc_length); FX_LPBYTE icc_data = FX_Alloc(FX_BYTE, icc_data_length); FXSYS_memcpy32(icc_data, "\x49\x43\x43\x5f\x50\x52\x4f\x46\x49\x4c\x45\x00", 12); icc_data[13] = (FX_BYTE)icc_segment_num; for (FX_BYTE i = 0; i < (icc_segment_num - 1); i++) { icc_data[12] = i + 1; FXSYS_memcpy32(icc_data + JPEG_OVERHEAD_LEN, icc_buf_ptr + i * icc_segment_size, icc_segment_size); jpeg_write_marker(cinfo, JPEG_MARKER_ICC, icc_data, icc_data_length); } icc_data[12] = (FX_BYTE)icc_segment_num; FX_DWORD icc_size = (icc_segment_num - 1) * icc_segment_size; FXSYS_memcpy32(icc_data + JPEG_OVERHEAD_LEN, icc_buf_ptr + icc_size, icc_length - icc_size); jpeg_write_marker(cinfo, JPEG_MARKER_ICC, icc_data, JPEG_OVERHEAD_LEN + icc_length - icc_size); FX_Free(icc_data); return TRUE; }
void CPDF_StandardCryptoHandler::CryptBlock(FX_BOOL bEncrypt, FX_DWORD objnum, FX_DWORD gennum, FX_LPCBYTE src_buf, FX_DWORD src_size, FX_LPBYTE dest_buf, FX_DWORD& dest_size) { if (m_Cipher == FXCIPHER_NONE) { FXSYS_memcpy32(dest_buf, src_buf, src_size); return; } FX_BYTE realkey[16]; int realkeylen = 16; if (m_Cipher != FXCIPHER_AES || m_KeyLen != 32) { FX_BYTE key1[32]; FXSYS_memcpy32(key1, m_EncryptKey, m_KeyLen); key1[m_KeyLen + 0] = (FX_BYTE)objnum; key1[m_KeyLen + 1] = (FX_BYTE)(objnum >> 8); key1[m_KeyLen + 2] = (FX_BYTE)(objnum >> 16); key1[m_KeyLen + 3] = (FX_BYTE)gennum; key1[m_KeyLen + 4] = (FX_BYTE)(gennum >> 8); FXSYS_memcpy32(key1 + m_KeyLen, &objnum, 3); FXSYS_memcpy32(key1 + m_KeyLen + 3, &gennum, 2); if (m_Cipher == FXCIPHER_AES) { FXSYS_memcpy32(key1 + m_KeyLen + 5, "sAlT", 4); } CRYPT_MD5Generate(key1, m_Cipher == FXCIPHER_AES ? m_KeyLen + 9 : m_KeyLen + 5, realkey); realkeylen = m_KeyLen + 5; if (realkeylen > 16) { realkeylen = 16; } }
FX_STRSIZE CFX_WideString::Replace(FX_LPCWSTR lpszOld, FX_LPCWSTR lpszNew) { if (GetLength() < 1) { return 0; } if (lpszOld == NULL) { return 0; } FX_STRSIZE nSourceLen = (FX_STRSIZE)FXSYS_wcslen(lpszOld); if (nSourceLen == 0) { return 0; } FX_STRSIZE nReplacementLen = lpszNew ? (FX_STRSIZE)FXSYS_wcslen(lpszNew) : 0; FX_STRSIZE nCount = 0; FX_LPWSTR lpszStart = m_pData->m_String; FX_LPWSTR lpszEnd = m_pData->m_String + m_pData->m_nDataLength; FX_LPWSTR lpszTarget; { while ((lpszTarget = (FX_LPWSTR)FXSYS_wcsstr(lpszStart, lpszOld)) != NULL && lpszStart < lpszEnd) { nCount++; lpszStart = lpszTarget + nSourceLen; } } if (nCount > 0) { CopyBeforeWrite(); FX_STRSIZE nOldLength = m_pData->m_nDataLength; FX_STRSIZE nNewLength = nOldLength + (nReplacementLen - nSourceLen) * nCount; if (m_pData->m_nAllocLength < nNewLength || m_pData->m_nRefs > 1) { CFX_StringDataW* pOldData = m_pData; FX_LPCWSTR pstr = m_pData->m_String; m_pData = FX_AllocStringW(nNewLength); if (!m_pData) { return 0; } FXSYS_memcpy32(m_pData->m_String, pstr, pOldData->m_nDataLength * sizeof(FX_WCHAR)); FX_ReleaseStringW(pOldData); } lpszStart = m_pData->m_String; lpszEnd = m_pData->m_String + FX_MAX(m_pData->m_nDataLength, nNewLength); { while ((lpszTarget = (FX_LPWSTR)FXSYS_wcsstr(lpszStart, lpszOld)) != NULL && lpszStart < lpszEnd) { FX_STRSIZE nBalance = nOldLength - (FX_STRSIZE)(lpszTarget - m_pData->m_String + nSourceLen); FXSYS_memmove32(lpszTarget + nReplacementLen, lpszTarget + nSourceLen, nBalance * sizeof(FX_WCHAR)); FXSYS_memcpy32(lpszTarget, lpszNew, nReplacementLen * sizeof(FX_WCHAR)); lpszStart = lpszTarget + nReplacementLen; lpszStart[nBalance] = 0; nOldLength += (nReplacementLen - nSourceLen); } } ASSERT(m_pData->m_String[nNewLength] == 0); m_pData->m_nDataLength = nNewLength; } return nCount; }
void CFX_WideString::ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCWSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCWSTR lpszSrc2Data) { FX_STRSIZE nNewLen = nSrc1Len + nSrc2Len; if (nNewLen == 0) { return; } m_pData = FX_AllocStringW(nNewLen); if (m_pData) { FXSYS_memcpy32(m_pData->m_String, lpszSrc1Data, nSrc1Len * sizeof(FX_WCHAR)); FXSYS_memcpy32(m_pData->m_String + nSrc1Len, lpszSrc2Data, nSrc2Len * sizeof(FX_WCHAR)); } }
CFX_WideString::CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2) { m_pData = NULL; int nNewLen = str1.GetLength() + str2.GetLength(); if (nNewLen == 0) { return; } m_pData = FX_AllocStringW(nNewLen); if (m_pData) { FXSYS_memcpy32(m_pData->m_String, str1.GetPtr(), str1.GetLength()*sizeof(FX_WCHAR)); FXSYS_memcpy32(m_pData->m_String + str1.GetLength(), str2.GetPtr(), str2.GetLength()*sizeof(FX_WCHAR)); } }
CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData, FX_BOOL bAlpha) { int width = pbmi->bmiHeader.biWidth; int height = pbmi->bmiHeader.biHeight; BOOL bBottomUp = TRUE; if (height < 0) { height = -height; bBottomUp = FALSE; } int pitch = (width * pbmi->bmiHeader.biBitCount + 31) / 32 * 4; CFX_DIBitmap* pBitmap = FX_NEW CFX_DIBitmap; if (!pBitmap) { return NULL; } FXDIB_Format format = bAlpha ? (FXDIB_Format)(pbmi->bmiHeader.biBitCount + 0x200) : (FXDIB_Format)pbmi->bmiHeader.biBitCount; FX_BOOL ret = pBitmap->Create(width, height, format); if (!ret) { delete pBitmap; return NULL; } FXSYS_memcpy32(pBitmap->GetBuffer(), pData, pitch * height); if (bBottomUp) { FX_LPBYTE temp_buf = FX_Alloc(FX_BYTE, pitch); if (!temp_buf) { if (pBitmap) { delete pBitmap; } return NULL; } int top = 0, bottom = height - 1; while (top < bottom) { FXSYS_memcpy32(temp_buf, pBitmap->GetBuffer() + top * pitch, pitch); FXSYS_memcpy32(pBitmap->GetBuffer() + top * pitch, pBitmap->GetBuffer() + bottom * pitch, pitch); FXSYS_memcpy32(pBitmap->GetBuffer() + bottom * pitch, temp_buf, pitch); top ++; bottom --; } FX_Free(temp_buf); temp_buf = NULL; } if (pbmi->bmiHeader.biBitCount == 1) { for (int i = 0; i < 2; i ++) { pBitmap->SetPaletteEntry(i, ((FX_DWORD*)pbmi->bmiColors)[i] | 0xff000000); } } else if (pbmi->bmiHeader.biBitCount == 8) { for (int i = 0; i < 256; i ++) { pBitmap->SetPaletteEntry(i, ((FX_DWORD*)pbmi->bmiColors)[i] | 0xff000000); } } return pBitmap; }
FX_LPWSTR CFX_WideString::GetBuffer(FX_STRSIZE nMinBufLength) { if (m_pData == NULL && nMinBufLength == 0) { return NULL; } if (m_pData && m_pData->m_nRefs <= 1 && m_pData->m_nAllocLength >= nMinBufLength) { return m_pData->m_String; } if (m_pData == NULL) { m_pData = FX_AllocStringW(nMinBufLength); if (!m_pData) { return NULL; } m_pData->m_nDataLength = 0; m_pData->m_String[0] = 0; return m_pData->m_String; } CFX_StringDataW* pOldData = m_pData; FX_STRSIZE nOldLen = pOldData->m_nDataLength; if (nMinBufLength < nOldLen) { nMinBufLength = nOldLen; } m_pData = FX_AllocStringW(nMinBufLength); if (!m_pData) { return NULL; } FXSYS_memcpy32(m_pData->m_String, pOldData->m_String, (nOldLen + 1)*sizeof(FX_WCHAR)); m_pData->m_nDataLength = nOldLen; pOldData->m_nRefs --; if (pOldData->m_nRefs <= 0) { FX_Free(pOldData); } return m_pData->m_String; }
void CFX_WideString::AssignCopy(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData) { AllocBeforeWrite(nSrcLen); FXSYS_memcpy32(m_pData->m_String, lpszSrcData, nSrcLen * sizeof(FX_WCHAR)); m_pData->m_nDataLength = nSrcLen; m_pData->m_String[nSrcLen] = 0; }
void CPDF_Stream::SetData(FX_LPCBYTE pData, FX_DWORD size, FX_BOOL bCompressed, FX_BOOL bKeepBuf) { if (m_GenNum == (FX_DWORD) - 1) { if (m_pDataBuf) { FX_Free(m_pDataBuf); } } else { m_GenNum = (FX_DWORD) - 1; m_pCryptoHandler = NULL; } if (bKeepBuf) { m_pDataBuf = (FX_LPBYTE)pData; } else { m_pDataBuf = FX_Alloc(FX_BYTE, size); if (pData) { FXSYS_memcpy32(m_pDataBuf, pData, size); } } m_dwSize = size; if (m_pDict == NULL) { m_pDict = new CPDF_Dictionary; } m_pDict->SetAtInteger(FX_BSTRC("Length"), size); if (!bCompressed) { m_pDict->RemoveAt(FX_BSTRC("Filter")); m_pDict->RemoveAt(FX_BSTRC("DecodeParms")); } }
void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) { if (ncomps > MAX_PATTERN_COLORCOMPS) { return; } if (m_pCS == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) { if (m_pBuffer) { FX_Free(m_pBuffer); } m_pCS = CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN); m_pBuffer = m_pCS->CreateBuf(); } CPDF_DocPageData *pDocPageData = NULL; PatternValue* pvalue = (PatternValue*)m_pBuffer; if (pvalue->m_pPattern && pvalue->m_pPattern->m_pDocument) { pDocPageData = pvalue->m_pPattern->m_pDocument->GetPageData(); if (pDocPageData) { pDocPageData->ReleasePattern(pvalue->m_pPattern->m_pPatternObj); } } pvalue->m_nComps = ncomps; pvalue->m_pPattern = pPattern; if (ncomps) { FXSYS_memcpy32(pvalue->m_Comps, comps, ncomps * sizeof(FX_FLOAT)); } pvalue->m_pCountedPattern = NULL; if (pPattern && pPattern->m_pDocument) { if (!pDocPageData) { pDocPageData = pPattern->m_pDocument->GetPageData(); } pvalue->m_pCountedPattern = pDocPageData->FindPatternPtr(pPattern->m_pPatternObj); } }
CPDF_ClipPathData::CPDF_ClipPathData(const CPDF_ClipPathData& src) { m_pPathList = NULL; m_pPathList = NULL; m_pTextList = NULL; m_PathCount = src.m_PathCount; if (m_PathCount) { int alloc_size = m_PathCount; if (alloc_size % 8) { alloc_size += 8 - (alloc_size % 8); } FX_NEW_VECTOR(m_pPathList, CPDF_Path, alloc_size); for (int i = 0; i < m_PathCount; i ++) { m_pPathList[i] = src.m_pPathList[i]; } m_pTypeList = FX_Alloc(FX_BYTE, alloc_size); FXSYS_memcpy32(m_pTypeList, src.m_pTypeList, m_PathCount); } else { m_pPathList = NULL; m_pTypeList = NULL; } m_TextCount = src.m_TextCount; if (m_TextCount) { m_pTextList = FX_Alloc(CPDF_TextObject*, m_TextCount); for (int i = 0; i < m_TextCount; i ++) { if (src.m_pTextList[i]) { m_pTextList[i] = new CPDF_TextObject; m_pTextList[i]->Copy(src.m_pTextList[i]); } else { m_pTextList[i] = NULL; } } } else {
FX_DWORD _DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) { if (pDecoder == NULL) { return (FX_DWORD) - 1; } int ncomps = pDecoder->CountComps(); int bpc = pDecoder->GetBPC(); int width = pDecoder->GetWidth(); int height = pDecoder->GetHeight(); int pitch = (width * ncomps * bpc + 7) / 8; if (height == 0 || pitch > (1 << 30) / height) { delete pDecoder; return -1; } dest_size = pitch * height; dest_buf = FX_Alloc( FX_BYTE, dest_size); for (int row = 0; row < height; row ++) { FX_LPBYTE pLine = pDecoder->GetScanline(row); if (pLine == NULL) { break; } FXSYS_memcpy32(dest_buf + row * pitch, pLine, pitch); } FX_DWORD srcoff = pDecoder->GetSrcOffset(); delete pDecoder; return srcoff; }
CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(FX_LPCBYTE owner_pass, FX_DWORD pass_size, FX_INT32 key_len) { CFX_ByteString okey = m_pEncryptDict->GetString(FX_BSTRC("O")); FX_BYTE passcode[32]; FX_DWORD i; for (i = 0; i < 32; i ++) { passcode[i] = i < pass_size ? owner_pass[i] : defpasscode[i - pass_size]; } FX_BYTE digest[16]; CRYPT_MD5Generate(passcode, 32, digest); if (m_Revision >= 3) { for (int i = 0; i < 50; i ++) { CRYPT_MD5Generate(digest, 16, digest); } } FX_BYTE enckey[32]; FXSYS_memset32(enckey, 0, sizeof(enckey)); FX_DWORD copy_len = key_len; if (copy_len > sizeof(digest)) { copy_len = sizeof(digest); } FXSYS_memcpy32(enckey, digest, copy_len); int okeylen = okey.GetLength(); if (okeylen > 32) { okeylen = 32; } FX_BYTE okeybuf[64]; FXSYS_memset32(okeybuf, 0, sizeof(okeybuf)); FXSYS_memcpy32(okeybuf, (FX_LPCSTR)okey, okeylen); if (m_Revision == 2) { CRYPT_ArcFourCryptBlock(okeybuf, okeylen, enckey, key_len); } else { for (int i = 19; i >= 0; i --) { FX_BYTE tempkey[32]; FXSYS_memset32(tempkey, 0, sizeof(tempkey)); for (int j = 0; j < m_KeyLen; j ++) { tempkey[j] = enckey[j] ^ i; } CRYPT_ArcFourCryptBlock(okeybuf, okeylen, tempkey, key_len); } } int len = 32; while (len && defpasscode[len - 1] == okeybuf[len - 1]) { len --; } return CFX_ByteString(okeybuf, len); }
FX_BOOL CFX_BasicArray::Copy(const CFX_BasicArray& src) { if (!SetSize(src.m_nSize, -1)) { return FALSE; } FXSYS_memcpy32(m_pData, src.m_pData, src.m_nSize * m_nUnitSize); return TRUE; }
void CFX_BinaryBuf::AppendBlock(const void* pBuf, FX_STRSIZE size) { ExpandBuf(size); if (pBuf && m_pBuffer) { FXSYS_memcpy32(m_pBuffer + m_DataSize, pBuf, size); } m_DataSize += size; }
void CPDF_Color::SetValue(FX_FLOAT* comps) { if (m_pBuffer == NULL) { return; } if (m_pCS->GetFamily() != PDFCS_PATTERN) { FXSYS_memcpy32(m_pBuffer, comps, m_pCS->CountComponents() * sizeof(FX_FLOAT)); } }
FX_BOOL CFX_BasicArray::Append(const CFX_BasicArray& src) { int nOldSize = m_nSize; if (!SetSize(m_nSize + src.m_nSize, -1)) { return FALSE; } FXSYS_memcpy32(m_pData + nOldSize * m_nUnitSize, src.m_pData, src.m_nSize * m_nUnitSize); return TRUE; }
FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword(FX_LPCBYTE password, FX_DWORD pass_size, FX_BOOL bIgnoreEncryptMeta, FX_LPBYTE key, FX_INT32 key_len) { CalcEncryptKey(m_pEncryptDict, password, pass_size, key, key_len, bIgnoreEncryptMeta, m_pParser->GetIDArray()); CFX_ByteString ukey = m_pEncryptDict ? m_pEncryptDict->GetString(FX_BSTRC("U")) : CFX_ByteString(); if (ukey.GetLength() < 16) { return FALSE; } FX_BYTE ukeybuf[32]; if (m_Revision == 2) { FXSYS_memcpy32(ukeybuf, defpasscode, 32); CRYPT_ArcFourCryptBlock(ukeybuf, 32, key, key_len); } else { FX_BYTE test[32], tmpkey[32]; FX_DWORD copy_len = sizeof(test); if (copy_len > (FX_DWORD)ukey.GetLength()) { copy_len = ukey.GetLength(); } FXSYS_memset32(test, 0, sizeof(test)); FXSYS_memset32(tmpkey, 0, sizeof(tmpkey)); FXSYS_memcpy32(test, (FX_LPCSTR)ukey, copy_len); for (int i = 19; i >= 0; i --) { for (int j = 0; j < key_len; j ++) { tmpkey[j] = key[j] ^ i; } CRYPT_ArcFourCryptBlock(test, 32, tmpkey, key_len); } FX_BYTE md5[100]; CRYPT_MD5Start(md5); CRYPT_MD5Update(md5, defpasscode, 32); CPDF_Array* pIdArray = m_pParser->GetIDArray(); if (pIdArray) { CFX_ByteString id = pIdArray->GetString(0); CRYPT_MD5Update(md5, (FX_LPBYTE)(FX_LPCSTR)id, id.GetLength()); } CRYPT_MD5Finish(md5, ukeybuf); return FXSYS_memcmp32(test, ukeybuf, 16) == 0; } if (FXSYS_memcmp32((FX_LPVOID)(FX_LPCSTR)ukey, ukeybuf, 16) == 0) { return TRUE; } return FALSE; }
void CPDF_TextObject::SetData(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos, FX_FLOAT x, FX_FLOAT y) { ASSERT(m_nChars == 0); m_nChars = nChars; m_PosX = x; m_PosY = y; if (nChars == 0) { return; } if (nChars == 1) { m_pCharCodes = (FX_DWORD*)(FX_UINTPTR) * pCharCodes; } else { m_pCharCodes = FX_Alloc(FX_DWORD, nChars); FXSYS_memcpy32(m_pCharCodes, pCharCodes, sizeof(FX_DWORD)*nChars); m_pCharPos = FX_Alloc(FX_FLOAT, nChars - 1); FXSYS_memcpy32(m_pCharPos, pCharPos, sizeof(FX_FLOAT) * (nChars - 1)); } RecalcPositionData(); }
FX_BOOL CPDF_Stream::ReadRawData(FX_FILESIZE offset, FX_LPBYTE buf, FX_DWORD size) const { if ((m_GenNum != (FX_DWORD) - 1) && m_pFile) { return m_pFile->ReadBlock(buf, m_FileOffset + offset, size); } if (m_pDataBuf) { FXSYS_memcpy32(buf, m_pDataBuf + offset, size); } return TRUE; }
CFX_WideString::CFX_WideString(const CFX_WideStringC& str) { if (str.IsEmpty()) { m_pData = NULL; return; } m_pData = FX_AllocStringW(str.GetLength()); if (m_pData) { FXSYS_memcpy32(m_pData->m_String, str.GetPtr(), str.GetLength()*sizeof(FX_WCHAR)); } }
CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont, FX_BOOL bVert, FX_BOOL bTranslateName) { LOGFONTA lfa; FXSYS_memcpy32(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa); CFX_ByteString face = CFX_ByteString::FromUnicode(pLogFont->lfFaceName); if (face.GetLength() >= LF_FACESIZE) { return NULL; } FXSYS_strcpy(lfa.lfFaceName, (FX_LPCSTR)face); return AddWindowsFont(&lfa, bVert, bTranslateName); }
FX_LPBYTE CPDF_StreamAcc::DetachData() { if (m_bNewBuf) { FX_LPBYTE p = m_pData; m_pData = NULL; m_dwSize = 0; return p; } FX_LPBYTE p = FX_Alloc(FX_BYTE, m_dwSize); FXSYS_memcpy32(p, m_pData, m_dwSize); return p; }
void CFX_BinaryBuf::InsertBlock(FX_STRSIZE pos, const void* pBuf, FX_STRSIZE size) { ExpandBuf(size); if (!m_pBuffer) { return; } FXSYS_memmove32(m_pBuffer + pos + size, m_pBuffer + pos, m_DataSize - pos); if (pBuf) { FXSYS_memcpy32(m_pBuffer + pos, pBuf, size); } m_DataSize += size; }
FX_BOOL CFX_BasicArray::Append(const CFX_BasicArray& src) { int nOldSize = m_nSize; pdfium::base::CheckedNumeric<int> newSize = m_nSize; newSize += src.m_nSize; if (m_nUnitSize != src.m_nUnitSize || !newSize.IsValid() || !SetSize(newSize.ValueOrDie())) { return FALSE; } FXSYS_memcpy32(m_pData + nOldSize * m_nUnitSize, src.m_pData, src.m_nSize * m_nUnitSize); return TRUE; }
static FX_BOOL _JpegLoadIccProfile(j_decompress_ptr cinfo, FX_LPBYTE* icc_buf_ptr, FX_DWORD* icc_length) { if(icc_buf_ptr == NULL || icc_length == NULL) { return FALSE; } *icc_buf_ptr = NULL; *icc_length = 0; FX_LPBYTE icc_data_ptr = NULL; FX_DWORD icc_data_len = 0; FX_BYTE count_icc_marker = 0; FX_BYTE num_icc_marker = 0; jpeg_saved_marker_ptr marker_list[256] = {NULL}; for (jpeg_saved_marker_ptr cur_marker = cinfo->marker_list; cur_marker != NULL; cur_marker = cur_marker->next) { if(_JpegIsIccMarker(cur_marker)) { if(count_icc_marker == 0) { num_icc_marker = cur_marker->data[13]; } else if(num_icc_marker != cur_marker->data[13]) { return FALSE; } int sn = cur_marker->data[12] - 1; if(sn < 0 || sn >= num_icc_marker) { return FALSE; } if(marker_list[sn] == NULL) { marker_list[sn] = cur_marker; } else { return FALSE; } count_icc_marker ++; icc_data_len += (cur_marker->data_length - JPEG_OVERHEAD_LEN); } } if(count_icc_marker != num_icc_marker) { return FALSE; } if(num_icc_marker == 0) { return TRUE; } icc_data_ptr = FX_Alloc(FX_BYTE, icc_data_len); if(icc_buf_ptr == NULL) { return FALSE; } *icc_buf_ptr = icc_data_ptr; *icc_length = icc_data_len; for (int idx = 0; idx < num_icc_marker; idx++) { icc_data_len = marker_list[idx]->data_length - JPEG_OVERHEAD_LEN; FXSYS_memcpy32(icc_data_ptr, marker_list[idx]->data + JPEG_OVERHEAD_LEN, icc_data_len); icc_data_ptr += icc_data_len; } return TRUE; }
FX_LPBYTE CCodec_ScanlineDecoder::ReadNextLine() { FX_LPBYTE pLine = v_GetNextLine(); if (pLine == NULL) { return NULL; } if (m_pDataCache && m_NextLine == m_pDataCache->m_nCachedLines) { FXSYS_memcpy32(&m_pDataCache->m_Data + m_NextLine * m_Pitch, pLine, m_Pitch); m_pDataCache->m_nCachedLines ++; } return pLine; }
void CFX_WideString::CopyBeforeWrite() { if (m_pData == NULL || m_pData->m_nRefs <= 1) { return; } CFX_StringDataW* pData = m_pData; m_pData->m_nRefs --; FX_STRSIZE nDataLength = pData->m_nDataLength; m_pData = FX_AllocStringW(nDataLength); if (m_pData != NULL) { FXSYS_memcpy32(m_pData->m_String, pData->m_String, (nDataLength + 1) * sizeof(FX_WCHAR)); } }
FX_BOOL CFX_Font::LoadEmbedded(FX_LPCBYTE data, FX_DWORD size) { m_pFontDataAllocation = FX_Alloc(FX_BYTE, size); if (!m_pFontDataAllocation) { return FALSE; } FXSYS_memcpy32(m_pFontDataAllocation, data, size); m_Face = FT_LoadFont((FX_LPBYTE)m_pFontDataAllocation, size); m_pFontData = (FX_LPBYTE)m_pFontDataAllocation; m_bEmbedded = TRUE; m_dwSize = size; return m_Face != NULL; }
void CPDF_Stream::InitStream(FX_LPBYTE pData, FX_DWORD size, CPDF_Dictionary* pDict) { InitStream(pDict); m_GenNum = (FX_DWORD) - 1; m_pDataBuf = FX_Alloc(FX_BYTE, size); if (pData) { FXSYS_memcpy32(m_pDataBuf, pData, size); } m_dwSize = size; if (m_pDict) { m_pDict->SetAtInteger(FX_BSTRC("Length"), size); } }