src/bcenabler.cpp
// Searches /proc/self/maps for the first free page after the given address
Searches /proc/self/maps for the first free page after the given address
Searches / proc / self / maps for the first free page after the given address
static void *find_free_page(uintptr_t address) {
    std::ifstream procMaps("/proc/self/maps");
    uintptr_t end{};
    for (std::string line; std::getline(procMaps, line); ) {
        std::size_t addressSeparator{line.find('-')};
        uintptr_t start{std::strtoull(line.substr(0, addressSeparator).c_str(), nullptr, 16)};
        if (end > address && start != end)
            return reinterpret_cast<void *>(end);
        end = std::strtoull(line.substr(addressSeparator + 1, line.find( ' ')).c_str(), nullptr, 16);
    }
    return nullptr;
}
static void * find_free_page ( uintptr_t address ) { std :: ifstream procMaps ( " " ) ; uintptr_t end { } ; for ( std :: string line ; std :: getline ( procMaps , line ) ; ) { std :: size_t addressSeparator { line . find ( ' ' ) } ; uintptr_t start { std :: strtoull ( line . substr ( 0 , addressSeparator ) . c_str ( ) , nullptr , 16 ) } ; if ( end > address && start != end ) return reinterpret_cast < void * > ( end ) ; end = std :: strtoull ( line . substr ( addressSeparator + 1 , line . find ( ' ' ) ) . c_str ( ) , nullptr , 16 ) ; } return nullptr ; }
Searches /proc/self/maps for the first free page after the given address
Searches / proc / self / maps for the first free page after the given address