Author: ion
Date: Mon Jan 8 22:40:10 2007
New Revision: 25384
URL:
http://svn.reactos.org/svn/reactos?rev=25384&view=rev
Log:
- Implement ObFindHandleForObject and add it to the NDK. However, it depends on
ExEnumHandleTable which is still unimplemented.
- Fix up prototype of the function (it returns TRUE/FALSE, not NTSTATUS) and fix callers
to use it properly.
- Also add ExEnumHandleTable to NDK.
Modified:
trunk/reactos/include/ndk/exfuncs.h
trunk/reactos/include/ndk/obfuncs.h
trunk/reactos/ntoskrnl/ex/sysinfo.c
trunk/reactos/ntoskrnl/include/internal/ob.h
trunk/reactos/ntoskrnl/ob/obhandle.c
trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
Modified: trunk/reactos/include/ndk/exfuncs.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/exfuncs.h?rev=…
==============================================================================
--- trunk/reactos/include/ndk/exfuncs.h (original)
+++ trunk/reactos/include/ndk/exfuncs.h Mon Jan 8 22:40:10 2007
@@ -101,6 +101,19 @@
NTAPI
ExTryToAcquireResourceExclusiveLite(
IN PERESOURCE Resource
+);
+
+//
+// Handle Table Functions
+//
+NTKERNELAPI
+BOOLEAN
+NTAPI
+ExEnumHandleTable(
+ IN PHANDLE_TABLE HandleTable,
+ IN PVOID Callback,
+ IN OUT PVOID Param,
+ OUT PHANDLE Handle OPTIONAL
);
#endif
Modified: trunk/reactos/include/ndk/obfuncs.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/obfuncs.h?rev=…
==============================================================================
--- trunk/reactos/include/ndk/obfuncs.h (original)
+++ trunk/reactos/include/ndk/obfuncs.h Mon Jan 8 22:40:10 2007
@@ -109,7 +109,7 @@
);
NTKERNELAPI
-NTSTATUS
+BOOLEAN
NTAPI
ObFindHandleForObject(
IN PEPROCESS Process,
Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/sysinfo.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/sysinfo.c (original)
+++ trunk/reactos/ntoskrnl/ex/sysinfo.c Mon Jan 8 22:40:10 2007
@@ -41,16 +41,15 @@
/*
* @unimplemented
*/
-VOID
-STDCALL
-ExEnumHandleTable (
- PULONG HandleTable,
- PVOID Callback,
- PVOID Param,
- PHANDLE Handle OPTIONAL
- )
-{
- UNIMPLEMENTED;
+BOOLEAN
+NTAPI
+ExEnumHandleTable(IN PHANDLE_TABLE HandleTable,
+ IN PVOID Callback,
+ IN OUT PVOID Param,
+ OUT PHANDLE Handle OPTIONAL)
+{
+ UNIMPLEMENTED;
+ return FALSE;
}
/*
Modified: trunk/reactos/ntoskrnl/include/internal/ob.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ob.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ob.h Mon Jan 8 22:40:10 2007
@@ -79,6 +79,12 @@
PHANDLE_TABLE HandleTable;
KPROCESSOR_MODE AccessMode;
} OBP_CLOSE_HANDLE_CONTEXT, *POBP_CLOSE_HANDLE_CONTEXT;
+typedef struct _OBP_FIND_HANDLE_DATA
+{
+ POBJECT_HEADER ObjectHeader;
+ POBJECT_TYPE ObjectType;
+ POBJECT_HANDLE_INFORMATION HandleInformation;
+} OBP_FIND_HANDLE_DATA, *POBP_FIND_HANDLE_DATA;
//
// Private Temporary Buffer for Lookup Routines
Modified: trunk/reactos/ntoskrnl/ob/obhandle.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obhandle.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obhandle.c (original)
+++ trunk/reactos/ntoskrnl/ob/obhandle.c Mon Jan 8 22:40:10 2007
@@ -22,6 +22,18 @@
#define TAG_OB_HANDLE TAG('O', 'b', 'H', 'd')
/* PRIVATE FUNCTIONS *********************************************************/
+
+BOOLEAN
+NTAPI
+ObpEnumFindHandleProcedure(IN PHANDLE_TABLE_ENTRY HandleEntry,
+ IN HANDLE Handle,
+ IN PVOID Context)
+{
+ /* FIXME: TODO */
+ DPRINT1("Not yet implemented!\n");
+ KEBUGCHECK(0);
+ return FALSE;
+}
POBJECT_HANDLE_COUNT_ENTRY
NTAPI
@@ -583,7 +595,6 @@
!(ObjectHeader->Flags & OB_FLAG_EXCLUSIVE))
{
/* Incorrect attempt */
- DPRINT1("Failing here\n");
Status = STATUS_INVALID_PARAMETER;
goto Quickie;
}
@@ -827,7 +838,6 @@
!(ObjectHeader->Flags & OB_FLAG_EXCLUSIVE))
{
/* Incorrect attempt */
- DPRINT1("failing here\n");
Status = STATUS_INVALID_PARAMETER;
goto Quickie;
}
@@ -2196,15 +2206,75 @@
return Status;
}
-NTSTATUS STDCALL
+/*++
+* @name ObFindHandleForObject
+* @implemented NT4
+*
+* The ObFindHandleForObject routine <FILLMEIN>
+*
+* @param Process
+* <FILLMEIN>.
+*
+* @param Object
+* <FILLMEIN>.
+*
+* @param ObjectType
+* <FILLMEIN>.
+*
+* @param HandleInformation
+* <FILLMEIN>.
+*
+* @param HandleReturn
+* <FILLMEIN>.
+*
+* @return <FILLMEIN>.
+*
+* @remarks None.
+*
+*--*/
+BOOLEAN
+NTAPI
ObFindHandleForObject(IN PEPROCESS Process,
IN PVOID Object,
IN POBJECT_TYPE ObjectType,
IN POBJECT_HANDLE_INFORMATION HandleInformation,
- OUT PHANDLE HandleReturn)
+ OUT PHANDLE Handle)
{
- DPRINT("ObFindHandleForObject is unimplemented!\n");
- return STATUS_UNSUCCESSFUL;
+ OBP_FIND_HANDLE_DATA FindData;
+ BOOLEAN Result = FALSE;
+
+ /* Make sure we have an object table */
+ if (Process->ObjectTable)
+ {
+ /* Check if we have an object */
+ if (Object)
+ {
+ /* Set its header */
+ FindData.ObjectHeader = OBJECT_TO_OBJECT_HEADER(Object);
+ }
+ else
+ {
+ /* Otherwise, no object to match*/
+ FindData.ObjectHeader = NULL;
+ }
+
+ /* Set other information */
+ FindData.ObjectType = ObjectType;
+ FindData.HandleInformation = HandleInformation;
+
+ /* Enumerate the handle table */
+ if (ExEnumHandleTable(Process->ObjectTable,
+ ObpEnumFindHandleProcedure,
+ &FindData,
+ Handle))
+ {
+ /* Set success */
+ Result = TRUE;
+ }
+ }
+
+ /* Return the result */
+ return Result;
}
/*++
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c Mon Jan 8 22:40:10 2007
@@ -299,15 +299,14 @@
{
/* search the process handle table for (inherited) window station
handles, use a more appropriate one than WinSta0 if possible. */
- Status = ObFindHandleForObject(Process,
- NULL,
- ExWindowStationObjectType,
- NULL,
- (PHANDLE)hWinSta);
- if(!NT_SUCCESS(Status))
- {
- /* we had no luck searching for opened handles, use WinSta0 now */
- RtlInitUnicodeString(&WinSta, L"WinSta0");
+ if (!ObFindHandleForObject(Process,
+ NULL,
+ ExWindowStationObjectType,
+ NULL,
+ (PHANDLE)hWinSta))
+ {
+ /* we had no luck searching for opened handles, use WinSta0 now */
+ RtlInitUnicodeString(&WinSta, L"WinSta0");
}
}
@@ -315,12 +314,11 @@
{
/* search the process handle table for (inherited) desktop
handles, use a more appropriate one than Default if possible. */
- Status = ObFindHandleForObject(Process,
- NULL,
- ExDesktopObjectType,
- NULL,
- (PHANDLE)hDesktop);
- if(!NT_SUCCESS(Status))
+ if (!ObFindHandleForObject(Process,
+ NULL,
+ ExDesktopObjectType,
+ NULL,
+ (PHANDLE)hDesktop))
{
/* we had no luck searching for opened handles, use Desktop now */
RtlInitUnicodeString(&Desktop, L"Default");
@@ -479,13 +477,11 @@
ASSERT(DesktopObject);
- Status = ObFindHandleForObject(PsGetCurrentProcess(),
- DesktopObject,
- ExDesktopObjectType,
- NULL,
- (PHANDLE)&Ret);
-
- if(!NT_SUCCESS(Status))
+ if (!ObFindHandleForObject(PsGetCurrentProcess(),
+ DesktopObject,
+ ExDesktopObjectType,
+ NULL,
+ (PHANDLE)&Ret))
{
Status = ObOpenObjectByPointer(DesktopObject,
0,