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