;-------------------------------------------------------------------------- ifdef DEBUG DEBUG_RETAIL equ 1 endif ; ifdef DEBUG ;-------------------------------------------------------------------------- ?PLM = 1 ?WIN = 0 PMODE = 1 .xlist include cmacros.inc include windows.inc include mmsystem.inc ; include logerror.inc include mmddk.inc .list ;-------------------------------------------------------------------------- ;/* Error modifier bits */ ERR_WARNING equ 08000h ERR_PARAM equ 04000h ;/* Generic parameter values */ ERR_BAD_VALUE equ 06001h ERR_BAD_FLAGS equ 06002h ERR_BAD_INDEX equ 06003h ERR_BAD_DVALUE equ 07004h ERR_BAD_DFLAGS equ 07005h ERR_BAD_DINDEX equ 07006h ERR_BAD_PTR equ 07007h ERR_BAD_FUNC_PTR equ 07008h ERR_BAD_SELECTOR equ 06009h ERR_BAD_STRING_PTR equ 0700ah ERR_BAD_HANDLE equ 0600bh ;/* KERNEL parameter errors */ ERR_BAD_HINSTANCE equ 06020h ERR_BAD_HMODULE equ 06021h ERR_BAD_GLOBAL_HANDLE equ 06022h ERR_BAD_LOCAL_HANDLE equ 06023h ERR_BAD_ATOM equ 06024h ERR_BAD_HFILE equ 06025h ;/* USER parameter errors */ ERR_BAD_HWND equ 06040h ERR_BAD_HMENU equ 06041h ERR_BAD_HCURSOR equ 06042h ERR_BAD_HICON equ 06043h ERR_BAD_HDWP equ 06044h ERR_BAD_CID equ 06045h ERR_BAD_HDRVR equ 06046h DBF_TRACE equ 00000h DBF_WARNING equ 04000h DBF_ERROR equ 08000h DBF_FATAL equ 0c000h ; [Windows] DebugFilter and flags values DBF_KERNEL equ 01000h DBF_USER equ 00800h DBF_GDI equ 00400h DBF_MMSYSTEM equ 00040h DBF_PENWIN equ 00020h DBF_APPLICATION equ 00010h DBF_DRIVER equ 00008h ;-------------------------------------------------------------------------- AssertF macro reg local assert_ok ifdef DEBUG or reg,reg jnz assert_ok int 3 assert_ok: endif endm AssertT macro reg local assert_ok ifdef DEBUG or reg,reg jz assert_ok int 3 assert_ok: endif endm ;-------------------------------------------------------------------------- ; ; DebugErr() macro ; ifdef DEBUG_RETAIL externFP _DebugOutput ; in KERNEL (3.1 or above) DebugErr macro flags,msg local a,b push cs push offset a push flags or DBF_DRIVER call _DebugOutput add sp,6 jmp short b a: db "MSVIDEO: " db msg db 13,10,0 b: endm else ; DEBUG DebugErr macro flags,msg endm endif ; DEBUG ;-------------------------------------------------------------------------- ; Define the return address as a type using the DefD macro in order to ; be able to pass it as a parameter to the LogParamError function. ReturnAddr equ (dword ptr [bp+2]) DefD ReturnAddr ;-------------------------------------------------------------------------- NSTYPE equ 00007h ; Segment type mask NSCODE equ 00000h ; Code segment NSDATA equ 00001h ; Data segment NSITER equ 00008h ; Iterated segment flag NSMOVE equ 00010h ; Movable segment flag NSPURE equ 00020h ; Pure segment flag NSPRELOAD equ 00040h ; Preload segment flag NSRELOC equ 00100h ; Segment has relocations NSDEBUG equ 00200h ; Segment has debug info NSDPL equ 00C00h ; 286 DPL bits NSDISCARD equ 01000h ; Discard bit for segment CODEINFO struc ns_sector dw ? ; File sector of start of segment ns_cbseg dw ? ; Number of bytes in file ns_flags dw ? ; Attribute flags ns_minalloc dw ? ; Minimum allocation in bytes ns_handle dw ? ; handle to object ns_align dw ? ; file alignment CODEINFO ends DSC_CODE_BIT equ 08h ;-------------------------------------------------------------------------- externA __AHINCR externA __WINFLAGS externFP LogParamError ;(WORD wError, FARPROC lpfn, DWORD dValue); externFP IsWindow ;(HWND hwnd); externFP GetCodeInfo ;(FARPROC lpfnProc, LPVOID lpSegInfo); externFP GetCurrentTask ;(void); externFP IsTask ;(HANDLE hTask); ; Windows internal pointer validation tools. externFP IsBadReadPtr ;(LPVOID lp, WORD cb); externFP IsBadWritePtr ;(LPVOID lp, WORD cb); externFP IsBadHugeReadPtr ;(LPVOID lp, DWORD cb); externFP IsBadHugeWritePtr ;(LPVOID lp, DWORD cb); externFP IsBadCodePtr ;(FARPROC lp); externFP IsBadStringPtr ;(LPSTR lpsz, WORD wMaxLen); externFP IsSharedSelector ;(WORD wSelector); ;-------------------------------------------------------------------------- sBegin Data sEnd Data ;-------------------------------------------------------------------------- ;;;createSeg _TEXT, CodeRes, word, public, CODE ;;;createSeg FIX, CodeFix, word, public, CODE createSeg MSVIDEO, CodeRes, word, public, CODE sBegin CodeRes assumes cs, CodeRes assumes ds, Data ;-------------------------------------------------------------------------- ; @doc INTERNAL ; ; @func BOOL | ValidateReadPointer | validates that a pointer is valid to ; read from. ; ; @parm LPVOID | lpPoint| pointer to validate ; @parm DWORD | dLen | supposed length of said pointer ; ; @rdesc Returns TRUE if
is a valid pointer ; Returns FALSE if
is not a valid pointer
;
; @comm will generate error if the pointer is invalid
;
cProc ValidateReadPointer, is a valid pointer
; Returns FALSE if is not a valid pointer
;
; @comm will generate error if the pointer is invalid
;
cProc ValidateWritePointer,