Microsoft DirectX 8.0

Pointer Validation Macros

Microsoft® DirectShow® provides several macros for validating pointers.

Declaration: Wxdebug.h

MacroDescription
CheckPointerChecks whether a pointer is NULL.
ValidateReadPtrVerifies that the calling process has read access to a memory block.
ValidateReadWritePtrVerifies that the calling process has read/write access to a memory block.
ValidateStringPtrVerifies that the calling process has read access to a string.
ValidateStringPtrAVerifies that the calling process has read access to an ANSI string.
ValidateStringPtrWVerifies that the calling process has read access to a wide-character string.
ValidateWritePtrVerifies that the calling process has write access to a memory block.

CheckPointer

Pointer Validation Macros

Checks whether a pointer is NULL. If the pointer is NULL, the function or method in which the macro appears returns the specified value.

Syntax

CheckPointer(
    p,
    ret
);

Parameters

p
Pointer to check.
ret
Value that the function or method returns if p is NULL.

Example

HRESULT MyFunction(VOID *pSomeParameter)
{
    CheckPointer(pSomeParameter, E_INVALIDARG)

    // Rest of the function (not shown).
}

ValidateReadPtr

Pointer Validation Macros

Verifies that the calling process has read access to a memory block. If not, the macro calls the DbgBreak macro.

Syntax

ValidateReadPtr(
    const void *p,
    UINT cb
);

Parameters

p
Pointer to a memory block.
cb
Size of the memory block, in bytes.

Remarks

This macro is ignored unless DEBUG or VFWROBUST is defined when the DirectShow base-class header file is included. This macro can have a significant performance cost.

ValidateReadWritePtr

Pointer Validation Macros

Verifies that the calling process has read/write access to a memory block. If not, the macro calls the DbgBreak macro.

Syntax

ValidateReadWritePtr(
    const void *p,
    UINT cb
);

Parameters

p
Pointer to a memory block.
cb
Size of the memory block, in bytes.

Remarks

This macro is ignored unless DEBUG or VFWROBUST is defined when the DirectShow base-class header file is included. This macro can have a significant performance cost.

ValidateStringPtr

Pointer Validation Macros

Verifies that the calling process has read access to a string. If not, the macro calls the DbgBreak macro.

Syntax

ValidateStringPtr(
    LPCTSTR p
);

Parameters

p
Pointer to a NULL-terminated TCHAR string.

Remarks

This macro is ignored unless DEBUG or VFWROBUST is defined when the DirectShow base-class header file is included. This macro can have a significant performance cost.

ValidateStringPtrA

Pointer Validation Macros

Verifies that the calling process has read access to an ANSI string. If not, the macro calls the DbgBreak macro.

Syntax

ValidateStringPtrA(
    LPCSTR p
);

Parameters

p
Pointer to a NULL-terminated ANSI string.

Remarks

This macro is ignored unless DEBUG or VFWROBUST is defined when the DirectShow base-class header file is included.

ValidateStringPtrW

Pointer Validation Macros

Verifies that the calling process has read access to a wide-character string. If not, the macro calls the DbgBreak macro.

Syntax

ValidateStringPtrW(
    LPCWSTR p
);

Parameters

p
Pointer to a NULL-terminated wide-character string.

Remarks

This macro is ignored unless DEBUG or VFWROBUST is defined when the DirectShow base-class header file is included. This macro can have a significant performance cost.

ValidateWritePtr

Pointer Validation Macros

Verifies that the calling process has write access to a memory block. If not, the macro calls the DbgBreak macro.

Syntax

ValidateWritePtr(
    const void *p,
    UINT cb
);

Parameters

p
Pointer to a memory block.
cb
Size of the memory block, in bytes.

Remarks

This macro is ignored unless DEBUG or VFWROBUST is defined when the DirectShow base-class header file is included. This macro can have a significant performance cost.