--- trunk/reactos/ntoskrnl/ex/sysinfo.c 2005-02-28 22:03:10 UTC (rev 13786)
+++ trunk/reactos/ntoskrnl/ex/sysinfo.c 2005-03-01 02:32:09 UTC (rev 13787)
@@ -811,13 +811,107 @@
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)
--- trunk/reactos/ntoskrnl/ob/handle.c 2005-02-28 22:03:10 UTC (rev 13786)
+++ trunk/reactos/ntoskrnl/ob/handle.c 2005-03-01 02:32:09 UTC (rev 13787)
@@ -1014,8 +1014,9 @@
{
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 @@
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 */