ReactOS 0.4.16-dev-1946-g52006dd
ExHardError.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite Hard error message test
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8#include <kmt_test.h>
9
10/* TODO: don't require user interaction, test Io* routines,
11 * test NTSTATUS values with special handling */
12
13static
14VOID
17 IN INT Count,
18 ...)
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}
27
28#define NoResponse 27
29
30#define CheckHardError(ErrStatus, UnicodeStringMask, ResponseOption, \
31 ExpectedStatus, ExpectedResponse, \
32 NumberOfParameters, ...) do \
33{ \
34 SetParameters(HardErrorParameters, NumberOfParameters, __VA_ARGS__);\
35 Response = NoResponse; \
36 _SEH2_TRY { \
37 Status = ExRaiseHardError(ErrStatus, \
38 NumberOfParameters, \
39 UnicodeStringMask, \
40 HardErrorParameters, \
41 ResponseOption, \
42 &Response); \
43 } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { \
44 Status = _SEH2_GetExceptionCode(); \
45 } _SEH2_END; \
46 ok_eq_hex(Status, ExpectedStatus); \
47 ok_eq_ulong(Response, (ULONG)ExpectedResponse); \
48} while (0)
49
50#define CheckInformationalHardError(ErrStatus, String, Thread, \
51 ExpectedStatus, ExpectedRet) do \
52{ \
53 Status = STATUS_SUCCESS; \
54 Ret = !ExpectedRet; \
55 _SEH2_TRY { \
56 Ret = IoRaiseInformationalHardError(ErrStatus, \
57 String, \
58 Thread); \
59 } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { \
60 Status = _SEH2_GetExceptionCode(); \
61 } _SEH2_END; \
62 ok_eq_hex(Status, ExpectedStatus); \
63 ok_eq_bool(Ret, ExpectedRet); \
64} while (0)
65
66static
67VOID
69 BOOLEAN InteractivePart1,
70 BOOLEAN InteractivePart2,
71 BOOLEAN InteractivePart3,
72 BOOLEAN InteractivePart4)
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
97 // The return value is a random large value on Windows Server 2003
99 {
100#if _WIN64
102 {
104 }
105 else
106 {
108 }
109#else
110 // Return value is also a random large value on 32-bit 8+
112 {
114 }
115#endif
116 }
117
118 if (InteractivePart1)
119 {
120 // TODO: these 2 are interactive on ROS
121 CheckHardError(0x40000005, 0, OptionOkNoWait, STATUS_SUCCESS, ResponseOk, 0, 0); // outputs a balloon notification
122 CheckHardError(0x4000000f, 0, OptionOkNoWait, STATUS_SUCCESS, ResponseOk, 0, 0); // outputs a balloon notification
123 CheckHardError(0x40000006, 0, OptionAbortRetryIgnore, STATUS_SUCCESS, ResponseAbort, 0, 0); // outputs a box :|
124 CheckHardError(0x40000006, 0, OptionAbortRetryIgnore, STATUS_SUCCESS, ResponseRetry, 0, 0); // outputs a box :|
125 CheckHardError(0x40000006, 0, OptionAbortRetryIgnore, STATUS_SUCCESS, ResponseIgnore, 0, 0); // outputs a box :|
126 CheckHardError(0x40000008, 0, OptionCancelTryContinue, STATUS_SUCCESS, ResponseCancel, 0, 0); // outputs a box :|
127 CheckHardError(0x40000008, 0, OptionCancelTryContinue, STATUS_SUCCESS, ResponseTryAgain, 0, 0); // outputs a box :|
128 CheckHardError(0x40000008, 0, OptionCancelTryContinue, STATUS_SUCCESS, ResponseContinue, 0, 0); // outputs a box :|
129 CheckHardError(0x40000010, 0, OptionOkCancel, STATUS_SUCCESS, ResponseOk, 0, 0); // outputs a box :|
130 CheckHardError(0x40000010, 0, OptionOkCancel, STATUS_SUCCESS, ResponseCancel, 0, 0); // outputs a box :|
131 CheckHardError(0x40000011, 0, OptionRetryCancel, STATUS_SUCCESS, ResponseRetry, 0, 0); // outputs a box :|
132 CheckHardError(0x40000011, 0, OptionRetryCancel, STATUS_SUCCESS, ResponseCancel, 0, 0); // outputs a box :|
133 CheckHardError(0x40000012, 0, OptionYesNo, STATUS_SUCCESS, ResponseYes, 0, 0); // outputs a box :|
134 CheckHardError(0x40000012, 0, OptionYesNo, STATUS_SUCCESS, ResponseNo, 0, 0); // outputs a box :|
135 CheckHardError(0x40000013, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseYes, 0, 0); // outputs a box :|
136 CheckHardError(0x40000013, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 0, 0); // outputs a box :|
137 CheckHardError(0x40000013, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 0, 0); // outputs a box :|
138 }
139 CheckHardError(0x40000009, 0, 9, STATUS_SUCCESS, ResponseReturnToCaller, 0, 0);
140 CheckHardError(0x4000000a, 0, 10, STATUS_SUCCESS, ResponseReturnToCaller, 0, 0);
141 CheckHardError(0x4000000b, 0, 11, STATUS_SUCCESS, ResponseReturnToCaller, 0, 0);
142 CheckHardError(0x4000000c, 0, 12, STATUS_SUCCESS, ResponseReturnToCaller, 0, 0);
143 CheckHardError(0x4000000d, 0, MAXULONG / 2 + 1, STATUS_SUCCESS, ResponseReturnToCaller, 0, 0);
145
146 if (InteractivePart2)
147 {
148 /* try a message with one parameter */
153 /* give too many parameters */
157 CheckHardError(STATUS_DLL_NOT_FOUND, 3, OptionYesNoCancel, STATUS_SUCCESS, ResponseYes, 4, &String1, &String2, 0, 0); // outputs a box :|
158 /* try with stuff that's not a UNICODE_STRING */
159 CheckHardError(STATUS_DLL_NOT_FOUND, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 1, &String1Ansi); // outputs a box :|
160 CheckHardError(STATUS_DLL_NOT_FOUND, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 1, L"Parameter1"); // outputs a box :|
161 CheckHardError(STATUS_DLL_NOT_FOUND, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 1, "Parameter1"); // outputs a box :|
164 CheckHardError(STATUS_DLL_NOT_FOUND, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 1, &String1Ansi); // outputs a box :|
165 CheckHardError(STATUS_DLL_NOT_FOUND, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 1, L"Parameter1"); // outputs a box :|
166 CheckHardError(STATUS_DLL_NOT_FOUND, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 1, "Parameter1"); // outputs a box :|
169 }
170 if (InteractivePart3)
171 {
172 /* try a message with one parameter */
177 /* give too many parameters */
183 CheckHardError(STATUS_SERVICE_NOTIFICATION, 3, OptionOkNoWait, STATUS_SUCCESS, ResponseOk, 4, &String1, &String2, 0, 0); // outputs a balloon notification
184 /* try with stuff that's not a UNICODE_STRING */
195 }
196 if (InteractivePart4)
197 {
198 /* try a message with one parameter */
203 /* give too many parameters */
207 CheckHardError(STATUS_FATAL_APP_EXIT, 3, OptionYesNoCancel, STATUS_SUCCESS, ResponseYes, 4, &String1, &String2, 0, 0); // outputs a box :|
208 /* try with stuff that's not a UNICODE_STRING */
209 CheckHardError(STATUS_FATAL_APP_EXIT, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 1, &String1Ansi); // outputs a box :|
210 CheckHardError(STATUS_FATAL_APP_EXIT, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 1, L"Parameter1"); // outputs a box :|
211 CheckHardError(STATUS_FATAL_APP_EXIT, 1, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 1, "Parameter1"); // outputs a box :|
214 CheckHardError(STATUS_FATAL_APP_EXIT, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 1, &String1Ansi); // outputs a box :|
215 CheckHardError(STATUS_FATAL_APP_EXIT, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 1, L"Parameter1"); // outputs a box :|
216 CheckHardError(STATUS_FATAL_APP_EXIT, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 1, "Parameter1"); // outputs a box :|
219
220 // TODO: these 3 are interactive on ROS
221 CheckInformationalHardError(STATUS_WAIT_0, NULL, NULL, STATUS_SUCCESS, TRUE); // outputs a balloon notification
222 CheckInformationalHardError(STATUS_DLL_NOT_FOUND, &String1, NULL, STATUS_SUCCESS, TRUE); // outputs a balloon notification
223 CheckInformationalHardError(STATUS_DLL_NOT_FOUND, NULL, NULL, STATUS_SUCCESS, TRUE); // outputs a balloon notification
224 }
226
227 ok_bool_true(IoSetThreadHardErrorMode(TRUE), "IoSetThreadHardErrorMode returned");
228 ok_bool_true(IoSetThreadHardErrorMode(FALSE), "IoSetThreadHardErrorMode returned");
229 ok_bool_false(IoSetThreadHardErrorMode(FALSE), "IoSetThreadHardErrorMode returned");
236 ok_bool_false(IoSetThreadHardErrorMode(TRUE), "IoSetThreadHardErrorMode returned");
237}
238
239START_TEST(ExHardError)
240{
242}
243
244/* Here's how to do the interactive test:
245 * - First there will be a few messages random messages. If there's
246 * multiple options available, the same box will appear multiple times --
247 * click the buttons in order from left to right
248 * - After that, you must verify the error parameters. You should always
249 * see Parameter1 or Parameter2 for strings, and 0x12345678 for numbers.
250 * if there's a message saying an exception occured during processing,
251 * click cancel. If there's a bad parameter (Parameter1+, Parameter1+Garbage
252 * or an empty string for example), click no. Otherwise click yes. */
253START_TEST(ExHardErrorInteractive)
254{
256}
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define CheckHardError(ErrStatus, UnicodeStringMask, ResponseOption, ExpectedStatus, ExpectedResponse, NumberOfParameters,...)
Definition: ExHardError.c:30
#define CheckInformationalHardError(ErrStatus, String, Thread, ExpectedStatus, ExpectedRet)
Definition: ExHardError.c:50
#define NoResponse
Definition: ExHardError.c:28
static VOID TestHardError(BOOLEAN InteractivePart1, BOOLEAN InteractivePart2, BOOLEAN InteractivePart3, BOOLEAN InteractivePart4)
Definition: ExHardError.c:68
static VOID SetParameters(OUT PULONG_PTR Parameters, IN INT Count,...)
Definition: ExHardError.c:15
unsigned char BOOLEAN
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define va_arg(ap, T)
Definition: acmsvcex.h:89
#define GetNTVersion()
Definition: apitest.h:17
#define ok_bool_false(value, desc)
Definition: apitest.h:136
#define ok_bool_true(value, desc)
Definition: apitest.h:135
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define L(x)
Definition: resources.c:13
#define STATUS_ACCESS_VIOLATION
Status
Definition: gdiplustypes.h:25
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
@ OptionYesNoCancel
Definition: extypes.h:191
@ OptionYesNo
Definition: extypes.h:190
@ OptionAbortRetryIgnore
Definition: extypes.h:186
@ OptionCancelTryContinue
Definition: extypes.h:194
@ OptionShutdownSystem
Definition: extypes.h:192
@ OptionOkCancel
Definition: extypes.h:188
@ OptionRetryCancel
Definition: extypes.h:189
@ OptionOk
Definition: extypes.h:187
@ OptionOkNoWait
Definition: extypes.h:193
@ ResponseNo
Definition: extypes.h:204
@ ResponseNotHandled
Definition: extypes.h:200
@ ResponseTryAgain
Definition: extypes.h:208
@ ResponseOk
Definition: extypes.h:205
@ ResponseRetry
Definition: extypes.h:206
@ ResponseReturnToCaller
Definition: extypes.h:199
@ ResponseIgnore
Definition: extypes.h:203
@ ResponseCancel
Definition: extypes.h:202
@ ResponseYes
Definition: extypes.h:207
@ ResponseAbort
Definition: extypes.h:201
@ ResponseContinue
Definition: extypes.h:209
_In_ const STRING * String2
Definition: rtlfuncs.h:2404
int Count
Definition: noreturn.cpp:7
#define UNICODE_NULL
#define ANSI_NULL
BOOLEAN NTAPI IoSetThreadHardErrorMode(IN BOOLEAN HardErrorEnabled)
Definition: error.c:726
#define STATUS_WAIT_0
Definition: ntstatus.h:330
#define STATUS_DLL_NOT_FOUND
Definition: ntstatus.h:639
#define STATUS_FATAL_APP_EXIT
Definition: ntstatus.h:210
#define STATUS_SERVICE_NOTIFICATION
Definition: ntstatus.h:213
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
#define _WIN32_WINNT_WIN8
Definition: sdkddkver.h:29
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ncftp.h:89
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define MAXULONG
Definition: typedefs.h:251
uint32_t * PULONG_PTR
Definition: typedefs.h:65
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175