mirror of
https://github.com/reactos/reactos.git
synced 2025-04-21 12:40:33 +00:00
- Implement ExEnumHandleTable. Had to add a small hack due to some memory freeing/init problem that requires more investigation.
- Implement ObpEnumFindHandleProcedure. svn path=/trunk/; revision=25593
This commit is contained in:
parent
50d8fb4688
commit
b440bf6fae
6 changed files with 120 additions and 21 deletions
|
@ -111,8 +111,8 @@ BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
ExEnumHandleTable(
|
ExEnumHandleTable(
|
||||||
IN PHANDLE_TABLE HandleTable,
|
IN PHANDLE_TABLE HandleTable,
|
||||||
IN PVOID Callback,
|
IN PEX_ENUM_HANDLE_CALLBACK EnumHandleProcedure,
|
||||||
IN OUT PVOID Param,
|
IN OUT PVOID Context,
|
||||||
OUT PHANDLE Handle OPTIONAL
|
OUT PHANDLE Handle OPTIONAL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -361,6 +361,17 @@ NTSTATUS
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Enumeration Callback
|
||||||
|
//
|
||||||
|
struct _HANDLE_TABLE_ENTRY;
|
||||||
|
typedef BOOLEAN
|
||||||
|
(NTAPI *PEX_ENUM_HANDLE_CALLBACK)(
|
||||||
|
IN struct _HANDLE_TABLE_ENTRY *HandleTableEntry,
|
||||||
|
IN HANDLE Handle,
|
||||||
|
IN PVOID Context
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Compatibility with Windows XP Drivers using ERESOURCE
|
// Compatibility with Windows XP Drivers using ERESOURCE
|
||||||
//
|
//
|
||||||
|
|
|
@ -39,7 +39,7 @@ ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
||||||
ULONG_PTR TableBase;
|
ULONG_PTR TableBase;
|
||||||
PHANDLE_TABLE_ENTRY Entry = NULL;
|
PHANDLE_TABLE_ENTRY Entry = NULL;
|
||||||
EXHANDLE Handle = LookupHandle;
|
EXHANDLE Handle = LookupHandle;
|
||||||
PCHAR Level1, Level2, Level3;
|
PUCHAR Level1, Level2, Level3;
|
||||||
|
|
||||||
/* Clear the tag bits and check what the next handle is */
|
/* Clear the tag bits and check what the next handle is */
|
||||||
Handle.TagBits = 0;
|
Handle.TagBits = 0;
|
||||||
|
@ -1239,3 +1239,61 @@ ExSweepHandleTable(IN PHANDLE_TABLE HandleTable,
|
||||||
Handle.Value += SizeOfHandle(1);
|
Handle.Value += SizeOfHandle(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
ExEnumHandleTable(IN PHANDLE_TABLE HandleTable,
|
||||||
|
IN PEX_ENUM_HANDLE_CALLBACK EnumHandleProcedure,
|
||||||
|
IN OUT PVOID Context,
|
||||||
|
OUT PHANDLE EnumHandle OPTIONAL)
|
||||||
|
{
|
||||||
|
EXHANDLE Handle;
|
||||||
|
PHANDLE_TABLE_ENTRY HandleTableEntry;
|
||||||
|
BOOLEAN Result = FALSE;
|
||||||
|
PAGED_CODE();
|
||||||
|
|
||||||
|
/* Enter a critical region */
|
||||||
|
KeEnterCriticalRegion();
|
||||||
|
|
||||||
|
/* Set the initial value and loop the entries */
|
||||||
|
Handle.Value = 0;
|
||||||
|
while ((HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, Handle)))
|
||||||
|
{
|
||||||
|
/* Validate the entry */
|
||||||
|
if ((HandleTableEntry) &&
|
||||||
|
(HandleTableEntry->Object) &&
|
||||||
|
(HandleTableEntry->NextFreeTableEntry != -2) &&
|
||||||
|
(HandleTableEntry->Object != (PVOID)0xCDCDCDCD)) // HACK OF ETERNAL LAPDANCE
|
||||||
|
{
|
||||||
|
/* Lock the entry */
|
||||||
|
if (ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
|
||||||
|
{
|
||||||
|
/* Notify the callback routine */
|
||||||
|
Result = EnumHandleProcedure(HandleTableEntry,
|
||||||
|
Handle.GenericHandleOverlay,
|
||||||
|
Context);
|
||||||
|
|
||||||
|
/* Unlock it */
|
||||||
|
ExUnlockHandleTableEntry(HandleTable, HandleTableEntry);
|
||||||
|
|
||||||
|
/* Was this the one looked for? */
|
||||||
|
if (Result)
|
||||||
|
{
|
||||||
|
/* If so, return it if requested */
|
||||||
|
if (EnumHandle) *EnumHandle = Handle.GenericHandleOverlay;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Go to the next entry */
|
||||||
|
Handle.Value += SizeOfHandle(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Leave the critical region and return callback result */
|
||||||
|
KeLeaveCriticalRegion();
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
|
@ -38,20 +38,6 @@ ExGetPreviousMode (VOID)
|
||||||
return KeGetPreviousMode();
|
return KeGetPreviousMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
BOOLEAN
|
|
||||||
NTAPI
|
|
||||||
ExEnumHandleTable(IN PHANDLE_TABLE HandleTable,
|
|
||||||
IN PVOID Callback,
|
|
||||||
IN OUT PVOID Param,
|
|
||||||
OUT PHANDLE Handle OPTIONAL)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -177,10 +177,46 @@ ObpEnumFindHandleProcedure(IN PHANDLE_TABLE_ENTRY HandleEntry,
|
||||||
IN HANDLE Handle,
|
IN HANDLE Handle,
|
||||||
IN PVOID Context)
|
IN PVOID Context)
|
||||||
{
|
{
|
||||||
/* FIXME: TODO */
|
POBJECT_HEADER ObjectHeader;
|
||||||
DPRINT1("Not yet implemented!\n");
|
ACCESS_MASK GrantedAccess;
|
||||||
KEBUGCHECK(0);
|
ULONG HandleAttributes;
|
||||||
return FALSE;
|
POBP_FIND_HANDLE_DATA FindData = Context;
|
||||||
|
|
||||||
|
/* Get the object header */
|
||||||
|
ObjectHeader = ObpGetHandleObject(HandleEntry);
|
||||||
|
|
||||||
|
/* Make sure it's valid and matching */
|
||||||
|
if ((FindData->ObjectHeader) && (FindData->ObjectHeader != ObjectHeader))
|
||||||
|
{
|
||||||
|
/* No match, fail */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now attempt to match the object type */
|
||||||
|
if ((FindData->ObjectType) && (FindData->ObjectType != ObjectHeader->Type))
|
||||||
|
{
|
||||||
|
/* No match, fail */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if we have extra information */
|
||||||
|
if (FindData->HandleInformation)
|
||||||
|
{
|
||||||
|
/* Get the granted access and attributes */
|
||||||
|
GrantedAccess = HandleEntry->GrantedAccess;
|
||||||
|
HandleAttributes = HandleEntry->ObAttributes & OBJ_HANDLE_ATTRIBUTES;
|
||||||
|
|
||||||
|
/* Attempt to match them */
|
||||||
|
if ((FindData->HandleInformation->HandleAttributes != HandleAttributes) ||
|
||||||
|
(FindData->HandleInformation->GrantedAccess != GrantedAccess))
|
||||||
|
{
|
||||||
|
/* No match, fail */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We have a match */
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
POBJECT_HANDLE_COUNT_ENTRY
|
POBJECT_HANDLE_COUNT_ENTRY
|
||||||
|
|
|
@ -297,6 +297,7 @@ IntParseDesktopPath(PEPROCESS Process,
|
||||||
|
|
||||||
if(!WinStaPresent)
|
if(!WinStaPresent)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
/* search the process handle table for (inherited) window station
|
/* search the process handle table for (inherited) window station
|
||||||
handles, use a more appropriate one than WinSta0 if possible. */
|
handles, use a more appropriate one than WinSta0 if possible. */
|
||||||
if (!ObFindHandleForObject(Process,
|
if (!ObFindHandleForObject(Process,
|
||||||
|
@ -304,6 +305,7 @@ IntParseDesktopPath(PEPROCESS Process,
|
||||||
ExWindowStationObjectType,
|
ExWindowStationObjectType,
|
||||||
NULL,
|
NULL,
|
||||||
(PHANDLE)hWinSta))
|
(PHANDLE)hWinSta))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
/* we had no luck searching for opened handles, use WinSta0 now */
|
/* we had no luck searching for opened handles, use WinSta0 now */
|
||||||
RtlInitUnicodeString(&WinSta, L"WinSta0");
|
RtlInitUnicodeString(&WinSta, L"WinSta0");
|
||||||
|
@ -312,6 +314,7 @@ IntParseDesktopPath(PEPROCESS Process,
|
||||||
|
|
||||||
if(!DesktopPresent && hDesktop != NULL)
|
if(!DesktopPresent && hDesktop != NULL)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
/* search the process handle table for (inherited) desktop
|
/* search the process handle table for (inherited) desktop
|
||||||
handles, use a more appropriate one than Default if possible. */
|
handles, use a more appropriate one than Default if possible. */
|
||||||
if (!ObFindHandleForObject(Process,
|
if (!ObFindHandleForObject(Process,
|
||||||
|
@ -319,6 +322,7 @@ IntParseDesktopPath(PEPROCESS Process,
|
||||||
ExDesktopObjectType,
|
ExDesktopObjectType,
|
||||||
NULL,
|
NULL,
|
||||||
(PHANDLE)hDesktop))
|
(PHANDLE)hDesktop))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
/* we had no luck searching for opened handles, use Desktop now */
|
/* we had no luck searching for opened handles, use Desktop now */
|
||||||
RtlInitUnicodeString(&Desktop, L"Default");
|
RtlInitUnicodeString(&Desktop, L"Default");
|
||||||
|
@ -497,6 +501,10 @@ IntGetDesktopObjectHandle(PDESKTOP_OBJECT DesktopObject)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT1("Got handle: %lx\n", Ret);
|
||||||
|
}
|
||||||
|
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue