diff --git a/reactos/include/epsapi.h b/reactos/include/epsapi.h index bca16aca890..6e7cecfaa94 100644 --- a/reactos/include/epsapi.h +++ b/reactos/include/epsapi.h @@ -32,10 +32,10 @@ /* OBJECTS */ /* TYPES */ -typedef NTSTATUS (NTAPI *PPROC_ENUM_ROUTINE)(IN PSYSTEM_PROCESSES CurrentProcess, +typedef NTSTATUS (NTAPI *PPROC_ENUM_ROUTINE)(IN PSYSTEM_PROCESS_INFORMATION CurrentProcess, IN OUT PVOID CallbackContext); -typedef NTSTATUS (NTAPI *PTHREAD_ENUM_ROUTINE)(IN PSYSTEM_THREADS CurrentThread, +typedef NTSTATUS (NTAPI *PTHREAD_ENUM_ROUTINE)(IN PSYSTEM_THREAD_INFORMATION CurrentThread, IN OUT PVOID CallbackContext); typedef NTSTATUS (NTAPI *PSYSMOD_ENUM_ROUTINE)(IN PSYSTEM_MODULE_INFORMATION_ENTRY CurrentModule, @@ -67,36 +67,36 @@ PsaEnumerateThreads(IN PTHREAD_ENUM_ROUTINE Callback, /* capturing & walking */ NTSTATUS NTAPI -PsaCaptureProcessesAndThreads(OUT PSYSTEM_PROCESSES * ProcessesAndThreads); +PsaCaptureProcessesAndThreads(OUT PSYSTEM_PROCESS_INFORMATION * ProcessesAndThreads); NTSTATUS NTAPI -PsaWalkProcessesAndThreads(IN PSYSTEM_PROCESSES ProcessesAndThreads, +PsaWalkProcessesAndThreads(IN PSYSTEM_PROCESS_INFORMATION ProcessesAndThreads, IN PPROC_ENUM_ROUTINE ProcessCallback, IN OUT PVOID ProcessCallbackContext, IN PTHREAD_ENUM_ROUTINE ThreadCallback, IN OUT PVOID ThreadCallbackContext); NTSTATUS NTAPI -PsaWalkProcesses(IN PSYSTEM_PROCESSES ProcessesAndThreads, +PsaWalkProcesses(IN PSYSTEM_PROCESS_INFORMATION ProcessesAndThreads, IN PPROC_ENUM_ROUTINE Callback, IN OUT PVOID CallbackContext); NTSTATUS NTAPI -PsaWalkThreads(IN PSYSTEM_PROCESSES ProcessesAndThreads, +PsaWalkThreads(IN PSYSTEM_PROCESS_INFORMATION ProcessesAndThreads, IN PTHREAD_ENUM_ROUTINE Callback, IN OUT PVOID CallbackContext); -PSYSTEM_PROCESSES FASTCALL -PsaWalkFirstProcess(IN PSYSTEM_PROCESSES ProcessesAndThreads); +PSYSTEM_PROCESS_INFORMATION FASTCALL +PsaWalkFirstProcess(IN PSYSTEM_PROCESS_INFORMATION ProcessesAndThreads); -PSYSTEM_PROCESSES FASTCALL -PsaWalkNextProcess(IN PSYSTEM_PROCESSES CurrentProcess); +PSYSTEM_PROCESS_INFORMATION FASTCALL +PsaWalkNextProcess(IN PSYSTEM_PROCESS_INFORMATION CurrentProcess); -PSYSTEM_THREADS FASTCALL -PsaWalkFirstThread(IN PSYSTEM_PROCESSES CurrentProcess); +PSYSTEM_THREAD_INFORMATION FASTCALL +PsaWalkFirstThread(IN PSYSTEM_PROCESS_INFORMATION CurrentProcess); -PSYSTEM_THREADS FASTCALL -PsaWalkNextThread(IN PSYSTEM_THREADS CurrentThread); +PSYSTEM_THREAD_INFORMATION FASTCALL +PsaWalkNextThread(IN PSYSTEM_THREAD_INFORMATION CurrentThread); /* System modules */ /* enumeration */ diff --git a/reactos/include/ntos/zwtypes.h b/reactos/include/ntos/zwtypes.h index a5f3677f924..1b771a08de4 100755 --- a/reactos/include/ntos/zwtypes.h +++ b/reactos/include/ntos/zwtypes.h @@ -326,53 +326,73 @@ typedef struct _SYSTEM_PERFORMANCE_INFORMATION { ULONG SystemCalls; } SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION; +#ifndef __USE_W32API + // SystemProcessThreadInfo (5) -typedef struct _SYSTEM_THREAD_INFORMATION +typedef struct _SYSTEM_THREAD_INFORMATION { - TIME KernelTime; - TIME UserTime; - TIME CreateTime; - ULONG WaitTime; - PVOID StartAddress; - CLIENT_ID ClientId; - KPRIORITY Priority; - LONG BasePriority; - ULONG ContextSwitches; - LONG ThreadState; - KWAIT_REASON WaitReason; + 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_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION; -typedef struct SYSTEM_PROCESS_INFORMATION +typedef struct _SYSTEM_PROCESS_INFORMATION { - ULONG NextEntryOffset; - ULONG NumberOfThreads; - LARGE_INTEGER SpareLi1; - LARGE_INTEGER SpareLi2; - LARGE_INTEGER SpareLi3; - TIME CreateTime; - TIME UserTime; - TIME KernelTime; - UNICODE_STRING ImageName; - ULONG BasePriority; - HANDLE UniqueProcessId; - HANDLE InheritedFromUniqueProcessId; - ULONG HandleCount; - ULONG SessionId; - ULONG SpareUl3; - ULONG PeakVirtualSize; - ULONG VirtualSize; - ULONG PageFaultCount; - ULONG PeakWorkingSetSize; - ULONG WorkingSetSize; - ULONG QuotaPeakPagedPoolUsage; - ULONG QuotaPagedPoolUsage; - ULONG QuotaPeakNonPagedPoolUsage; - ULONG QuotaNonPagedPoolUsage; - ULONG PagefileUsage; - ULONG PeakPagefileUsage; - ULONG PrivatePageCount; + 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; + + /* Finally, the array of Threads */ + SYSTEM_THREAD_INFORMATION TH[1]; } SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION; +#endif + // SystemModuleInformation (11) typedef struct _SYSTEM_MODULE_INFORMATION_ENTRY { ULONG Unknown1; @@ -1300,69 +1320,6 @@ struct _SYSTEM_PATH_INFORMATION } SYSTEM_PATH_INFORMATION, * PSYSTEM_PATH_INFORMATION; -// SystemProcessInformation (5) - -#ifndef __USE_W32API - -typedef struct _SYSTEM_THREADS { - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER CreateTime; - ULONG WaitTime; - PVOID StartAddress; - CLIENT_ID ClientId; - KPRIORITY Priority; - KPRIORITY BasePriority; - ULONG ContextSwitchCount; - ULONG State; - KWAIT_REASON WaitReason; -} SYSTEM_THREADS, *PSYSTEM_THREADS; - -#endif /* __USE_W32API */ - -typedef struct _SYSTEM_PROCESSES_NT4 -{ - SIZE_T NextEntryDelta; - ULONG ThreadCount; - ULONG Reserved1[6]; - LARGE_INTEGER CreateTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER KernelTime; - UNICODE_STRING ProcessName; - KPRIORITY BasePriority; - HANDLE ProcessId; - HANDLE InheritedFromProcessId; - ULONG HandleCount; - ULONG Reserved2[2]; - VM_COUNTERS VmCounters; - SYSTEM_THREADS Threads[ANYSIZE_ARRAY]; -} SYSTEM_PROCESSES_NT4, *PSYSTEM_PROCESSES_NT4; - -typedef struct _SYSTEM_PROCESSES_NT5 -{ - SIZE_T NextEntryDelta; - ULONG ThreadCount; - ULONG Reserved1[6]; - LARGE_INTEGER CreateTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER KernelTime; - UNICODE_STRING ProcessName; - KPRIORITY BasePriority; - HANDLE ProcessId; - HANDLE InheritedFromProcessId; - ULONG HandleCount; - ULONG Reserved2[2]; - VM_COUNTERS VmCounters; - IO_COUNTERS IoCounters; - SYSTEM_THREADS Threads[ANYSIZE_ARRAY]; -} SYSTEM_PROCESSES_NT5, *PSYSTEM_PROCESSES_NT5; - -#ifndef __USE_W32API - -/* Not sure. What version are we emulating? */ -typedef SYSTEM_PROCESSES_NT5 SYSTEM_PROCESSES, *PSYSTEM_PROCESSES; - -#endif /* __USE_W32API */ // SystemCallCountInformation (6) typedef diff --git a/reactos/lib/ntdll/rtl/dbgbuffer.c b/reactos/lib/ntdll/rtl/dbgbuffer.c index 707635d40c8..98b73f02363 100644 --- a/reactos/lib/ntdll/rtl/dbgbuffer.c +++ b/reactos/lib/ntdll/rtl/dbgbuffer.c @@ -349,14 +349,13 @@ else Buf->Unknown[0] = (ULONG)NtCurrentProcess(); - ClientId.UniqueThread = INVALID_HANDLE_VALUE; + ClientId.UniqueThread = 0; ClientId.UniqueProcess = (HANDLE)ProcessId; - ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); - ObjectAttributes.RootDirectory = (HANDLE)NULL; - ObjectAttributes.SecurityDescriptor = NULL; - ObjectAttributes.SecurityQualityOfService = NULL; - ObjectAttributes.ObjectName = NULL; - ObjectAttributes.Attributes = 0; + InitializeObjectAttributes(&ObjectAttributes, + NULL, + 0, + NULL, + NULL); Status = NtOpenProcess( &hProcess, (PROCESS_ALL_ACCESS), diff --git a/reactos/lib/psapi/psapi.c b/reactos/lib/psapi/psapi.c index ff2464c6db0..c6cb1275588 100644 --- a/reactos/lib/psapi/psapi.c +++ b/reactos/lib/psapi/psapi.c @@ -71,7 +71,7 @@ typedef struct _ENUM_PROCESSES_CONTEXT } ENUM_PROCESSES_CONTEXT, *PENUM_PROCESSES_CONTEXT; NTSTATUS STDCALL -EnumProcessesCallback(IN PSYSTEM_PROCESSES CurrentProcess, +EnumProcessesCallback(IN PSYSTEM_PROCESS_INFORMATION CurrentProcess, IN OUT PVOID CallbackContext) { PENUM_PROCESSES_CONTEXT Context = (PENUM_PROCESSES_CONTEXT)CallbackContext; @@ -83,7 +83,7 @@ EnumProcessesCallback(IN PSYSTEM_PROCESSES CurrentProcess, } /* return current process */ - *Context->lpidProcess = (DWORD)CurrentProcess->ProcessId; + *Context->lpidProcess = (DWORD)CurrentProcess->UniqueProcessId; /* go to next array slot */ Context->lpidProcess++; diff --git a/reactos/w32api/include/ddk/ntapi.h b/reactos/w32api/include/ddk/ntapi.h index 275fe062e7b..f3506aef87e 100644 --- a/reactos/w32api/include/ddk/ntapi.h +++ b/reactos/w32api/include/ddk/ntapi.h @@ -264,48 +264,16 @@ typedef struct _VM_COUNTERS { } VM_COUNTERS; typedef enum _THREAD_STATE { - StateInitialized, - StateReady, - StateRunning, - StateStandby, - StateTerminated, - StateWait, - StateTransition, - StateUnknown + Initialized, + Ready, + Running, + Standby, + Terminated, + Wait, + Transition, + DeferredReady } THREAD_STATE; -typedef struct _SYSTEM_THREADS { - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER CreateTime; - ULONG WaitTime; - PVOID StartAddress; - CLIENT_ID ClientId; - KPRIORITY Priority; - KPRIORITY BasePriority; - ULONG ContextSwitchCount; - THREAD_STATE State; - KWAIT_REASON WaitReason; -} SYSTEM_THREADS, *PSYSTEM_THREADS; - -typedef struct _SYSTEM_PROCESSES { - ULONG NextEntryDelta; - ULONG ThreadCount; - ULONG Reserved1[6]; - LARGE_INTEGER CreateTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER KernelTime; - UNICODE_STRING ProcessName; - KPRIORITY BasePriority; - HANDLE ProcessId; - HANDLE InheritedFromProcessId; - ULONG HandleCount; - ULONG Reserved2[2]; - VM_COUNTERS VmCounters; - IO_COUNTERS IoCounters; - SYSTEM_THREADS Threads[1]; -} SYSTEM_PROCESSES, *PSYSTEM_PROCESSES; - typedef struct _SYSTEM_CALLS_INFORMATION { ULONG Size; ULONG NumberOfDescriptorTables; @@ -659,50 +627,67 @@ typedef struct _SYSTEM_MEMORY_USAGE_INFORMATION { SYSTEM_MEMORY_USAGE MemoryUsage[1]; } SYSTEM_MEMORY_USAGE_INFORMATION, *PSYSTEM_MEMORY_USAGE_INFORMATION; -typedef struct _SYSTEM_THREAD_INFORMATION +// SystemProcessThreadInfo (5) +typedef struct _SYSTEM_THREAD_INFORMATION { - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER CreateTime; - ULONG WaitTime; - PVOID StartAddress; - CLIENT_ID ClientId; - KPRIORITY Priority; - LONG BasePriority; - ULONG ContextSwitches; - ULONG ThreadState; - KWAIT_REASON WaitReason; + 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_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION; -typedef struct SYSTEM_PROCESS_INFORMATION +typedef struct _SYSTEM_PROCESS_INFORMATION { - 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; - ULONG BasePriority; - HANDLE UniqueProcessId; - HANDLE InheritedFromUniqueProcessId; - ULONG HandleCount; - ULONG SessionId; - ULONG SpareUl3; - ULONG PeakVirtualSize; - ULONG VirtualSize; - ULONG PageFaultCount; - ULONG PeakWorkingSetSize; - ULONG WorkingSetSize; - ULONG QuotaPeakPagedPoolUsage; - ULONG QuotaPagedPoolUsage; - ULONG QuotaPeakNonPagedPoolUsage; - ULONG QuotaNonPagedPoolUsage; - ULONG PagefileUsage; - ULONG PeakPagefileUsage; - ULONG PrivatePageCount; + 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; + + /* Finally, the array of Threads */ + SYSTEM_THREAD_INFORMATION TH[1]; } SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION; NTOSAPI