IsBadReadPtr

IsBadReadPtr,是一個計算機函式。

函式原型:

BOOL IsBadReadPtr(CONST VOID *lp,UINT_PTR ucb);

參數:

lp 表示要檢查的記憶體指針

ucb 要檢查的記憶體塊的大小

返回:

如果調用進程有許可權訪問該記憶體,返回0

否則,返回非0

說明:

該函式檢查調用進程是否有讀取指定記憶體的內容的許可權,微軟提供的32位作業系統下的API

IsBadReadPtr
TheIsBadReadPtrfunctionverifiesthatthecallingprocesshasreadaccesstothespecifiedrangeofmemory.
BOOLIsBadReadPtr(
CONSTVOID*lp,//memoryaddress
UINT_PTRucb//sizeofblock
);
Parameters
lp
[in]Pointertothefirstbyteofthememoryblock.
ucb
[in]Specifiesthesize,inbytes,ofthememoryblock.Ifthisparameteriszero,thereturnvalueiszero.
ReturnValues
Ifthecallingprocesshasreadaccesstoallbytesinthespecifiedmemoryrange,thereturnvalueiszero.
Ifthecallingprocessdoesnothavereadaccesstoallbytesinthespecifiedmemoryrange,thereturnvalueisnonzero.
Iftheapplicationiscompiledasadebuggingversion,andtheprocessdoesnothavereadaccesstoallbytesinthespecifiedmemoryrange,thefunctioncausesanassertionandbreaksintotheDebugger.Leavingthedebugger,thefunctioncontinuesasusual,andreturnsanonzerovalueThisbehaviorisbydesign,asadebuggingaid.
Remarks
Thisfunctionistypicallyusedwhenworkingwithpointersreturnedfromthird-partylibraries,whereyoucannotdeterminethememorymanagementbehaviorinthethird-partyDLL.
Threadsinaprocessareexpectedtocooperateinsuchawaythatonewillnotfreememorythattheotherneeds.Useofthisfunctiondoesnotnegatetheneedtodothis.Ifthisisnotdone,theapplicationmayfailinanunpredictablemanner.
Dereferencingpotentiallyinvalidpointerscandisablestackexpansioninotherthreads.Athreadexhaustingitsstack,whenstackexpansionhasbeendisabled,resultsintheimmediateterminationoftheparentprocess,withnopop-uperrorwindowordiagnosticinformation.
Ifthecallingprocesshasreadaccesstosome,butnotall,ofthebytesinthespecifiedmemoryrange,thereturnvalueisnonzero.
Inapreemptivemultitaskingenvironment,itispossibleforsomeotherthreadtochangetheprocess'saccesstothememorybeingtested.Evenwhenthefunctionindicatesthattheprocesshasreadaccesstothespecifiedmemory,youshouldusestructuredexceptionhandlingwhenattemptingtoaccessthememory.Useofstructuredexceptionhandlingenablesthesystemtonotifytheprocessifanaccessviolationexceptionoccurs,givingtheprocessanopportunitytohandletheexception.
Requirements
WindowsNT/2000/XP:IncludedinWindowsNT3.1andlater.
Windows95/98/Me:IncludedinWindows95andlater.
Header:DeclaredinWinbase.h;includeWindows.h.
Library:UseKernel32.lib

相關詞條

相關搜尋

熱門詞條

聯絡我們