本文整理汇总了C++中CopyMemory函数的典型用法代码示例。如果您正苦于以下问题:C++ CopyMemory函数的具体用法?C++ CopyMemory怎么用?C++ CopyMemory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CopyMemory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xf_rail_window_common
//.........这里部分代码省略.........
appWindow->clientOffsetY = windowState->clientOffsetY;
}
if (fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
{
appWindow->clientAreaWidth = windowState->clientAreaWidth;
appWindow->clientAreaHeight = windowState->clientAreaHeight;
}
if (fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
{
appWindow->windowClientDeltaX = windowState->windowClientDeltaX;
appWindow->windowClientDeltaY = windowState->windowClientDeltaY;
}
if (fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
{
if (appWindow->windowRects)
{
free(appWindow->windowRects);
appWindow->windowRects = NULL;
}
appWindow->numWindowRects = windowState->numWindowRects;
if (appWindow->numWindowRects)
{
appWindow->windowRects = (RECTANGLE_16*) calloc(appWindow->numWindowRects,
sizeof(RECTANGLE_16));
if (!appWindow->windowRects)
return FALSE;
CopyMemory(appWindow->windowRects, windowState->windowRects,
appWindow->numWindowRects * sizeof(RECTANGLE_16));
}
}
if (fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET)
{
appWindow->visibleOffsetX = windowState->visibleOffsetX;
appWindow->visibleOffsetY = windowState->visibleOffsetY;
}
if (fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
{
if (appWindow->visibilityRects)
{
free(appWindow->visibilityRects);
appWindow->visibilityRects = NULL;
}
appWindow->numVisibilityRects = windowState->numVisibilityRects;
if (appWindow->numVisibilityRects)
{
appWindow->visibilityRects = (RECTANGLE_16*) calloc(
appWindow->numVisibilityRects, sizeof(RECTANGLE_16));
if (!appWindow->visibilityRects)
return FALSE;
CopyMemory(appWindow->visibilityRects, windowState->visibilityRects,
appWindow->numVisibilityRects * sizeof(RECTANGLE_16));
}
}
示例2: switch
//游戏场景
bool CGameClientDlg::OnGameSceneMessage(BYTE cbGameStation, bool bLookonOther, const void * pBuffer, WORD wDataSize)
{
switch (cbGameStation)
{
case GS_FREE: //空闲状态
{
//效验数据
if (wDataSize!=sizeof(CMD_S_StatusFree)) return false;
CMD_S_StatusFree * pStatusFree=(CMD_S_StatusFree *)pBuffer;
//设置控件
if (IsLookonMode()==false)
{
m_GameClientView.m_btStart.ShowWindow(SW_SHOW);
m_GameClientView.m_btStart.SetFocus();
}
//设置时间
if (IsLookonMode()==false) SetGameTimer(GetMeChairID(),IDI_START_GAME,30);
return true;
}
case GS_PLAYING: //游戏状态
{
//效验数据
if (wDataSize!=sizeof(CMD_S_StatusPlay)) return false;
CMD_S_StatusPlay * pStatusPlay=(CMD_S_StatusPlay *)pBuffer;
//下注信息
m_lMaxScore=pStatusPlay->lMaxScore;
m_lCellScore=pStatusPlay->lCellScore;
m_lTurnMaxScore=pStatusPlay->lTurnMaxScore;
m_lTurnLessScore=pStatusPlay->lTurnLessScore;
CopyMemory(m_lTableScore,pStatusPlay->lTableScore,sizeof(m_lTableScore));
//状态变量
m_wCurrentUser=pStatusPlay->wCurrentUser;
m_bAddScore=(pStatusPlay->bAddScore==TRUE)?true:false;
m_bShowHand=(pStatusPlay->bShowHand==TRUE)?true:false;
CopyMemory(m_cbPlayStatus,pStatusPlay->cbPlayStatus,sizeof(m_cbPlayStatus));
//帐号名字
for (WORD i=0;i<GAME_PLAYER;i++)
{
const tagUserData * pUserData=GetUserData(i);
if (pUserData!=NULL) lstrcpyn(m_szAccounts[i],pUserData->szName,CountArray(m_szAccounts[i]));
}
//设置界面
LONG lTableScore=0L;
for (WORD i=0;i<GAME_PLAYER;i++)
{
//设置位置
WORD wViewChairID=SwitchViewChairID(i);
//设置扑克
if (m_cbPlayStatus[i]==TRUE)
{
BYTE cbCardCount=pStatusPlay->cbCardCount[i];
m_GameClientView.m_CardControl[wViewChairID].SetCardData(pStatusPlay->cbHandCardData[i],cbCardCount);
}
lTableScore += m_lTableScore[2*i+1];
//筹码设置
m_GameClientView.m_PlayerJeton[wViewChairID].SetScore(m_lTableScore[2*i]);
//设置下注
m_GameClientView.SetUserTableScore(wViewChairID,m_lTableScore[2*i]+m_lTableScore[2*i+1]);
}
m_GameClientView.m_PlayerJeton[GAME_PLAYER].SetScore(lTableScore);
//
m_GameClientView.SetCellScore(m_lCellScore);
//玩家设置
if (IsLookonMode()==false)
{
//控制设置
m_GameClientView.m_CardControl[2].SetPositively(true);
if (m_wCurrentUser==GetMeChairID()) UpdateScoreControl();
}
//设置定时器
SetGameTimer(m_wCurrentUser,IDI_USER_ADD_SCORE,TIME_USER_ADD_SCORE);
return true;
}
}
return false;
}
示例3: DetourAttachEx
//.........这里部分代码省略.........
pTrampoline->rAlign[n].obTrampoline
));
}
DETOUR_TRACE((" ]\n"));
}
#endif
if (cbTarget < cbJump || nAlign > ARRAYSIZE(pTrampoline->rAlign)) {
// Too few instructions.
error = ERROR_INVALID_BLOCK;
if (s_fIgnoreTooSmall) {
goto stop;
}
else {
DETOUR_BREAK();
goto fail;
}
}
if (pbTrampoline > pbPool) {
__debugbreak();
}
#if 0 // [GalenH]
if (cbTarget < pbTrampoline - pTrampoline->rbCode) {
__debugbreak();
}
#endif
pTrampoline->cbCode = (BYTE)(pbTrampoline - pTrampoline->rbCode);
pTrampoline->cbRestore = (BYTE)cbTarget;
CopyMemory(pTrampoline->rbRestore, pbTarget, cbTarget);
#if !defined(DETOURS_IA64)
if (cbTarget > sizeof(pTrampoline->rbCode) - cbJump) {
// Too many instructions.
error = ERROR_INVALID_HANDLE;
DETOUR_BREAK();
goto fail;
}
#endif // !DETOURS_IA64
pTrampoline->pbRemain = pbTarget + cbTarget;
pTrampoline->pbDetour = (PBYTE)pDetour;
#ifdef DETOURS_IA64
#error Feature not supported in this release.
示例4: CopyMemory
//-----------------------------------------------------------------------------
// Name: CWaveFile::Read()
// Desc: Reads section of data from a wave file into pBuffer and returns
// how much read in pdwSizeRead, reading not more than dwSizeToRead.
// This uses m_ck to determine where to start reading from. So
// subsequent calls will be continue where the last left off unless
// Reset() is called.
//-----------------------------------------------------------------------------
HRESULT CPCMFile::Read( BYTE* pBuffer, DWORD dwSizeToRead, DWORD* pdwSizeRead )
{
if( m_bIsReadingFromMemory )
{
if( m_pbDataCur == NULL )
return CO_E_NOTINITIALIZED;
if( pdwSizeRead != NULL )
*pdwSizeRead = 0;
if( (BYTE*)(m_pbDataCur + dwSizeToRead) >
(BYTE*)(m_pbData + m_ulDataSize) )
{
dwSizeToRead = m_ulDataSize - (DWORD)(m_pbDataCur - m_pbData);
}
CopyMemory( pBuffer, m_pbDataCur, dwSizeToRead );
if( pdwSizeRead != NULL )
*pdwSizeRead = dwSizeToRead;
return S_OK;
}
else
{
MMIOINFO mmioinfoIn; // current status of m_hmmio
if( m_hmmio == NULL )
return CO_E_NOTINITIALIZED;
if( pBuffer == NULL || pdwSizeRead == NULL )
return E_INVALIDARG;
if( pdwSizeRead != NULL )
*pdwSizeRead = 0;
if( 0 != mmioGetInfo( m_hmmio, &mmioinfoIn, 0 ) )
return DXTRACE_ERR( TEXT("mmioGetInfo"), E_FAIL );
UINT cbDataIn = dwSizeToRead;
if( cbDataIn > m_ck.cksize )
cbDataIn = m_ck.cksize;
m_ck.cksize -= cbDataIn;
for( DWORD cT = 0; cT < cbDataIn; cT++ )
{
// Copy the bytes from the io to the buffer.
if( mmioinfoIn.pchNext == mmioinfoIn.pchEndRead )
{
if( 0 != mmioAdvance( m_hmmio, &mmioinfoIn, MMIO_READ ) )
return DXTRACE_ERR( TEXT("mmioAdvance"), E_FAIL );
//if( mmioinfoIn.pchNext == mmioinfoIn.pchEndRead )
// return DXTRACE_ERR( TEXT("mmioinfoIn.pchNext"), E_FAIL );
}
// Actual copy.
*((BYTE*)pBuffer+cT) = *((BYTE*)mmioinfoIn.pchNext);
mmioinfoIn.pchNext++;
}
if( 0 != mmioSetInfo( m_hmmio, &mmioinfoIn, 0 ) )
return DXTRACE_ERR( TEXT("mmioSetInfo"), E_FAIL );
if( pdwSizeRead != NULL )
*pdwSizeRead = cbDataIn;
return S_OK;
}
}
示例5: WndProc
//.........这里部分代码省略.........
for(i = 0 ; i < sizeof(ptWaveL)/sizeof(ptWaveL[0]) ; i++)
ptWaveL[i].y=250; //center for wave drawn 195
if(wfe.nChannels == 2)
for(i=0 ; i<sizeof(ptWaveR)/sizeof(ptWaveR[0]) ; i++)
ptWaveR[i].y=250; //center for wave drawn 195
play = FALSE;
rcMove.left = rcInfo[0].left;
wsprintf(strState, "ready");
KillTimer(hwnd, 1);
InvalidateRect(hwnd, &rcWave, FALSE);
InvalidateRect(hwnd, &rcInfo[0], FALSE);
InvalidateRect(hwnd, &rcInfo[1], FALSE);
InvalidateRect(hwnd, &rcInfo[3], FALSE);
return 0;
case WM_TIMER:
rcMove.left-= 1;
if(rcMove.left<-sizeFile.cx) rcMove.left = rcInfo[0].right;
waveOutGetPosition(hWaveOut, &mmTime, sizeof(MMTIME));
dwOffset = mmTime.u.cb;
iTimeCursor = (double)dwOffset/whdr.dwBufferLength*600; //change Cursor coordinate
for(i = -612 ; i <= 612 ; i++) //-310 310
{ //left
s = 0;
dw = dwOffset + i*wfe.nBlockAlign;
if(0 <= dw && dw < whdr.dwBufferLength)
{
CopyMemory(&s, whdr.lpData+dw, wfe.wBitsPerSample/8);
if(wfe.wBitsPerSample == 8) s-= 128; // shift no volume(128) to 0
}
ptWaveL[i+612].y = 185*(-s)/wHalfMaxAmp + 250; //ptWaveL[i+310].y + 195;
}
if(wfe.nChannels == 2)
{ //stereo
for(i = -612 ; i <= 612 ; i++)//-310 310
{ //right
s = 0;
dw = dwOffset + i*wfe.nBlockAlign + wfe.wBitsPerSample/8;
if(0 <= dw && dw < whdr.dwBufferLength)
{
CopyMemory(&s, whdr.lpData + dw, wfe.wBitsPerSample/8);
if(wfe.wBitsPerSample == 8) s-=128; //shift no volume(128) to 0
}
ptWaveR[i+612].y = 185*(-s)/wHalfMaxAmp + 250; //ptWaveR[i+310].y +195
}
}
dw = (double)dwOffset/wfe.nAvgBytesPerSec*100;
wsprintf(strTime, "%02d:%02d:%02d/%02d:%02d:%02d",
(dw/100)/60,(dw/100)%60,dw%100, //current time
(maxTime/100)/60,(maxTime/100)%60,maxTime%100); //total time
InvalidateRect(hwnd, &rcWave, FALSE);
InvalidateRect(hwnd, &rcInfo[0], FALSE);
InvalidateRect(hwnd, &rcInfo[1], FALSE);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
StretchDIBits(hdc_mem, 0, 0, iWidth, iHeight, 0, 0, iWidth, iHeight, lpPixel, &bmpInfo, DIB_RGB_COLORS, SRCCOPY);
示例6: bmptoDIB
LPDWORD bmptoDIB(TCHAR *fileName, LPBITMAPINFO lpbiInfo)
{
HANDLE fhBMP;
int iFileSize;
LPBYTE lpBMP;
DWORD dwReadSize;
LPBITMAPFILEHEADER lpbmpfh;
LPBITMAPINFO lpbiBMPInfo;
LPBYTE lpBMPPixel;
LPDWORD dwColors;
int iwidth,iheight;
LPDWORD lpPixel;
int bitCount;
int iLength,x,y;
TCHAR err[20];
fhBMP = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(fhBMP == INVALID_HANDLE_VALUE)
{
CloseHandle(fhBMP);
wsprintf(err, TEXT("cannot open a file %d"), GetLastError());
MessageBox(NULL, err, fileName, MB_OK);
return NULL;
}
iFileSize=GetFileSize(fhBMP,NULL);
lpBMP=(LPBYTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,iFileSize);
ReadFile(fhBMP,lpBMP,iFileSize,&dwReadSize,NULL);
CloseHandle(fhBMP);
lpbmpfh=(LPBITMAPFILEHEADER)(lpBMP);
lpbiBMPInfo=(LPBITMAPINFO)(lpBMP+sizeof(BITMAPFILEHEADER));
bitCount = lpbiBMPInfo->bmiHeader.biBitCount;
if(lpbmpfh->bfType!=('M'<<8)+'B' || bitCount != 8 && bitCount != 24)
{
HeapFree(GetProcessHeap(),0,lpBMP);
MessageBox(NULL,TEXT("Can read only 8 or 24 bit files"),fileName,MB_OK);
return NULL;
}
lpBMPPixel=lpBMP+(lpbmpfh->bfOffBits);
dwColors=(LPDWORD)(lpbiBMPInfo->bmiColors);
iwidth=lpbiBMPInfo->bmiHeader.biWidth;
iheight=lpbiBMPInfo->bmiHeader.biHeight;
lpPixel=(LPDWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,iwidth*iheight*4);
lpbiInfo->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
lpbiInfo->bmiHeader.biWidth=iwidth;
lpbiInfo->bmiHeader.biHeight=iheight;
lpbiInfo->bmiHeader.biPlanes=1;
lpbiInfo->bmiHeader.biBitCount=32;
lpbiInfo->bmiHeader.biCompression=BI_RGB;
if(iwidth*(bitCount/8)%4) iLength=iwidth*(bitCount/8)+(4-iwidth*(bitCount/8)%4);
else iLength=iwidth*(bitCount/8);
switch(bitCount)
{
case 8:
for(y=0;y<iheight;y++)
for(x=0;x<iwidth;x++)
CopyMemory(lpPixel+x+y*iwidth,dwColors+lpBMPPixel[x+y*iLength],3);
case 24:
for(y=0;y<iheight;y++)
for(x=0;x<iwidth;x++)
CopyMemory(lpPixel+x+y*iwidth,lpBMPPixel+x*3+y*iLength,3);
break;
}
HeapFree(GetProcessHeap(),0,lpBMP);
return lpPixel;
}
示例7: sizeof
//.........这里部分代码省略.........
m_sWidth = dTemplateEx->cx;
m_sHeight = dTemplateEx->cy;
wItems = dTemplateEx->cDlgItems;
}
else {
m_bExtended = false;
DLGTEMPLATE* dTemplate = (DLGTEMPLATE*)pbData;
m_dwStyle = dTemplate->style;
m_dwExtStyle = dTemplate->dwExtendedStyle;
m_sX = dTemplate->x;
m_sY = dTemplate->y;
m_sWidth = dTemplate->cx;
m_sHeight = dTemplate->cy;
wItems = dTemplate->cdit;
}
BYTE* seeker = pbData + (m_bExtended ? sizeof(DLGTEMPLATEEX) : sizeof(DLGTEMPLATE));
// Read menu variant length array
ReadVarLenArr(seeker, m_szMenu, m_uCodePage);
// Read class variant length array
ReadVarLenArr(seeker, m_szClass, m_uCodePage);
// Read title variant length array
ReadVarLenArr(seeker, m_szTitle, m_uCodePage);
// Read font size and variant length array (only if style DS_SETFONT is used!)
if (m_dwStyle & DS_SETFONT) {
m_sFontSize = *(short*)seeker;
seeker += sizeof(short);
if (m_bExtended) {
m_sFontWeight = *(short*)seeker;
seeker += sizeof(short);
m_bItalic = *(BYTE*)seeker;
seeker += sizeof(BYTE);
m_bCharset = *(BYTE*)seeker;
seeker += sizeof(BYTE);
}
ReadVarLenArr(seeker, m_szFont, m_uCodePage);
}
// Read items
for (int i = 0; i < wItems; i++) {
// DLGITEMTEMPLATE[EX]s must be aligned on DWORD boundry
if (DWORD(seeker - pbData) % sizeof(DWORD))
seeker += sizeof(WORD);
DialogItemTemplate* item = new DialogItemTemplate;
ZeroMemory(item, sizeof(DialogItemTemplate));
if (m_bExtended) {
DLGITEMTEMPLATEEX* rawItem = (DLGITEMTEMPLATEEX*)seeker;
item->dwHelpId = rawItem->helpID;
item->dwStyle = rawItem->style;
item->dwExtStyle = rawItem->exStyle;
item->sX = rawItem->x;
item->sY = rawItem->y;
item->sWidth = rawItem->cx;
item->sHeight = rawItem->cy;
item->wId = rawItem->id;
seeker += sizeof(DLGITEMTEMPLATEEX);
}
else {
DLGITEMTEMPLATE* rawItem = (DLGITEMTEMPLATE*)seeker;
item->dwStyle = rawItem->style;
item->dwExtStyle = rawItem->dwExtendedStyle;
item->sX = rawItem->x;
item->sY = rawItem->y;
item->sWidth = rawItem->cx;
item->sHeight = rawItem->cy;
item->wId = rawItem->id;
seeker += sizeof(DLGITEMTEMPLATE);
}
// Read class variant length array
ReadVarLenArr(seeker, item->szClass, m_uCodePage);
// Read title variant length array
ReadVarLenArr(seeker, item->szTitle, m_uCodePage);
// Read creation data variant length array
// First read the size of the array (no null termination)
item->wCreateDataSize = *(WORD*)seeker;
seeker += sizeof(WORD);
// Then read the array it self (if size is not 0)
if (item->wCreateDataSize) {
item->wCreateDataSize -= sizeof(WORD); // Size includes size field itself...
item->szCreationData = new char[item->wCreateDataSize];
CopyMemory(item->szCreationData, seeker, item->wCreateDataSize);
seeker += item->wCreateDataSize;
}
// Add the item to the vector
m_vItems.push_back(item);
}
}
示例8: CopyMemory
/*************************************************************************************
* FlushBuffer: pushes the buffer onto main array
*
**************************************************************************************/
BOOL cCombH::FlushBuffer()
{
//4 steps:
//0. check that there is data to flush.
//a. if socheck that regions are sequential and unique
//b. wham the regionBuffer onto each of the combos in the buffer
//c. copy the buffer to the main buffer
//d. clean out the buffer memory
BOOL bRetCode = false;
LPCOMBINATION pCMNew = NULL;
LPCOMBINATION p = NULL;
LPCOMBINATION q = NULL;
//0. check that there is data to flush.
if (!(0 < m_lComboBufferCount)) {goto SAFE_EXIT;}
if (!(0 < m_lRegionBufferCount)) {goto SAFE_EXIT;}
//a. if socheck that regions are sequential and unique
if (!CheckRegionsAreSequentialAndUnique()) {goto SAFE_EXIT;}
//b. wham the regionBuffer onto each of the combos in the buffer
for(q = m_pCMComboBuffer; q<m_pCMComboBuffer+m_lComboBufferCount;q++)
{
q->lRegionCount = m_lRegionBufferCount;
LPULONG pl = new ULONG[m_lRegionBufferCount];
CopyMemory(pl,m_plRegionBuffer,m_lRegionBufferCount*sizeof(ULONG));
q->plDisjointRegions = pl;
pl = NULL;
}
//c. copy the buffer to the main buffer
//initialize a new buffer with additional combo members
pCMNew = new COMBINATION[m_lCombinationCount + m_lComboBufferCount];
//copy the existing array into a new array
if (0 < m_lCombinationCount)
{
CopyMemory(pCMNew,m_pCMCombinations,m_lCombinationCount*sizeof(COMBINATION));
delete [] m_pCMCombinations;
}
m_pCMCombinations = pCMNew;
//get a pointer to the last elements of the combination array
p = m_pCMCombinations+m_lCombinationCount;
//copy the combo buffer over to the main array
CopyMemory(p,m_pCMComboBuffer,m_lComboBufferCount*sizeof(COMBINATION));
//increment total number of combinations
m_lCombinationCount += m_lComboBufferCount;
bRetCode = true;
SAFE_EXIT:
//d. clean out the buffer memory
delete[] m_pCMComboBuffer;
m_pCMComboBuffer = NULL;
m_lComboBufferCount = 0;
delete [] m_plRegionBuffer;
m_plRegionBuffer = NULL;
m_lRegionBufferCount = 0;
return bRetCode;
}
示例9: HrFindExchangeGlobalAddressList
//.........这里部分代码省略.........
// ---------------------------------------------------
// Initialize provider restriction to only Exchange providers
SRestrictAnd[0].rt = RES_PROPERTY;
SRestrictAnd[0].res.resProperty.relop = RELOP_EQ;
SRestrictAnd[0].res.resProperty.ulPropTag = PR_AB_PROVIDER_ID;
SPropProvider.ulPropTag = PR_AB_PROVIDER_ID;
SPropProvider.Value.bin.cb = 16;
SPropProvider.Value.bin.lpb = (LPBYTE)muid;
SRestrictAnd[0].res.resProperty.lpProp = &SPropProvider;
// Initialize container ID restriction to only GAL container
SRestrictAnd[1].rt = RES_PROPERTY;
SRestrictAnd[1].res.resProperty.relop = RELOP_EQ;
SRestrictAnd[1].res.resProperty.ulPropTag = PR_EMS_AB_CONTAINERID;
SPropID.ulPropTag = PR_EMS_AB_CONTAINERID;
SPropID.Value.l = 0;
SRestrictAnd[1].res.resProperty.lpProp = &SPropID;
// Initialize AND restriction
SRestrictGAL.rt = RES_AND;
SRestrictGAL.res.resAnd.cRes = 2;
SRestrictGAL.res.resAnd.lpRes = &SRestrictAnd[0];
// Restrict the table to the GAL - only a single row should remain
// Get the row corresponding to the GAL
//
// Query all the rows
//
hr = HrQueryAllRows(
lpContainerTable,
(LPSPropTagArray)&rgPropTags,
&SRestrictGAL,
NULL,
0,
&lpRows);
if(FAILED(hr) || (lpRows == NULL) || (lpRows->cRows != 1))
{
hr = HR_LOG(E_FAIL);
goto cleanup;
}
// Get the entry ID for the GAL
lpCurrProp = &(lpRows->aRow[0].lpProps[0]);
if(lpCurrProp->ulPropTag == PR_ENTRYID)
{
cbContainerEntryId = lpCurrProp->Value.bin.cb;
lpContainerEntryId = (LPENTRYID)lpCurrProp->Value.bin.lpb;
}
else
{
hr = HR_LOG(EDK_E_NOT_FOUND);
goto cleanup;
}
hr = MAPIAllocateBuffer(cbContainerEntryId, (LPVOID *)lppeid);
if(FAILED(hr))
{
*lpcbeid = 0;
*lppeid = NULL;
}
else
{
CopyMemory(
*lppeid,
lpContainerEntryId,
cbContainerEntryId);
*lpcbeid = cbContainerEntryId;
}
cleanup:
ULRELEASE(lpRootContainer);
ULRELEASE(lpContainerTable);
ULRELEASE(lpContainer);
FREEPROWS(lpRows);
if(FAILED(hr))
{
MAPIFREEBUFFER(*lppeid);
*lpcbeid = 0;
*lppeid = NULL;
}
RETURN(hr);
}
示例10: WanPacketRemovePacketsFromRingBuffer
/*!
\brief Moves the packets from the ring buffer to a given buffer.
\param pWanAdapter Pointer to WAN_ADAPTER structure associated with this instance.
\param Buffer Pointer to the destination, user allocated, buffer.
\param BuffSize Size of the buffer.
\return It returns the number of bytes correctly written to the destination buffer
*/
DWORD WanPacketRemovePacketsFromRingBuffer(PWAN_ADAPTER pWanAdapter, PUCHAR Buffer, DWORD BuffSize)
{
DWORD Copied;
struct bpf_hdr *Header;
Copied = 0;
DWORD ToCopy;
DWORD Increment;
ResetEvent(pWanAdapter->hReadEvent);
while (BuffSize > Copied)
{
if ( pWanAdapter->Free < pWanAdapter->Size )
{ //there are some packets in the selected (aka LocalData) buffer
Header = (struct bpf_hdr*)(pWanAdapter->Buffer + pWanAdapter->C);
if (Header->bh_caplen + sizeof (struct bpf_hdr) > BuffSize - Copied)
{ //if the packet does not fit into the user buffer, we've ended copying packets
return Copied;
}
*((struct bpf_hdr*)(Buffer + Copied)) = *Header;
Copied += sizeof(struct bpf_hdr);
pWanAdapter->C += sizeof(struct bpf_hdr);
if ( pWanAdapter->C == pWanAdapter->Size )
pWanAdapter->C = 0;
if ( pWanAdapter->Size - pWanAdapter->C < (DWORD)Header->bh_caplen )
{
//the packet is fragmented in the buffer (i.e. it skips the buffer boundary)
ToCopy = pWanAdapter->Size - pWanAdapter->C;
CopyMemory(Buffer + Copied,pWanAdapter->Buffer + pWanAdapter->C, ToCopy);
CopyMemory(Buffer + Copied + ToCopy, pWanAdapter->Buffer + 0, Header->bh_caplen - ToCopy);
pWanAdapter->C = Header->bh_caplen - ToCopy;
}
else
{
//the packet is not fragmented
CopyMemory(Buffer + Copied ,pWanAdapter->Buffer + pWanAdapter->C ,Header->bh_caplen);
pWanAdapter->C += Header->bh_caplen;
// if (c==size) inutile, contemplato nell "header atomico"
// c=0;
}
Copied += ALIGN_TO_WORD(Header->bh_caplen);
Increment = Header->bh_caplen + sizeof(struct bpf_hdr);
if ( pWanAdapter->Size - pWanAdapter->C < sizeof(struct bpf_hdr) )
{ //the next packet would be saved at the end of the buffer, but the NewHeader struct would be fragmented
//so the producer (--> the consumer) skips to the beginning of the buffer
Increment += pWanAdapter->Size - pWanAdapter->C;
pWanAdapter->C = 0;
}
pWanAdapter->Free += Increment;
}
else
return Copied;
}
return Copied;
}
示例11: CopyProtoentToBuffer
SIZE_T
WSAAPI
CopyProtoentToBuffer(IN PCHAR Buffer,
IN INT BufferLength,
IN PPROTOENT Protoent)
{
SIZE_T BufferSize, CurrentSize, NameSize;
PCHAR p = Buffer;
DWORD Aliases = 0;
DWORD i;
PPROTOENT ReturnedProtoent = (PPROTOENT)Buffer;
/* Determine the buffer size required */
BufferSize = BytesInProtoent(Protoent);
/* Check which size to use */
if ((DWORD)BufferLength > BufferSize)
{
/* Zero the buffer */
ZeroMemory(Buffer, BufferSize);
}
else
{
/* Zero the buffer */
ZeroMemory(Buffer, BufferLength);
}
/* Start with the raw servent */
CurrentSize = sizeof(PROTOENT);
/* Return the size needed now */
if (CurrentSize > (DWORD)BufferLength) return BufferSize;
/* Copy the servent and initialize it */
CopyMemory(p, Protoent, sizeof(PROTOENT));
p = Buffer + CurrentSize;
ReturnedProtoent->p_name = NULL;
ReturnedProtoent->p_aliases = NULL;
/* Find out how many aliases there are */
while (Protoent->p_aliases[Aliases])
{
/* Increase the alias count */
Aliases++;
}
/* Add the aliases to the size, and validate it */
CurrentSize += (Aliases + 1) * sizeof(ULONG_PTR);
if (CurrentSize > (DWORD)BufferLength)
{
/* Clear the aliases and return */
Protoent->p_aliases = NULL;
return BufferSize;
}
/* Write the aliases, update the pointer */
ReturnedProtoent->p_aliases = (PCHAR*)p;
p = Buffer + CurrentSize;
/* Add the service name to the size, and validate it */
NameSize = strlen(Protoent->p_name) + sizeof(CHAR);
CurrentSize += NameSize;
if (CurrentSize > (DWORD)BufferLength) return BufferSize;
/* Write the service name and update the pointer */
ReturnedProtoent->p_name = p;
CopyMemory(p, Protoent->p_name, NameSize);
p = Buffer + CurrentSize;
/* Now add the aliases */
for (i = 0; i < Aliases; i++)
{
/* Update size and validate */
NameSize = strlen(Protoent->p_aliases[i]) + sizeof(CHAR);
CurrentSize += NameSize;
if (CurrentSize > (DWORD)BufferLength) return BufferSize;
/* Write pointer and copy */
ReturnedProtoent->p_aliases[i] = p;
CopyMemory(p, Protoent->p_aliases[i], NameSize);
/* Update pointer */
p = Buffer + CurrentSize;
}
/* Finalize the list and return */
ReturnedProtoent->p_aliases[i] = NULL;
return BufferSize;
}
示例12: FreePIDLArray
void CShellContextMenu::SetPath(const tstring& strPath)
{
// free all allocated datas
if(m_psfFolder && bDelete)
m_psfFolder->Release();
m_psfFolder = NULL;
FreePIDLArray(m_pidlArray);
m_pidlArray = NULL;
// get IShellFolder interface of Desktop(root of shell namespace)
IShellFolder* psfDesktop = NULL;
SHGetDesktopFolder(&psfDesktop);
// ParseDisplayName creates a PIDL from a file system path relative to the IShellFolder interface
// but since we use the Desktop as our interface and the Desktop is the namespace root
// that means that it's a fully qualified PIDL, which is what we need
LPITEMIDLIST pidl = NULL;
psfDesktop->ParseDisplayName(NULL, 0, (LPOLESTR)const_cast<TCHAR*>(strPath.c_str()), NULL, &pidl, NULL);
// now we need the parent IShellFolder interface of pidl, and the relative PIDL to that interface
typedef HRESULT (CALLBACK* LPFUNC)(LPCITEMIDLIST pidl, REFIID riid, void **ppv, LPCITEMIDLIST *ppidlLast);
LPFUNC MySHBindToParent = (LPFUNC)GetProcAddress(LoadLibrary(_T("shell32")), "SHBindToParent");
if(MySHBindToParent == NULL) return;
MySHBindToParent(pidl, IID_IShellFolder, (LPVOID*)&m_psfFolder, NULL);
// get interface to IMalloc (need to free the PIDLs allocated by the shell functions)
LPMALLOC lpMalloc = NULL;
SHGetMalloc(&lpMalloc);
lpMalloc->Free(pidl);
// now we need the relative pidl
IShellFolder* psfFolder = NULL;
HRESULT res = psfDesktop->ParseDisplayName (NULL, 0, (LPOLESTR)const_cast<TCHAR*>(strPath.c_str()), NULL, &pidl, NULL);
if(res != S_OK) return;
LPITEMIDLIST pidlItem = NULL;
SHBindToParent(pidl, IID_IShellFolder, (LPVOID*)&psfFolder, (LPCITEMIDLIST*)&pidlItem);
// copy pidlItem to m_pidlArray
m_pidlArray = (LPITEMIDLIST *) realloc(m_pidlArray, sizeof (LPITEMIDLIST));
int nSize = 0;
LPITEMIDLIST pidlTemp = pidlItem;
if(pidlTemp) //[+]PPA http://iceberg.leschat.net/forum/index.php?s=&showtopic=265&view=findpost&p=26331
while(pidlTemp->mkid.cb)
{
nSize += pidlTemp->mkid.cb;
pidlTemp = (LPITEMIDLIST) (((LPBYTE) pidlTemp) + pidlTemp->mkid.cb);
}
LPITEMIDLIST pidlRet = (LPITEMIDLIST) calloc(nSize + sizeof (USHORT), sizeof (BYTE));
CopyMemory(pidlRet, pidlItem, nSize);
m_pidlArray[0] = pidlRet;
//free(pidlItem);
lpMalloc->Free(pidl);
lpMalloc->Release();
if(psfFolder) //[+]PPA http://iceberg.leschat.net/forum/index.php?showtopic=265&st=2320&#
psfFolder->Release();
psfDesktop->Release();
bDelete = true; // indicates that m_psfFolder should be deleted by CShellContextMenu
}
示例13: switch
//用户通知
bool CClientKernel::OnIPCUser(const IPC_Head * pHead, const void * pIPCBuffer, WORD wDataSize, HWND hWndSend)
{
switch (pHead->wSubCmdID)
{
case IPC_SUB_USER_COME: //用户消息
{
//效验参数
if (wDataSize<sizeof(tagUserInfoHead)) return false;
//读取基本信息
tagUserData *pUserData = new tagUserData;
tagUserInfoHead * pUserInfoHead=(tagUserInfoHead *)pIPCBuffer;
pUserData->wFaceID=pUserInfoHead->wFaceID;
//pUserData->dwCustomFaceVer=pUserInfoHead->dwCustomFaceVer;
pUserData->wTableID=pUserInfoHead->wTableID;
pUserData->wChairID=pUserInfoHead->wChairID;
pUserData->cbGender=pUserInfoHead->cbGender;
pUserData->cbUserStatus=pUserInfoHead->cbUserStatus;
pUserData->cbMemberOrder=pUserInfoHead->cbMemberOrder;
pUserData->cbMasterOrder=pUserInfoHead->cbMasterOrder;
pUserData->dwUserID=pUserInfoHead->dwUserID;
pUserData->dwGameID=pUserInfoHead->dwGameID;
pUserData->dwGroupID=pUserInfoHead->dwGroupID;
pUserData->dwUserRight=pUserInfoHead->dwUserRight;
//pUserData->dwLoveliness=pUserInfoHead->dwLoveliness;
pUserData->dwMasterRight=pUserInfoHead->dwMasterRight;
pUserData->lScore=pUserInfoHead->UserScoreInfo.lScore;
//pUserData->lGameGold=pUserInfoHead->UserScoreInfo.lGameGold;
//pUserData->lInsureScore=pUserInfoHead->UserScoreInfo.lInsureScore;
pUserData->lWinCount=pUserInfoHead->UserScoreInfo.lWinCount;
pUserData->lLostCount=pUserInfoHead->UserScoreInfo.lLostCount;
pUserData->lDrawCount=pUserInfoHead->UserScoreInfo.lDrawCount;
pUserData->lFleeCount=pUserInfoHead->UserScoreInfo.lFleeCount;
pUserData->lExperience=pUserInfoHead->UserScoreInfo.lExperience;
//for ( WORD wPropID = 0; wPropID < PROPERTY_COUNT; ++wPropID )
//{
//pUserData->dwPropResidualTime[wPropID] = pUserInfoHead->dwPropResidualTime[wPropID];
//}
//读取扩展信息
void * pDataBuffer=NULL;
tagDataDescribe DataDescribe;
CRecvPacketHelper RecvPacket(pUserInfoHead+1,wDataSize-sizeof(tagUserInfoHead));
while (true)
{
pDataBuffer=RecvPacket.GetData(DataDescribe);
if (DataDescribe.wDataDescribe==DTP_NULL) break;
switch (DataDescribe.wDataDescribe)
{
case DTP_USER_ACCOUNTS: //用户帐户
{
if (DataDescribe.wDataSize<=sizeof(pUserData->szName))
{
CopyMemory(&pUserData->szName,pDataBuffer,DataDescribe.wDataSize);
//pUserData->szName[sizeof(pUserData->czNickName)-1]=0;
}
break;
}
case DTP_UNDER_WRITE: //个性签名
{
if (DataDescribe.wDataSize<=sizeof(pUserData->szUnderWrite))
{
CopyMemory(&pUserData->szUnderWrite,pDataBuffer,DataDescribe.wDataSize);
//pUserData->szUnderWrite[CountArray(UserData.szUnderWrite)-1]=0;
}
break;
}
case DTP_USER_GROUP_NAME: //用户社团
{
if (DataDescribe.wDataSize<=sizeof(pUserData->szGroupName))
{
CopyMemory(&pUserData->szGroupName,pDataBuffer,DataDescribe.wDataSize);
//pUserData->szGroupName[CountArray(UserData.szGroupName)-1]=0;
}
break;
}
case DTP_USER_COMPANION: //用户关系
{
if (DataDescribe.wDataSize<=sizeof(pUserData->cbCompanion))
{
CopyMemory(&pUserData->cbCompanion,pDataBuffer,DataDescribe.wDataSize);
}
break;
}
//case DTP_USER_NICKNAME: //用户昵称
// {
// if (DataDescribe.wDataSize<=sizeof(pUserData->czNickName))
// {
// CopyMemory(&pUserData->szNickName,pDataBuffer,DataDescribe.wDataSize);
// }
// break;
// }
}
}
//.........这里部分代码省略.........
示例14: _TIFFmemcpy
void
_TIFFmemcpy(void* d, const tdata_t s, tsize_t c)
{
CopyMemory(d, s, c);
}
示例15: ASSERT
BOOL CTwiBootProgDoc::LoadIntelHex(CString FilePath)
{
ASSERT (m_pBuffer == NULL);
ASSERT(m_BufferLength == 0);
try
{
CStdioFile File(FilePath, CFile::modeRead|CFile::typeText);
CIntelHexRec Rec;
CString str;
ULONG len = 0, Addr = 0;
if (!CalcIntelHexSize(&File, &len))
throw erInvalidHexFormat;
m_BufferLength = len;
m_pBuffer = new BYTE[len];
FillMemory(m_pBuffer, m_BufferLength, 0xFF);
File.SeekToBegin();
while(File.ReadString(str))
{
if (!Rec.InitFromString(str))
throw erInvalidHexFormat;
switch(Rec.m_Type)
{
case cHexTypeData:
Addr &= 0xFFFF0000;
Addr |= Rec.m_Addr;
CopyMemory(m_pBuffer + Addr, Rec.m_Data, Rec.m_Size);
break;
case cHexTypeEndOfData:
break;
case cHexTypeExtLinearAddr:
Addr = Rec.GetExtAddr();
break;
default:
ASSERT(FALSE);
throw erInvalidHexFormat;
}
}
File.Close();
return TRUE;
}
catch (CFileException* ex)
{
CString strErr;
strErr.Format(IDS_OPEN_FAILED_WITH_ERRNO, ex->m_cause);
AfxMessageBox(strErr);
ex->Delete();
return FALSE;
}
catch (int Err)
{
switch (Err)
{
case erInvalidHexFormat:
AfxMessageBox(IDS_INVALID_HEX_FORMAT);
break;
default:
ASSERT(FALSE);
AfxMessageBox(IDS_OPEN_FAILED);
break;
}
return FALSE;
}
}