mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 12:35:26 +00:00
f2cb3c38fe
Always map memory as writable, but private when read-only
25 lines
655 B
C++
25 lines
655 B
C++
#pragma once
|
|
|
|
#include <utils.hpp>
|
|
|
|
struct mmap_data {
|
|
uint8_t *buf = nullptr;
|
|
size_t sz = 0;
|
|
|
|
mmap_data() = default;
|
|
mmap_data(const mmap_data&) = delete;
|
|
mmap_data(mmap_data &&other) { consume(other); }
|
|
~mmap_data() { if (buf) munmap(buf, sz); }
|
|
mmap_data& operator=(mmap_data &&other) { consume(other); return *this; }
|
|
|
|
using str_pairs = std::initializer_list<std::pair<std::string_view, std::string_view>>;
|
|
int patch(str_pairs list);
|
|
bool contains(std::string_view pattern);
|
|
|
|
static mmap_data rw(const char *name);
|
|
static mmap_data ro(const char *name);
|
|
|
|
private:
|
|
void consume(mmap_data &other);
|
|
};
|