ReactOS  0.4.15-dev-5492-g47f3a4e
seh0027.c
Go to the documentation of this file.
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 
11  RaiseException(Status, 0, /*no flags*/ 0, 0);
12  return;
13 }
14 
16  PEXCEPTION_RECORD ExceptionRecord;
17 
18  ExceptionRecord = ExceptionPointers->ExceptionRecord;
19  if ((ExceptionRecord->ExceptionCode == (STATUS_INTEGER_OVERFLOW)) &&
20  ((ExceptionRecord->ExceptionFlags & 0x10) == 0)) {
21  /* set counter = 23 */
22  *Counter += 17;
24  } else if ((ExceptionRecord->ExceptionCode == EXCEPTION_EXECUTE_HANDLER) &&
25  ((ExceptionRecord->ExceptionFlags & 0x10) != 0)) {
26  /* set counter = 42 */
27  *Counter += 19;
28  /* return COTINUE SEARCH */
29  return 0;
30  }
31  /* never gets here due to exception being rasied */
32  *Counter += 23;
33  return 1;
34 }
35 
37  try {
38  /* set counter = 6 */
39  *Counter += 5;
40  RaiseException(EXCEPTION_INT_OVERFLOW, 0, /*no flags*/ 0, 0);
41  }
43  endtry
44  /* set counter = 59 */
45  *Counter += 9;
46  return;
47 }
48 
50  PEXCEPTION_RECORD ExceptionRecord;
51 
52  ExceptionRecord = ExceptionPointers->ExceptionRecord;
53  if ((ExceptionRecord->ExceptionCode == EXCEPTION_EXECUTE_HANDLER) &&
54  ((ExceptionRecord->ExceptionFlags & 0x10) == 0)) {
55  /* set counter = 53 */
56  *Counter += 11;
57  return 1;
58  } else {
59  *Counter += 13;
60  return 0;
61  }
62 }
63 
64 int main() {
65  LONG Counter;
66 
67  Counter = 0;
68 
69  try {
70  try {
71  /* set counter = 1 */
72  Counter += 1;
73  except1(&Counter);
74  }
76  /* set counter = 55 */
77  Counter += 2;
78  }
79  endtry
80  }
81  except(1) { Counter += 3; }
82  endtry
83 
84  if (Counter != 55) {
85  printf("TEST 27 FAILED. Counter = %d\n\r", Counter);
86  return -1;
87  }
88 
89  return 0;
90 }
char test[]
Definition: seh0027.c:8
#define GetExceptionInformation()
Definition: seh.h:26
#define endtry
Definition: seh.h:24
#define EXCEPTION_INT_OVERFLOW
Definition: winbase.h:324
int main()
Definition: seh0027.c:64
ULONG except2(PEXCEPTION_POINTERS ExceptionPointers, PLONG Counter)
Definition: seh0027.c:49
DWORD ExceptionCode
Definition: compat.h:208
#define STATUS_INTEGER_OVERFLOW
Definition: ntstatus.h:385
long LONG
Definition: pedump.c:60
Status
Definition: gdiplustypes.h:24
#define printf
Definition: freeldr.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned long DWORD
Definition: ntddk_ex.h:95
void except1(PLONG Counter)
Definition: seh0027.c:36
#define except(x)
Definition: btrfs_drv.h:136
ULONG except3(PEXCEPTION_POINTERS ExceptionPointers, PLONG Counter)
Definition: seh0027.c:15
VOID WINAPI RaiseException(IN DWORD dwExceptionCode, IN DWORD dwExceptionFlags, IN DWORD nNumberOfArguments, IN CONST ULONG_PTR *lpArguments OPTIONAL)
Definition: except.c:700
static LARGE_INTEGER Counter
Definition: clock.c:43
unsigned int ULONG
Definition: retypes.h:1
DWORD ExceptionFlags
Definition: compat.h:209
PEXCEPTION_RECORD ExceptionRecord
Definition: rtltypes.h:200
void rtlRaiseStatus(DWORD Status)
Definition: seh0027.c:10
signed int * PLONG
Definition: retypes.h:5