1*fe36f081STimo Kreuzer // Copyright (c) Microsoft. All rights reserved.
2*fe36f081STimo Kreuzer // Licensed under the MIT license. See LICENSE file in the project root for
3*fe36f081STimo Kreuzer // full license information.
4*fe36f081STimo Kreuzer 
5*fe36f081STimo Kreuzer #include <windows.h>
6*fe36f081STimo Kreuzer #include "seh.h"
7*fe36f081STimo Kreuzer 
8*fe36f081STimo Kreuzer char test[] = "SEH0010.c";
9*fe36f081STimo Kreuzer 
rtlRaiseExcpt(DWORD Status)10*fe36f081STimo Kreuzer void rtlRaiseExcpt(DWORD Status) {
11*fe36f081STimo Kreuzer   RaiseException(Status, 0, /*no flags*/ 0, 0);
12*fe36f081STimo Kreuzer   return;
13*fe36f081STimo Kreuzer }
14*fe36f081STimo Kreuzer 
tfRaiseExcpt(DWORD Status,PLONG Counter)15*fe36f081STimo Kreuzer void tfRaiseExcpt(DWORD Status, PLONG Counter) {
16*fe36f081STimo Kreuzer   try {
17*fe36f081STimo Kreuzer     rtlRaiseExcpt(Status);
18*fe36f081STimo Kreuzer   }
19*fe36f081STimo Kreuzer   finally {
20*fe36f081STimo Kreuzer     if (abnormal_termination() != 0)
21*fe36f081STimo Kreuzer     /*
22*fe36f081STimo Kreuzer      * not abnormal termination
23*fe36f081STimo Kreuzer      * counter should eqaul 99
24*fe36f081STimo Kreuzer      */
25*fe36f081STimo Kreuzer     {
26*fe36f081STimo Kreuzer       *Counter = 99;
27*fe36f081STimo Kreuzer     } else {
28*fe36f081STimo Kreuzer       *Counter = 100;
29*fe36f081STimo Kreuzer     }
30*fe36f081STimo Kreuzer   }
31*fe36f081STimo Kreuzer   endtry
32*fe36f081STimo Kreuzer   return;
33*fe36f081STimo Kreuzer }
34*fe36f081STimo Kreuzer 
main()35*fe36f081STimo Kreuzer int main() {
36*fe36f081STimo Kreuzer   LONG Counter;
37*fe36f081STimo Kreuzer 
38*fe36f081STimo Kreuzer   Counter = 0;
39*fe36f081STimo Kreuzer 
40*fe36f081STimo Kreuzer   try {
41*fe36f081STimo Kreuzer     tfRaiseExcpt(STATUS_ACCESS_VIOLATION, &Counter);
42*fe36f081STimo Kreuzer   }
43*fe36f081STimo Kreuzer   except((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 1 : 0)
44*fe36f081STimo Kreuzer   /* exception raised was 0xC0000005L, and execute handler */
45*fe36f081STimo Kreuzer   {
46*fe36f081STimo Kreuzer     Counter -= 1;
47*fe36f081STimo Kreuzer   }
48*fe36f081STimo Kreuzer   endtry
49*fe36f081STimo Kreuzer 
50*fe36f081STimo Kreuzer   if (Counter != 98) {
51*fe36f081STimo Kreuzer     printf("TEST 10 FAILED. Counter = %d\n\r", Counter);
52*fe36f081STimo Kreuzer     return -1;
53*fe36f081STimo Kreuzer   }
54*fe36f081STimo Kreuzer 
55*fe36f081STimo Kreuzer   return 0;
56*fe36f081STimo Kreuzer }
57