Fix Process/Thread information structures to match Windows 2000 and have
proper structure. Fix bug in ntdll related to OpenProcess
Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
Modified: trunk/reactos/ntoskrnl/ps/process.c
_____
Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
--- trunk/reactos/ntoskrnl/ex/sysinfo.c 2005-04-18 17:46:59 UTC (rev
14674)
+++ trunk/reactos/ntoskrnl/ex/sysinfo.c 2005-04-18 17:48:01 UTC (rev
14675)
@@ -562,12 +562,12 @@
/* scan the process list */
- PSYSTEM_PROCESSES Spi
- = (PSYSTEM_PROCESSES) Buffer;
+ PSYSTEM_PROCESS_INFORMATION Spi
+ = (PSYSTEM_PROCESS_INFORMATION) Buffer;
- *ReqSize = sizeof(SYSTEM_PROCESSES);
+ *ReqSize = sizeof(SYSTEM_PROCESS_INFORMATION);
- if (Size < sizeof(SYSTEM_PROCESSES))
+ if (Size < sizeof(SYSTEM_PROCESS_INFORMATION))
{
return (STATUS_INFO_LENGTH_MISMATCH); // in case buffer
size is too small
}
@@ -578,14 +578,14 @@
do
{
- PSYSTEM_PROCESSES SpiCur;
+ PSYSTEM_PROCESS_INFORMATION SpiCur;
int curSize, i = 0;
ANSI_STRING imgName;
int inLen=32; // image name len in bytes
PLIST_ENTRY current_entry;
PETHREAD current;
- SpiCur = (PSYSTEM_PROCESSES)pCur;
+ SpiCur = (PSYSTEM_PROCESS_INFORMATION)pCur;
current_entry = pr->ThreadListHead.Flink;
while (current_entry != &pr->ThreadListHead)
@@ -595,7 +595,7 @@
}
// size of the structure for every process
- curSize =
sizeof(SYSTEM_PROCESSES)-sizeof(SYSTEM_THREADS)+sizeof(SYSTEM_THREADS)*n
Threads;
+ curSize =
sizeof(SYSTEM_PROCESS_INFORMATION)-sizeof(SYSTEM_THREAD_INFORMATION)+siz
eof(SYSTEM_THREAD_INFORMATION)*nThreads;
ovlSize += curSize+inLen;
if (ovlSize > Size)
@@ -607,45 +607,45 @@
}
// fill system information
- SpiCur->NextEntryDelta = curSize+inLen; // relative
offset to the beginnnig of the next structure
- SpiCur->ThreadCount = nThreads;
+ SpiCur->NextEntryOffset = curSize+inLen; // relative
offset to the beginnnig of the next structure
+ SpiCur->NumberOfThreads = nThreads;
SpiCur->CreateTime = pr->CreateTime;
SpiCur->UserTime.QuadPart = pr->Pcb.UserTime * 100000LL;
SpiCur->KernelTime.QuadPart = pr->Pcb.KernelTime * 100000LL;
- SpiCur->ProcessName.Length = strlen(pr->ImageFileName) *
sizeof(WCHAR);
- SpiCur->ProcessName.MaximumLength = inLen;
- SpiCur->ProcessName.Buffer = (void*)(pCur+curSize);
+ SpiCur->ImageName.Length = strlen(pr->ImageFileName) *
sizeof(WCHAR);
+ SpiCur->ImageName.MaximumLength = inLen;
+ SpiCur->ImageName.Buffer = (void*)(pCur+curSize);
// copy name to the end of the struct
if(pr != PsIdleProcess)
{
RtlInitAnsiString(&imgName, pr->ImageFileName);
- RtlAnsiStringToUnicodeString(&SpiCur->ProcessName,
&imgName, FALSE);
+ RtlAnsiStringToUnicodeString(&SpiCur->ImageName,
&imgName, FALSE);
}
else
{
- RtlInitUnicodeString(&SpiCur->ProcessName, NULL);
+ RtlInitUnicodeString(&SpiCur->ImageName, NULL);
}
SpiCur->BasePriority = pr->Pcb.BasePriority;
- SpiCur->ProcessId = pr->UniqueProcessId;
- SpiCur->InheritedFromProcessId =
pr->InheritedFromUniqueProcessId;
+ SpiCur->UniqueProcessId = pr->UniqueProcessId;
+ SpiCur->InheritedFromUniqueProcessId =
pr->InheritedFromUniqueProcessId;
SpiCur->HandleCount = (pr->ObjectTable ?
ObpGetHandleCountByHandleTable(pr->ObjectTable) : 0);
- SpiCur->VmCounters.PeakVirtualSize =
pr->PeakVirtualSize;
- SpiCur->VmCounters.VirtualSize =
pr->VirtualSize.QuadPart;
- SpiCur->VmCounters.PageFaultCount = pr->LastFaultCount;
- SpiCur->VmCounters.PeakWorkingSetSize =
pr->Vm.PeakWorkingSetSize; // Is this right using ->Vm. here ?
- SpiCur->VmCounters.WorkingSetSize =
pr->Vm.WorkingSetSize; // Is this right using ->Vm. here ?
- SpiCur->VmCounters.QuotaPeakPagedPoolUsage =
+ SpiCur->PeakVirtualSize = pr->PeakVirtualSize;
+ SpiCur->VirtualSize = pr->VirtualSize.QuadPart;
+ SpiCur->PageFaultCount = pr->LastFaultCount;
+ SpiCur->PeakWorkingSetSize = pr->Vm.PeakWorkingSetSize;
// Is this right using ->Vm. here ?
+ SpiCur->WorkingSetSize = pr->Vm.WorkingSetSize; // Is
this right using ->Vm. here ?
+ SpiCur->QuotaPeakPagedPoolUsage =
pr->QuotaPeakPoolUsage[0];
- SpiCur->VmCounters.QuotaPagedPoolUsage =
+ SpiCur->QuotaPagedPoolUsage =
pr->QuotaPoolUsage[0];
- SpiCur->VmCounters.QuotaPeakNonPagedPoolUsage =
+ SpiCur->QuotaPeakNonPagedPoolUsage =
pr->QuotaPeakPoolUsage[1];
- SpiCur->VmCounters.QuotaNonPagedPoolUsage =
+ SpiCur->QuotaNonPagedPoolUsage =
pr->QuotaPoolUsage[1];
- SpiCur->VmCounters.PagefileUsage = pr->PagefileUsage; //
FIXME
- SpiCur->VmCounters.PeakPagefileUsage =
pr->PeakPagefileUsage;
+ SpiCur->PagefileUsage = pr->PagefileUsage; // FIXME
+ SpiCur->PeakPagefileUsage = pr->PeakPagefileUsage;
// KJK::Hyperion: I don't know what does this mean.
VM_COUNTERS
// doesn't seem to contain any equivalent field
//SpiCur->TotalPrivateBytes = pr->NumberOfPrivatePages;
//FIXME: bytes != pages
@@ -656,17 +656,17 @@
current = CONTAINING_RECORD(current_entry, ETHREAD,
ThreadListEntry);
- SpiCur->Threads[i].KernelTime.QuadPart =
current->Tcb.KernelTime * 100000LL;
- SpiCur->Threads[i].UserTime.QuadPart =
current->Tcb.UserTime * 100000LL;
-// SpiCur->Threads[i].CreateTime = current->CreateTime;
- SpiCur->Threads[i].WaitTime = current->Tcb.WaitTime;
- SpiCur->Threads[i].StartAddress = (PVOID)
current->StartAddress;
- SpiCur->Threads[i].ClientId = current->Cid;
- SpiCur->Threads[i].Priority = current->Tcb.Priority;
- SpiCur->Threads[i].BasePriority =
current->Tcb.BasePriority;
- SpiCur->Threads[i].ContextSwitchCount =
current->Tcb.ContextSwitches;
- SpiCur->Threads[i].State = current->Tcb.State;
- SpiCur->Threads[i].WaitReason =
current->Tcb.WaitReason;
+ SpiCur->TH[i].KernelTime.QuadPart =
current->Tcb.KernelTime * 100000LL;
+ SpiCur->TH[i].UserTime.QuadPart =
current->Tcb.UserTime * 100000LL;
+// SpiCur->TH[i].CreateTime = current->CreateTime;
+ SpiCur->TH[i].WaitTime = current->Tcb.WaitTime;
+ SpiCur->TH[i].StartAddress = (PVOID)
current->StartAddress;
+ SpiCur->TH[i].ClientId = current->Cid;
+ SpiCur->TH[i].Priority = current->Tcb.Priority;
+ SpiCur->TH[i].BasePriority =
current->Tcb.BasePriority;
+ SpiCur->TH[i].ContextSwitches =
current->Tcb.ContextSwitches;
+ SpiCur->TH[i].ThreadState = current->Tcb.State;
+ SpiCur->TH[i].WaitReason = current->Tcb.WaitReason;
i++;
current_entry = current_entry->Flink;
}
@@ -675,7 +675,7 @@
nThreads = 0;
if ((pr == syspr) || (pr == NULL))
{
- SpiCur->NextEntryDelta = 0;
+ SpiCur->NextEntryOffset = 0;
break;
}
else
_____
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
--- trunk/reactos/ntoskrnl/include/internal/ke.h 2005-04-18
17:46:59 UTC (rev 14674)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h 2005-04-18
17:48:01 UTC (rev 14675)
@@ -49,6 +49,7 @@
#define IPI_REQUEST_DPC 2
#define IPI_REQUEST_FREEZE 3
+#ifndef __USE_W32API
typedef enum _KTHREAD_STATE {
Initialized,
Ready,
@@ -59,6 +60,7 @@
Transition,
DeferredReady,
} THREAD_STATE, *PTHREAD_STATE;
+#endif
/* MACROS
************************************************************************
*/
_____
Modified: trunk/reactos/ntoskrnl/ps/process.c
--- trunk/reactos/ntoskrnl/ps/process.c 2005-04-18 17:46:59 UTC (rev
14674)
+++ trunk/reactos/ntoskrnl/ps/process.c 2005-04-18 17:48:01 UTC (rev
14675)
@@ -363,7 +363,7 @@
Status = PsCreateCidHandle(Process,
PsProcessType,
&Process->UniqueProcessId);
- DPRINT1("Created CID: %d\n", Process->UniqueProcessId);
+ DPRINT("Created CID: %d\n", Process->UniqueProcessId);
if(!NT_SUCCESS(Status))
{
DPRINT1("Failed to create CID handle (unique process ID)!
Status: 0x%x\n", Status);
@@ -873,7 +873,8 @@
if (ClientId->UniqueThread)
{
/* Get the Process */
- DPRINT1("Opening by Thread ID: %x\n",
ClientId->UniqueThread);
+ if (ClientId->UniqueThread == (HANDLE)-1) KEBUGCHECK(0);
+ DPRINT("Opening by Thread ID: %x\n",
ClientId->UniqueThread);
Status = PsLookupProcessThreadByCid(ClientId,
&Process,
&Thread);
@@ -882,7 +883,7 @@
else
{
/* Get the Process */
- DPRINT1("Opening by Process ID: %x\n",
ClientId->UniqueProcess);
+ DPRINT("Opening by Process ID: %x\n",
ClientId->UniqueProcess);
Status =
PsLookupProcessByProcessId(ClientId->UniqueProcess,
&Process);
DPRINT("Found: %x\n", Process);