Partial implementation of SystemHandleInformation and ObpGetNextHandleByProcessCount (Name will change very soon). Fix GetHandleCountByHandleTable return real number of open handles.

svn path=/trunk/; revision=13787
This commit is contained in:
James Tabor 2005-03-01 02:32:09 +00:00
parent 643b34465c
commit 95957e5826
2 changed files with 127 additions and 5 deletions

View file

@ -811,13 +811,107 @@ QSI_DEF(SystemNonPagedPoolInformation)
return (STATUS_NOT_IMPLEMENTED);
}
VOID
ObpGetNextHandleByProcessCount(PSYSTEM_HANDLE_TABLE_ENTRY_INFO pshi,
PEPROCESS Process,
int Count);
/* Class 16 - Handle Information */
QSI_DEF(SystemHandleInformation)
{
/* FIXME */
DPRINT1("NtQuerySystemInformation - SystemHandleInformation not implemented\n");
return (STATUS_NOT_IMPLEMENTED);
PSYSTEM_HANDLE_INFORMATION Shi =
(PSYSTEM_HANDLE_INFORMATION) Buffer;
DPRINT("NtQuerySystemInformation - SystemHandleInformation\n");
if (Size < sizeof (SYSTEM_HANDLE_INFORMATION))
{
* ReqSize = sizeof (SYSTEM_HANDLE_INFORMATION);
return (STATUS_INFO_LENGTH_MISMATCH);
}
DPRINT("SystemHandleInformation 1\n");
PEPROCESS pr, syspr;
int curSize, i = 0;
ULONG hCount = 0;
/* First Calc Size from Count. */
syspr = PsGetNextProcess(NULL);
pr = syspr;
do
{
hCount = hCount + ObpGetHandleCountByHandleTable(&pr->HandleTable);
curSize = sizeof(SYSTEM_HANDLE_INFORMATION)+
( (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO) * hCount) -
(sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO) ));
Shi->NumberOfHandles = hCount;
if (curSize > Size)
{
*ReqSize = curSize;
DPRINT1("SystemHandleInformation 2\n");
return (STATUS_INFO_LENGTH_MISMATCH);
}
pr = PsGetNextProcess(pr);
if ((pr == syspr) || (pr == NULL))
break;
} while ((pr != syspr) && (pr != NULL));
if (pr != NULL)
{
ObDereferenceObject(pr);
}
DPRINT("SystemHandleInformation 3\n");
/* Now get Handles from all processs. */
syspr = PsGetNextProcess(NULL);
pr = syspr;
do
{
int Count = 0, HandleCount = 0;
HandleCount = ObpGetHandleCountByHandleTable(&pr->HandleTable);
for (Count = 0; HandleCount > 0 ; HandleCount--)
{
ObpGetNextHandleByProcessCount( &Shi->Handles[i], pr, Count);
Count++;
i++;
}
pr = PsGetNextProcess(pr);
if ((pr == syspr) || (pr == NULL))
break;
} while ((pr != syspr) && (pr != NULL));
if (pr != NULL)
{
ObDereferenceObject(pr);
}
DPRINT("SystemHandleInformation 4\n");
return (STATUS_SUCCESS);
}
/*
SSI_DEF(SystemHandleInformation)
{
return (STATUS_SUCCESS);
}
*/
/* Class 17 - Information */
QSI_DEF(SystemObjectInformation)

View file

@ -1014,8 +1014,9 @@ ObpGetHandleCountByHandleTable(PHANDLE_TABLE HandleTable)
{
Header = BODY_TO_HEADER(ObjectBody);
/* Make sure this is real. */
if (Header->ObjectType != NULL)
/* Make sure this is real. Okay! For real!*/
if ((Header->ObjectType != NULL) &&
(Header->ObjectType->Close != NULL))
Count++;
}
}
@ -1078,4 +1079,31 @@ ObFindHandleForObject(IN PEPROCESS Process,
return STATUS_UNSUCCESSFUL;
}
VOID
ObpGetNextHandleByProcessCount(PSYSTEM_HANDLE_TABLE_ENTRY_INFO pshi,
PEPROCESS Process,
int Count)
{
ULONG P;
KIRQL oldIrql;
// pshi->HandleValue;
P = (ULONG) Process->UniqueProcessId;
pshi->UniqueProcessId = (USHORT) P;
KeAcquireSpinLock( &Process->HandleTable.ListLock, &oldIrql );
// pshi->GrantedAccess;
// pshi->Object;
// pshi->ObjectTypeIndex;
// pshi->HandleAttributes;
KeReleaseSpinLock( &Process->HandleTable.ListLock, oldIrql );
return;
}
/* EOF */