#include vmm.h
_Assert_Range(DWORD pStruc, DWORD ulSize, DWORD sSignature,
DWORD lSignatureOffset, DWORD ulFlags);
Verifies that a pointer to any structure is valid. Uses the C calling convention.
ASSERT_RANGE_NULL_BAD | Return failure for NULL pointers. May not be combined with ASSERT_RANGE_NULL_OK. |
ASSERT_RANGE_NULL_OK | Return success for NULL pointers. May not be combined with ASSERT_RANGE_NULL_BAD. |
ASSERT_RANGE_NO_DEBUG | Do not output a debugging message on failure when debugger is present. This flag is ignored if no debugger is installed. |
The following validation steps are taken.
For example, suppose you have a structure defined as follows:
struct ABC {
DWORD member1;
BYTE member2[20];
DWORD dwSignature;
};
// Every valid ABC has ABCSIGNATURE stored in the dwSignature field.
#define ABCSIGNATURE 0x31415926
If you want to check whether some pointer variable p is a valid pointer to a ABC, except that null pointers are okay, then you would write
if (!_Assert_Range(p, sizeof(SAMPLE), ABCSIGNATURE,
offsetof( SAMPLE, dwSignature), ASSERT_RANGE_NULL_OK)) {
return ERROR_INVALID_PARAMETER;
}
This service can be called only at a time when page faults can safely be handled. It cannot be called at hardware interrupt time, nor at any other time when paging is not allowed. Since this service touches the memory at pStruc as part of the validation (even if sSignature is zero), if pStruc points to a phys/linear region owned by memory-mapped hardware, there may be unusual side-effects.