ReactOS 0.4.15-dev-7931-gfd331f1
seh0029.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#define faill()
9#define startest()
10#define finish()
11
12char test[] = "SEH0029.c";
13
14void AccessViolation(PLONG BlackHole, PLONG BadAddress) {
15 *BlackHole += *BadAddress;
16 return;
17}
18
19int main() {
20 PCHAR BadByte;
21 PLONG BlackHole;
24
25 BadByte = (PCHAR)((PVOID)0);
26 BadByte += 1;
27 BlackHole = &Counter;
28
29 Counter = 0;
30
31 try {
32 /* set counter = 1 */
33 Counter += 1;
34 /*
35 * create a DATA MISALIGNMENT ERROR by passing
36 * a Byte into a LONG. Passing (PLONG)1.
37 */
38 AccessViolation(BlackHole, (PLONG)BadByte);
39 }
42 ? 1
43 : ((ExceptionCode == STATUS_ACCESS_VIOLATION) ? 1 : 0))) {
44 Counter += 1;
45 }
46 endtry
47
48 if (Counter != 2) {
49 printf("TEST 29 FAILED. Counter = %d\n\r", Counter);
50 return -1;
51 } else {
52 /*
53 ISSUE-REVIEW:a-sibyvi-2003/10/20
54 This test was expecting STATUS_DATATYPE_MISALIGNMENT
55 which is no longer true for UTC and Phoenix. So changing the test
56 to expect Acces Violation instead.
57 ISSUE-REVIEW:v-simwal-2011-01-25 Either MISALIGNMENT or ACCESS VIOLATION
58 counts as a pass.
59 */
62 printf(
63 "TEST 29 FAILED. Expected ACCESS_VIOLATION, got exception = %d\n\r",
65 return -1;
66 }
67 }
68 return 0;
69}
#define except(x)
Definition: btrfs_drv.h:136
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1774
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:97
#define PCHAR
Definition: match.c:90
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:183
long LONG
Definition: pedump.c:60
void AccessViolation(PLONG BlackHole, PLONG BadAddress)
Definition: seh0029.c:14
char test[]
Definition: seh0029.c:12
int main()
Definition: seh0029.c:19
#define endtry
Definition: seh.h:24
#define GetExceptionCode()
Definition: seh.h:27
static LARGE_INTEGER Counter
Definition: clock.c:43
int32_t * PLONG
Definition: typedefs.h:58
char * PCHAR
Definition: typedefs.h:51