-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscanner.hpp
38 lines (31 loc) · 1.14 KB
/
scanner.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//===========================================================================//
//
// Author: NULLderef
// Purpose: Portal 2: Multiplayer Mod server plugin
//
//===========================================================================//
#ifndef SCANNER_HPP
#define SCANNER_HPP
#include <span>
#include <string>
#include <vector>
#include <memory>
namespace Memory {
class ScannerImplementation {
public:
virtual uintptr_t Scan(std::span<uint8_t> region, std::string pattern, int offset) = 0;
virtual std::vector<uintptr_t> ScanMultiple(std::span<uint8_t> region, std::string pattern, int offset) = 0;
};
class Scanner {
public:
template<typename T = uintptr_t> static T Scan(std::span<uint8_t> region, std::string pattern, int offset = 0) {
return reinterpret_cast<T>(Scanner::Implementation().get()->Scan(region, pattern, offset));
}
static std::vector<uintptr_t> ScanMultiple(std::span<uint8_t> region, std::string pattern, int offset = 0) {
return Scanner::Implementation().get()->ScanMultiple(region, pattern, offset);
}
private:
static std::unique_ptr<ScannerImplementation>& Implementation();
};
};
#endif // SCANNER_HPP