本文整理汇总了C++中FXSYS_memcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ FXSYS_memcpy函数的具体用法?C++ FXSYS_memcpy怎么用?C++ FXSYS_memcpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FXSYS_memcpy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _JpegEmbedIccProfile
static FX_BOOL _JpegEmbedIccProfile(j_compress_ptr cinfo, const uint8_t* 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);
uint8_t* icc_data = FX_Alloc(uint8_t, icc_data_length);
FXSYS_memcpy(icc_data, "\x49\x43\x43\x5f\x50\x52\x4f\x46\x49\x4c\x45\x00", 12);
icc_data[13] = (uint8_t)icc_segment_num;
for (uint8_t i = 0; i < (icc_segment_num - 1); i++) {
icc_data[12] = i + 1;
FXSYS_memcpy(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] = (uint8_t)icc_segment_num;
FX_DWORD icc_size = (icc_segment_num - 1) * icc_segment_size;
FXSYS_memcpy(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;
}
示例2: FXSYS_memcpy
void CPDF_StandardCryptoHandler::CryptBlock(FX_BOOL bEncrypt,
FX_DWORD objnum,
FX_DWORD gennum,
const uint8_t* src_buf,
FX_DWORD src_size,
uint8_t* dest_buf,
FX_DWORD& dest_size) {
if (m_Cipher == FXCIPHER_NONE) {
FXSYS_memcpy(dest_buf, src_buf, src_size);
return;
}
uint8_t realkey[16];
int realkeylen = 16;
if (m_Cipher != FXCIPHER_AES || m_KeyLen != 32) {
uint8_t key1[32];
FXSYS_memcpy(key1, m_EncryptKey, m_KeyLen);
key1[m_KeyLen + 0] = (uint8_t)objnum;
key1[m_KeyLen + 1] = (uint8_t)(objnum >> 8);
key1[m_KeyLen + 2] = (uint8_t)(objnum >> 16);
key1[m_KeyLen + 3] = (uint8_t)gennum;
key1[m_KeyLen + 4] = (uint8_t)(gennum >> 8);
FXSYS_memcpy(key1 + m_KeyLen, &objnum, 3);
FXSYS_memcpy(key1 + m_KeyLen + 3, &gennum, 2);
if (m_Cipher == FXCIPHER_AES) {
FXSYS_memcpy(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;
}
}
示例3: FXSYS_memcpy
void CPDF_CryptoHandler::CryptBlock(bool bEncrypt,
uint32_t objnum,
uint32_t gennum,
const uint8_t* src_buf,
uint32_t src_size,
uint8_t* dest_buf,
uint32_t& dest_size) {
if (m_Cipher == FXCIPHER_NONE) {
FXSYS_memcpy(dest_buf, src_buf, src_size);
return;
}
uint8_t realkey[16];
int realkeylen = 16;
if (m_Cipher != FXCIPHER_AES || m_KeyLen != 32) {
uint8_t key1[32];
PopulateKey(objnum, gennum, key1);
if (m_Cipher == FXCIPHER_AES) {
FXSYS_memcpy(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;
}
}
if (m_Cipher == FXCIPHER_AES) {
CRYPT_AESSetKey(m_pAESContext, 16, m_KeyLen == 32 ? m_EncryptKey : realkey,
m_KeyLen, bEncrypt);
if (bEncrypt) {
uint8_t iv[16];
for (int i = 0; i < 16; i++) {
iv[i] = (uint8_t)rand();
}
CRYPT_AESSetIV(m_pAESContext, iv);
FXSYS_memcpy(dest_buf, iv, 16);
int nblocks = src_size / 16;
CRYPT_AESEncrypt(m_pAESContext, dest_buf + 16, src_buf, nblocks * 16);
uint8_t padding[16];
FXSYS_memcpy(padding, src_buf + nblocks * 16, src_size % 16);
FXSYS_memset(padding + src_size % 16, 16 - src_size % 16,
16 - src_size % 16);
CRYPT_AESEncrypt(m_pAESContext, dest_buf + nblocks * 16 + 16, padding,
16);
dest_size = 32 + nblocks * 16;
} else {
CRYPT_AESSetIV(m_pAESContext, src_buf);
CRYPT_AESDecrypt(m_pAESContext, dest_buf, src_buf + 16, src_size - 16);
dest_size = src_size - 16;
dest_size -= dest_buf[dest_size - 1];
}
} else {
ASSERT(dest_size == src_size);
if (dest_buf != src_buf) {
FXSYS_memcpy(dest_buf, src_buf, src_size);
}
CRYPT_ArcFourCryptBlock(dest_buf, dest_size, realkey, realkeylen);
}
}
示例4: FXSYS_wcslen
FX_STRSIZE CFX_WideString::Replace(const FX_WCHAR* lpszOld, const FX_WCHAR* lpszNew)
{
if (GetLength() < 1) {
return 0;
}
if (lpszOld == NULL) {
return 0;
}
FX_STRSIZE nSourceLen = FXSYS_wcslen(lpszOld);
if (nSourceLen == 0) {
return 0;
}
FX_STRSIZE nReplacementLen = lpszNew ? FXSYS_wcslen(lpszNew) : 0;
FX_STRSIZE nCount = 0;
FX_WCHAR* lpszStart = m_pData->m_String;
FX_WCHAR* lpszEnd = m_pData->m_String + m_pData->m_nDataLength;
FX_WCHAR* lpszTarget;
{
while ((lpszTarget = (FX_WCHAR*)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) {
StringData* pOldData = m_pData;
const FX_WCHAR* pstr = m_pData->m_String;
m_pData = StringData::Create(nNewLength);
if (!m_pData) {
return 0;
}
FXSYS_memcpy(m_pData->m_String, pstr, pOldData->m_nDataLength * sizeof(FX_WCHAR));
pOldData->Release();
}
lpszStart = m_pData->m_String;
lpszEnd = m_pData->m_String + FX_MAX(m_pData->m_nDataLength, nNewLength);
{
while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) != NULL && lpszStart < lpszEnd) {
FX_STRSIZE nBalance = nOldLength - (FX_STRSIZE)(lpszTarget - m_pData->m_String + nSourceLen);
FXSYS_memmove(lpszTarget + nReplacementLen, lpszTarget + nSourceLen, nBalance * sizeof(FX_WCHAR));
FXSYS_memcpy(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;
}
示例5: FXSYS_memcpy
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 = StringData::Create(nNewLen);
if (m_pData) {
FXSYS_memcpy(m_pData->m_String, str1.GetPtr(), str1.GetLength()*sizeof(FX_WCHAR));
FXSYS_memcpy(m_pData->m_String + str1.GetLength(), str2.GetPtr(), str2.GetLength()*sizeof(FX_WCHAR));
}
}
示例6: ASSERT
void CFDE_TxtEdtBuf::Insert(int32_t nPos,
const FX_WCHAR* lpText,
int32_t nLength) {
ASSERT(nPos >= 0 && nPos <= m_nTotal);
FDE_CHUNKPLACE cp;
Index2CP(nPos, cp);
int32_t nLengthTemp = nLength;
if (cp.nCharIndex != 0) {
FDE_CHUNKHEADER* lpNewChunk =
static_cast<FDE_CHUNKHEADER*>(m_pAllocator->Alloc(
sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR)));
FDE_CHUNKHEADER* lpChunk = m_Chunks[cp.nChunkIndex];
int32_t nCopy = lpChunk->nUsed - cp.nCharIndex;
FXSYS_memcpy(lpNewChunk->wChars, lpChunk->wChars + cp.nCharIndex,
nCopy * sizeof(FX_WCHAR));
lpChunk->nUsed -= nCopy;
cp.nChunkIndex++;
m_Chunks.InsertAt(cp.nChunkIndex, lpNewChunk);
lpNewChunk->nUsed = nCopy;
cp.nCharIndex = 0;
}
if (cp.nChunkIndex != 0) {
FDE_CHUNKHEADER* lpChunk = m_Chunks[cp.nChunkIndex - 1];
if (lpChunk->nUsed != m_nChunkSize) {
cp.nChunkIndex--;
int32_t nFree = m_nChunkSize - lpChunk->nUsed;
int32_t nCopy = std::min(nLengthTemp, nFree);
FXSYS_memcpy(lpChunk->wChars + lpChunk->nUsed, lpText,
nCopy * sizeof(FX_WCHAR));
lpText += nCopy;
nLengthTemp -= nCopy;
lpChunk->nUsed += nCopy;
cp.nChunkIndex++;
}
}
while (nLengthTemp > 0) {
FDE_CHUNKHEADER* lpChunk =
static_cast<FDE_CHUNKHEADER*>(m_pAllocator->Alloc(
sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR)));
ASSERT(lpChunk);
int32_t nCopy = std::min(nLengthTemp, m_nChunkSize);
FXSYS_memcpy(lpChunk->wChars, lpText, nCopy * sizeof(FX_WCHAR));
lpText += nCopy;
nLengthTemp -= nCopy;
lpChunk->nUsed = nCopy;
m_Chunks.InsertAt(cp.nChunkIndex, lpChunk);
cp.nChunkIndex++;
}
m_nTotal += nLength;
m_bChanged = TRUE;
}
示例7: _CompactStringStore
static void _CompactStringStore(_CompactString* pCompact,
const uint8_t* pStr,
int len) {
if (len < (int)sizeof(_CompactString)) {
pCompact->m_CompactLen = (uint8_t)len;
FXSYS_memcpy(&pCompact->m_LenHigh, pStr, len);
return;
}
pCompact->m_CompactLen = 0xff;
pCompact->m_LenHigh = len / 256;
pCompact->m_LenLow = len % 256;
pCompact->m_pBuffer = FX_Alloc(uint8_t, len);
FXSYS_memcpy(pCompact->m_pBuffer, pStr, len);
}
示例8: CalcEncryptKey
FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword(
const uint8_t* password,
FX_DWORD pass_size,
FX_BOOL bIgnoreEncryptMeta,
uint8_t* key,
int32_t 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;
}
uint8_t ukeybuf[32];
if (m_Revision == 2) {
FXSYS_memcpy(ukeybuf, defpasscode, 32);
CRYPT_ArcFourCryptBlock(ukeybuf, 32, key, key_len);
} else {
uint8_t test[32], tmpkey[32];
FX_DWORD copy_len = sizeof(test);
if (copy_len > (FX_DWORD)ukey.GetLength()) {
copy_len = ukey.GetLength();
}
FXSYS_memset(test, 0, sizeof(test));
FXSYS_memset(tmpkey, 0, sizeof(tmpkey));
FXSYS_memcpy(test, ukey.c_str(), 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);
}
uint8_t 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, (uint8_t*)id.c_str(), id.GetLength());
}
CRYPT_MD5Finish(md5, ukeybuf);
return FXSYS_memcmp(test, ukeybuf, 16) == 0;
}
if (FXSYS_memcmp((void*)ukey.c_str(), ukeybuf, 16) == 0) {
return TRUE;
}
return FALSE;
}
示例9: CRYPT_MD5Generate
CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(
const uint8_t* owner_pass,
FX_DWORD pass_size,
int32_t key_len) {
CFX_ByteString okey = m_pEncryptDict->GetString(FX_BSTRC("O"));
uint8_t passcode[32];
FX_DWORD i;
for (i = 0; i < 32; i++) {
passcode[i] = i < pass_size ? owner_pass[i] : defpasscode[i - pass_size];
}
uint8_t digest[16];
CRYPT_MD5Generate(passcode, 32, digest);
if (m_Revision >= 3) {
for (int i = 0; i < 50; i++) {
CRYPT_MD5Generate(digest, 16, digest);
}
}
uint8_t enckey[32];
FXSYS_memset(enckey, 0, sizeof(enckey));
FX_DWORD copy_len = key_len;
if (copy_len > sizeof(digest)) {
copy_len = sizeof(digest);
}
FXSYS_memcpy(enckey, digest, copy_len);
int okeylen = okey.GetLength();
if (okeylen > 32) {
okeylen = 32;
}
uint8_t okeybuf[64];
FXSYS_memset(okeybuf, 0, sizeof(okeybuf));
FXSYS_memcpy(okeybuf, okey.c_str(), okeylen);
if (m_Revision == 2) {
CRYPT_ArcFourCryptBlock(okeybuf, okeylen, enckey, key_len);
} else {
for (int i = 19; i >= 0; i--) {
uint8_t tempkey[32];
FXSYS_memset(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);
}
示例10: FXSYS_memcpy
FX_BOOL CFX_BasicArray::Copy(const CFX_BasicArray& src) {
if (!SetSize(src.m_nSize)) {
return FALSE;
}
FXSYS_memcpy(m_pData, src.m_pData, src.m_nSize * m_nUnitSize);
return TRUE;
}
示例11: Index2CP
void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText,
int32_t nBegin,
int32_t nLength) const {
FDE_CHUNKPLACE cp;
Index2CP(nBegin, cp);
int32_t nLeave = nLength;
int32_t nCount = m_Chunks.GetSize();
FX_WCHAR* lpDstBuf = wsText.GetBuffer(nLength);
int32_t nChunkIndex = cp.nChunkIndex;
FDE_CHUNKHEADER* lpChunkHeader = m_Chunks[nChunkIndex];
int32_t nCopyLength = lpChunkHeader->nUsed - cp.nCharIndex;
FX_WCHAR* lpSrcBuf = lpChunkHeader->wChars + cp.nCharIndex;
while (nLeave > 0) {
if (nLeave <= nCopyLength) {
nCopyLength = nLeave;
}
FXSYS_memcpy(lpDstBuf, lpSrcBuf, nCopyLength * sizeof(FX_WCHAR));
nChunkIndex++;
if (nChunkIndex >= nCount) {
break;
}
lpChunkHeader = m_Chunks[nChunkIndex];
lpSrcBuf = lpChunkHeader->wChars;
nLeave -= nCopyLength;
lpDstBuf += nCopyLength;
nCopyLength = lpChunkHeader->nUsed;
}
wsText.ReleaseBuffer();
}
示例12: FX_Free
void CPDF_Stream::SetData(const uint8_t* 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 = (uint8_t*)pData;
} else {
m_pDataBuf = FX_Alloc(uint8_t, size);
if (pData) {
FXSYS_memcpy(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"));
}
}
示例13: while
FX_BOOL CXFA_FileRead::ReadBlock(void* buffer,
FX_FILESIZE offset,
size_t size) {
int32_t iCount = m_Data.GetSize();
int32_t index = 0;
while (index < iCount) {
CPDF_StreamAcc& acc = m_Data[index];
FX_FILESIZE dwSize = acc.GetSize();
if (offset < dwSize) {
break;
}
offset -= dwSize;
index++;
}
while (index < iCount) {
CPDF_StreamAcc& acc = m_Data[index];
uint32_t dwSize = acc.GetSize();
size_t dwRead = std::min(size, static_cast<size_t>(dwSize - offset));
FXSYS_memcpy(buffer, acc.GetData() + offset, dwRead);
size -= dwRead;
if (size == 0) {
return TRUE;
}
buffer = (uint8_t*)buffer + dwRead;
offset = 0;
index++;
}
return FALSE;
}
示例14: FPDF_StringHandleGetStringByIndex
DLLEXPORT FPDF_BOOL STDCALL
FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE sHandle,
int index,
FPDF_BYTESTRING bsText,
FPDF_DWORD* size) {
if (!sHandle || !size)
return FALSE;
int count = FPDF_StringHandleCounts(sHandle);
if (index < 0 || index >= count)
return FALSE;
std::vector<CFX_ByteString>* sSuggestWords = FromFPDFStringHandle(sHandle);
int len = (*sSuggestWords)[index].GetLength();
if (!bsText) {
*size = len;
return TRUE;
}
int real_size = len < *size ? len : *size;
if (real_size > 0)
FXSYS_memcpy((void*)bsText, (const FX_CHAR*)(*sSuggestWords)[index],
real_size);
*size = real_size;
return TRUE;
}
示例15: FXSYS_memcpy
bool CFX_BasicArray::Copy(const CFX_BasicArray& src) {
if (!SetSize(src.m_nSize)) {
return false;
}
FXSYS_memcpy(m_pData, src.m_pData, src.m_nSize * m_nUnitSize);
return true;
}