HydraHook
Direct3D and Core Audio hooking library for Windows
Loading...
Searching...
No Matches
Exceptions.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
9#include <Windows.h>
10#include <stdexcept>
11
12namespace HydraHook
13{
14 namespace Core
15 {
16 namespace Exceptions
17 {
18 class RuntimeException : public std::runtime_error
19 {
20 public:
21 explicit RuntimeException(const std::string &msg) :
22 std::runtime_error(msg.c_str())
23 { }
24
25 explicit RuntimeException(const char *msg) :
26 std::runtime_error(msg)
27 { }
28 };
29
31 {
32 public:
33 explicit DetourException(const std::string &msg) :
34 RuntimeException(msg.c_str())
35 { }
36
37 explicit DetourException(const char *msg) :
39 { }
40 };
41
42 class GenericWinAPIException : public std::runtime_error
43 {
44 DWORD last_error_;
45
46 public:
47 explicit GenericWinAPIException(const std::string &msg) :
48 std::runtime_error(msg.c_str()), last_error_(GetLastError())
49 { }
50
51 explicit GenericWinAPIException(const char *msg) :
52 std::runtime_error(msg), last_error_(GetLastError())
53 { }
54
55 virtual DWORD get_last_error() const
56 {
57 return last_error_;
58 }
59 };
60
62 {
63 public:
64 explicit ModuleNotFoundException(const std::string &msg) :
66 { }
67
68 explicit ModuleNotFoundException(const char *msg) :
70 { }
71 };
72
74 {
75 public:
76 explicit ProcAddressNotFoundException(const std::string &msg) :
78 { }
79
80 explicit ProcAddressNotFoundException(const char *msg) :
82 { }
83 };
84
86 {
87 HRESULT hresult_;
88
89 public:
90 explicit COMInterfaceException(const std::string &msg, HRESULT result) :
91 RuntimeException(msg), hresult_(result)
92 { }
93
94 explicit COMInterfaceException(const char *msg, HRESULT result) :
95 RuntimeException(msg), hresult_(result)
96 { }
97
98 HRESULT hresult() const
99 {
100 return hresult_;
101 }
102 };
103
105 {
106 public:
107 explicit DXAPIException(const std::string &msg, HRESULT result) :
108 COMInterfaceException(msg, result)
109 { }
110
111 explicit DXAPIException(const char *msg, HRESULT result) :
112 COMInterfaceException(msg, result)
113 { }
114 };
115
117 {
118 public:
119 explicit ARCException(const std::string &msg, HRESULT result) :
120 COMInterfaceException(msg, result)
121 { }
122
123 explicit ARCException(const char *msg, HRESULT result) :
124 COMInterfaceException(msg, result)
125 { }
126 };
127
129 {
130 DWORD code_;
131 EXCEPTION_POINTERS* info_;
132
133 public:
134 SehException(DWORD code, EXCEPTION_POINTERS* info) :
135 RuntimeException("Structured exception"),
136 code_(code), info_(info)
137 { }
138
139 DWORD code() const { return code_; }
140 EXCEPTION_POINTERS* exception_pointers() const { return info_; }
141 };
142 };
143 };
144};
ARCException(const std::string &msg, HRESULT result)
ARCException(const char *msg, HRESULT result)
COMInterfaceException(const std::string &msg, HRESULT result)
COMInterfaceException(const char *msg, HRESULT result)
DXAPIException(const char *msg, HRESULT result)
DXAPIException(const std::string &msg, HRESULT result)
EXCEPTION_POINTERS * exception_pointers() const
SehException(DWORD code, EXCEPTION_POINTERS *info)