Skip to content

Commit 03f4387

Browse files
authored
[KMTEST] ExHardError and RtlCaptureContextKM fixes (reactos#8342)
- Adjust expected values according to NT version and architecture
1 parent 7e6e327 commit 03f4387

File tree

2 files changed

+45
-12
lines changed

2 files changed

+45
-12
lines changed

modules/rostests/apitests/rtl/amd64/RtlCaptureContext.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,20 @@ START_TEST(RtlCaptureContext)
154154
ok_eq_hex64(CapturedContext.Legacy[7].Low, OriginalContext.Legacy[7].Low);
155155
ok_eq_hex64(CapturedContext.Legacy[7].High, OriginalContext.Legacy[7].High & 0xFF);
156156
#else
157-
ok_eq_hex(CapturedContext.FltSave.ControlWord, 0xcccc);
158-
ok_eq_hex(CapturedContext.FltSave.StatusWord, 0xcccc);
159-
ok_eq_hex(CapturedContext.FltSave.TagWord, 0xcc);
160-
ok_eq_hex(CapturedContext.FltSave.Reserved1, 0xcc);
157+
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
158+
{
159+
ok_eq_hex(CapturedContext.FltSave.ControlWord, 0x27f);
160+
ok_eq_hex(CapturedContext.FltSave.StatusWord, 0x00);
161+
ok_eq_hex(CapturedContext.FltSave.TagWord, 0x00);
162+
ok_eq_hex(CapturedContext.FltSave.Reserved1, 0x00);
163+
}
164+
else
165+
{
166+
ok_eq_hex(CapturedContext.FltSave.ControlWord, 0xcccc);
167+
ok_eq_hex(CapturedContext.FltSave.StatusWord, 0xcccc);
168+
ok_eq_hex(CapturedContext.FltSave.TagWord, 0xcc);
169+
ok_eq_hex(CapturedContext.FltSave.Reserved1, 0xcc);
170+
}
161171
ok_eq_hex(CapturedContext.FltSave.MxCsr_Mask, 0xcccccccc);
162172
ok_eq_hex(CapturedContext.FltSave.ErrorOpcode, 0xcccc);
163173
ok_eq_hex(CapturedContext.FltSave.ErrorOffset, 0xcccccccc);
@@ -168,7 +178,10 @@ START_TEST(RtlCaptureContext)
168178
ok_eq_hex(CapturedContext.FltSave.Reserved3, 0xcccc);
169179

170180
/* We get the value from OriginalContext.MxCsr, since we set that later in the wrapper */
171-
ok_eq_hex(CapturedContext.FltSave.MxCsr, 0xcccccccc);
181+
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
182+
ok_eq_hex(CapturedContext.FltSave.MxCsr, 0xffff);
183+
else
184+
ok_eq_hex(CapturedContext.FltSave.MxCsr, 0xcccccccc);
172185

173186
/* Legacy floating point registers are truncated to 10 bytes */
174187
ok_eq_hex64(CapturedContext.Legacy[0].Low, 0xcccccccccccccccc);

modules/rostests/kmtests/ntos_ex/ExHardError.c

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,27 @@ TestHardError(
9494
CheckHardError(0x40000003, 0, OptionOk, STATUS_SUCCESS, ResponseNotHandled, 6, 1, 2, 3, 4, 5, 6); // TODO: interactive on ROS
9595
}
9696

97-
CheckHardError(0x40000004, 0, OptionShutdownSystem, STATUS_PRIVILEGE_NOT_HELD, ResponseNotHandled, 0, 0);
97+
// The return value is a random large value on Windows Server 2003
98+
if (GetNTVersion() > _WIN32_WINNT_WS03)
99+
{
100+
#if _WIN64
101+
if (GetNTVersion() == _WIN32_WINNT_VISTA)
102+
{
103+
CheckHardError(0x40000004, 0, OptionShutdownSystem, STATUS_PRIVILEGE_NOT_HELD, 64, 0, 0);
104+
}
105+
else
106+
{
107+
CheckHardError(0x40000004, 0, OptionShutdownSystem, STATUS_PRIVILEGE_NOT_HELD, ResponseReturnToCaller, 0, 0);
108+
}
109+
#else
110+
// Return value is also a random large value on 32-bit 8+
111+
if (GetNTVersion() < _WIN32_WINNT_WIN8)
112+
{
113+
CheckHardError(0x40000004, 0, OptionShutdownSystem, STATUS_PRIVILEGE_NOT_HELD, ResponseReturnToCaller, 0, 0);
114+
}
115+
#endif
116+
}
117+
98118
if (InteractivePart1)
99119
{
100120
// TODO: these 2 are interactive on ROS
@@ -116,12 +136,12 @@ TestHardError(
116136
CheckHardError(0x40000013, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseNo, 0, 0); // outputs a box :|
117137
CheckHardError(0x40000013, 0, OptionYesNoCancel, STATUS_SUCCESS, ResponseCancel, 0, 0); // outputs a box :|
118138
}
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);
124-
CheckHardError(0x4000000d, 0, MAXULONG, STATUS_SUCCESS, ResponseNotHandled, 0, 0);
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);
144+
CheckHardError(0x4000000d, 0, MAXULONG, STATUS_SUCCESS, ResponseReturnToCaller, 0, 0);
125145

126146
if (InteractivePart2)
127147
{

0 commit comments

Comments
 (0)