2005-01-25 05:11:17 +00:00
|
|
|
/* $Id$
|
2001-11-04 21:53:20 +00:00
|
|
|
*
|
|
|
|
* ReactOS Project
|
|
|
|
* TList
|
|
|
|
*
|
|
|
|
* Copyright (c) 2000,2001 Emanuele Aliberti
|
|
|
|
*/
|
|
|
|
#include <reactos/buildno.h>
|
2003-08-03 18:06:02 +00:00
|
|
|
#define NTOS_MODE_USER
|
2001-11-04 21:53:20 +00:00
|
|
|
#include <ntos.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
2003-04-14 01:19:08 +00:00
|
|
|
#include <epsapi.h>
|
2003-04-22 03:20:25 +00:00
|
|
|
#include <getopt.h>
|
2003-04-14 01:19:08 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
#ifndef PAGE_SIZE
|
|
|
|
#define PAGE_SIZE 4096
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ALREADY_PROCESSED ((DWORD)-1)
|
|
|
|
|
|
|
|
LPWSTR ThreadStateName [] =
|
|
|
|
{
|
|
|
|
L"Initialized",
|
|
|
|
L"Ready",
|
|
|
|
L"Running",
|
|
|
|
L"Standby",
|
|
|
|
L"Terminated",
|
|
|
|
L"Wait",
|
|
|
|
L"Transition",
|
|
|
|
L"Unknown",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2003-04-14 01:19:08 +00:00
|
|
|
void *PsaiMalloc(SIZE_T size)
|
|
|
|
{
|
|
|
|
void * pBuf = NULL;
|
|
|
|
NTSTATUS nErrCode;
|
|
|
|
|
|
|
|
nErrCode = NtAllocateVirtualMemory
|
|
|
|
(
|
|
|
|
NtCurrentProcess(),
|
|
|
|
&pBuf,
|
|
|
|
0,
|
|
|
|
(PULONG)&size,
|
|
|
|
MEM_COMMIT,
|
|
|
|
PAGE_READWRITE
|
|
|
|
);
|
|
|
|
|
|
|
|
if(NT_SUCCESS(nErrCode)) return pBuf;
|
|
|
|
else return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PsaiFree(void *ptr)
|
|
|
|
{
|
|
|
|
ULONG nSize = 0;
|
2001-11-04 21:53:20 +00:00
|
|
|
|
2003-04-14 01:19:08 +00:00
|
|
|
NtFreeVirtualMemory(NtCurrentProcess(), &ptr, &nSize, MEM_RELEASE);
|
|
|
|
}
|
2001-11-04 21:53:20 +00:00
|
|
|
|
|
|
|
int STDCALL PrintBanner (VOID)
|
|
|
|
{
|
|
|
|
printf ("ReactOS "KERNEL_RELEASE_STR" T(ask)List\n");
|
|
|
|
printf ("Copyright (c) 2000,2001 Emanuele Aliberti\n\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2003-04-22 03:20:25 +00:00
|
|
|
int STDCALL PrintSynopsys (int nRetVal)
|
2001-11-04 21:53:20 +00:00
|
|
|
{
|
|
|
|
PrintBanner ();
|
|
|
|
printf ("Usage: tlist [-t | PID | -l]\n\n"
|
|
|
|
" -t print the task list tree\n"
|
|
|
|
" PID print module information for this ID\n"
|
|
|
|
" -l print license information\n");
|
2003-04-22 03:20:25 +00:00
|
|
|
return nRetVal;
|
2001-11-04 21:53:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int STDCALL PrintLicense (VOID)
|
|
|
|
{
|
|
|
|
PrintBanner ();
|
|
|
|
printf (
|
|
|
|
"This program is free software; you can redistribute it and/or modify\n"
|
|
|
|
"it under the terms of the GNU General Public License as published by\n"
|
|
|
|
"the Free Software Foundation; either version 2 of the License, or\n"
|
|
|
|
"(at your option) any later version.\n\n");
|
|
|
|
printf (
|
|
|
|
"This program is distributed in the hope that it will be useful,\n"
|
|
|
|
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
|
|
|
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
|
|
|
"GNU General Public License for more details.\n\n");
|
|
|
|
printf (
|
|
|
|
"You should have received a copy of the GNU General Public License\n"
|
|
|
|
"along with this program; if not, write to the Free Software\n"
|
|
|
|
"Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL STDCALL AcquirePrivileges (VOID)
|
|
|
|
{
|
|
|
|
/* TODO: implement it */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int STDCALL
|
|
|
|
ProcessHasDescendants (
|
2005-05-04 18:53:47 +00:00
|
|
|
HANDLE Pid,
|
|
|
|
PSYSTEM_PROCESS_INFORMATION pInfo
|
2001-11-04 21:53:20 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
LONG Count = 0;
|
|
|
|
|
|
|
|
if (NULL == pInfo) return 0;
|
|
|
|
do {
|
|
|
|
|
2005-05-04 18:53:47 +00:00
|
|
|
if (ALREADY_PROCESSED != (DWORD)pInfo->InheritedFromUniqueProcessId)
|
2001-11-04 21:53:20 +00:00
|
|
|
{
|
2005-05-04 18:53:47 +00:00
|
|
|
if ((Pid != (HANDLE)pInfo->UniqueProcessId) && (Pid == (HANDLE)pInfo->InheritedFromUniqueProcessId))
|
2001-11-04 21:53:20 +00:00
|
|
|
{
|
|
|
|
++ Count;
|
|
|
|
}
|
|
|
|
}
|
2005-05-04 18:53:47 +00:00
|
|
|
pInfo = (PSYSTEM_PROCESS_INFORMATION)((PBYTE)pInfo + pInfo->NextEntryOffset);
|
2001-11-04 21:53:20 +00:00
|
|
|
|
2005-05-04 18:53:47 +00:00
|
|
|
} while (0 != pInfo->NextEntryOffset);
|
2001-11-04 21:53:20 +00:00
|
|
|
|
|
|
|
return Count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL STDCALL
|
|
|
|
GetProcessInfo (
|
2005-05-04 18:53:47 +00:00
|
|
|
PSYSTEM_PROCESS_INFORMATION pInfo,
|
2001-11-04 21:53:20 +00:00
|
|
|
LPWSTR * Module,
|
|
|
|
LPWSTR * Title
|
|
|
|
)
|
|
|
|
{
|
2005-05-04 18:53:47 +00:00
|
|
|
*Module = (pInfo->ImageName.Length ? pInfo->ImageName.Buffer : L"System process");
|
2001-11-04 21:53:20 +00:00
|
|
|
*Title = L""; /* TODO: check if the process has any window */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int STDCALL PrintProcessInfoDepth (
|
2005-05-04 18:53:47 +00:00
|
|
|
PSYSTEM_PROCESS_INFORMATION pInfo,
|
2001-11-04 21:53:20 +00:00
|
|
|
LONG Depth
|
|
|
|
)
|
|
|
|
{
|
|
|
|
INT d = 0;
|
|
|
|
LPWSTR Module = L"";
|
|
|
|
LPWSTR Title = L"";
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
for (d = 0; d < Depth; d ++) printf (" ");
|
|
|
|
GetProcessInfo (pInfo, & Module, & Title);
|
|
|
|
wprintf (
|
|
|
|
L"%s (%d, %d) %s\n",
|
|
|
|
Module,
|
2005-05-04 18:53:47 +00:00
|
|
|
pInfo->UniqueProcessId,
|
|
|
|
pInfo->InheritedFromUniqueProcessId,
|
2001-11-04 21:53:20 +00:00
|
|
|
Title
|
|
|
|
);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int STDCALL
|
|
|
|
PrintProcessAndDescendants (
|
2005-05-04 18:53:47 +00:00
|
|
|
PSYSTEM_PROCESS_INFORMATION pInfo,
|
|
|
|
PSYSTEM_PROCESS_INFORMATION pInfoBase,
|
2001-11-04 21:53:20 +00:00
|
|
|
LONG Depth
|
|
|
|
)
|
|
|
|
{
|
2005-05-04 18:53:47 +00:00
|
|
|
HANDLE Pid = 0;
|
2001-11-04 21:53:20 +00:00
|
|
|
|
|
|
|
if (NULL == pInfo) return EXIT_FAILURE;
|
|
|
|
/* Print current pInfo process */
|
|
|
|
PrintProcessInfoDepth (pInfo, Depth ++);
|
2005-05-04 18:53:47 +00:00
|
|
|
pInfo->InheritedFromUniqueProcessId = (HANDLE)ALREADY_PROCESSED;
|
2001-11-04 21:53:20 +00:00
|
|
|
/* Save current process' PID */
|
2005-05-04 18:53:47 +00:00
|
|
|
Pid = pInfo->UniqueProcessId;
|
2001-11-04 21:53:20 +00:00
|
|
|
/* Scan and print possible children */
|
|
|
|
do {
|
|
|
|
|
2005-05-04 18:53:47 +00:00
|
|
|
if (ALREADY_PROCESSED != (DWORD)pInfo->InheritedFromUniqueProcessId)
|
2001-11-04 21:53:20 +00:00
|
|
|
{
|
2005-05-04 18:53:47 +00:00
|
|
|
if (Pid == pInfo->InheritedFromUniqueProcessId)
|
2001-11-04 21:53:20 +00:00
|
|
|
{
|
|
|
|
if (ProcessHasDescendants (Pid, pInfoBase))
|
|
|
|
{
|
|
|
|
PrintProcessAndDescendants (
|
|
|
|
pInfo,
|
|
|
|
pInfoBase,
|
|
|
|
Depth
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PrintProcessInfoDepth (pInfo, Depth);
|
2005-05-04 18:53:47 +00:00
|
|
|
pInfo->InheritedFromUniqueProcessId = (HANDLE)ALREADY_PROCESSED;
|
2001-11-04 21:53:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-05-04 18:53:47 +00:00
|
|
|
pInfo = (PSYSTEM_PROCESS_INFORMATION)((PBYTE)pInfo + pInfo->NextEntryOffset);
|
2001-11-04 21:53:20 +00:00
|
|
|
|
2005-05-04 18:53:47 +00:00
|
|
|
} while (0 != pInfo->NextEntryOffset);
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int STDCALL PrintProcessList (BOOL DisplayTree)
|
|
|
|
{
|
2005-05-04 18:53:47 +00:00
|
|
|
PSYSTEM_PROCESS_INFORMATION pInfo = NULL;
|
|
|
|
PSYSTEM_PROCESS_INFORMATION pInfoBase = NULL;
|
2001-11-04 21:53:20 +00:00
|
|
|
LONG Length = 0;
|
|
|
|
LPWSTR Module = L"";
|
|
|
|
LPWSTR Title = L"";
|
|
|
|
|
2003-04-14 01:19:08 +00:00
|
|
|
if (!NT_SUCCESS(PsaCaptureProcessesAndThreads(&pInfoBase)))
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
pInfo = PsaWalkFirstProcess(pInfoBase);
|
|
|
|
|
|
|
|
while (pInfo)
|
|
|
|
{
|
2001-11-04 21:53:20 +00:00
|
|
|
if (FALSE == DisplayTree)
|
|
|
|
{
|
|
|
|
GetProcessInfo (pInfo, & Module, & Title);
|
|
|
|
wprintf (
|
|
|
|
L"%4d %-16s %s\n",
|
2005-05-04 18:53:47 +00:00
|
|
|
pInfo->UniqueProcessId,
|
2001-11-04 21:53:20 +00:00
|
|
|
Module,
|
|
|
|
Title,
|
2005-05-04 18:53:47 +00:00
|
|
|
pInfo->InheritedFromUniqueProcessId
|
2001-11-04 21:53:20 +00:00
|
|
|
);
|
|
|
|
}
|
2005-05-07 21:24:31 +00:00
|
|
|
else
|
2001-11-04 21:53:20 +00:00
|
|
|
{
|
2005-05-04 18:53:47 +00:00
|
|
|
if (ALREADY_PROCESSED != (DWORD)pInfo->InheritedFromUniqueProcessId)
|
2001-11-04 21:53:20 +00:00
|
|
|
{
|
|
|
|
PrintProcessAndDescendants (pInfo, pInfoBase, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-14 01:19:08 +00:00
|
|
|
pInfo = PsaWalkNextProcess(pInfo);
|
|
|
|
}
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2003-04-14 01:19:08 +00:00
|
|
|
PsaFreeCapture(pInfoBase);
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-04 18:53:47 +00:00
|
|
|
int STDCALL PrintThreads (PSYSTEM_PROCESS_INFORMATION pInfo)
|
2001-11-04 21:53:20 +00:00
|
|
|
{
|
2005-05-04 18:53:47 +00:00
|
|
|
ULONG i = 0;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
HANDLE hThread = INVALID_HANDLE_VALUE;
|
|
|
|
OBJECT_ATTRIBUTES Oa = {0};
|
|
|
|
PVOID Win32StartAddress = NULL;
|
|
|
|
THREAD_BASIC_INFORMATION tInfo = {0};
|
|
|
|
ULONG ReturnLength = 0;
|
|
|
|
PSYSTEM_THREAD_INFORMATION CurThread;
|
2001-11-04 21:53:20 +00:00
|
|
|
|
|
|
|
if (NULL == pInfo) return EXIT_FAILURE;
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2003-04-14 01:19:08 +00:00
|
|
|
CurThread = PsaWalkFirstThread(pInfo);
|
2001-11-04 21:53:20 +00:00
|
|
|
|
2005-05-04 18:53:47 +00:00
|
|
|
wprintf (L" NumberOfThreads: %d\n", pInfo->NumberOfThreads);
|
2001-11-04 21:53:20 +00:00
|
|
|
|
2005-05-04 18:53:47 +00:00
|
|
|
for (i = 0; i < pInfo->NumberOfThreads; i ++, CurThread = PsaWalkNextThread(CurThread))
|
2001-11-04 21:53:20 +00:00
|
|
|
{
|
|
|
|
Status = NtOpenThread (
|
|
|
|
& hThread,
|
|
|
|
THREAD_QUERY_INFORMATION,
|
|
|
|
& Oa,
|
2003-04-14 01:19:08 +00:00
|
|
|
& CurThread->ClientId
|
2001-11-04 21:53:20 +00:00
|
|
|
);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
Status = NtQueryInformationThread (
|
|
|
|
hThread,
|
|
|
|
ThreadBasicInformation,
|
|
|
|
(PVOID) & tInfo,
|
|
|
|
sizeof tInfo,
|
|
|
|
& ReturnLength
|
|
|
|
);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
NtClose (hThread);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = NtQueryInformationThread (
|
|
|
|
hThread,
|
|
|
|
ThreadQuerySetWin32StartAddress,
|
|
|
|
(PVOID) & Win32StartAddress,
|
|
|
|
sizeof Win32StartAddress,
|
|
|
|
& ReturnLength
|
|
|
|
);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
NtClose (hThread);
|
|
|
|
continue;
|
|
|
|
}
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
NtClose (hThread);
|
|
|
|
|
|
|
|
/* Now print the collected information */
|
|
|
|
wprintf (L" %4d Win32StartAddr:0x%08x LastErr:0x%08x State:%s\n",
|
2003-04-14 01:19:08 +00:00
|
|
|
CurThread->ClientId.UniqueThread,
|
2001-11-04 21:53:20 +00:00
|
|
|
Win32StartAddress,
|
|
|
|
0 /* FIXME: ((PTEB) tInfo.TebBaseAddress)->LastErrorValue */,
|
2005-05-04 18:53:47 +00:00
|
|
|
ThreadStateName[CurThread->ThreadState]
|
2001-11-04 21:53:20 +00:00
|
|
|
);
|
2005-05-07 21:24:31 +00:00
|
|
|
}
|
2001-11-04 21:53:20 +00:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int STDCALL PrintModules (VOID)
|
|
|
|
{
|
|
|
|
/* TODO */
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-05-04 18:53:47 +00:00
|
|
|
PSYSTEM_PROCESS_INFORMATION STDCALL
|
2001-11-04 21:53:20 +00:00
|
|
|
GetProcessInfoPid (
|
2005-05-04 18:53:47 +00:00
|
|
|
PSYSTEM_PROCESS_INFORMATION pInfoBase,
|
|
|
|
HANDLE Pid
|
2001-11-04 21:53:20 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if (NULL == pInfoBase) return NULL;
|
|
|
|
|
2003-04-14 01:19:08 +00:00
|
|
|
pInfoBase = PsaWalkFirstProcess(pInfoBase);
|
|
|
|
|
|
|
|
while(pInfoBase)
|
|
|
|
{
|
2005-05-04 18:53:47 +00:00
|
|
|
if (Pid == pInfoBase->UniqueProcessId)
|
2001-11-04 21:53:20 +00:00
|
|
|
{
|
|
|
|
return pInfoBase;
|
|
|
|
}
|
|
|
|
|
2003-04-14 01:19:08 +00:00
|
|
|
pInfoBase = PsaWalkNextProcess(pInfoBase);
|
|
|
|
}
|
2001-11-04 21:53:20 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int STDCALL PrintProcess (char * PidStr)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = 0;
|
|
|
|
HANDLE hProcess = 0;
|
|
|
|
OBJECT_ATTRIBUTES Oa = {0};
|
|
|
|
CLIENT_ID ClientId = {0, 0};
|
|
|
|
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
ClientId.UniqueProcess = (PVOID) atol (PidStr);
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
if (FALSE == AcquirePrivileges ())
|
|
|
|
{
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
Status = NtOpenProcess (
|
|
|
|
& hProcess,
|
|
|
|
PROCESS_QUERY_INFORMATION,
|
|
|
|
& Oa,
|
|
|
|
& ClientId
|
|
|
|
);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
ULONG ReturnLength = 0;
|
|
|
|
PROCESS_BASIC_INFORMATION PsBasic;
|
|
|
|
VM_COUNTERS PsVm;
|
2005-05-04 18:53:47 +00:00
|
|
|
PSYSTEM_PROCESS_INFORMATION pInfo = NULL;
|
|
|
|
PSYSTEM_PROCESS_INFORMATION pInfoBase = NULL;
|
2001-11-04 21:53:20 +00:00
|
|
|
LONG pInfoBaseLength = 0;
|
|
|
|
LPWSTR Module = L"";
|
|
|
|
LPWSTR Title = L"";
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
Status = NtQueryInformationProcess (
|
|
|
|
hProcess,
|
|
|
|
ProcessBasicInformation,
|
|
|
|
& PsBasic,
|
|
|
|
sizeof (PsBasic),
|
|
|
|
& ReturnLength
|
|
|
|
);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
Status = NtQueryInformationProcess (
|
|
|
|
hProcess,
|
|
|
|
ProcessVmCounters,
|
|
|
|
& PsVm,
|
|
|
|
sizeof (PsVm),
|
|
|
|
& ReturnLength
|
|
|
|
);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2003-04-14 01:19:08 +00:00
|
|
|
if (!NT_SUCCESS(PsaCaptureProcessesAndThreads (&pInfoBase)))
|
|
|
|
return EXIT_FAILURE;
|
2001-11-04 21:53:20 +00:00
|
|
|
|
2005-05-04 18:53:47 +00:00
|
|
|
pInfo = GetProcessInfoPid (pInfoBase, ClientId.UniqueProcess);
|
2001-11-04 21:53:20 +00:00
|
|
|
if (NULL == pInfo) return EXIT_FAILURE;
|
|
|
|
|
|
|
|
GetProcessInfo (pInfo, & Module, & Title);
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
wprintf (L"%4d %s\n", ClientId.UniqueProcess, Module);
|
|
|
|
#if 0
|
|
|
|
printf (" CWD: %s\n", ""); /* it won't appear if empty */
|
|
|
|
printf (" CmdLine: %s\n", ""); /* it won't appear if empty */
|
|
|
|
#endif
|
|
|
|
printf (" VirtualSize: %5ld kb PeakVirtualSize: %5ld kb\n",
|
|
|
|
((LONG) PsVm.VirtualSize / 1024),
|
|
|
|
((LONG) PsVm.PeakVirtualSize / 1024)
|
|
|
|
);
|
|
|
|
printf (" WorkingSetSize: %5ld kb PeakWorkingSetSize: %5ld kb\n",
|
|
|
|
((LONG) PsVm.WorkingSetSize / 1024),
|
|
|
|
((LONG) PsVm.PeakWorkingSetSize / 1024)
|
|
|
|
);
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
PrintThreads (pInfo);
|
|
|
|
|
|
|
|
PrintModules ();
|
2003-04-14 01:19:08 +00:00
|
|
|
|
|
|
|
PsaFreeCapture(pInfoBase);
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
NtClose (hProcess);
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2001-11-04 21:53:20 +00:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main (int argc, char * argv [])
|
|
|
|
{
|
2003-04-22 03:20:25 +00:00
|
|
|
int c;
|
|
|
|
|
|
|
|
if(1 == argc) return PrintProcessList(FALSE);
|
|
|
|
|
|
|
|
while((c = getopt(argc, argv, "tl")) != -1)
|
|
|
|
{
|
|
|
|
switch(c)
|
2001-11-04 21:53:20 +00:00
|
|
|
{
|
2003-04-22 03:20:25 +00:00
|
|
|
case 't': return PrintProcessList(TRUE);
|
|
|
|
case 'l': return PrintLicense();
|
|
|
|
default: return PrintSynopsys(EXIT_FAILURE);
|
2001-11-04 21:53:20 +00:00
|
|
|
}
|
2003-04-22 03:20:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(isdigit(argv[optind][0]))
|
|
|
|
return PrintProcess (argv[1]);
|
|
|
|
|
|
|
|
return PrintSynopsys(EXIT_SUCCESS);
|
2001-11-04 21:53:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|