-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathentry.cpp
97 lines (81 loc) · 2.36 KB
/
entry.cpp
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
/*
* This file is a part of the "Nullboard Backup Agent" source
* code and it is distributed under the terms of 2-clause BSD
* license.
*
* Copyright (c) 2022 Alexander Pankratov, [email protected].
* All rights reserved.
*/
#include "enforce.h"
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <exception>
/*
*
*/
#define __try_cpp_exceptions__ try
#define __catch_cpp_exceptions__ \
catch (std::exception & ) { printf("\nWhoops - std::exception\n"); }
/*
*
*/
#define __try_seh_exceptions__ __try
#define __catch_seh_exceptions__ __except ( EXCEPTION_EXECUTE_HANDLER ) { printf("\nWhoops - seh::exception\n"); }
/*
*
*/
void on_assert(const char * exp, const char * file, const char * func, int line)
{
printf("\nWhoops - assertion failed - line %d\n", line);
exit( 100 ); // RC_whoops_assert
}
/*
*
*/
int wmain_app(int argc, wchar_t ** argv);
int wmain_seh(int argc, wchar_t ** argv)
{
int r = 101; // RC_whoops_seh
__try_seh_exceptions__
{
r = wmain_app(argc, argv);
}
__catch_seh_exceptions__
return r;
}
/*
* subsystem: console
*/
int wmain(int argc, wchar_t ** argv)
{
int r = 102; // RC_whoops_cpp
__try_cpp_exceptions__
{
r = wmain_seh(argc, argv);
}
__catch_cpp_exceptions__
return r;
}
/*
* subsystem: windows
*/
int __stdcall wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
LPWSTR _cmd_line, int show_cmd)
{
extern HINSTANCE sfc_instance;
sfc_instance = instance;
return wmain(__argc, __wargv);
}
/*
* super-duper crap-o-matic
*/
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif