VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Image.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <string>
6#include <string_view>
7#include <vector>
8
9namespace VoltMod
10{
11
12/** A process mapping and the file backing it. */
13struct Image
14{
15 const uint8_t* Base = nullptr;
16 size_t Size = 0;
17 std::string Path;
18
19 bool Contains(const void* address) const
20 {
21 const auto* at = static_cast<const uint8_t*>(address);
22 return Base && at >= Base && at < Base + Size;
23 }
24};
25
27{
28 const uint8_t* Base;
29 size_t Size;
30};
31
32/**
33 * Locate the exact platform @p fileName and populate its mapping and readable scan ranges.
34 *
35 * Windows returns the mapped image as one range. Linux returns individual PT_LOAD segments because
36 * the full module span may contain unmapped gaps.
37 *
38 * @return false when the module is not loaded. Both outputs remain unchanged.
39 */
40bool FindModuleAndRanges(std::string_view fileName, Image& module, std::vector<ScanRange>& ranges);
41
42} // namespace VoltMod
bool FindModuleAndRanges(std::string_view fileName, Image &module, std::vector< ScanRange > &ranges)
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
std::string Path
Definition Image.hpp:17
const uint8_t * Base
Definition Image.hpp:15
size_t Size
Definition Image.hpp:16
bool Contains(const void *address) const
Definition Image.hpp:19
const uint8_t * Base
Definition Image.hpp:28