forked from NytroRST/ShellcodeCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSEHUtils.h
More file actions
38 lines (31 loc) · 792 Bytes
/
SEHUtils.h
File metadata and controls
38 lines (31 loc) · 792 Bytes
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
#ifndef SEHUTILIS_H
#define SEHUTILIS_H
#include <windows.h>
#include <exception>
struct seh_exception : public std::exception
{
seh_exception(const char* message, DWORD code) : exception(message), m_code(code) {}
DWORD Code() const { return m_code; }
private:
const DWORD m_code;
};
void CxxTranslateSehException(unsigned int, EXCEPTION_POINTERS* pointers)
{
DWORD exceptionCode = pointers->ExceptionRecord->ExceptionCode;
const char* msg = nullptr;
switch (exceptionCode) {
case EXCEPTION_ACCESS_VIOLATION:
msg = "Access violation.";
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
msg = "Out of bound access.";
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
msg = "Illegal instruction.";
break;
default:
break;
}
throw seh_exception(msg, exceptionCode);
}
#endif