На самом деле я Zodiak
-
Автор темы
- #1
Заебись поинтер чек братва ? Реально хайпово ? Или лютый кринж ? Жидкий такой кринжулик...?
C++:
template <typename T>
static bool pointer_check ( uintptr_t adress, pointer_check_properties* ret_props = 0 )
{
if ( adress <= 0x40000 || adress >= 0x7ffffffffff )
return false;
MEMORY_BASIC_INFORMATION basic_info;
auto query_result = VirtualQuery ( ( void* ) adress, &basic_info, sizeof ( MEMORY_BASIC_INFORMATION ) );
if ( !query_result )
return false;
auto allocation_base = basic_info.AllocationBase;
auto allocation_protect = basic_info.AllocationProtect;
auto base_adress = basic_info.BaseAddress;
auto protect = basic_info.Protect;
auto region_size = basic_info.RegionSize;
auto max_valid_adress = ( uintptr_t ) allocation_base + region_size;
if ( !allocation_base ||
allocation_protect == PAGE_NOACCESS ||
allocation_protect == 0 ||
protect == PAGE_NOACCESS ||
protect == 0 ||
!base_adress ||
!region_size ||
max_valid_adress <= adress
)
return false;
if ( IsBadReadPtr ( ( void* ) adress, sizeof( T ) ) )
return false;
if ( protect != PAGE_READONLY )
if ( IsBadWritePtr ( ( void* ) adress, sizeof ( T ) ) )
return false;
if ( ret_props )
ret_props->page_protection = protect;
return true;
}