VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
SigScanner.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <cstddef>
7#include <cstdint>
8#include <string>
9#include <string_view>
10
11namespace VoltMod
12{
13
15{
16 void* Address = nullptr; // first match, or nullptr
17 bool Unique = true; // false when another match exists
18 Image Module; // scanned module; Base is null when it was not loaded
19};
20
21std::string PlatformModuleName(std::string_view moduleName);
22
23bool FindImage(std::string_view moduleName, Image& module);
24
25/**
26 * Scan a loaded module for a byte pattern with `?` wildcards. Address holds the first match, while
27 * Unique reports whether it is safe to bind.
28 */
29ScanResult FindPatternEx(std::string_view moduleName, const std::string& pattern);
30
31/**
32 * Resolve the 32-bit displacement at `matchAddress + ripOffset` relative to the instruction end.
33 *
34 * @return 0 when the displacement is not wholly inside the module.
35 */
37
38/**
39 * Whether @p address lies in committed, executable memory.
40 *
41 * This accepts hook trampolines allocated outside a module while rejecting vtable slots that point
42 * at data, such as RTTI, strings, or the tail of a shorter table.
43 */
44bool IsExecutableAddress(const void* address);
45
46/**
47 * Whether the complete span [@p address, @p address + @p bytes) is readable in one mapping.
48 *
49 * Use this before dereferencing untrusted object bytes. Calling @ref IsExecutableAddress on `p[0]`
50 * is already too late because evaluating `p[0]` performs the unsafe read.
51 */
52bool IsReadableAddress(const void* address, size_t bytes);
53
54} // namespace VoltMod
Checked rel32 decoding for signature bindings.
bool FindImage(std::string_view moduleName, Image &module)
ScanResult FindPatternEx(std::string_view moduleName, const std::string &pattern)
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
bool IsExecutableAddress(const void *address)
bool IsReadableAddress(const void *address, size_t bytes)
uintptr_t ResolveRelativeAddress(const Image &module, uintptr_t matchAddress, int ripOffset, int ripSize)
constexpr int Rel32Size
std::string PlatformModuleName(std::string_view moduleName)