Refactored code

This commit is contained in:
a2x
2023-09-16 13:32:01 +10:00
parent a3a3427561
commit a8d3318d94
58 changed files with 787 additions and 635 deletions

View File

@@ -1,36 +1,31 @@
#pragma once
#include <cstdint>
#include "utility/address.hpp"
#include <optional>
#include <string_view>
#include <vector>
namespace process {
bool attach(std::string_view process_name);
bool attach(std::string_view process_name) noexcept;
[[nodiscard]] std::optional<std::uintptr_t> find_pattern(std::string_view module_name, std::string_view pattern) noexcept;
[[nodiscard]] std::optional<utility::Address> find_pattern(std::string_view module_name, std::string_view pattern) noexcept;
[[nodiscard]] std::optional<std::uintptr_t> get_export(std::uintptr_t module_base, std::string_view function_name) noexcept;
[[nodiscard]] std::optional<std::uintptr_t> get_module_base_by_name(std::string_view module_name) noexcept;
[[nodiscard]] std::optional<std::uintptr_t> get_export(std::string_view module_name, std::string_view function_name) noexcept;
std::optional<std::uintptr_t> get_module_export_by_name(std::uintptr_t module_base, std::string_view function_name) noexcept;
[[nodiscard]] std::optional<std::vector<std::string>> get_loaded_modules() noexcept;
[[nodiscard]] std::optional<std::uintptr_t> get_module_base(std::string_view module_name) noexcept;
[[nodiscard]] std::optional<std::uintptr_t> resolve_jmp(std::uintptr_t address) noexcept;
[[nodiscard]] std::optional<std::uintptr_t> resolve_rip_relative_address(std::uintptr_t address) noexcept;
[[nodiscard]] std::optional<std::vector<std::string>> loaded_modules() noexcept;
bool read_memory(std::uintptr_t address, void* buffer, std::size_t size) noexcept;
bool write_memory(std::uintptr_t address, const void* buffer, std::size_t size) noexcept;
std::string read_string(std::uintptr_t address, std::size_t length) noexcept;
[[nodiscard]] std::string read_string(std::uintptr_t address, std::size_t length) noexcept;
template <typename T>
T read_memory(const std::uintptr_t address) noexcept {
T buffer = {};
T buffer{};
read_memory(address, &buffer, sizeof(T));