- fixed definition of IO_COUNTERS structure to make it binary compatible with Windows (and make EPSAPI enumerate threads correctly on Windows)

- cleaned up some makefiles, added dependency tracking
 - tlist now uses EPSAPI, and, incidentally, a bug has also been fixed

svn path=/trunk/; revision=4535
This commit is contained in:
KJK::Hyperion 2003-04-14 01:19:08 +00:00
parent e7940ebdad
commit 1bd4ae1455
16 changed files with 144 additions and 136 deletions

View file

@ -619,9 +619,9 @@ typedef struct _QUOTA_LIMITS
// Information class 2
typedef struct _IO_COUNTERS
{
ULONG ReadOperationCount;
ULONG WriteOperationCount;
ULONG OtherOperationCount;
LARGE_INTEGER ReadOperationCount;
LARGE_INTEGER WriteOperationCount;
LARGE_INTEGER OtherOperationCount;
LARGE_INTEGER ReadTransferCount;
LARGE_INTEGER WriteTransferCount;
LARGE_INTEGER OtherTransferCount;

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.25 2003/02/02 19:24:15 hyperion Exp $
# $Id: makefile,v 1.26 2003/04/14 01:19:06 hyperion Exp $
PATH_TO_TOP = ../..
@ -50,13 +50,11 @@ TARGET_OBJECTS = \
$(SERVICE_OBJECTS) \
$(TOKEN_OBJECTS)
TARGET_CLEAN = \
misc/*.o \
reg/*.o \
sec/*.o \
service/*.o \
token/*.o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.17 2003/04/13 03:24:26 hyperion Exp $
# $Id: makefile,v 1.18 2003/04/14 01:19:06 hyperion Exp $
PATH_TO_TOP = ../..
@ -25,10 +25,14 @@ TARGET_OBJECTS = \
label.o \
media.o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk
TARGET_FILES = misc/*.o
# EOF

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.25 2003/03/20 03:02:07 mtempel Exp $
# $Id: makefile,v 1.26 2003/04/14 01:19:06 hyperion Exp $
PATH_TO_TOP = ../..
@ -18,23 +18,28 @@ TARGET_LFLAGS = -nostartfiles -nostdlib
TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a
TARGET_OBJECTS = $(TARGET_NAME).o
MAIN_OBJECTS = main/dllmain.o
TARGET_CLEAN = main/*.o misc/*.o objects/*.o
MISC_OBJECTS = misc/stubs.o misc/stubsa.o misc/stubsw.o misc/win32k.o
OBJECTS_OBJECTS = \
objects/dc.o \
objects/line.o \
objects/pen.o \
objects/bitblt.o \
objects/text.o \
objects/region.o \
objects/brush.o \
objects/fillshap.o
TARGET_OBJECTS = $(MAIN_OBJECTS) $(MISC_OBJECTS) $(OBJECTS_OBJECTS)
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
MAIN_OBJECTS = main/dllmain.o
MISC_OBJECTS = misc/stubs.o misc/stubsa.o misc/stubsw.o misc/win32k.o
OBJECTS_OBJECTS = objects/dc.o objects/line.o objects/pen.o objects/bitblt.o objects/text.o objects/region.o objects/brush.o objects/fillshap.o
OBJECTS = $(MAIN_OBJECTS) $(MISC_OBJECTS) $(OBJECTS_OBJECTS)
$(TARGET_NAME).o: $(OBJECTS)
$(LD) -r $(OBJECTS) -o $(TARGET_NAME).o
include $(TOOLS_PATH)/depend.mk
# EOF

View file

@ -14,6 +14,11 @@ TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk

View file

@ -14,6 +14,11 @@ TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.62 2003/04/02 00:23:12 hyperion Exp $
# $Id: makefile,v 1.63 2003/04/14 01:19:06 hyperion Exp $
PATH_TO_TOP = ../..
@ -98,11 +98,14 @@ TARGET_OBJECTS = $(MISC_OBJECTS) $(FILE_OBJECTS) $(THREAD_OBJECTS) \
#$(NLS_OBJECTS)
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk
$(TARGET_NAME).coff: errcodes.rc
errcodes.rc: $(TARGET_NAME).mc

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.8 2003/02/02 19:24:15 hyperion Exp $
# $Id: makefile,v 1.9 2003/04/14 01:19:07 hyperion Exp $
PATH_TO_TOP = ../..
@ -20,23 +20,18 @@ TARGET_CFLAGS = \
TARGET_LFLAGS = -nostartfiles -nostdlib
TARGET_OBJECTS = $(TARGET_NAME).o
MISC_OBJECTS = \
misc/dllmain.o misc/event.o misc/helpers.o \
misc/sndrcv.o misc/stubs.o
TARGET_CLEAN = misc/*.o
TARGET_OBJECTS = $(MISC_OBJECTS)
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
MISC_OBJECTS = \
misc/dllmain.o misc/event.o misc/helpers.o \
misc/sndrcv.o misc/stubs.o
OBJECTS = $(MISC_OBJECTS)
$(TARGET_NAME).o: $(OBJECTS)
$(LD) -r $(OBJECTS) -o $(TARGET_NAME).o
include $(TOOLS_PATH)/depend.mk
# EOF

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.6 2003/04/13 03:24:26 hyperion Exp $
# $Id: makefile,v 1.7 2003/04/14 01:19:07 hyperion Exp $
PATH_TO_TOP = ../..
@ -20,8 +20,12 @@ TARGET_OBJECTS = \
misc/stubs.o \
misc/win32.o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk
# EOF

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.11 2003/02/02 19:24:16 hyperion Exp $
# $Id: Makefile,v 1.12 2003/04/14 01:19:07 hyperion Exp $
PATH_TO_TOP = ../..
@ -19,14 +19,6 @@ TARGET_CFLAGS = \
TARGET_LFLAGS = -nostartfiles -nostdlib
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CLEAN = controls/*.o misc/*.o windows/*.o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
CONTROLS_OBJECTS = \
controls/combobox.o \
controls/listbox.o \
@ -72,12 +64,17 @@ WINDOWS_OBJECTS = \
windows/rect.o \
windows/text.o
OBJECTS = \
TARGET_OBJECTS = \
$(MISC_OBJECTS) \
$(WINDOWS_OBJECTS) \
$(CONTROLS_OBJECTS)
$(TARGET_NAME).o: $(OBJECTS)
$(LD) -r $(OBJECTS) -o $(TARGET_NAME).o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk
# EOF

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.10 2003/02/02 19:24:16 hyperion Exp $
# $Id: makefile,v 1.11 2003/04/14 01:19:07 hyperion Exp $
PATH_TO_TOP = ../..
@ -26,10 +26,12 @@ TARGET_OBJECTS = \
misc/event.o misc/handle.o misc/ns.o \
misc/sndrcv.o misc/stubs.o misc/upcall.o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
TARGET_CLEAN = misc/*.o
include $(TOOLS_PATH)/depend.mk
# EOF

View file

@ -21,6 +21,10 @@ TARGET_SDKLIBS = ntdll.a kernel32.a ws2_32.a
TARGET_OBJECTS = $(TARGET_NAME).o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk

View file

@ -14,6 +14,10 @@ TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.3 2003/04/13 03:24:26 hyperion Exp $
# $Id: Makefile,v 1.4 2003/04/14 01:19:08 hyperion Exp $
PATH_TO_TOP = ../..
@ -14,8 +14,12 @@ TARGET_OBJECTS = \
adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zutil.o \
inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk
# EOF

View file

@ -12,12 +12,16 @@ TARGET_APPTYPE = console
TARGET_NAME = tlist
TARGET_SDKLIBS = kernel32.a user32.a ntdll.a
TARGET_SDKLIBS = epsapi.a kernel32.a user32.a ntdll.a
TARGET_OBJECTS = $(TARGET_NAME).o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk
# EOF

View file

@ -1,4 +1,4 @@
/* $Id: tlist.c,v 1.3 2003/03/31 21:03:42 hyperion Exp $
/* $Id: tlist.c,v 1.4 2003/04/14 01:19:08 hyperion Exp $
*
* ReactOS Project
* TList
@ -14,6 +14,8 @@
#include <string.h>
#include <ctype.h>
#include <epsapi.h>
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif
@ -33,7 +35,31 @@ LPWSTR ThreadStateName [] =
NULL
};
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;
NtFreeVirtualMemory(NtCurrentProcess(), &ptr, &nSize, MEM_RELEASE);
}
int STDCALL PrintBanner (VOID)
{
@ -78,56 +104,6 @@ BOOL STDCALL AcquirePrivileges (VOID)
return TRUE;
}
PSYSTEM_PROCESSES STDCALL
GetProcessAndThreadsInfo (PULONG Size)
{
NTSTATUS Status = STATUS_SUCCESS;
PSYSTEM_PROCESSES pInfo = NULL;
ULONG Length = PAGE_SIZE;
ULONG RequiredLength = 0;
while (TRUE)
{
Status = NtAllocateVirtualMemory (
NtCurrentProcess(),
(PVOID) & pInfo,
0,
& Length,
(MEM_RESERVE | MEM_COMMIT),
PAGE_READWRITE
);
if (!NT_SUCCESS(Status) || (NULL == pInfo))
{
fprintf (stderr, "%s(%d): Status = 0x%08lx\n",__FUNCTION__,__LINE__,Status);
return NULL;
}
/*
* Obtain required buffer size (well, try to...)
*/
if (NtQuerySystemInformation (
SystemProcessesAndThreadsInformation,
pInfo,
Length,
& RequiredLength
) != STATUS_INFO_LENGTH_MISMATCH)
{
break;
}
NtFreeVirtualMemory (NtCurrentProcess(), (PVOID)&pInfo, & Length, MEM_RELEASE);
Length += PAGE_SIZE;
}
if (!NT_SUCCESS(Status))
{
NtFreeVirtualMemory (NtCurrentProcess(), (PVOID)&pInfo, & Length, MEM_RELEASE);
return NULL;
}
if (NULL != Size)
{
*Size = Length;
}
return pInfo;
}
int STDCALL
ProcessHasDescendants (
ULONG Pid,
@ -239,11 +215,13 @@ int STDCALL PrintProcessList (BOOL DisplayTree)
LPWSTR Module = L"";
LPWSTR Title = L"";
if (!NT_SUCCESS(PsaCaptureProcessesAndThreads(&pInfoBase)))
return EXIT_FAILURE;
pInfo = GetProcessAndThreadsInfo (& Length);
if (NULL == pInfo) return EXIT_FAILURE;
pInfoBase = pInfo;
do {
pInfo = PsaWalkFirstProcess(pInfoBase);
while (pInfo)
{
if (FALSE == DisplayTree)
{
GetProcessInfo (pInfo, & Module, & Title);
@ -262,16 +240,11 @@ int STDCALL PrintProcessList (BOOL DisplayTree)
PrintProcessAndDescendants (pInfo, pInfoBase, 0);
}
}
(PBYTE) pInfo += pInfo->NextEntryDelta;
} while (0 != pInfo->NextEntryDelta);
pInfo = PsaWalkNextProcess(pInfo);
}
NtFreeVirtualMemory (
NtCurrentProcess(),
(PVOID) & pInfoBase,
& Length,
MEM_RELEASE
);
PsaFreeCapture(pInfoBase);
return EXIT_SUCCESS;
}
@ -279,25 +252,28 @@ int STDCALL PrintProcessList (BOOL DisplayTree)
int STDCALL PrintThreads (PSYSTEM_PROCESSES pInfo)
{
ULONG ThreadIndex = 0;
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_THREADS CurThread;
if (NULL == pInfo) return EXIT_FAILURE;
CurThread = PsaWalkFirstThread(pInfo);
wprintf (L" NumberOfThreads: %d\n", pInfo->ThreadCount);
for (ThreadIndex = 0; ThreadIndex < pInfo->ThreadCount; ThreadIndex ++)
for (i = 0; i < pInfo->ThreadCount; i ++, CurThread = PsaWalkNextThread(CurThread))
{
Status = NtOpenThread (
& hThread,
THREAD_QUERY_INFORMATION,
& Oa,
& pInfo->Threads[ThreadIndex].ClientId
& CurThread->ClientId
);
if (!NT_SUCCESS(Status))
{
@ -334,10 +310,10 @@ int STDCALL PrintThreads (PSYSTEM_PROCESSES pInfo)
/* Now print the collected information */
wprintf (L" %4d Win32StartAddr:0x%08x LastErr:0x%08x State:%s\n",
pInfo->Threads[ThreadIndex].ClientId.UniqueThread,
CurThread->ClientId.UniqueThread,
Win32StartAddress,
0 /* FIXME: ((PTEB) tInfo.TebBaseAddress)->LastErrorValue */,
ThreadStateName[pInfo->Threads[ThreadIndex].State]
ThreadStateName[CurThread->State]
);
}
return EXIT_SUCCESS;
@ -356,15 +332,18 @@ GetProcessInfoPid (
)
{
if (NULL == pInfoBase) return NULL;
do {
pInfoBase = PsaWalkFirstProcess(pInfoBase);
while(pInfoBase)
{
if (Pid == pInfoBase->ProcessId)
{
return pInfoBase;
}
(PBYTE) pInfoBase += pInfoBase->NextEntryDelta;
} while (0 != pInfoBase->NextEntryDelta);
pInfoBase = PsaWalkNextProcess(pInfoBase);
}
return NULL;
}
@ -424,8 +403,8 @@ int STDCALL PrintProcess (char * PidStr)
return EXIT_FAILURE;
}
pInfoBase = GetProcessAndThreadsInfo (& pInfoBaseLength);
if (NULL == pInfoBase) return EXIT_FAILURE;
if (!NT_SUCCESS(PsaCaptureProcessesAndThreads (&pInfoBase)))
return EXIT_FAILURE;
pInfo = GetProcessInfoPid (pInfoBase, (DWORD) ClientId.UniqueProcess);
if (NULL == pInfo) return EXIT_FAILURE;
@ -450,12 +429,7 @@ int STDCALL PrintProcess (char * PidStr)
PrintModules ();
NtFreeVirtualMemory (
NtCurrentProcess(),
(PVOID) & pInfoBase,
& pInfoBaseLength,
MEM_RELEASE
);
PsaFreeCapture(pInfoBase);
NtClose (hProcess);