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