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 "seh.h"
7 
8 char test[] = "SEH0018.c";
9 int perfect;
10 
11 void rtlRaiseException(DWORD Status) {
12   RaiseException(Status, 0, /*no flags*/ 0, 0);
13   return;
14 }
15 
16 void eret(DWORD Status, PLONG Counter) {
17   try {
18     try {
19       rtlRaiseException(Status);
20     }
21     except((((DWORD)GetExceptionCode()) == Status) ? 1 : 0)
22     /* exeption handler should get executed */
23     {
24       /* set counter = 2 */
25       *Counter += 1;
26       return;
27     }
28     endtry
29   }
30   finally {
31     /* set counter = 3 */
32     *Counter += 1;
33   }
34   endtry
35 
36   return;
37 }
38 
39 int main() {
40 
41   LONG Counter;
42 
43   Counter = 0;
44 
45   try {
46     /* set counter = 1 */
47     Counter += 1;
48     eret(EXCEPTION_ACCESS_VIOLATION, &Counter);
49   }
50   finally {
51     /* set counter = 4 */
52     Counter += 1;
53   }
54   endtry
55 
56   if (Counter != 4) {
57     printf("TEST 18 FAILED. Counter = %d\n\r", Counter);
58     return -1;
59   }
60 
61   return 0;
62 }
63