I give up! I fix the rest of the headers later.

svn path=/trunk/; revision=15479
This commit is contained in:
James Tabor 2005-05-23 19:17:36 +00:00
parent 15e364a635
commit a1b9addb33

View file

@ -1,4 +1,4 @@
/* $Id$ /*
* *
* ReactOS ps - process list console viewer * ReactOS ps - process list console viewer
* *
@ -23,7 +23,69 @@
*/ */
#include <windows.h> #include <windows.h>
#include <ddk/ntapi.h> /* NOTE: W32API ddk/ntapi.h header has wrong definition of SYSTEM_PROCESSES. */
#include <ntos/types.h>
typedef struct _SYSTEM_THREADS
{
LARGE_INTEGER KernelTime;
LARGE_INTEGER UserTime;
LARGE_INTEGER CreateTime;
ULONG WaitTime;
PVOID StartAddress;
CLIENT_ID ClientId;
KPRIORITY Priority;
LONG BasePriority;
ULONG ContextSwitches;
ULONG ThreadState;
ULONG WaitReason;
} SYSTEM_THREADS, *PSYSTEM_THREADS;
typedef struct _SYSTEM_PROCESSES
{
ULONG NextEntryOffset;
ULONG NumberOfThreads;
LARGE_INTEGER SpareLi1;
LARGE_INTEGER SpareLi2;
LARGE_INTEGER SpareLi3;
LARGE_INTEGER CreateTime;
LARGE_INTEGER UserTime;
LARGE_INTEGER KernelTime;
UNICODE_STRING ImageName;
KPRIORITY BasePriority;
HANDLE UniqueProcessId;
HANDLE InheritedFromUniqueProcessId;
ULONG HandleCount;
ULONG SessionId;
ULONG PageDirectoryFrame;
/*
* This part corresponds to VM_COUNTERS_EX.
* NOTE: *NOT* THE SAME AS VM_COUNTERS!
*/
ULONG PeakVirtualSize;
ULONG VirtualSize;
ULONG PageFaultCount;
ULONG PeakWorkingSetSize;
ULONG WorkingSetSize;
ULONG QuotaPeakPagedPoolUsage;
ULONG QuotaPagedPoolUsage;
ULONG QuotaPeakNonPagedPoolUsage;
ULONG QuotaNonPagedPoolUsage;
ULONG PagefileUsage;
ULONG PeakPagefileUsage;
ULONG PrivateUsage;
/* This part corresponds to IO_COUNTERS */
LARGE_INTEGER ReadOperationCount;
LARGE_INTEGER WriteOperationCount;
LARGE_INTEGER OtherOperationCount;
LARGE_INTEGER ReadTransferCount;
LARGE_INTEGER WriteTransferCount;
LARGE_INTEGER OtherTransferCount;
SYSTEM_THREADS Threads [1];
} SYSTEM_PROCESSES, *PSYSTEM_PROCESSES;
// x00000000 00000000 000:00:00 000:00:00 () // x00000000 00000000 000:00:00 000:00:00 ()
@ -47,7 +109,6 @@ struct status {
{-1," ? "} {-1," ? "}
}; };
struct waitres { struct waitres {
DWORD state; DWORD state;
char desc[17]; char desc[17];
@ -89,7 +150,6 @@ struct waitres {
{34,"MaximumWaitReason"}, {34,"MaximumWaitReason"},
{-1," ? "} {-1," ? "}
}; };
BOOL CALLBACK BOOL CALLBACK
EnumThreadProc(HWND hwnd, LPARAM lp) EnumThreadProc(HWND hwnd, LPARAM lp)
{ {
@ -117,8 +177,8 @@ int main()
DWORD r; DWORD r;
ANSI_STRING astring; ANSI_STRING astring;
HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE); HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE);
PSYSTEM_PROCESS_INFORMATION SystemProcesses = NULL; PSYSTEM_PROCESSES SystemProcesses = NULL;
PSYSTEM_PROCESS_INFORMATION CurrentProcess; PSYSTEM_PROCESSES CurrentProcess;
ULONG BufferSize, ReturnSize; ULONG BufferSize, ReturnSize;
NTSTATUS Status; NTSTATUS Status;
char buf[256]; char buf[256];
@ -182,36 +242,36 @@ int main()
struct waitres *waitt; struct waitres *waitt;
char szWindowName[30] = {" "}; char szWindowName[30] = {" "};
ptime = CurrentProcess->TH[ti].KernelTime; ptime = CurrentProcess->Threads[ti].KernelTime;
thour = (ptime.QuadPart / (10000000LL * 3600LL)); thour = (ptime.QuadPart / (10000000LL * 3600LL));
tmin = (ptime.QuadPart / (10000000LL * 60LL)) % 60LL; tmin = (ptime.QuadPart / (10000000LL * 60LL)) % 60LL;
tsec = (ptime.QuadPart / 10000000LL) % 60LL; tsec = (ptime.QuadPart / 10000000LL) % 60LL;
ptime = CurrentProcess->TH[ti].UserTime; ptime = CurrentProcess->Threads[ti].UserTime;
thour1 = (ptime.QuadPart / (10000000LL * 3600LL)); thour1 = (ptime.QuadPart / (10000000LL * 3600LL));
tmin1 = (ptime.QuadPart / (10000000LL * 60LL)) % 60LL; tmin1 = (ptime.QuadPart / (10000000LL * 60LL)) % 60LL;
tsec1 = (ptime.QuadPart / 10000000LL) % 60LL; tsec1 = (ptime.QuadPart / 10000000LL) % 60LL;
statt = thread_stat; statt = thread_stat;
while (statt->state != CurrentProcess->TH[ti].ThreadState && statt->state >= 0) while (statt->state != CurrentProcess->Threads[ti].ThreadState && statt->state >= 0)
statt++; statt++;
waitt = waitreason; waitt = waitreason;
while (waitt->state != CurrentProcess->TH[ti].WaitReason && waitt->state >= 0) while (waitt->state != CurrentProcess->Threads[ti].WaitReason && waitt->state >= 0)
waitt++; waitt++;
wsprintf (buf1, wsprintf (buf1,
"t% %8d %3d:%02d:%02d %3d:%02d:%02d %s %s\n", "t% %8d %3d:%02d:%02d %3d:%02d:%02d %s %s\n",
CurrentProcess->TH[ti].ClientId.UniqueThread, CurrentProcess->Threads[ti].ClientId.UniqueThread,
thour, tmin, tsec, thour1, tmin1, tsec1, thour, tmin, tsec, thour1, tmin1, tsec1,
statt->desc , waitt->desc); statt->desc , waitt->desc);
WriteFile(stdout, buf1, lstrlen(buf1), &r, NULL); WriteFile(stdout, buf1, lstrlen(buf1), &r, NULL);
EnumThreadWindows((DWORD)CurrentProcess->TH[ti].ClientId.UniqueThread, EnumThreadWindows((DWORD)CurrentProcess->Threads[ti].ClientId.UniqueThread,
(ENUMWINDOWSPROC) EnumThreadProc, (ENUMWINDOWSPROC) EnumThreadProc,
(LPARAM)(LPTSTR) szWindowName ); (LPARAM)(LPTSTR) szWindowName );
} }
CurrentProcess = (PSYSTEM_PROCESS_INFORMATION)((ULONG_PTR)CurrentProcess + CurrentProcess = (PSYSTEM_PROCESSES)((ULONG_PTR)CurrentProcess +
CurrentProcess->NextEntryOffset); CurrentProcess->NextEntryOffset);
} }
return (0); return (0);