forked from bb107/MemoryModulePP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunhandled_exception.cpp
More file actions
49 lines (36 loc) · 1.03 KB
/
unhandled_exception.cpp
File metadata and controls
49 lines (36 loc) · 1.03 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
#include <Windows.h>
#include <cstdio>
#ifdef _WIN64
DWORD Value;
volatile LPDWORD lpAddr;
LONG WINAPI Filter(_In_ struct _EXCEPTION_POINTERS* ExceptionInfo) {
if (ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION) {
lpAddr = &Value;
// +++++++
// begin compiler specific
// +++++++
//ExceptionInfo->ContextRecord->Rip -= 7;
ExceptionInfo->ContextRecord->Rax = (ULONG_PTR)lpAddr;
// +++++++
// end compiler specific
// +++++++
return EXCEPTION_CONTINUE_EXECUTION;
}
return EXCEPTION_CONTINUE_SEARCH;
}
#endif
int unhandled_exception() {
#ifdef _WIN64
auto filter = SetUnhandledExceptionFilter(Filter);
auto ff = SetUnhandledExceptionFilter(filter);
if (ff != Filter) {
printf("%p\t%p\t%p\nfailed\n", filter, ff, Filter);
return 0;
}
filter = SetUnhandledExceptionFilter(Filter);
lpAddr = nullptr;
*lpAddr = 1;
SetUnhandledExceptionFilter(filter);
#endif
return 1234;
}