ReactOS  0.4.14-dev-358-gbef841c
tlist.c File Reference
#include <reactos/buildno.h>
#include <windows.h>
#include <ndk/ntndk.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <epsapi/epsapi.h>
#include <getopt.h>
Include dependency graph for tlist.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 
#define PAGE_SIZE   4096
 
#define ALREADY_PROCESSED   ((DWORD)-1)
 

Functions

voidPsaiMalloc (SIZE_T size)
 
void PsaiFree (void *ptr)
 
int WINAPI PrintBanner (VOID)
 
int WINAPI PrintSynopsys (int nRetVal)
 
int WINAPI PrintLicense (VOID)
 
BOOL WINAPI AcquirePrivileges (VOID)
 
int WINAPI ProcessHasDescendants (HANDLE Pid, PSYSTEM_PROCESS_INFORMATION pInfo)
 
BOOL WINAPI GetProcessInfo (PSYSTEM_PROCESS_INFORMATION pInfo, LPWSTR *Module, LPWSTR *Title)
 
int WINAPI PrintProcessInfoDepth (PSYSTEM_PROCESS_INFORMATION pInfo, LONG Depth)
 
int WINAPI PrintProcessAndDescendants (PSYSTEM_PROCESS_INFORMATION pInfo, PSYSTEM_PROCESS_INFORMATION pInfoBase, LONG Depth)
 
int WINAPI PrintProcessList (BOOL DisplayTree)
 
int WINAPI PrintThreads (PSYSTEM_PROCESS_INFORMATION pInfo)
 
int WINAPI PrintModules (VOID)
 
PSYSTEM_PROCESS_INFORMATION WINAPI GetProcessInfoPid (PSYSTEM_PROCESS_INFORMATION pInfoBase, HANDLE Pid)
 
int WINAPI PrintProcess (char *PidStr)
 
int main (int argc, char *argv [])
 

Variables

LPWSTR ThreadStateName []
 

Macro Definition Documentation

◆ ALREADY_PROCESSED

#define ALREADY_PROCESSED   ((DWORD)-1)

Definition at line 25 of file tlist.c.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 10 of file tlist.c.

◆ PAGE_SIZE

#define PAGE_SIZE   4096

Definition at line 22 of file tlist.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 8 of file tlist.c.

Function Documentation

◆ AcquirePrivileges()

BOOL WINAPI AcquirePrivileges ( VOID  )

Definition at line 103 of file tlist.c.

104 {
105  /* TODO: implement it */
106  return TRUE;
107 }
#define TRUE
Definition: types.h:120

Referenced by PrintProcess().

◆ GetProcessInfo()

BOOL WINAPI GetProcessInfo ( PSYSTEM_PROCESS_INFORMATION  pInfo,
LPWSTR Module,
LPWSTR Title 
)

Definition at line 136 of file tlist.c.

141 {
142  *Module = (pInfo->ImageName.Length ? pInfo->ImageName.Buffer : L"System process");
143  *Title = L""; /* TODO: check if the process has any window */
144  return TRUE;
145 }
#define TRUE
Definition: types.h:120
static const WCHAR Title[]
Definition: oid.c:1259
UNICODE_STRING ImageName
Definition: extypes.h:890
static const WCHAR L[]
Definition: oid.c:1250

Referenced by PrintProcess(), PrintProcessInfoDepth(), and PrintProcessList().

◆ GetProcessInfoPid()

PSYSTEM_PROCESS_INFORMATION WINAPI GetProcessInfoPid ( PSYSTEM_PROCESS_INFORMATION  pInfoBase,
HANDLE  Pid 
)

Definition at line 330 of file tlist.c.

334 {
335  if (NULL == pInfoBase) return NULL;
336 
337  pInfoBase = PsaWalkFirstProcess(pInfoBase);
338 
339  while(pInfoBase)
340  {
341  if (Pid == pInfoBase->UniqueProcessId)
342  {
343  return pInfoBase;
344  }
345 
346  pInfoBase = PsaWalkNextProcess(pInfoBase);
347  }
348 
349  return NULL;
350 }
PSYSTEM_PROCESSES FASTCALL PsaWalkNextProcess(IN PSYSTEM_PROCESSES CurrentProcess)
smooth NULL
Definition: ftsmooth.c:416
PSYSTEM_PROCESSES FASTCALL PsaWalkFirstProcess(IN PSYSTEM_PROCESSES ProcessesAndThreads)

Referenced by PrintProcess().

◆ main()

int main ( int argc  ,
char argv[] 
)

hosttype.c Copyright (C) 2002 by Brian Palmer brian.nosp@m.p@sg.nosp@m.inet..nosp@m.com

Definition at line 442 of file tlist.c.

443 {
444  int c;
445 
446  if(1 == argc) return PrintProcessList(FALSE);
447 
448  while((c = getopt(argc, argv, "tl")) != -1)
449  {
450  switch(c)
451  {
452  case 't': return PrintProcessList(TRUE);
453  case 'l': return PrintLicense();
454  default: return PrintSynopsys(EXIT_FAILURE);
455  }
456  }
457 
458  if(isdigit(argv[optind][0]))
459  return PrintProcess (argv[1]);
460 
461  return PrintSynopsys(EXIT_SUCCESS);
462 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
int optind
Definition: getopt.c:47
int WINAPI PrintProcess(char *PidStr)
Definition: tlist.c:352
#define argv
Definition: mplay32.c:18
int WINAPI PrintLicense(VOID)
Definition: tlist.c:83
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
#define isdigit(c)
Definition: acclib.h:68
const GLubyte * c
Definition: glext.h:8905
#define EXIT_FAILURE
Definition: jerror.c:33
int getopt(int nargc, char *const *nargv, const char *ostr)
Definition: getopt.c:55
int WINAPI PrintSynopsys(int nRetVal)
Definition: tlist.c:73
int WINAPI PrintProcessList(BOOL DisplayTree)
Definition: tlist.c:212
#define c
Definition: ke_i.h:80

◆ PrintBanner()

int WINAPI PrintBanner ( VOID  )

Definition at line 66 of file tlist.c.

67 {
68  printf ("ReactOS "KERNEL_VERSION_STR" T(ask)List\n");
69  printf ("Copyright (c) 2000,2001 Emanuele Aliberti\n\n");
70  return EXIT_SUCCESS;
71 }
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
#define printf
Definition: config.h:203

Referenced by PrintLicense(), and PrintSynopsys().

◆ PrintLicense()

int WINAPI PrintLicense ( VOID  )

Definition at line 83 of file tlist.c.

84 {
85  PrintBanner ();
86  printf (
87 "This program is free software; you can redistribute it and/or modify\n"
88 "it under the terms of the GNU General Public License as published by\n"
89 "the Free Software Foundation; either version 2 of the License, or\n"
90 "(at your option) any later version.\n\n");
91  printf (
92 "This program is distributed in the hope that it will be useful,\n"
93 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
94 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
95 "GNU General Public License for more details.\n\n");
96  printf (
97 "You should have received a copy of the GNU General Public License\n"
98 "along with this program; if not, write to the Free Software\n"
99 "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n");
100  return EXIT_SUCCESS;
101 }
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
int WINAPI PrintBanner(VOID)
Definition: tlist.c:66
#define printf
Definition: config.h:203

Referenced by main().

◆ PrintModules()

int WINAPI PrintModules ( VOID  )

Definition at line 323 of file tlist.c.

324 {
325  /* TODO */
326  return EXIT_SUCCESS;
327 }
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55

Referenced by PrintProcess().

◆ PrintProcess()

int WINAPI PrintProcess ( char PidStr)

Definition at line 352 of file tlist.c.

353 {
354  NTSTATUS Status = 0;
355  HANDLE hProcess = 0;
356  OBJECT_ATTRIBUTES Oa = {0};
357  CLIENT_ID ClientId = {0, 0};
358 
359 
361 
362  if (FALSE == AcquirePrivileges ())
363  {
364  return EXIT_FAILURE;
365  }
366 
368  & hProcess,
370  & Oa,
371  & ClientId
372  );
373  if (NT_SUCCESS(Status))
374  {
375  ULONG ReturnLength = 0;
377  VM_COUNTERS PsVm;
379  PSYSTEM_PROCESS_INFORMATION pInfoBase = NULL;
380  LPWSTR Module = L"";
381  LPWSTR Title = L"";
382 
384  hProcess,
386  & PsBasic,
387  sizeof (PsBasic),
388  & ReturnLength
389  );
390  if (!NT_SUCCESS(Status))
391  {
392  return EXIT_FAILURE;
393  }
395  hProcess,
397  & PsVm,
398  sizeof (PsVm),
399  & ReturnLength
400  );
401  if (!NT_SUCCESS(Status))
402  {
403  return EXIT_FAILURE;
404  }
405 
406  if (!NT_SUCCESS(PsaCaptureProcessesAndThreads (&pInfoBase)))
407  return EXIT_FAILURE;
408 
409  pInfo = GetProcessInfoPid (pInfoBase, ClientId.UniqueProcess);
410  if (NULL == pInfo) return EXIT_FAILURE;
411 
412  GetProcessInfo (pInfo, & Module, & Title);
413 
414  wprintf (L"%4d %s\n", HandleToUlong(ClientId.UniqueProcess), Module);
415 #if 0
416  printf (" CWD: %s\n", ""); /* it won't appear if empty */
417  printf (" CmdLine: %s\n", ""); /* it won't appear if empty */
418 #endif
419  printf (" VirtualSize: %5ld kb PeakVirtualSize: %5ld kb\n",
420  ((LONG) PsVm.VirtualSize / 1024),
421  ((LONG) PsVm.PeakVirtualSize / 1024)
422  );
423  printf (" WorkingSetSize: %5ld kb PeakWorkingSetSize: %5ld kb\n",
424  ((LONG) PsVm.WorkingSetSize / 1024),
425  ((LONG) PsVm.PeakWorkingSetSize / 1024)
426  );
427 
428  PrintThreads (pInfo);
429 
430  PrintModules ();
431 
432  PsaFreeCapture(pInfoBase);
433 
434  NtClose (hProcess);
435 
436  return EXIT_SUCCESS;
437  }
438  return EXIT_FAILURE;
439 }
BOOL WINAPI GetProcessInfo(PSYSTEM_PROCESS_INFORMATION pInfo, LPWSTR *Module, LPWSTR *Title)
Definition: tlist.c:136
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
SIZE_T PeakVirtualSize
Definition: winternl.h:1605
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:158
PSYSTEM_PROCESS_INFORMATION WINAPI GetProcessInfoPid(PSYSTEM_PROCESS_INFORMATION pInfoBase, HANDLE Pid)
Definition: tlist.c:330
LONG NTSTATUS
Definition: precomp.h:26
#define HandleToUlong(h)
Definition: basetsd.h:79
NTSTATUS NTAPI NtQueryInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:59
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
int WINAPI PrintModules(VOID)
Definition: tlist.c:323
SIZE_T VirtualSize
Definition: winternl.h:1606
#define wprintf(...)
Definition: whoami.c:18
HANDLE UniqueProcess
Definition: compat.h:482
NTSTATUS NTAPI NtOpenProcess(OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId)
Definition: process.c:1440
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI AcquirePrivileges(VOID)
Definition: tlist.c:103
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1176
static const WCHAR Title[]
Definition: oid.c:1259
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define UlongToHandle(ul)
Definition: basetsd.h:97
VOID NTAPI PsaFreeCapture(IN PVOID Capture)
Definition: processes.c:188
#define EXIT_FAILURE
Definition: jerror.c:33
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
NTSTATUS NTAPI PsaCaptureProcessesAndThreads(OUT PSYSTEM_PROCESSES *ProcessesAndThreads)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
SIZE_T WorkingSetSize
Definition: winternl.h:1609
int WINAPI PrintThreads(PSYSTEM_PROCESS_INFORMATION pInfo)
Definition: tlist.c:254
unsigned int ULONG
Definition: retypes.h:1
SIZE_T PeakWorkingSetSize
Definition: winternl.h:1608
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define printf
Definition: config.h:203

Referenced by main().

◆ PrintProcessAndDescendants()

int WINAPI PrintProcessAndDescendants ( PSYSTEM_PROCESS_INFORMATION  pInfo,
PSYSTEM_PROCESS_INFORMATION  pInfoBase,
LONG  Depth 
)

Definition at line 169 of file tlist.c.

174 {
175  HANDLE Pid = 0;
176 
177  if (NULL == pInfo) return EXIT_FAILURE;
178  /* Print current pInfo process */
179  PrintProcessInfoDepth (pInfo, Depth ++);
181  /* Save current process' PID */
182  Pid = pInfo->UniqueProcessId;
183  /* Scan and print possible children */
184  do {
185 
187  {
188  if (Pid == pInfo->InheritedFromUniqueProcessId)
189  {
190  if (ProcessHasDescendants (Pid, pInfoBase))
191  {
193  pInfo,
194  pInfoBase,
195  Depth
196  );
197  }
198  else
199  {
200  PrintProcessInfoDepth (pInfo, Depth);
202  }
203  }
204  }
205  pInfo = (PSYSTEM_PROCESS_INFORMATION)((PBYTE)pInfo + pInfo->NextEntryOffset);
206 
207  } while (0 != pInfo->NextEntryOffset);
208 
209  return EXIT_SUCCESS;
210 }
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:656
#define HandleToUlong(h)
Definition: basetsd.h:79
#define ALREADY_PROCESSED
Definition: tlist.c:25
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
smooth NULL
Definition: ftsmooth.c:416
#define UlongToHandle(ul)
Definition: basetsd.h:97
int WINAPI PrintProcessInfoDepth(PSYSTEM_PROCESS_INFORMATION pInfo, LONG Depth)
Definition: tlist.c:147
#define EXIT_FAILURE
Definition: jerror.c:33
HANDLE InheritedFromUniqueProcessId
Definition: extypes.h:893
int WINAPI ProcessHasDescendants(HANDLE Pid, PSYSTEM_PROCESS_INFORMATION pInfo)
Definition: tlist.c:110
int WINAPI PrintProcessAndDescendants(PSYSTEM_PROCESS_INFORMATION pInfo, PSYSTEM_PROCESS_INFORMATION pInfoBase, LONG Depth)
Definition: tlist.c:169
struct _SYSTEM_PROCESS_INFORMATION * PSYSTEM_PROCESS_INFORMATION
BYTE * PBYTE
Definition: pedump.c:66

Referenced by PrintProcessList().

◆ PrintProcessInfoDepth()

int WINAPI PrintProcessInfoDepth ( PSYSTEM_PROCESS_INFORMATION  pInfo,
LONG  Depth 
)

Definition at line 147 of file tlist.c.

151 {
152  INT d = 0;
153  LPWSTR Module = L"";
154  LPWSTR Title = L"";
155 
156  for (d = 0; d < Depth; d ++) printf (" ");
157  GetProcessInfo (pInfo, & Module, & Title);
158  wprintf (
159  L"%s (%d, %d) %s\n",
160  Module,
163  Title
164  );
165  return EXIT_SUCCESS;
166 }
BOOL WINAPI GetProcessInfo(PSYSTEM_PROCESS_INFORMATION pInfo, LPWSTR *Module, LPWSTR *Title)
Definition: tlist.c:136
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:656
#define HandleToUlong(h)
Definition: basetsd.h:79
#define wprintf(...)
Definition: whoami.c:18
int32_t INT
Definition: typedefs.h:56
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
static const WCHAR Title[]
Definition: oid.c:1259
#define d
Definition: ke_i.h:81
static const WCHAR L[]
Definition: oid.c:1250
HANDLE InheritedFromUniqueProcessId
Definition: extypes.h:893
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define printf
Definition: config.h:203

Referenced by PrintProcessAndDescendants().

◆ PrintProcessList()

int WINAPI PrintProcessList ( BOOL  DisplayTree)

Definition at line 212 of file tlist.c.

213 {
215  PSYSTEM_PROCESS_INFORMATION pInfoBase = NULL;
216  LPWSTR Module = L"";
217  LPWSTR Title = L"";
218 
219  if (!NT_SUCCESS(PsaCaptureProcessesAndThreads(&pInfoBase)))
220  return EXIT_FAILURE;
221 
222  pInfo = PsaWalkFirstProcess(pInfoBase);
223 
224  while (pInfo)
225  {
226  if (FALSE == DisplayTree)
227  {
228  GetProcessInfo (pInfo, & Module, & Title);
229  wprintf (
230  L"%4d %-16s %s (%04d)\n",
232  Module,
233  Title,
235  );
236  }
237  else
238  {
240  {
241  PrintProcessAndDescendants (pInfo, pInfoBase, 0);
242  }
243  }
244 
245  pInfo = PsaWalkNextProcess(pInfo);
246  }
247 
248  PsaFreeCapture(pInfoBase);
249 
250  return EXIT_SUCCESS;
251 }
BOOL WINAPI GetProcessInfo(PSYSTEM_PROCESS_INFORMATION pInfo, LPWSTR *Module, LPWSTR *Title)
Definition: tlist.c:136
#define HandleToUlong(h)
Definition: basetsd.h:79
#define ALREADY_PROCESSED
Definition: tlist.c:25
PSYSTEM_PROCESSES FASTCALL PsaWalkNextProcess(IN PSYSTEM_PROCESSES CurrentProcess)
#define wprintf(...)
Definition: whoami.c:18
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
smooth NULL
Definition: ftsmooth.c:416
PSYSTEM_PROCESSES FASTCALL PsaWalkFirstProcess(IN PSYSTEM_PROCESSES ProcessesAndThreads)
static const WCHAR Title[]
Definition: oid.c:1259
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI PsaFreeCapture(IN PVOID Capture)
Definition: processes.c:188
#define EXIT_FAILURE
Definition: jerror.c:33
NTSTATUS NTAPI PsaCaptureProcessesAndThreads(OUT PSYSTEM_PROCESSES *ProcessesAndThreads)
static const WCHAR L[]
Definition: oid.c:1250
HANDLE InheritedFromUniqueProcessId
Definition: extypes.h:893
int WINAPI PrintProcessAndDescendants(PSYSTEM_PROCESS_INFORMATION pInfo, PSYSTEM_PROCESS_INFORMATION pInfoBase, LONG Depth)
Definition: tlist.c:169
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by main().

◆ PrintSynopsys()

int WINAPI PrintSynopsys ( int  nRetVal)

Definition at line 73 of file tlist.c.

74 {
75  PrintBanner ();
76  printf ("Usage: tlist [-t | PID | -l]\n\n"
77  " -t print the task list tree\n"
78  " PID print module information for this ID\n"
79  " -l print license information\n");
80  return nRetVal;
81 }
int WINAPI PrintBanner(VOID)
Definition: tlist.c:66
#define printf
Definition: config.h:203

Referenced by main().

◆ PrintThreads()

int WINAPI PrintThreads ( PSYSTEM_PROCESS_INFORMATION  pInfo)

Definition at line 254 of file tlist.c.

255 {
256  ULONG i = 0;
259  OBJECT_ATTRIBUTES Oa = {0};
260  PVOID Win32StartAddress = NULL;
261  THREAD_BASIC_INFORMATION tInfo = {0};
262  ULONG ReturnLength = 0;
263  PSYSTEM_THREAD_INFORMATION CurThread;
264 
265  if (NULL == pInfo) return EXIT_FAILURE;
266 
267  CurThread = PsaWalkFirstThread(pInfo);
268 
269  wprintf (L" NumberOfThreads: %d\n", pInfo->NumberOfThreads);
270 
271  for (i = 0; i < pInfo->NumberOfThreads; i ++, CurThread = PsaWalkNextThread(CurThread))
272  {
273  Status = NtOpenThread (
274  & hThread,
276  & Oa,
277  & CurThread->ClientId
278  );
279  if (!NT_SUCCESS(Status))
280  {
281  continue;
282  }
283 
285  hThread,
287  (PVOID) & tInfo,
288  sizeof tInfo,
289  & ReturnLength
290  );
291  if (!NT_SUCCESS(Status))
292  {
293  NtClose (hThread);
294  continue;
295  }
296 
298  hThread,
300  (PVOID) & Win32StartAddress,
301  sizeof Win32StartAddress,
302  & ReturnLength
303  );
304  if (!NT_SUCCESS(Status))
305  {
306  NtClose (hThread);
307  continue;
308  }
309 
310  NtClose (hThread);
311 
312  /* Now print the collected information */
313  wprintf (L" %4d Win32StartAddr:0x%p LastErr:0x%08x State:%s\n",
314  HandleToUlong(CurThread->ClientId.UniqueThread),
315  Win32StartAddress,
316  0 /* FIXME: ((PTEB) tInfo.TebBaseAddress)->LastErrorValue */,
317  ThreadStateName[CurThread->ThreadState]
318  );
319  }
320  return EXIT_SUCCESS;
321 }
LPWSTR ThreadStateName[]
Definition: tlist.c:27
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
NTSTATUS NTAPI NtOpenThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId OPTIONAL)
Definition: thread.c:1013
LONG NTSTATUS
Definition: precomp.h:26
#define HandleToUlong(h)
Definition: basetsd.h:79
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define wprintf(...)
Definition: whoami.c:18
PSYSTEM_THREADS FASTCALL PsaWalkNextThread(IN PSYSTEM_THREADS CurrentThread)
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PSYSTEM_THREADS FASTCALL PsaWalkFirstThread(IN PSYSTEM_PROCESSES CurrentProcess)
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define EXIT_FAILURE
Definition: jerror.c:33
NTSTATUS NTAPI NtQueryInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, OUT PVOID ThreadInformation, IN ULONG ThreadInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:2497
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
HANDLE hThread
Definition: wizard.c:27
#define THREAD_QUERY_INFORMATION
Definition: pstypes.h:141
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by PrintProcess().

◆ ProcessHasDescendants()

int WINAPI ProcessHasDescendants ( HANDLE  Pid,
PSYSTEM_PROCESS_INFORMATION  pInfo 
)

Definition at line 110 of file tlist.c.

114 {
115  LONG Count = 0;
116 
117  if (NULL == pInfo) return 0;
118  do {
119 
121  {
122  if ((Pid != (HANDLE)pInfo->UniqueProcessId) && (Pid == (HANDLE)pInfo->InheritedFromUniqueProcessId))
123  {
124  ++ Count;
125  }
126  }
127  pInfo = (PSYSTEM_PROCESS_INFORMATION)((PBYTE)pInfo + pInfo->NextEntryOffset);
128 
129  } while (0 != pInfo->NextEntryOffset);
130 
131  return Count;
132 }
#define HandleToUlong(h)
Definition: basetsd.h:79
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define ALREADY_PROCESSED
Definition: tlist.c:25
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
HANDLE InheritedFromUniqueProcessId
Definition: extypes.h:893
struct _SYSTEM_PROCESS_INFORMATION * PSYSTEM_PROCESS_INFORMATION
BYTE * PBYTE
Definition: pedump.c:66

Referenced by PrintProcessAndDescendants().

◆ PsaiFree()

void PsaiFree ( void ptr)

Definition at line 59 of file tlist.c.

60 {
61  SIZE_T nSize = 0;
62 
64 }
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2031
static PVOID ptr
Definition: dispmode.c:27
#define NtCurrentProcess()
Definition: nt_native.h:1657
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define MEM_RELEASE
Definition: nt_native.h:1316
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5090

◆ PsaiMalloc()

void* PsaiMalloc ( SIZE_T  size)

Definition at line 40 of file tlist.c.

41 {
42  void * pBuf = NULL;
43  NTSTATUS nErrCode;
44 
45  nErrCode = NtAllocateVirtualMemory
46  (
48  &pBuf,
49  0,
50  &size,
51  MEM_COMMIT,
53  );
54 
55  if(NT_SUCCESS(nErrCode)) return pBuf;
56  else return NULL;
57 }
LONG NTSTATUS
Definition: precomp.h:26
#define MEM_COMMIT
Definition: nt_native.h:1313
smooth NULL
Definition: ftsmooth.c:416
#define NtCurrentProcess()
Definition: nt_native.h:1657
GLsizeiptr size
Definition: glext.h:5919
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtAllocateVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UBaseAddress, IN ULONG_PTR ZeroBits, IN OUT PSIZE_T URegionSize, IN ULONG AllocationType, IN ULONG Protect)
Definition: virtual.c:4367
#define PAGE_READWRITE
Definition: nt_native.h:1304

Variable Documentation

◆ ThreadStateName

LPWSTR ThreadStateName[]
Initial value:
=
{
L"Initialized",
L"Ready",
L"Running",
L"Standby",
L"Terminated",
L"Wait",
L"Transition",
L"Unknown",
}
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR L[]
Definition: oid.c:1250

Definition at line 27 of file tlist.c.

Referenced by PrintThreads().