core/win32/os.c
/* is_readable_without_exception checks to see that all bytes with addresses
 * from pc to pc+size-1 are readable and that reading from there won't
 * generate an exception.  this is a stronger check than
 * !not_readable() below.
 * FIXME : beware of multi-thread races, just because this returns true, 
 * doesn't mean another thread can't make the region unreadable between the 
 * check here and the actual read later.  See safe_read() as an alt.
 */
is_readable_without_exception checks to see that all bytes with addresses
from pc to pc+size-1 are readable and that reading from there won't
generate an exception.  this is a stronger check than
!not_readable() below.
FIXME : beware of multi-thread races, just because this returns true,
doesn't mean another thread can't make the region unreadable between the
check here and the actual read later.  See safe_read() as an alt.
is_readable_without_exception checks to see that all bytes with addresses from pc to pc + size - 1 are readable and that reading from there won ' t generate an exception . this is a stronger check than !not_readable () below . FIXME : beware of multi - thread races just because this returns true doesn ' t mean another thread can ' t make the region unreadable between the check here and the actual read later . See safe_read () as an alt .
static bool 
query_is_readable_without_exception(byte *pc, size_t size)
{
    MEMORY_BASIC_INFORMATION mbi;
    byte *check_pc = (byte *) ALIGN_BACKWARD(pc, PAGE_SIZE);
    size_t res;
    if (size > (size_t)((byte *)POINTER_MAX - pc))
        size = (byte *)POINTER_MAX - pc;
    do {
        res = query_virtual_memory(check_pc, &mbi, sizeof(mbi));
        if (res != sizeof(mbi)) {
            return false;
        } else {
            if (mbi.State != MEM_COMMIT ||
                TEST(PAGE_GUARD, mbi.Protect) ||
                !prot_is_readable(mbi.Protect))
                return false;
        }
        check_pc += PAGE_SIZE;
    } while (check_pc != 0 && check_pc < pc+size);
    return true;
}
static bool query_is_readable_without_exception ( byte * pc , size_t size ) { MEMORY_BASIC_INFORMATION mbi ; byte * check_pc = ( byte * ) ALIGN_BACKWARD ( pc , PAGE_SIZE ) ; size_t res ; if ( size > ( size_t ) ( ( byte * ) POINTER_MAX - pc ) ) size = ( byte * ) POINTER_MAX - pc ; do { res = query_virtual_memory ( check_pc , & mbi , sizeof ( mbi ) ) ; if ( res != sizeof ( mbi ) ) { return false ; } else { if ( mbi . State != MEM_COMMIT || TEST ( PAGE_GUARD , mbi . Protect ) || ! prot_is_readable ( mbi . Protect ) ) return false ; } check_pc += PAGE_SIZE ; } while ( check_pc != 0 && check_pc < pc + size ) ; return true ; }
is_readable_without_exception checks to see that all bytes with addresses
 from pc to pc+size-1 are readable and that reading from there won't
 generate an exception.
is_readable_without_exception checks to see that all bytes with addresses from pc to pc + size - 1 are readable and that reading from there won ' t generate an exception .
/* FIXME: this routine can walk by mbi.RegionSize instead of pages */ /*overflow*/