本文整理汇总了C++中IsBadReadPtr函数的典型用法代码示例。如果您正苦于以下问题:C++ IsBadReadPtr函数的具体用法?C++ IsBadReadPtr怎么用?C++ IsBadReadPtr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsBadReadPtr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MessageBoxIndirectW_new
/* MAKE_EXPORT MessageBoxIndirectW_new=MessageBoxIndirectW */
int WINAPI MessageBoxIndirectW_new(const LPMSGBOXPARAMSW lpMsgBoxParams)
{
LPSTR lpszText = NULL;
LPSTR lpszCaption = NULL;
LPSTR lpszIcon = NULL;
MSGBOXPARAMSA mbp;
if(IsBadReadPtr(lpMsgBoxParams, sizeof(MSGBOXPARAMSW)))
return 0;
memcpy(&mbp, lpMsgBoxParams, sizeof(MSGBOXPARAMSA));
STACK_WtoA(lpMsgBoxParams->lpszText, lpszText);
STACK_WtoA(lpMsgBoxParams->lpszCaption, lpszCaption);
STACK_WtoA(lpMsgBoxParams->lpszIcon, lpszIcon);
mbp.lpszText = lpszText;
mbp.lpszCaption = lpszCaption;
mbp.lpszIcon = lpszIcon;
return MessageBoxIndirectA(&mbp);
}
示例2: Accept
BOOL
CNamedPipeTransport::
Accept(
LPOVERLAPPED lpOverlapped)
{
_ASSERTE(
(NULL == lpOverlapped) ||
(!IsBadReadPtr(lpOverlapped, sizeof(OVERLAPPED)) &&
NULL != lpOverlapped->hEvent &&
INVALID_HANDLE_VALUE != lpOverlapped->hEvent));
BOOL fConnected = ::ConnectNamedPipe(m_hPipe, lpOverlapped);
if (fConnected) {
XTLTRACE1(TRACE_LEVEL_VERBOSE,
"Accepting a new connection.\n");
return TRUE;
}
if (lpOverlapped) {
// if overlapped operation ConnectNamedPipe should return FALSE;
DWORD dwError = ::GetLastError();
switch (dwError) {
case ERROR_PIPE_CONNECTED:
::SetEvent(lpOverlapped->hEvent);
// omitting break is intentional
case ERROR_IO_PENDING:
XTLTRACE1(TRACE_LEVEL_INFORMATION,
"Accepting a new connection.\n");
return TRUE;
default: // An error occurs during the connect operation
XTLTRACE1(TRACE_LEVEL_ERROR,
"ConnectNamedPipe failed, error=0x%X\n", GetLastError());
return FALSE;
}
}
return FALSE;
}
示例3: unit_useMenu
INT unit_useMenu(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
CDebug cDbg("unit useMenu");
myUnit* lpUnit = (myUnit*)JS_GetPrivate(cx, obj);
*rval = JSVAL_FALSE;
if(argc < 1 || !JSVAL_IS_INT(argv[0]))
return JS_TRUE;
if(!lpUnit || IsBadReadPtr(lpUnit, sizeof(myUnit)) || lpUnit->_dwPrivateType != PRIVATE_UNIT)
return JS_TRUE;
UnitAny* pUnit = D2CLIENT_FindUnit(lpUnit->dwUnitId, lpUnit->dwType);
if(!pUnit)
return JS_TRUE;
*rval = BOOLEAN_TO_JSVAL(ClickNPCMenu(pUnit->dwTxtFileNo, JSVAL_TO_INT(argv[0])));
return JS_TRUE;
}
示例4: invokeResponseCallback
//请求返回后,调用回调函数
void BaseHTTPRequestHandler::invokeResponseCallback(char *buf,size_t len) {
CALLBACK_DATA callback_data;
if(buf == NULL || len == 0)
return;
if(IsBadReadPtr(buf,len))
return;
memset(&callback_data, 0, sizeof(CALLBACK_DATA));
callback_data.buf=(char*)malloc(len);
memset(callback_data.buf,0,len);
memcpy_s(callback_data.buf,len,buf,len);
m_pHttpService_Params->response_callback(&callback_data);
//处理完之后,清理掉内存
if (callback_data.buf != NULL) {
free(callback_data.buf);
callback_data.buf = NULL;
}
}
示例5: lock
int CStockManager::GetStocksList(CArray<CodeInfo>* pArInfo, CArray<StockUserInfo>& stockInfo, BOOL bCompareOnlyMainMarket)
{
if ( m_ayStocks.GetCount() <= 0)
{
return 0;
}
if (pArInfo != NULL )
{
CHSDSStockInfoIntact* pStock = NULL;
CSingleLock lock(&m_mutexStock);
if (lock.Lock())
{
if (pArInfo->GetSize() > 0)
for ( int i=0; i<pArInfo->GetCount(); i++ )
{
CodeInfo* pCode = &pArInfo->GetAt(i);
if ( pCode && !IsBadReadPtr(pCode, sizeof(CodeInfo)))
{
int nIndex = -1;
m_mapIndex.Lookup(pCode->GetCode(), (CObject*&)nIndex);
if ( nIndex >=0 && nIndex<m_ayStocks.GetCount() )
{
CHSDSStockInfoIntact* pStock = m_ayStocks.GetAt(nIndex);
if (pStock != NULL)
{
StockUserInfo stock;
memset(&stock, 0, sizeof(StockUserInfo));
stock.Copy(&pStock->m_stockInfo);
stockInfo.Add(stock);
}
}
}
}
}
lock.Unlock();
return stockInfo.GetSize();
}
return 0;
}
示例6: dll_intercept
static int dll_intercept(register void* addr)
{
IMAGE_DOS_HEADER* dosp = (IMAGE_DOS_HEADER*)addr;
IMAGE_NT_HEADERS* ntp;
IMAGE_EXPORT_DIRECTORY* exp;
register int i;
register int j;
register int base;
DWORD* names;
WORD* ordinals;
DWORD* functions;
char* name;
void* fun;
if (IsBadReadPtr(addr, sizeof(*dosp)))
return 0;
if (dosp->e_magic != IMAGE_DOS_SIGNATURE)
return 0;
ntp = ptr(IMAGE_NT_HEADERS, dosp, dosp->e_lfanew);
exp = ptr(IMAGE_EXPORT_DIRECTORY, addr, ntp->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
if ((void*)exp == (void*)ntp)
return 1;
base = exp->Base - 1;
names = ptr(DWORD, addr, exp->AddressOfNames);
ordinals = ptr(WORD, addr, exp->AddressOfNameOrdinals);
functions = ptr(DWORD, addr, exp->AddressOfFunctions);
for (i = j = 0; i < (int)exp->NumberOfNames; i++)
{
name = ptr(char, addr, names[i]);
if (strcmp(name, sys_call[j].name) == 0)
{
fun = ptr(void, addr, functions[ordinals[i]-base]);
sys_call[j].actual = (Syscall_f)fun;
trace_error(-2, "%3d %3d %p %s", i, j, fun, name);
if (++j >= elementsof(sys_call))
return 1;
}
}
示例7: VFindNextFileW
NEWAPI
BOOL
WINAPI
VFindNextFileW(
HANDLE hFindFile,
LPWIN32_FIND_DATAW lpFindFileData
)
{
BOOL retValue = FALSE;
//find a file
RESTORE_API(FindNextFileW);
OLDCALL(FindNextFileW, 2);
REPLACE_API(FindNextFileW);
if (retValue)
{
if (!IsBadReadPtr(lpFindFileData, sizeof(WIN32_FIND_DATAW)))
{
//while we are finding a hidden file
RESTORE_API(FindNextFileW);
while (posw0(lpFindFileData->cFileName) != MAXDWORD)
{
//get next file
retValue = FindNextFileW(hFindFile, lpFindFileData);
//if there is no file to get then fail
if (!retValue)
{
//we keep the error from FindNextFileW, NO SetLastError(ERROR_NO_MORE_FILES);
break;
}
}
REPLACE_API(FindNextFileW);
}
}
return retValue;
}
示例8: recPaketProcces_BATTLE_PRACTICE_BATTINGTRADE_CANCEL
void CGonryunPractice_Decoder::
recPaketProcces_BATTLE_PRACTICE_BATTINGTRADE_CANCEL(playerCharacter_t* pPlayer)
{
if((TRUE == IsBadWritePtr(pPlayer,sizeof(playerCharacter_t))) ||
(TRUE == IsBadReadPtr(pPlayer,sizeof(playerCharacter_t)))) {
return;
}
if( (playerCharacter_t::tagGonryunBattlePractice::MEMBERSHIP_LEADER != pPlayer->GonryunBattlePractice.MemberShip) &&
(playerCharacter_t::tagGonryunBattlePractice::MEMBERSHIP_OPENENT != pPlayer->GonryunBattlePractice.MemberShip) ) {
GTH_DisconnectPlayer(pPlayer,FALSE);
return;
}
int Tagetidx = MSG_ReadShort();
playerCharacter_t* pTargetPlayer= gcpTools->GetPlayerRecordPointer(Tagetidx);
if(NULL == pTargetPlayer){
GTH_DisconnectPlayer(pPlayer,FALSE);
return;
}
if( (playerCharacter_t::tagGonryunBattlePractice::MEMBERSHIP_LEADER != pTargetPlayer->GonryunBattlePractice.MemberShip) &&
(playerCharacter_t::tagGonryunBattlePractice::MEMBERSHIP_OPENENT != pTargetPlayer->GonryunBattlePractice.MemberShip) ) {
GTH_DisconnectPlayer(pPlayer,FALSE);
return;
}
pPlayer->GonryunBattlePractice.bBattingOkSignal = FALSE;
pPlayer->GonryunBattlePractice.bBattingAdmitSignal = FALSE;
pTargetPlayer->GonryunBattlePractice.bBattingOkSignal = FALSE;
pTargetPlayer->GonryunBattlePractice.bBattingAdmitSignal = FALSE;
m_cpVirtualEncoder->SendMessage_BattingTrade_CancelBatting( pPlayer, TRUE );
m_cpVirtualEncoder->SendMessage_BattingTrade_CancelBatting( pTargetPlayer,FALSE );
}
示例9: GetValue
// Get string file info.
// Key name is something like "CompanyName".
BOOL CVersion::GetValue(LPCTSTR lpKeyName,LPTSTR szValue)
{
TCHAR sz[MAX_PATH];
UINT iLenVal;
LPVOID lpvi;
if (!this->pVersionInfo)
return FALSE;
if (IsBadWritePtr(szValue,1))
return FALSE;
if (IsBadReadPtr(lpKeyName,1))
return FALSE;
*szValue=0;
// To get a string value must pass query in the form
//
// "\StringFileInfo\<langID><codepage>\keyname"
//
// where <lang-codepage> is the languageID concatenated with the
// code page, in hex. Wow.
//
_stprintf(sz,_TEXT("\\StringFileInfo\\%04x%04x\\%s"),
this->LangAndCodePage.wLanguage,
this->LangAndCodePage.wCodePage,
lpKeyName);
if(!VerQueryValue(this->pVersionInfo,sz,&lpvi,&iLenVal))
return FALSE;
if (iLenVal>MAX_PATH)
iLenVal=MAX_PATH;
memcpy(szValue,lpvi,iLenVal*sizeof(TCHAR));
return TRUE;
}
示例10: guard
BOOL CHSDownloadData::DownLoadData()
{
CriticalGuard guard(&m_critical);
long lLen;
StockUserInfo* pStock = NULL;
short nPeriod;
SetTaskMask(m_nCulType);
m_nCulType ++;
if ( m_nCulType >= 4)
m_nCulType = 1;
GetNextCode(&pStock, nPeriod);
char* pBuffer = MakeReqPacket(&pStock->m_ciStockCode,nPeriod,lLen);
if(pBuffer == NULL)
{
DownLoadData();
}
else
{
HSMarketDataType market = pStock->m_ciStockCode.m_cCodeType & 0xF000;
char cServerType = CEV_Connect_HQ;
if(market == FUTURES_MARKET)
{
//cServerType = CEV_Connect_QH; //期货
}
if (market == HK_MARKET)
{
//cServerType = CEV_Connect_GG; //港股
}
if ( m_pDataSource && !IsBadReadPtr(m_pDataSource,1))
m_pDataSource->HSDataSource_RequestAsyncData(m_nDataSourceID,pBuffer,lLen,-1,e_DataSouceSend_Normal|e_DataSourceSend_HQDataDownLoad,
m_lHandle);
TRACE2("\r\n send packet code:%s, nPeriod:%d \r\n", pStock->GetName(),nPeriod);
}
return TRUE;
}
示例11: recPaketProcces_BATTLE_PRACTICE_BATTINGTRADE_OK
void CGonryunPractice_Decoder::
recPaketProcces_BATTLE_PRACTICE_BATTINGTRADE_OK(playerCharacter_t* pPlayer)
{
if((TRUE == IsBadWritePtr(pPlayer,sizeof(playerCharacter_t))) ||
(TRUE == IsBadReadPtr(pPlayer,sizeof(playerCharacter_t)))) {
return;
}
int TargetIdx = MSG_ReadShort();
playerCharacter_t* pTargetPlayer= gcpTools->GetPlayerRecordPointer(TargetIdx);
if(NULL == pTargetPlayer) {
GTH_DisconnectPlayer(pPlayer,FALSE);
return;
}
pPlayer->GonryunBattlePractice.bBattingOkSignal = TRUE;
m_cpVirtualEncoder->SendMessage_BattingTrade_OkBatting( pPlayer, TRUE );
m_cpVirtualEncoder->SendMessage_BattingTrade_OkBatting( pTargetPlayer, FALSE );
}
示例12: hexdump8
static char * hexdump8(char * out,unsigned address,const char * msg,int from,int to)
{
unsigned max = (to-from)*16;
if (!IsBadReadPtr((const void*)(address+(from*16)),max))
{
out += sprintf(out,"%s (%08Xh):",msg,address);
unsigned n;
const unsigned char * src = (const unsigned char*)(address)+(from*16);
for(n=0;n<max;n++)
{
if (n%16==0)
{
out += sprintf(out,"\n%08Xh: ",src);
}
out += sprintf(out," %02X",*(src++));
}
*(out++) = '\n';
*out=0;
}
return out;
}
示例13: ReplaceToolTipText
//-----------------------------------------------------------------------------
// Name: ReplaceText
// Object: change text of a button
// Parameters :
// in : int ButtonID : button id
// TCHAR* NewToolTipText : new text associated with tooltip
// out :
// return : TRUE on success, FALSE on error
//-----------------------------------------------------------------------------
BOOL CToolbar::ReplaceToolTipText(int ButtonID,TCHAR* NewToolTipText)
{
TBBUTTONINFO ButtonInfo={0};
// retrieve button param
ButtonInfo.dwMask=TBIF_LPARAM;
ButtonInfo.cbSize=sizeof(TBBUTTONINFO);
// get button info
if (SendMessage( this->hwndTB,(UINT) TB_GETBUTTONINFO,(WPARAM) ButtonID,(LPARAM) &ButtonInfo)==-1)
return FALSE;
if (IsBadReadPtr((PVOID)ButtonInfo.lParam,sizeof(CToolbarButtonUserData)))
return FALSE;
// change tooltip
((CToolbarButtonUserData*)ButtonInfo.lParam)->SetToolTip(NewToolTipText);
// set button info
if (SendMessage( this->hwndTB,(UINT) TB_SETBUTTONINFO,(WPARAM) ButtonID,(LPARAM) &ButtonInfo)==-1)
return FALSE;
return TRUE;
}
示例14: get_valid_frame
PBYTE get_valid_frame(PBYTE esp)
{
PDWORD cur_stack_loc = NULL;
const int max_search = 400;
WCHAR module_name[MAX_PATH];
PBYTE module_addr = 0;
// round to highest multiple of four
esp = (esp + (4 - ((int)esp % 4)) % 4);
// scroll through stack a few hundred places.
for (cur_stack_loc = (PDWORD) esp; cur_stack_loc < (PDWORD)esp + max_search; cur_stack_loc += 1)
{
// if you can read the pointer,
if (IsBadReadPtr(cur_stack_loc, sizeof(PDWORD)))
{
continue;
}
// check if it's in a module
if (!Get_Module_By_Ret_Addr((PBYTE)*cur_stack_loc, module_name, module_addr))
{
continue;
}
// check if the code before the instruction ptr is a call
if(!has_valid_call_before(cur_stack_loc))
{
continue;
}
// if these all pass, return that ebp, otherwise continue till we're dead
return (PBYTE)(cur_stack_loc - 1);
}
return NULL;
}
示例15: stack_first
bool dbgsymengine::stack_first (CONTEXT* pctx)
{
if (!pctx || IsBadReadPtr(pctx, sizeof(CONTEXT)))
return false;
if (!check())
return false;
if (!m_pframe)
{
m_pframe = new STACKFRAME;
if (!m_pframe) return false;
}
memset(m_pframe, 0, sizeof(STACKFRAME));
#ifdef _X86_
m_pframe->AddrPC.Offset = pctx->Eip;
m_pframe->AddrPC.Mode = AddrModeFlat;
m_pframe->AddrStack.Offset = pctx->Esp;
m_pframe->AddrStack.Mode = AddrModeFlat;
m_pframe->AddrFrame.Offset = pctx->Ebp;
m_pframe->AddrFrame.Mode = AddrModeFlat;
#else
m_pframe->AddrPC.Offset = (DWORD)pctx->Fir;
m_pframe->AddrPC.Mode = AddrModeFlat;
m_pframe->AddrReturn.Offset = (DWORD)pctx->IntRa;
m_pframe->AddrReturn.Mode = AddrModeFlat;
m_pframe->AddrStack.Offset = (DWORD)pctx->IntSp;
m_pframe->AddrStack.Mode = AddrModeFlat;
m_pframe->AddrFrame.Offset = (DWORD)pctx->IntFp;
m_pframe->AddrFrame.Mode = AddrModeFlat;
#endif
m_pctx = pctx;
return stack_next();
}