Re: [ros-dev] [ros-diffs] [tfaber] 69296: [KMTESTS] - Add missing OBJ_KERNEL_HANDLE - OBJ_KERNEL_HANDLE in user mode has no effect... no reason to make a define around it CORE-10207
Oh? I'll need to add a test for that then, thanks. What does Windows's RTL do, then? I know in XP/2003 it might just hand out user handles, but e.g. on Win7 that would cause verifier to bugcheck. On 2015-09-20 20:51, Alex Ionescu wrote: Actually, in XP, OBJ_KERNEL_HANDLE Did work, and gave you a kernel handle that you could never use. In Windows Vista, it returns a failure code. Not sure about 2003. Best regards, Alex Ionescu On Sat, Sep 19, 2015 at 2:46 PM,> wrote: Author: tfaber Date: Sat Sep 19 21:46:40 2015 New Revision: 69296 URL: http://svn.reactos.org/svn/reactos?rev=69296=rev Log: [KMTESTS] - Add missing OBJ_KERNEL_HANDLE - OBJ_KERNEL_HANDLE in user mode has no effect... no reason to make a define around it CORE-10207 Modified: trunk/rostests/kmtests/ntos_io/IoCreateFile.c trunk/rostests/kmtests/ntos_ke/KeEvent.c trunk/rostests/kmtests/rtl/RtlRegistry.c Modified: trunk/rostests/kmtests/ntos_io/IoCreateFile.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_io/IoCreateFile.c?rev=69296=69295=69296=diff == --- trunk/rostests/kmtests/ntos_io/IoCreateFile.c [iso-8859-1] (original) +++ trunk/rostests/kmtests/ntos_io/IoCreateFile.c [iso-8859-1] Sat Sep 19 21:46:40 2015 @@ -454,7 +454,7 @@ ok_eq_hex(IoStatusBlock.Status, 0x); if (Status == STATUS_SUCCESS) { -ObCloseHandle(ParentHandle, KernelMode); +ObCloseHandle(ParentHandle, UserMode); } /* Attempt relative target open */ @@ -462,7 +462,7 @@ IoStatusBlock.Information = 0x; InitializeObjectAttributes(, , - OBJ_CASE_INSENSITIVE, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); Status = ZwOpenFile(, GENERIC_WRITE | GENERIC_READ | SYNCHRONIZE, @@ -478,7 +478,7 @@ IoStatusBlock.Information = 0x; InitializeObjectAttributes(, , - OBJ_CASE_INSENSITIVE, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, SystemRootHandle, NULL); Status = IoCreateFile(, Modified: trunk/rostests/kmtests/ntos_ke/KeEvent.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_ke/KeEvent.c?rev=69296=69295=69296=diff == --- trunk/rostests/kmtests/ntos_ke/KeEvent.c[iso-8859-1] (original) +++ trunk/rostests/kmtests/ntos_ke/KeEvent.c[iso-8859-1] Sat Sep 19 21:46:40 2015 @@ -155,6 +155,7 @@ PVOID ThreadObjects[RTL_NUMBER_OF(Threads)]; LONG State; PKTHREAD Thread = KeGetCurrentThread(); +OBJECT_ATTRIBUTES ObjectAttributes; LongTimeout.QuadPart = -100 * MILLISECOND; ShortTimeout.QuadPart = -1 * MILLISECOND; @@ -165,7 +166,12 @@ { Threads[i].Event = Event; Threads[i].Signal = FALSE; -Status = PsCreateSystemThread([i].Handle, GENERIC_ALL, NULL, NULL, NULL, WaitForEventThread, [i]); +InitializeObjectAttributes(, + NULL, + OBJ_KERNEL_HANDLE, + NULL, + NULL); +Status = PsCreateSystemThread([i].Handle, GENERIC_ALL, , NULL, NULL, WaitForEventThread, [i]); ok_eq_hex(Status, STATUS_SUCCESS); Status = ObReferenceObjectByHandle(Threads[i].Handle, SYNCHRONIZE, *PsThreadType, KernelMode, (PVOID *)[i].Thread, NULL); ok_eq_hex(Status, STATUS_SUCCESS); Modified: trunk/rostests/kmtests/rtl/RtlRegistry.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/rtl/RtlRegistry.c?rev=69296=69295=69296=diff == --- trunk/rostests/kmtests/rtl/RtlRegistry.c[iso-8859-1] (original) +++ trunk/rostests/kmtests/rtl/RtlRegistry.c[iso-8859-1] Sat Sep 19 21:46:40 2015 @@ -7,12 +7,6 @@ #define KMT_EMULATE_KERNEL #include - -#ifdef KMT_KERNEL_MODE -#define KMT_KERNEL_HANDLE OBJ_KERNEL_HANDLE -#else -#define KMT_KERNEL_HANDLE 0 -#endif #ifndef RTL_NUMBER_OF #define RTL_NUMBER_OF(x) (sizeof(x) / sizeof(x[0])) @@ -212,7 +206,7 @@
Re: [ros-dev] [ros-diffs] [tfaber] 69296: [KMTESTS] - Add missing OBJ_KERNEL_HANDLE - OBJ_KERNEL_HANDLE in user mode has no effect... no reason to make a define around it CORE-10207
Actually, in XP, OBJ_KERNEL_HANDLE Did work, and gave you a kernel handle that you could never use. In Windows Vista, it returns a failure code. Not sure about 2003. Best regards, Alex Ionescu On Sat, Sep 19, 2015 at 2:46 PM,wrote: > Author: tfaber > Date: Sat Sep 19 21:46:40 2015 > New Revision: 69296 > > URL: http://svn.reactos.org/svn/reactos?rev=69296=rev > Log: > [KMTESTS] > - Add missing OBJ_KERNEL_HANDLE > - OBJ_KERNEL_HANDLE in user mode has no effect... no reason to make a > define around it > CORE-10207 > > Modified: > trunk/rostests/kmtests/ntos_io/IoCreateFile.c > trunk/rostests/kmtests/ntos_ke/KeEvent.c > trunk/rostests/kmtests/rtl/RtlRegistry.c > > Modified: trunk/rostests/kmtests/ntos_io/IoCreateFile.c > URL: > http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_io/IoCreateFile.c?rev=69296=69295=69296=diff > > == > --- trunk/rostests/kmtests/ntos_io/IoCreateFile.c [iso-8859-1] > (original) > +++ trunk/rostests/kmtests/ntos_io/IoCreateFile.c [iso-8859-1] Sat > Sep 19 21:46:40 2015 > @@ -454,7 +454,7 @@ > ok_eq_hex(IoStatusBlock.Status, 0x); > if (Status == STATUS_SUCCESS) > { > -ObCloseHandle(ParentHandle, KernelMode); > +ObCloseHandle(ParentHandle, UserMode); > } > > /* Attempt relative target open */ > @@ -462,7 +462,7 @@ > IoStatusBlock.Information = 0x; > InitializeObjectAttributes(, > , > - OBJ_CASE_INSENSITIVE, > + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, > NULL, NULL); > Status = ZwOpenFile(, > GENERIC_WRITE | GENERIC_READ | SYNCHRONIZE, > @@ -478,7 +478,7 @@ > IoStatusBlock.Information = 0x; > InitializeObjectAttributes(, > , > - OBJ_CASE_INSENSITIVE, > + OBJ_CASE_INSENSITIVE | > OBJ_KERNEL_HANDLE, > SystemRootHandle, > NULL); > Status = IoCreateFile(, > > Modified: trunk/rostests/kmtests/ntos_ke/KeEvent.c > URL: > http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_ke/KeEvent.c?rev=69296=69295=69296=diff > > == > --- trunk/rostests/kmtests/ntos_ke/KeEvent.c[iso-8859-1] (original) > +++ trunk/rostests/kmtests/ntos_ke/KeEvent.c[iso-8859-1] Sat Sep 19 > 21:46:40 2015 > @@ -155,6 +155,7 @@ > PVOID ThreadObjects[RTL_NUMBER_OF(Threads)]; > LONG State; > PKTHREAD Thread = KeGetCurrentThread(); > +OBJECT_ATTRIBUTES ObjectAttributes; > > LongTimeout.QuadPart = -100 * MILLISECOND; > ShortTimeout.QuadPart = -1 * MILLISECOND; > @@ -165,7 +166,12 @@ > { > Threads[i].Event = Event; > Threads[i].Signal = FALSE; > -Status = PsCreateSystemThread([i].Handle, GENERIC_ALL, > NULL, NULL, NULL, WaitForEventThread, [i]); > +InitializeObjectAttributes(, > + NULL, > + OBJ_KERNEL_HANDLE, > + NULL, > + NULL); > +Status = PsCreateSystemThread([i].Handle, GENERIC_ALL, > , NULL, NULL, WaitForEventThread, [i]); > ok_eq_hex(Status, STATUS_SUCCESS); > Status = ObReferenceObjectByHandle(Threads[i].Handle, > SYNCHRONIZE, *PsThreadType, KernelMode, (PVOID *)[i].Thread, NULL); > ok_eq_hex(Status, STATUS_SUCCESS); > > Modified: trunk/rostests/kmtests/rtl/RtlRegistry.c > URL: > http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/rtl/RtlRegistry.c?rev=69296=69295=69296=diff > > == > --- trunk/rostests/kmtests/rtl/RtlRegistry.c[iso-8859-1] (original) > +++ trunk/rostests/kmtests/rtl/RtlRegistry.c[iso-8859-1] Sat Sep 19 > 21:46:40 2015 > @@ -7,12 +7,6 @@ > > #define KMT_EMULATE_KERNEL > #include > - > -#ifdef KMT_KERNEL_MODE > -#define KMT_KERNEL_HANDLE OBJ_KERNEL_HANDLE > -#else > -#define KMT_KERNEL_HANDLE 0 > -#endif > > #ifndef RTL_NUMBER_OF > #define RTL_NUMBER_OF(x) (sizeof(x) / sizeof(x[0])) > @@ -212,7 +206,7 @@ > RtlInitUnicodeString(, L"\\Registry\\MACHINE\\Software"); > InitializeObjectAttributes(, > , > - OBJ_CASE_INSENSITIVE | KMT_KERNEL_HANDLE, > + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, > NULL, > NULL); > Status = ZwOpenKey(, > @@ -225,7 +219,7 @@ > RtlInitUnicodeString(, L"RtlRegistryKmtestKey"); > InitializeObjectAttributes(, >