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[] = "SEH0009.c"; 9 int perfect; 10 11 void AccessViolation(PLONG BlackHole, PLONG BadAddress) { 12 *BlackHole += *BadAddress; 13 return; 14 } 15 16 int main() { 17 PLONG BadAddress; 18 PLONG BlackHole; 19 LONG Counter; 20 21 BadAddress = (PLONG)((PVOID)0); 22 BlackHole = &Counter; 23 24 Counter = 0; 25 26 try { 27 Counter += 1; 28 AccessViolation(BlackHole, BadAddress); 29 } 30 except((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 1 : 0) 31 /* 32 * should be ACCESS VIOLATOIN 0xC0000005L) causing 33 * execution of handler 34 */ 35 { 36 Counter += 1; 37 } 38 endtry 39 40 if (Counter != 2) { 41 printf("TEST 9 FAILED. Counter = %d\n\r", Counter); 42 return -1; 43 } 44 45 return 0; 46 } 47