ReactOS 0.4.15-dev-7924-g5949c20
seh0026.c
Go to the documentation of this file.
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for
3// full license information.
4
5#include <windows.h>
6#include <setjmp.h>
7
8#include "seh.h"
9
10char test[] = "SEH0026.c";
11
12void dojump(jmp_buf JumpBuffer, PLONG Counter) {
13 try {
14 try {
15 /* set Counter = 1 */
16 *Counter += 1;
17 RaiseException(EXCEPTION_INT_OVERFLOW, 0, /*no flags*/ 0, 0);
18 }
19 finally {
20 /* set counter = 2 */
21 *Counter += 1;
22 }
23 endtry
24 }
25 finally {
26 /* set counter = 3 */
27 *Counter += 1;
28 longjmp(JumpBuffer, 1);
29 }
30 endtry
31}
32
33int main() {
34 jmp_buf JumpBuffer;
36
37 Counter = 0;
38
39 if (_setjmp(JumpBuffer) == 0) {
40 try {
41 try {
42 try {
43 try {
44 *(volatile LONG*)&Counter += 1;
45 dojump(JumpBuffer, &Counter);
46 }
47 finally { *(volatile LONG*)&Counter += 1; }
48 endtry
49 }
50 finally {
51 *(volatile LONG*)&Counter += 1;
52 longjmp(JumpBuffer, 1);
53 }
54 endtry
55 }
56 finally { *(volatile LONG*)&Counter += 1; }
57 endtry
58 }
59 except(1)
60 /* EXECUTE HANDLER after unwinding */
61 {
62 *(volatile LONG*)&Counter += 1;
63 }
64 endtry
65 } else {
66 /* set Counter = 4 */ //
67 *(volatile LONG*)&Counter += 1;
68 }
69
70 if (Counter != 8) {
71 printf("TEST 26 FAILED. Counter = %d\n\r", Counter);
72 return -1;
73 }
74
75 return 0;
76}
#define except(x)
Definition: btrfs_drv.h:136
_JBTYPE jmp_buf[_JBLEN]
Definition: setjmp.h:186
VOID WINAPI RaiseException(_In_ DWORD dwExceptionCode, _In_ DWORD dwExceptionFlags, _In_ DWORD nNumberOfArguments, _In_opt_ const ULONG_PTR *lpArguments)
Definition: except.c:700
#define printf
Definition: freeldr.h:93
long LONG
Definition: pedump.c:60
void dojump(jmp_buf JumpBuffer, PLONG Counter)
Definition: seh0026.c:12
char test[]
Definition: seh0026.c:10
int main()
Definition: seh0026.c:33
#define endtry
Definition: seh.h:24
static LARGE_INTEGER Counter
Definition: clock.c:43
int32_t * PLONG
Definition: typedefs.h:58
#define EXCEPTION_INT_OVERFLOW
Definition: winbase.h:324