ReactOS  0.4.14-dev-831-gef8c9239
ExHardError.c File Reference
#include <kmt_test.h>
Include dependency graph for ExHardError.c:

Go to the source code of this file.

Macros

#define NoResponse   27
 
#define CheckHardError(ErrStatus, UnicodeStringMask, ResponseOption, ExpectedStatus, ExpectedResponse, NumberOfParameters, ...)
 
#define CheckInformationalHardError(ErrStatus, String, Thread, ExpectedStatus, ExpectedRet)
 

Functions

static VOID SetParameters (OUT PULONG_PTR Parameters, IN INT Count,...)
 
static VOID TestHardError (BOOLEAN InteractivePart1, BOOLEAN InteractivePart2, BOOLEAN InteractivePart3, BOOLEAN InteractivePart4)
 
 START_TEST (ExHardError)
 
 START_TEST (ExHardErrorInteractive)
 

Macro Definition Documentation

◆ CheckHardError

#define CheckHardError (   ErrStatus,
  UnicodeStringMask,
  ResponseOption,
  ExpectedStatus,
  ExpectedResponse,
  NumberOfParameters,
  ... 
)
Value:
do \
{ \
SetParameters(HardErrorParameters, NumberOfParameters, __VA_ARGS__);\
Response = NoResponse; \
_SEH2_TRY { \
Status = ExRaiseHardError(ErrStatus, \
NumberOfParameters, \
UnicodeStringMask, \
HardErrorParameters, \
ResponseOption, \
&Response); \
Status = _SEH2_GetExceptionCode(); \
} _SEH2_END; \
ok_eq_hex(Status, ExpectedStatus); \
ok_eq_ulong(Response, (ULONG)ExpectedResponse); \
} while (0)
NTSTATUS NTAPI ExRaiseHardError(IN NTSTATUS ErrorStatus, IN ULONG NumberOfParameters, IN ULONG UnicodeStringParameterMask, IN PULONG_PTR Parameters, IN ULONG ValidResponseOptions, OUT PULONG Response)
Definition: harderr.c:386
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define NoResponse
Definition: ExHardError.c:28
Definition: ncftp.h:89
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12

Definition at line 30 of file ExHardError.c.

◆ CheckInformationalHardError

#define CheckInformationalHardError (   ErrStatus,
  String,
  Thread,
  ExpectedStatus,
  ExpectedRet 
)
Value:
do \
{ \
Status = STATUS_SUCCESS; \
Ret = !ExpectedRet; \
_SEH2_TRY { \
Ret = IoRaiseInformationalHardError(ErrStatus, \
String, \
Thread); \
Status = _SEH2_GetExceptionCode(); \
} _SEH2_END; \
ok_eq_hex(Status, ExpectedStatus); \
ok_eq_bool(Ret, ExpectedRet); \
} while (0)
static WCHAR String[]
Definition: stringtable.c:55
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
BOOLEAN NTAPI IoRaiseInformationalHardError(IN NTSTATUS ErrorStatus, IN PUNICODE_STRING String, IN PKTHREAD Thread)
Definition: error.c:694
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2938

Definition at line 50 of file ExHardError.c.

◆ NoResponse

#define NoResponse   27

Definition at line 28 of file ExHardError.c.

Function Documentation

◆ SetParameters()

static VOID SetParameters ( OUT PULONG_PTR  Parameters,
IN INT  Count,
  ... 
)
static

Definition at line 15 of file ExHardError.c.

19 {
20  INT i;
21  va_list Arguments;
22  va_start(Arguments, Count);
23  for (i = 0; i < Count; ++i)
24  Parameters[i] = va_arg(Arguments, ULONG_PTR);
25  va_end(Arguments);
26 }
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
int32_t INT
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
#define va_arg(ap, T)
Definition: acmsvcex.h:89
#define va_start(ap, A)
Definition: acmsvcex.h:91

Referenced by DECLARE_INTERFACE_().

◆ START_TEST() [1/2]

START_TEST ( ExHardError  )

Definition at line 219 of file ExHardError.c.

220 {
222 }
static VOID TestHardError(BOOLEAN InteractivePart1, BOOLEAN InteractivePart2, BOOLEAN InteractivePart3, BOOLEAN InteractivePart4)
Definition: ExHardError.c:68

◆ START_TEST() [2/2]

START_TEST ( ExHardErrorInteractive  )

Definition at line 233 of file ExHardError.c.

234 {
236 }
#define TRUE
Definition: types.h:120
static VOID TestHardError(BOOLEAN InteractivePart1, BOOLEAN InteractivePart2, BOOLEAN InteractivePart3, BOOLEAN InteractivePart4)
Definition: ExHardError.c:68

◆ TestHardError()

static VOID TestHardError ( BOOLEAN  InteractivePart1,
BOOLEAN  InteractivePart2,
BOOLEAN  InteractivePart3,
BOOLEAN  InteractivePart4 
)
static

Definition at line 68 of file ExHardError.c.

73 {
76  WCHAR StringBuffer1[] = L"Parameter1+Garbage";
77  CHAR StringBuffer1Ansi[] = "Parameter1+Garbage";
78  WCHAR StringBuffer2[] = L"Parameter2+Garbage";
79  UNICODE_STRING String1 = RTL_CONSTANT_STRING(StringBuffer1);
80  ANSI_STRING String1Ansi = RTL_CONSTANT_STRING(StringBuffer1Ansi);
82  ULONG_PTR HardErrorParameters[6];
83  BOOLEAN Ret;
84 
85  String1.Length = sizeof L"Parameter1" - sizeof UNICODE_NULL;
86  String1Ansi.Length = sizeof "Parameter1" - sizeof ANSI_NULL;
87  String2.Length = sizeof L"Parameter2" - sizeof UNICODE_NULL;
88 
89  if (InteractivePart1)
90  {
91  CheckHardError(0x40000000, 0, OptionOk, STATUS_SUCCESS, ResponseOk, 0, 0); // outputs a box :|
92  CheckHardError(0x40000001, 0, OptionOk, STATUS_SUCCESS, ResponseOk, 4, 1, 2, 3, 4); // outputs a box :|
93  CheckHardError(0x40000002, 0, OptionOk, STATUS_SUCCESS, ResponseOk, 5, 1, 2, 3, 4, 5); // outputs a box :|
94  CheckHardError(0x40000003, 0, OptionOk, STATUS_SUCCESS, ResponseNotHandled, 6, 1, 2, 3, 4, 5, 6); // TODO: interactive on ROS
95  }
96 
98  if (InteractivePart1)
99  {
100  // TODO: these 2 are interactive on ROS
101  CheckHardError(0x40000005, 0, OptionOkNoWait, STATUS_SUCCESS, ResponseOk, 0, 0); // outputs a balloon notification
102  CheckHardError(0x4000000f, 0, OptionOkNoWait, STATUS_SUCCESS, ResponseOk, 0, 0); // outputs a balloon notification
103  CheckHardError(0x40000006, 0, OptionAbortRetryIgnore, STATUS_SUCCESS, ResponseAbort, 0, 0); // outputs a box :|
104  CheckHardError(0x40000006, 0, OptionAbortRetryIgnore, STATUS_SUCCESS, ResponseRetry, 0, 0); // outputs a box :|
105  CheckHardError(0x40000006, 0, OptionAbortRetryIgnore, STATUS_SUCCESS, ResponseIgnore, 0, 0); // outputs a box :|
106  CheckHardError(0x40000008, 0, OptionCancelTryContinue, STATUS_SUCCESS, ResponseCancel, 0, 0); // outputs a box :|
107  CheckHardError(0x40000008, 0, OptionCancelTryContinue, STATUS_SUCCESS, ResponseTryAgain, 0, 0); // outputs a box :|
108  CheckHardError(0x40000008, 0, OptionCancelTryContinue, STATUS_SUCCESS, ResponseContinue, 0, 0); // outputs a box :|
109  CheckHardError(0x40000010, 0, OptionOkCancel, STATUS_SUCCESS, ResponseOk, 0, 0); // outputs a box :|
110  CheckHardError(0x40000010, 0, OptionOkCancel, STATUS_SUCCESS, ResponseCancel, 0, 0); // outputs a box :|
111  CheckHardError(0x40000011, 0, OptionRetryCancel, STATUS_SUCCESS, ResponseRetry, 0, 0); // outputs a box :|
112  CheckHardError(0x40000011, 0, OptionRetryCancel, STATUS_SUCCESS, ResponseCancel, 0, 0); // outputs a box :|
113  CheckHardError(0x40000012, 0, OptionYesNo, STATUS_SUCCESS, ResponseYes, 0, 0); // outputs a box :|
114  CheckHardError(0x40000012, 0, OptionYesNo, STATUS_SUCCESS, ResponseNo, 0, 0); // outputs a box :|
115  CheckHardError(0x40000013, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseYes, 0, 0); // outputs a box :|
116  CheckHardError(0x40000013, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 0, 0); // outputs a box :|
117  CheckHardError(0x40000013, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 0, 0); // outputs a box :|
118  }
119  CheckHardError(0x40000009, 0, 9, STATUS_SUCCESS, ResponseNotHandled, 0, 0);
120  CheckHardError(0x4000000a, 0, 10, STATUS_SUCCESS, ResponseNotHandled, 0, 0);
121  CheckHardError(0x4000000b, 0, 11, STATUS_SUCCESS, ResponseNotHandled, 0, 0);
122  CheckHardError(0x4000000c, 0, 12, STATUS_SUCCESS, ResponseNotHandled, 0, 0);
123  CheckHardError(0x4000000d, 0, MAXULONG / 2 + 1, STATUS_SUCCESS, ResponseNotHandled, 0, 0);
125 
126  if (InteractivePart2)
127  {
128  /* try a message with one parameter */
129  CheckHardError(STATUS_DLL_NOT_FOUND, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseYes, 1, &String1); // outputs a box :|
133  /* give too many parameters */
137  CheckHardError(STATUS_DLL_NOT_FOUND, 3, OptionYesNoCancel, STATUS_SUCCESS, ResponseYes, 4, &String1, &String2, 0, 0); // outputs a box :|
138  /* try with stuff that's not a UNICODE_STRING */
139  CheckHardError(STATUS_DLL_NOT_FOUND, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 1, &String1Ansi); // outputs a box :|
140  CheckHardError(STATUS_DLL_NOT_FOUND, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 1, L"Parameter1"); // outputs a box :|
141  CheckHardError(STATUS_DLL_NOT_FOUND, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 1, "Parameter1"); // outputs a box :|
144  CheckHardError(STATUS_DLL_NOT_FOUND, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 1, &String1Ansi); // outputs a box :|
145  CheckHardError(STATUS_DLL_NOT_FOUND, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 1, L"Parameter1"); // outputs a box :|
146  CheckHardError(STATUS_DLL_NOT_FOUND, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 1, "Parameter1"); // outputs a box :|
149  }
150  if (InteractivePart3)
151  {
152  /* try a message with one parameter */
157  /* give too many parameters */
162  CheckHardError(STATUS_SERVICE_NOTIFICATION, 3, OptionYesNoCancel, STATUS_SUCCESS, ResponseOk, 4, &String1, &String2, 0, 0); // outputs a box :|
163  CheckHardError(STATUS_SERVICE_NOTIFICATION, 3, OptionOkNoWait, STATUS_SUCCESS, ResponseOk, 4, &String1, &String2, 0, 0); // outputs a balloon notification
164  /* try with stuff that's not a UNICODE_STRING */
175  }
176  if (InteractivePart4)
177  {
178  /* try a message with one parameter */
179  CheckHardError(STATUS_FATAL_APP_EXIT, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseYes, 1, &String1); // outputs a box :|
183  /* give too many parameters */
187  CheckHardError(STATUS_FATAL_APP_EXIT, 3, OptionYesNoCancel, STATUS_SUCCESS, ResponseYes, 4, &String1, &String2, 0, 0); // outputs a box :|
188  /* try with stuff that's not a UNICODE_STRING */
189  CheckHardError(STATUS_FATAL_APP_EXIT, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 1, &String1Ansi); // outputs a box :|
190  CheckHardError(STATUS_FATAL_APP_EXIT, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 1, L"Parameter1"); // outputs a box :|
191  CheckHardError(STATUS_FATAL_APP_EXIT, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 1, "Parameter1"); // outputs a box :|
194  CheckHardError(STATUS_FATAL_APP_EXIT, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 1, &String1Ansi); // outputs a box :|
195  CheckHardError(STATUS_FATAL_APP_EXIT, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 1, L"Parameter1"); // outputs a box :|
196  CheckHardError(STATUS_FATAL_APP_EXIT, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 1, "Parameter1"); // outputs a box :|
199 
200  // TODO: these 3 are interactive on ROS
201  CheckInformationalHardError(STATUS_WAIT_0, NULL, NULL, STATUS_SUCCESS, TRUE); // outputs a balloon notification
202  CheckInformationalHardError(STATUS_DLL_NOT_FOUND, &String1, NULL, STATUS_SUCCESS, TRUE); // outputs a balloon notification
203  CheckInformationalHardError(STATUS_DLL_NOT_FOUND, NULL, NULL, STATUS_SUCCESS, TRUE); // outputs a balloon notification
204  }
206 
207  ok_bool_true(IoSetThreadHardErrorMode(TRUE), "IoSetThreadHardErrorMode returned");
208  ok_bool_true(IoSetThreadHardErrorMode(FALSE), "IoSetThreadHardErrorMode returned");
209  ok_bool_false(IoSetThreadHardErrorMode(FALSE), "IoSetThreadHardErrorMode returned");
216  ok_bool_false(IoSetThreadHardErrorMode(TRUE), "IoSetThreadHardErrorMode returned");
217 }
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define TRUE
Definition: types.h:120
#define CheckInformationalHardError(ErrStatus, String, Thread, ExpectedStatus, ExpectedRet)
Definition: ExHardError.c:50
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define ok_bool_false(value, desc)
Definition: kmt_test.h:257
#define ok_bool_true(value, desc)
Definition: kmt_test.h:256
#define STATUS_WAIT_0
Definition: ntstatus.h:223
#define UNICODE_NULL
#define ANSI_NULL
#define NoResponse
Definition: ExHardError.c:28
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN NTAPI IoSetThreadHardErrorMode(IN BOOLEAN HardErrorEnabled)
Definition: error.c:707
Status
Definition: gdiplustypes.h:24
#define CheckHardError(ErrStatus, UnicodeStringMask, ResponseOption, ExpectedStatus, ExpectedResponse, NumberOfParameters,...)
Definition: ExHardError.c:30
#define MAXULONG
Definition: typedefs.h:250
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
#define STATUS_DLL_NOT_FOUND
Definition: ntstatus.h:531
_In_ const STRING * String2
Definition: rtlfuncs.h:2292
unsigned int ULONG
Definition: retypes.h:1
struct Response Response
#define STATUS_FATAL_APP_EXIT
Definition: ntstatus.h:135
#define STATUS_SERVICE_NOTIFICATION
Definition: ntstatus.h:138
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by START_TEST().