forked from crosire/reshade
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhook.hpp
More file actions
72 lines (65 loc) · 1.47 KB
/
Copy pathhook.hpp
File metadata and controls
72 lines (65 loc) · 1.47 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Copyright (C) 2014 Patrick Mours. All rights reserved.
* License: https://github.com/crosire/reshade#license
*/
#pragma once
namespace reshade
{
struct hook
{
typedef void *address;
enum class status
{
unknown = -1,
success,
not_executable = 7,
unsupported_function,
allocation_failure,
memory_protection_failure,
};
hook();
hook(address target, address replacement);
/// <summary>
/// Return whether the hook is valid.
/// </summary>
bool valid() const;
/// <summary>
/// Return whether the hook is currently enabled.
/// </summary>
bool enabled() const;
/// <summary>
/// Return whether the hook is currently installed.
/// </summary>
bool installed() const;
/// <summary>
/// Return whether the hook is not currently installed.
/// </summary>
bool uninstalled() const
{
return !installed();
}
/// <summary>
/// Enable or disable the hook.
/// </summary>
/// <param name="enable">Boolean indicating if hook should be enabled or disabled.</param>
bool enable(bool enable = true) const;
/// <summary>
/// Install the hook.
/// </summary>
status install();
/// <summary>
/// Uninstall the hook.
/// </summary>
status uninstall();
/// <summary>
/// Return the trampoline function address of the hook.
/// </summary>
address call() const;
template <typename T>
inline T call() const
{
return reinterpret_cast<T>(call());
}
address target, replacement, trampoline;
};
}