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[] = "SEH0005.c";
9 int perfect;
10 
11 int main() {
12   PLONG BadAddress;
13   PLONG BlackHole;
14   LONG Counter;
15 
16   BadAddress = (PLONG)((PVOID)0);
17   BlackHole = &Counter;
18 
19   Counter = 0;
20 
21   try {
22     Counter += 1;
23     *BlackHole += *BadAddress;
24   }
25   except(Counter)
26   /* counter == 1 (EXECUTE HANDLER) */
27   {
28     Counter += 1;
29   }
30   endtry
31 
32   if (Counter != 2) {
33     printf("TEST 5 FAILED. Counter = %d\n\r", Counter);
34     return -1;
35   }
36 
37   return 0;
38 }
39