-
Notifications
You must be signed in to change notification settings - Fork 42
/
seh.h
121 lines (95 loc) · 2.63 KB
/
seh.h
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
*
* Copyright (C) 2010-2011 Amr Thabet <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to Amr Thabet
*
*/
#define SEH_MAGIC 0xBBBBBBBB
#define SIZEOF_387_REGS 80
#define MAXIMUM_EXTENSION 512
//Some exception codes
//Read or write memory violation
#define MEM_ACCESS 0xC0000005
//Divide by zero
#define DIV_ZERO_EXCEPTION 0xC0000094
//Divide overflow
#define DIV_OFLOW 0xC0000095
//The stack went beyond the maximum available size
#define STACK_OVERFLOW 0xC00000FD
//Violation of a guard page in memory set up using Virtual Alloc
#define GUARD_ERROR 0x80000001
#define CONTINUABLE 0
#define NON_CONTINUABLE 1
#define STACK_UNWINDING 2
#ifndef WIN32
struct FLOATING_SAVE_AREA {
DWORD ControlWord;
DWORD StatusWord;
DWORD TagWord;
DWORD ErrorOffset;
DWORD ErrorSelector;
DWORD DataOffset;
DWORD DataSelector;
byte RegisterArea[SIZEOF_387_REGS];
DWORD Cr0NpxState;
};
struct CONTEXT {
DWORD ContextFlags;
DWORD Dr0;
DWORD Dr1;
DWORD Dr2;
DWORD Dr3;
DWORD Dr6;
DWORD Dr7;
FLOATING_SAVE_AREA FloatSave;
DWORD SegGs;
DWORD SegFs;
DWORD SegEs;
DWORD SegDs;
DWORD Edi; //0x9C
DWORD Esi; //0xA0
DWORD Ebx; //0xA4
DWORD Edx; //0xA8
DWORD Ecx; //0xAC
DWORD Eax; //0xB0
DWORD Ebp; //0xB4
DWORD Eip; //0xB8
DWORD SegCs;
DWORD EFlags;
DWORD Esp;
DWORD SegSs;
byte ExtendedRegisters[MAXIMUM_EXTENSION];
};
#else
#include <windows.h>
#endif
#define MAXIMUM_PARMS 15
struct EMU_EXCEPTION_RECORD {
DWORD exceptionCode;
DWORD exceptionFlags;
DWORD exceptionRecord; //struct _EXCEPTION_RECORD *ExceptionRecord
DWORD exceptionAddress;
DWORD numberParameters;
DWORD exceptionInformation[MAXIMUM_PARMS];
};
struct EMU_EXCEPTION_POINTERS {
EMU_EXCEPTION_RECORD *exceptionRecord;
CONTEXT *contextRecord;
};
struct ERR {
DWORD nextErr; //struct _ERR *nextErr;
DWORD handler; //pointer to handler
};