Author: tfaber
Date: Sat Sep 10 10:38:43 2011
New Revision: 53667
URL:
http://svn.reactos.org/svn/reactos?rev=53667&view=rev
Log:
[KMTESTS/OB]
- ObReference: add better tests for closing invalid handles
Modified:
branches/GSoC_2011/KMTestSuite/kmtests/ntos_ob/ObReference.c
Modified: branches/GSoC_2011/KMTestSuite/kmtests/ntos_ob/ObReference.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/n…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/ntos_ob/ObReference.c [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/ntos_ob/ObReference.c [iso-8859-1] Sat Sep 10
10:38:43 2011
@@ -6,6 +6,8 @@
*/
#include <kmt_test.h>
+#define NDEBUG
+#include <debug.h>
#define CheckObject(Handle, Pointers, Handles) do \
{ \
@@ -189,6 +191,7 @@
for (i = 0; i < sizeof Tests / sizeof Tests[0]; ++i)
{
+ DPRINT("Run %d\n", i);
if (Tests[i].Name)
{
RtlInitUnicodeString(&Name, Tests[i].Name);
@@ -239,10 +242,78 @@
ExceptionStatus = STATUS_SUCCESS;
_SEH2_TRY {
+ /* TODO: this belongs in an ObHandle test if we ever have one */
+ /* NtClose must accept everything */
+ DPRINT("Closing null handle (NtClose)\n");
+ Status = NtClose(NULL);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ DPRINT("Closing null kernel handle (NtClose)\n");
+ Status = NtClose((HANDLE)0x80000000);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ DPRINT("Closing -1 handle (NtClose)\n");
+ Status = NtClose((HANDLE)0x7FFFFFFF);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ DPRINT("Closing -1 kernel handle (NtClose)\n");
+ Status = NtClose((HANDLE)0xFFFFFFFF);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ DPRINT("Closing 123 handle (NtClose)\n");
+ Status = NtClose((HANDLE)123);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ DPRINT("Closing 123 kernel handle (NtClose)\n");
+ Status = NtClose((HANDLE)(123 | 0x80000000));
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+
+ /* ObCloseHandle with UserMode accepts everything */
+ DPRINT("Closing null handle (ObCloseHandle, UserMode)\n");
+ Status = ObCloseHandle(NULL, UserMode);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ DPRINT("Closing null kernel handle (ObCloseHandle, UserMode)\n");
+ Status = ObCloseHandle((HANDLE)0x80000000, UserMode);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ DPRINT("Closing -1 handle (ObCloseHandle, UserMode)\n");
+ Status = ObCloseHandle((HANDLE)0x7FFFFFFF, UserMode);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ DPRINT("Closing -1 kernel handle (ObCloseHandle, UserMode)\n");
+ Status = ObCloseHandle((HANDLE)0xFFFFFFFF, UserMode);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ DPRINT("Closing 123 handle (ObCloseHandle, UserMode)\n");
+ Status = ObCloseHandle((HANDLE)123, UserMode);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ DPRINT("Closing 123 kernel handle (ObCloseHandle, UserMode)\n");
+ Status = ObCloseHandle((HANDLE)(123 | 0x80000000), UserMode);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+
+ /* ZwClose only accepts 0 and -1 */
+ DPRINT("Closing null handle (ZwClose)\n");
Status = ZwClose(NULL);
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
- Status = ZwClose((HANDLE)-1);
- ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ DPRINT("Closing null kernel handle (ZwClose)\n");
+ Status = ZwClose((HANDLE)0x80000000);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ /* INVALID_KERNEL_HANDLE, 0x7FFFFFFF
+ Status = ZwClose((HANDLE)0x7FFFFFFF);*/
+ DPRINT("Closing -1 kernel handle (ZwClose)\n");
+ Status = ZwClose((HANDLE)0xFFFFFFFF);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ /* INVALID_KERNEL_HANDLE, 0x7B, 1, 0, 0
+ Status = ZwClose((HANDLE)123);
+ Status = ZwClose((HANDLE)(123 | 0x80000000));*/
+
+ /* ObCloseHandle with KernelMode accepts only 0 and -1 */
+ DPRINT("Closing null handle (ObCloseHandle, KernelMode)\n");
+ Status = ObCloseHandle(NULL, KernelMode);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ DPRINT("Closing null kernel handle (ObCloseHandle, KernelMode)\n");
+ Status = ObCloseHandle((HANDLE)0x80000000, KernelMode);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ /* INVALID_KERNEL_HANDLE, 0x7FFFFFFF, 1, 0, 0
+ Status = ObCloseHandle((HANDLE)0x7FFFFFFF, KernelMode);*/
+ DPRINT("Closing -1 kernel handle (ObCloseHandle, KernelMode)\n");
+ Status = ObCloseHandle((HANDLE)0xFFFFFFFF, KernelMode);
+ ok_eq_hex(Status, STATUS_INVALID_HANDLE);
+ /* INVALID_KERNEL_HANDLE, 0x7B, 1, 0, 0
+ Status = ObCloseHandle((HANDLE)123, KernelMode);
+ Status = ObCloseHandle((HANDLE)(123 | 0x80000000), KernelMode);*/
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
ExceptionStatus = _SEH2_GetExceptionCode();
} _SEH2_END;