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