ReactOS  0.4.15-dev-2703-g05fb0f1
seh0011.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[] = "SEH0011.c";
9 int perfect;
10 
11 void AccessViolation(PLONG BlackHole, PLONG BadAddress) {
12  *BlackHole += *BadAddress;
13  return;
14 }
15 
16 void tfAccessViolation(PLONG BlackHole, PLONG BadAddress, PLONG Counter) {
17  try {
18  AccessViolation(BlackHole, BadAddress);
19  }
20  finally {
21  if (abnormal_termination() != 0)
22  /*
23  * not abnormal termination
24  * counter should equal 99
25  */
26  {
27  *Counter = 99;
28  } else {
29  *Counter = 100;
30  }
31  } endtry
32  return;
33 }
34 
35 int main() {
36  PLONG BadAddress;
37  PLONG BlackHole;
38  LONG Counter;
39 
40  BadAddress = (PLONG)((PVOID)0);
41  BlackHole = &Counter;
42 
43  Counter = 0;
44 
45  try {
46  tfAccessViolation(BlackHole, BadAddress, &Counter);
47  }
49  /*
50  * acception raised was 0xC00000005L (ACCESS VIOLATION)
51  * execute handler
52  */
53  {
54  Counter -= 1;
55  }
56  endtry
57 
58  if (Counter != 98) {
59  printf("TEST 11 FAILED. Counter = %d\n\r", Counter);
60  return -1;
61  }
62 
63  return 0;
64 }
#define endtry
Definition: seh.h:24
void AccessViolation(PLONG BlackHole, PLONG BadAddress)
Definition: seh0011.c:11
int perfect
Definition: seh0011.c:9
char test[]
Definition: seh0011.c:8
int main()
Definition: seh0011.c:35
long LONG
Definition: pedump.c:60
void tfAccessViolation(PLONG BlackHole, PLONG BadAddress, PLONG Counter)
Definition: seh0011.c:16
#define except(x)
Definition: btrfs_drv.h:139
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
static LARGE_INTEGER Counter
Definition: clock.c:43
#define GetExceptionCode()
Definition: seh.h:27
signed int * PLONG
Definition: retypes.h:5
#define abnormal_termination
Definition: seh.h:25
#define printf
Definition: config.h:203