Reactos

[NTDLL_APITEST] Add alignment probing tests for Query/Set information process related routines

+69
+35
modules/rostests/apitests/ntdll/NtQueryInformationProcess.c
··· 3 3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory 4 4 * PURPOSE: Tests for the NtQueryInformationProcess API 5 5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org> 6 + * George Bișoc <george.bisoc@reactos.org> 6 7 */ 7 8 8 9 #include "precomp.h" 10 + #include <internal/ps_i.h> 9 11 10 12 static LARGE_INTEGER TestStartTime; 11 13 ··· 322 324 trace("VdmPower = %lu\n", VdmPower); 323 325 } 324 326 327 + static 328 + void 329 + Test_ProcQueryAlignmentProbe(void) 330 + { 331 + ULONG InfoClass; 332 + 333 + /* Iterate over the process info classes and begin the tests */ 334 + for (InfoClass = 0; InfoClass < _countof(PsProcessInfoClass); InfoClass++) 335 + { 336 + /* The buffer is misaligned */ 337 + QuerySetProcessValidator(QUERY, 338 + InfoClass, 339 + (PVOID)(ULONG_PTR)1, 340 + PsProcessInfoClass[InfoClass].RequiredSizeQUERY, 341 + STATUS_DATATYPE_MISALIGNMENT); 342 + 343 + /* We query an invalid buffer address */ 344 + QuerySetProcessValidator(QUERY, 345 + InfoClass, 346 + (PVOID)(ULONG_PTR)PsProcessInfoClass[InfoClass].AlignmentQUERY, 347 + PsProcessInfoClass[InfoClass].RequiredSizeQUERY, 348 + STATUS_ACCESS_VIOLATION); 349 + 350 + /* The information length is wrong */ 351 + QuerySetProcessValidator(QUERY, 352 + InfoClass, 353 + (PVOID)(ULONG_PTR)PsProcessInfoClass[InfoClass].AlignmentQUERY, 354 + PsProcessInfoClass[InfoClass].RequiredSizeQUERY - 1, 355 + STATUS_INFO_LENGTH_MISMATCH); 356 + } 357 + } 358 + 325 359 START_TEST(NtQueryInformationProcess) 326 360 { 327 361 NTSTATUS Status; ··· 335 369 Test_ProcessTimes(); 336 370 Test_ProcessPriorityClassAlignment(); 337 371 Test_ProcessWx86Information(); 372 + Test_ProcQueryAlignmentProbe(); 338 373 }
+34
modules/rostests/apitests/ntdll/NtSetInformationProcess.c
··· 6 6 */ 7 7 8 8 #include "precomp.h" 9 + #include <internal/ps_i.h> 9 10 10 11 static 11 12 void ··· 265 266 ok_hex(Status, STATUS_PRIVILEGE_NOT_HELD); 266 267 } 267 268 269 + static 270 + void 271 + Test_ProcSetAlignmentProbe(void) 272 + { 273 + ULONG InfoClass; 274 + 275 + /* Iterate over the process info classes and begin the tests */ 276 + for (InfoClass = 0; InfoClass < _countof(PsProcessInfoClass); InfoClass++) 277 + { 278 + /* The buffer is misaligned */ 279 + QuerySetProcessValidator(SET, 280 + InfoClass, 281 + (PVOID)(ULONG_PTR)1, 282 + PsProcessInfoClass[InfoClass].RequiredSizeSET, 283 + STATUS_DATATYPE_MISALIGNMENT); 284 + 285 + /* We set an invalid buffer address */ 286 + QuerySetProcessValidator(SET, 287 + InfoClass, 288 + (PVOID)(ULONG_PTR)PsProcessInfoClass[InfoClass].AlignmentSET, 289 + PsProcessInfoClass[InfoClass].RequiredSizeSET, 290 + STATUS_ACCESS_VIOLATION); 291 + 292 + /* The information length is wrong */ 293 + QuerySetProcessValidator(SET, 294 + InfoClass, 295 + (PVOID)(ULONG_PTR)PsProcessInfoClass[InfoClass].AlignmentSET, 296 + PsProcessInfoClass[InfoClass].RequiredSizeSET - 1, 297 + STATUS_INFO_LENGTH_MISMATCH); 298 + } 299 + } 300 + 268 301 START_TEST(NtSetInformationProcess) 269 302 { 270 303 Test_ProcForegroundBackgroundClass(); 271 304 Test_ProcBasePriorityClass(); 272 305 Test_ProcRaisePriorityClass(); 273 306 Test_ProcessWx86InformationClass(); 307 + Test_ProcSetAlignmentProbe(); 274 308 }