diff --git a/reactos/ntoskrnl/ex/sysinfo.c b/reactos/ntoskrnl/ex/sysinfo.c index 1fc525c0ad8..0b4ee629b1e 100644 --- a/reactos/ntoskrnl/ex/sysinfo.c +++ b/reactos/ntoskrnl/ex/sysinfo.c @@ -1,4 +1,4 @@ -/* $Id: sysinfo.c,v 1.32 2004/04/28 20:50:02 hbirr Exp $ +/* $Id: sysinfo.c,v 1.33 2004/05/02 04:40:24 jimtabor Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -552,7 +552,7 @@ QSI_DEF(SystemProcessInformation) SpiCur->BasePriority = pr->Pcb.BasePriority; SpiCur->ProcessId = pr->UniqueProcessId; SpiCur->InheritedFromProcessId = (DWORD)(pr->InheritedFromUniqueProcessId); - SpiCur->HandleCount = ObGetObjectHandleCount(pr); + SpiCur->HandleCount = ObpGetHandleCountbyHandleTable(&pr->HandleTable); SpiCur->VmCounters.PeakVirtualSize = pr->PeakVirtualSize; SpiCur->VmCounters.VirtualSize = pr->VirtualSize.QuadPart; SpiCur->VmCounters.PageFaultCount = pr->LastFaultCount; diff --git a/reactos/ntoskrnl/include/internal/ob.h b/reactos/ntoskrnl/include/internal/ob.h index 37205fed06c..fc061e3bd92 100644 --- a/reactos/ntoskrnl/include/internal/ob.h +++ b/reactos/ntoskrnl/include/internal/ob.h @@ -133,4 +133,8 @@ ObDuplicateObject(PEPROCESS SourceProcess, BOOLEAN InheritHandle, ULONG Options); +ULONG +ObpGetHandleCountbyHandleTable(PHANDLE_TABLE HandleTable); + + #endif /* __INCLUDE_INTERNAL_OBJMGR_H */ diff --git a/reactos/ntoskrnl/ob/handle.c b/reactos/ntoskrnl/ob/handle.c index 439eb3be83a..68f51ee56df 100644 --- a/reactos/ntoskrnl/ob/handle.c +++ b/reactos/ntoskrnl/ob/handle.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: handle.c,v 1.54 2003/10/21 21:46:02 ekohl Exp $ +/* $Id: handle.c,v 1.55 2004/05/02 04:40:25 jimtabor Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -949,4 +949,35 @@ ObInsertObject(IN PVOID Object, Handle)); } + +ULONG +ObpGetHandleCountbyHandleTable(PHANDLE_TABLE HandleTable) +{ +unsigned int i, Count=0; +PHANDLE_BLOCK blk; +POBJECT_HEADER Header; +PVOID ObjectBody; +PLIST_ENTRY current = HandleTable->ListHead.Flink; + + while (current != &HandleTable->ListHead) + { + blk = CONTAINING_RECORD(current, HANDLE_BLOCK, entry); + + for ( i=0; ihandles[i].ObjectBody); + + if (ObjectBody != NULL) + { + Header = BODY_TO_HEADER(ObjectBody); + /* Make sure this is real. */ + if (Header->ObjectType != NULL) + Count++; + } + } + current = current->Flink; + } + return (Count); +} + /* EOF */ diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index cb242885b47..7cf0612b1c5 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -1,4 +1,4 @@ -/* $Id: process.c,v 1.130 2004/04/26 05:46:35 jimtabor Exp $ +/* $Id: process.c,v 1.131 2004/05/02 04:40:25 jimtabor Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -1118,7 +1118,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, else { PULONG HandleCount = (PULONG)ProcessInformation; - *HandleCount = ObGetObjectHandleCount(Process); + *HandleCount = ObpGetHandleCountbyHandleTable(&Process->HandleTable); if (ReturnLength) { *ReturnLength = sizeof(ULONG);