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[] = "SEH0027.c"; 9 int perfect; 10 11 void rtlRaiseStatus(DWORD Status) { 12 RaiseException(Status, 0, /*no flags*/ 0, 0); 13 return; 14 } 15 16 ULONG except3(PEXCEPTION_POINTERS ExceptionPointers, PLONG Counter) { 17 PEXCEPTION_RECORD ExceptionRecord; 18 19 ExceptionRecord = ExceptionPointers->ExceptionRecord; 20 if ((ExceptionRecord->ExceptionCode == (STATUS_INTEGER_OVERFLOW)) && 21 ((ExceptionRecord->ExceptionFlags & 0x10) == 0)) { 22 /* set counter = 23 */ 23 *Counter += 17; 24 rtlRaiseStatus(EXCEPTION_EXECUTE_HANDLER); 25 } else if ((ExceptionRecord->ExceptionCode == EXCEPTION_EXECUTE_HANDLER) && 26 ((ExceptionRecord->ExceptionFlags & 0x10) != 0)) { 27 /* set counter = 42 */ 28 *Counter += 19; 29 /* return COTINUE SEARCH */ 30 return 0; 31 } 32 /* never gets here due to exception being rasied */ 33 *Counter += 23; 34 return 1; 35 } 36 37 void except1(PLONG Counter) { 38 try { 39 /* set counter = 6 */ 40 *Counter += 5; 41 RaiseException(EXCEPTION_INT_OVERFLOW, 0, /*no flags*/ 0, 0); 42 } 43 except(except3(GetExceptionInformation(), Counter)) { *Counter += 7; } 44 endtry 45 /* set counter = 59 */ 46 *Counter += 9; 47 return; 48 } 49 50 ULONG except2(PEXCEPTION_POINTERS ExceptionPointers, PLONG Counter) { 51 PEXCEPTION_RECORD ExceptionRecord; 52 53 ExceptionRecord = ExceptionPointers->ExceptionRecord; 54 if ((ExceptionRecord->ExceptionCode == EXCEPTION_EXECUTE_HANDLER) && 55 ((ExceptionRecord->ExceptionFlags & 0x10) == 0)) { 56 /* set counter = 53 */ 57 *Counter += 11; 58 return 1; 59 } else { 60 *Counter += 13; 61 return 0; 62 } 63 } 64 65 int main() { 66 LONG Counter; 67 68 Counter = 0; 69 70 try { 71 try { 72 /* set counter = 1 */ 73 Counter += 1; 74 except1(&Counter); 75 } 76 except(except2(GetExceptionInformation(), &Counter)) { 77 /* set counter = 55 */ 78 Counter += 2; 79 } 80 endtry 81 } 82 except(1) { Counter += 3; } 83 endtry 84 85 if (Counter != 55) { 86 printf("TEST 27 FAILED. Counter = %d\n\r", Counter); 87 return -1; 88 } 89 90 return 0; 91 } 92