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[] = "SEH0007.c"; 9 10 int main() { 11 PLONG BadAddress; 12 PLONG BlackHole; 13 LONG Counter; 14 15 // startest(); 16 17 BadAddress = (PLONG)((PVOID)0); 18 BlackHole = &Counter; 19 20 Counter = 0; 21 try { 22 try { 23 Counter += 1; 24 *BlackHole += *BadAddress; 25 } 26 finally { 27 if (abnormal_termination() != 0) 28 /* 29 * should execute handler as not abnormal 30 * termination 31 */ 32 { 33 Counter += 1; 34 } 35 } 36 endtry 37 } 38 except(Counter) 39 /* counter is positive == EXECUTE_HANDLER */ 40 { 41 if (Counter == 2) 42 /* counter should equal 2 and execute handler */ 43 { 44 Counter += 1; 45 } 46 } 47 endtry 48 49 if (Counter != 3) { 50 printf("TEST 7 FAILED. Counter = %d\n\r", Counter); 51 return -1; 52 } 53 54 return 0; 55 } 56