ReactOS  0.4.15-dev-5112-g22d8c0f
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 
12 char test[] = "SEH0029.c";
13 
14 void AccessViolation(PLONG BlackHole, PLONG BadAddress) {
15  *BlackHole += *BadAddress;
16  return;
17 }
18 
19 int main() {
20  PCHAR BadByte;
21  PLONG BlackHole;
22  LONG Counter;
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 }
signed char * PCHAR
Definition: retypes.h:7
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1772
#define endtry
Definition: seh.h:24
long LONG
Definition: pedump.c:60
#define PCHAR
Definition: match.c:90
#define printf
Definition: freeldr.h:94
int main()
Definition: seh0029.c:19
unsigned long DWORD
Definition: ntddk_ex.h:95
#define except(x)
Definition: btrfs_drv.h:136
void AccessViolation(PLONG BlackHole, PLONG BadAddress)
Definition: seh0029.c:14
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
char test[]
Definition: seh0029.c:12
static LARGE_INTEGER Counter
Definition: clock.c:43
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:183
#define GetExceptionCode()
Definition: seh.h:27
signed int * PLONG
Definition: retypes.h:5