From 1bd4ae14556246836f4ab6b65dea8394b95efbac Mon Sep 17 00:00:00 2001 From: "KJK::Hyperion" Date: Mon, 14 Apr 2003 01:19:08 +0000 Subject: [PATCH] - 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 --- reactos/include/ntos/zwtypes.h | 6 +- reactos/lib/advapi32/makefile | 12 ++- reactos/lib/fmifs/makefile | 8 +- reactos/lib/gdi32/makefile | 31 +++++--- reactos/lib/iphlpapi/makefile | 5 ++ reactos/lib/iprtprio/makefile | 5 ++ reactos/lib/kernel32/makefile | 5 +- reactos/lib/msafd/makefile | 19 ++--- reactos/lib/psapi/makefile | 6 +- reactos/lib/user32/Makefile | 21 +++-- reactos/lib/ws2_32/makefile | 6 +- reactos/lib/ws2help/makefile | 4 + reactos/lib/wshirda/makefile | 4 + reactos/lib/zlib/Makefile | 6 +- rosapps/sysutils/tlist/Makefile | 6 +- rosapps/sysutils/tlist/tlist.c | 136 +++++++++++++------------------- 16 files changed, 144 insertions(+), 136 deletions(-) diff --git a/reactos/include/ntos/zwtypes.h b/reactos/include/ntos/zwtypes.h index f33d4d7090c..9bd7d743a1f 100755 --- a/reactos/include/ntos/zwtypes.h +++ b/reactos/include/ntos/zwtypes.h @@ -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; diff --git a/reactos/lib/advapi32/makefile b/reactos/lib/advapi32/makefile index 8e18c5bc3fb..65b2aa57aba 100644 --- a/reactos/lib/advapi32/makefile +++ b/reactos/lib/advapi32/makefile @@ -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 + diff --git a/reactos/lib/fmifs/makefile b/reactos/lib/fmifs/makefile index 004b0e95363..60a8414f873 100644 --- a/reactos/lib/fmifs/makefile +++ b/reactos/lib/fmifs/makefile @@ -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 = ../.. @@ -24,11 +24,15 @@ TARGET_OBJECTS = \ init.o \ 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 diff --git a/reactos/lib/gdi32/makefile b/reactos/lib/gdi32/makefile index 4f6547172ed..4926758d68f 100644 --- a/reactos/lib/gdi32/makefile +++ b/reactos/lib/gdi32/makefile @@ -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 diff --git a/reactos/lib/iphlpapi/makefile b/reactos/lib/iphlpapi/makefile index 4bf95dec0ba..a30d9a62cf0 100644 --- a/reactos/lib/iphlpapi/makefile +++ b/reactos/lib/iphlpapi/makefile @@ -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 + diff --git a/reactos/lib/iprtprio/makefile b/reactos/lib/iprtprio/makefile index 14403d3be1a..66ee0c33db6 100644 --- a/reactos/lib/iprtprio/makefile +++ b/reactos/lib/iprtprio/makefile @@ -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 + diff --git a/reactos/lib/kernel32/makefile b/reactos/lib/kernel32/makefile index 432009ccd94..4b9fc02f281 100644 --- a/reactos/lib/kernel32/makefile +++ b/reactos/lib/kernel32/makefile @@ -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 diff --git a/reactos/lib/msafd/makefile b/reactos/lib/msafd/makefile index 089eb928800..bc59a4c6232 100644 --- a/reactos/lib/msafd/makefile +++ b/reactos/lib/msafd/makefile @@ -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 diff --git a/reactos/lib/psapi/makefile b/reactos/lib/psapi/makefile index 9697b7f7614..8491b0c914b 100644 --- a/reactos/lib/psapi/makefile +++ b/reactos/lib/psapi/makefile @@ -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 diff --git a/reactos/lib/user32/Makefile b/reactos/lib/user32/Makefile index a2636fb9d0d..93eba585977 100644 --- a/reactos/lib/user32/Makefile +++ b/reactos/lib/user32/Makefile @@ -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 diff --git a/reactos/lib/ws2_32/makefile b/reactos/lib/ws2_32/makefile index 52226a5b06a..2fe2d61c955 100644 --- a/reactos/lib/ws2_32/makefile +++ b/reactos/lib/ws2_32/makefile @@ -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 diff --git a/reactos/lib/ws2help/makefile b/reactos/lib/ws2help/makefile index 0756122fabd..530ed19e20e 100644 --- a/reactos/lib/ws2help/makefile +++ b/reactos/lib/ws2help/makefile @@ -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 diff --git a/reactos/lib/wshirda/makefile b/reactos/lib/wshirda/makefile index 76a240caa59..a66aa2b783a 100644 --- a/reactos/lib/wshirda/makefile +++ b/reactos/lib/wshirda/makefile @@ -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 diff --git a/reactos/lib/zlib/Makefile b/reactos/lib/zlib/Makefile index 96c12b6bdc8..4946b1b085b 100644 --- a/reactos/lib/zlib/Makefile +++ b/reactos/lib/zlib/Makefile @@ -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 diff --git a/rosapps/sysutils/tlist/Makefile b/rosapps/sysutils/tlist/Makefile index f774028de35..a20a7edc630 100644 --- a/rosapps/sysutils/tlist/Makefile +++ b/rosapps/sysutils/tlist/Makefile @@ -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 diff --git a/rosapps/sysutils/tlist/tlist.c b/rosapps/sysutils/tlist/tlist.c index e4adea200b5..e1d9b8da03a 100644 --- a/rosapps/sysutils/tlist/tlist.c +++ b/rosapps/sysutils/tlist/tlist.c @@ -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 #include +#include + #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""; - - pInfo = GetProcessAndThreadsInfo (& Length); - if (NULL == pInfo) return EXIT_FAILURE; - pInfoBase = pInfo; - do { + if (!NT_SUCCESS(PsaCaptureProcessesAndThreads(&pInfoBase))) + return EXIT_FAILURE; + + 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; @@ -449,13 +428,8 @@ int STDCALL PrintProcess (char * PidStr) PrintThreads (pInfo); PrintModules (); - - NtFreeVirtualMemory ( - NtCurrentProcess(), - (PVOID) & pInfoBase, - & pInfoBaseLength, - MEM_RELEASE - ); + + PsaFreeCapture(pInfoBase); NtClose (hProcess);