scoped_unprotect::scoped_unprotect(byte_range region) : _region(region) { byte *page = reinterpret_cast<byte *>(reinterpret_cast<size_t>(region.begin()) & ~static_cast<size_t>(0x0FFF)); size_t full_length = region.length() + (region.begin() - page); _region = byte_range(page, full_length); if (mprotect(_region.begin(), _region.length(), PROT_EXEC | PROT_READ | PROT_WRITE)) throw std::runtime_error("Cannot change protection mode!"); }
void GetDeviceRegistryProperty( const sp_devinfo_data &DeviceInfoData, spdrp Property, registry::data_id_type &PropertyRegDataType, const byte_range &Buffer, dword_t &RequiredSize) const { exception::scope_last_error ScopeLastError; CBEAR_BERLIOS_DE_WINDOWS_FUNCTION( Char, ::SetupDiGetDeviceRegistryProperty)( this->internal(), const_cast<sp_devinfo_data::value_t *>( &DeviceInfoData.get()), Property.internal(), &PropertyRegDataType.get(), Buffer.begin(), (dword_t)Buffer.size(), &RequiredSize); }