diff --git a/modules/rostests/apitests/ntdll/NtQueryInformationProcess.c b/modules/rostests/apitests/ntdll/NtQueryInformationProcess.c index e392ead8760..94a07f17589 100644 --- a/modules/rostests/apitests/ntdll/NtQueryInformationProcess.c +++ b/modules/rostests/apitests/ntdll/NtQueryInformationProcess.c @@ -253,6 +253,76 @@ Test_ProcessPriorityClassAlignment(void) free(ProcPriority); } +static +void +Test_ProcessWx86Information(void) +{ + NTSTATUS Status; + ULONG VdmPower = 1, ReturnLength; + + /* Everything is NULL */ + Status = NtQueryInformationProcess(NULL, + ProcessWx86Information, + NULL, + 0, + NULL); + ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH); + + /* Given an invalid process handle */ + Status = NtQueryInformationProcess(NULL, + ProcessWx86Information, + &VdmPower, + sizeof(VdmPower), + NULL); + ok_hex(Status, STATUS_INVALID_HANDLE); + + /* Don't query anything */ + Status = NtQueryInformationProcess(NtCurrentProcess(), + ProcessWx86Information, + NULL, + sizeof(VdmPower), + NULL); + ok_hex(Status, STATUS_ACCESS_VIOLATION); + + /* The buffer is misaligned and information length is wrong */ + Status = NtQueryInformationProcess(NtCurrentProcess(), + ProcessWx86Information, + (PVOID)1, + 0, + NULL); + ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH); + + /* The buffer is misaligned */ + Status = NtQueryInformationProcess(NtCurrentProcess(), + ProcessWx86Information, + (PVOID)1, + sizeof(VdmPower), + NULL); + ok_hex(Status, STATUS_DATATYPE_MISALIGNMENT); + + /* The buffer is misaligned -- try with an alignment size of 2 */ + Status = NtQueryInformationProcess(NtCurrentProcess(), + ProcessWx86Information, + (PVOID)2, + sizeof(VdmPower), + NULL); + ok_hex(Status, STATUS_DATATYPE_MISALIGNMENT); + + /* Query the VDM power */ + Status = NtQueryInformationProcess(NtCurrentProcess(), + ProcessWx86Information, + &VdmPower, + sizeof(VdmPower), + &ReturnLength); + ok_hex(Status, STATUS_SUCCESS); + ok(ReturnLength != 0, "ReturnLength shouldn't be 0!\n"); + ok(VdmPower == 0 || VdmPower == 1, "The VDM power value must be within the boundary between 0 and 1, not anything else! Got %lu\n", VdmPower); + + /* Trace the VDM power value and returned length */ + trace("ReturnLength = %lu\n", ReturnLength); + trace("VdmPower = %lu\n", VdmPower); +} + START_TEST(NtQueryInformationProcess) { NTSTATUS Status; @@ -262,4 +332,5 @@ START_TEST(NtQueryInformationProcess) Test_ProcessTimes(); Test_ProcessPriorityClassAlignment(); + Test_ProcessWx86Information(); } diff --git a/modules/rostests/apitests/ntdll/NtSetInformationProcess.c b/modules/rostests/apitests/ntdll/NtSetInformationProcess.c index 0b805b3ca66..473780fe09f 100644 --- a/modules/rostests/apitests/ntdll/NtSetInformationProcess.c +++ b/modules/rostests/apitests/ntdll/NtSetInformationProcess.c @@ -215,9 +215,60 @@ Test_ProcForegroundBackgroundClass(void) HeapFree(GetProcessHeap(), 0, ProcForeground); } +static +void +Test_ProcessWx86InformationClass(void) +{ + NTSTATUS Status; + ULONG VdmPower = 1; + + /* Everything is NULL */ + Status = NtSetInformationProcess(NULL, + ProcessWx86Information, + NULL, + 0); + ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH); + + /* Don't set anything to the process */ + Status = NtSetInformationProcess(NtCurrentProcess(), + ProcessWx86Information, + NULL, + sizeof(VdmPower)); + ok_hex(Status, STATUS_ACCESS_VIOLATION); + + /* The buffer is misaligned and information length is wrong */ + Status = NtSetInformationProcess(NtCurrentProcess(), + ProcessWx86Information, + (PVOID)1, + 0); + ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH); + + /* The buffer is misaligned */ + Status = NtSetInformationProcess(NtCurrentProcess(), + ProcessWx86Information, + (PVOID)1, + sizeof(VdmPower)); + ok_hex(Status, STATUS_DATATYPE_MISALIGNMENT); + + /* The buffer is misaligned -- try with an alignment size of 2 */ + Status = NtSetInformationProcess(NtCurrentProcess(), + ProcessWx86Information, + (PVOID)2, + sizeof(VdmPower)); + ok_hex(Status, STATUS_DATATYPE_MISALIGNMENT); + + /* We do not have privileges to set the VDM power */ + Status = NtSetInformationProcess(NtCurrentProcess(), + ProcessWx86Information, + &VdmPower, + sizeof(VdmPower)); + ok_hex(Status, STATUS_PRIVILEGE_NOT_HELD); +} + START_TEST(NtSetInformationProcess) { Test_ProcForegroundBackgroundClass(); Test_ProcBasePriorityClass(); Test_ProcRaisePriorityClass(); + Test_ProcessWx86InformationClass(); }