ReactOS  0.4.15-dev-3442-gc05a45e
seh0013.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 <setjmp.h>
6 #include <windows.h>
7 #include "seh.h"
8 
9 char test[] = "SEH0013.c";
10 int perfect;
11 
13  RaiseException(Status, 0, /*no flags*/ 0, 0);
14  return;
15 }
16 
17 void AccessViolation(PLONG BlackHole, PLONG BadAddress) {
18  *BlackHole += *BadAddress;
19  return;
20 }
21 
22 int main() {
23  PLONG BadAddress;
24  PCHAR BadByte;
25  PLONG BlackHole;
26  ULONG Index2 = 1;
27  LONG Counter;
28 
29  BadAddress = (PLONG)((PVOID)0);
30  BadByte = (PCHAR)((PVOID)0);
31  BadByte += 1;
32  BlackHole = &Counter;
33 
34  Counter = 0;
35 
36  try {
37  AccessViolation(BlackHole, BadAddress);
38  }
40  /*
41  * exception handler should gete executed
42  * setting Counter to 1
43  */
44  {
45  Counter += 1;
46  try {
48  }
50  /* exception handler should get executed */
51  {
52  if (Counter != 1) {
53  printf("TEST 13 FAILED. Counter = %d\n\r", Counter);
54  return -1;
55  }
56  /* set's counter to 2 */
57  Counter += 1;
58  }
59  endtry
60  }
61  endtry
62 
63  if (Counter != 2) {
64  printf("TEST 13 FAILED. Counter= %d\n\r", Counter);
65  return -1;
66  }
67 
68  return 0;
69 }
signed char * PCHAR
Definition: retypes.h:7
void AccessViolation(PLONG BlackHole, PLONG BadAddress)
Definition: seh0013.c:17
#define endtry
Definition: seh.h:24
int main()
Definition: seh0013.c:22
char test[]
Definition: seh0013.c:9
int perfect
Definition: seh0013.c:10
long LONG
Definition: pedump.c:60
#define PCHAR
Definition: match.c:90
Status
Definition: gdiplustypes.h:24
unsigned long DWORD
Definition: ntddk_ex.h:95
void rtlRaiseException(DWORD Status)
Definition: seh0013.c:12
#define except(x)
Definition: btrfs_drv.h:139
VOID WINAPI RaiseException(IN DWORD dwExceptionCode, IN DWORD dwExceptionFlags, IN DWORD nNumberOfArguments, IN CONST ULONG_PTR *lpArguments OPTIONAL)
Definition: except.c:700
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
static LARGE_INTEGER Counter
Definition: clock.c:43
unsigned int ULONG
Definition: retypes.h:1
#define GetExceptionCode()
Definition: seh.h:27
signed int * PLONG
Definition: retypes.h:5
#define printf
Definition: config.h:203