ReactOS 0.4.15-dev-7924-g5949c20
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
8char test[] = "SEH0011.c";
9
10void AccessViolation(PLONG BlackHole, PLONG BadAddress) {
11 *BlackHole += *BadAddress;
12 return;
13}
14
15void 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
34int main() {
35 PLONG BadAddress;
36 PLONG BlackHole;
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 except(x)
Definition: btrfs_drv.h:136
#define printf
Definition: freeldr.h:93
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
long LONG
Definition: pedump.c:60
void AccessViolation(PLONG BlackHole, PLONG BadAddress)
Definition: seh0011.c:10
void tfAccessViolation(PLONG BlackHole, PLONG BadAddress, PLONG Counter)
Definition: seh0011.c:15
char test[]
Definition: seh0011.c:8
int main()
Definition: seh0011.c:34
#define endtry
Definition: seh.h:24
#define GetExceptionCode()
Definition: seh.h:27
#define abnormal_termination
Definition: seh.h:25
static LARGE_INTEGER Counter
Definition: clock.c:43
int32_t * PLONG
Definition: typedefs.h:58