ReactOS 0.4.16-dev-329-g9223134
test.h File Reference
#include <ntos.h>
Include dependency graph for test.h:

Go to the source code of this file.

Classes

struct  tagFOO
 
struct  SOUND_DEVICE_INIT
 

Macros

#define NTOS_MODE_USER
 
#define FAILED_WITH_STATUS   DEFINE_DBG_MSG("%s() failed, status 0x%08X")
 
#define DEFINE_DBG_MSG(__str__)   "PSAPI: " __str__ "\n"
 

Typedefs

typedef struct tagFOO FOO
 
typedef struct tagFOOPFOO
 
typedef struct tagFOOLPFOO
 
typedef NTSTATUS NTAPI(* PPROC_ENUM_ROUTINE) (IN PSYSTEM_PROCESSES CurrentProcess, IN OUT PVOID CallbackContext)
 
typedef NTSTATUS NTAPI(* PTHREAD_ENUM_ROUTINE) (IN PSYSTEM_THREADS CurrentThread, IN OUT PVOID CallbackContext)
 
typedef NTSTATUS NTAPI(* PSYSMOD_ENUM_ROUTINE) (IN PSYSTEM_MODULE_INFORMATION_ENTRY CurrentModule, IN OUT PVOID CallbackContext)
 
typedef NTSTATUS NTAPI(* PPROCMOD_ENUM_ROUTINE) (IN HANDLE ProcessHandle, IN PLDR_DATA_TABLE_ENTRY CurrentModule, IN OUT PVOID CallbackContext)
 

Functions

void_lfind (const void *match, const void *start, unsigned int *array_size, unsigned int elem_size, int(*cf)(const void *, const void *))
 
static struct _TEBNtCurrentTeb (void)
 
NTSTATUS NTAPI PsaEnumerateProcessesAndThreads (IN PPROC_ENUM_ROUTINE ProcessCallback, IN OUT PVOID ProcessCallbackContext, IN PTHREAD_ENUM_ROUTINE ThreadCallback, IN OUT PVOID ThreadCallbackContext)
 
NTSTATUS NTAPI PsaEnumerateProcesses (IN PPROC_ENUM_ROUTINE Callback, IN OUT PVOID CallbackContext)
 
NTSTATUS NTAPI PsaEnumerateThreads (IN PTHREAD_ENUM_ROUTINE Callback, IN OUT PVOID CallbackContext)
 
NTSTATUS NTAPI PsaCaptureProcessesAndThreads (OUT PSYSTEM_PROCESSES *ProcessesAndThreads)
 
NTSTATUS NTAPI PsaWalkProcessesAndThreads (IN PSYSTEM_PROCESSES 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, IN PPROC_ENUM_ROUTINE Callback, IN OUT PVOID CallbackContext)
 
NTSTATUS NTAPI PsaWalkThreads (IN PSYSTEM_PROCESSES ProcessesAndThreads, IN PTHREAD_ENUM_ROUTINE Callback, IN OUT PVOID CallbackContext)
 
PSYSTEM_PROCESSES FASTCALL PsaWalkFirstProcess (IN PSYSTEM_PROCESSES ProcessesAndThreads)
 
PSYSTEM_PROCESSES FASTCALL PsaWalkNextProcess (IN PSYSTEM_PROCESSES CurrentProcess)
 
PSYSTEM_THREADS FASTCALL PsaWalkFirstThread (IN PSYSTEM_PROCESSES CurrentProcess)
 
PSYSTEM_THREADS FASTCALL PsaWalkNextThread (IN PSYSTEM_THREADS CurrentThread)
 
NTSTATUS NTAPI PsaEnumerateSystemModules (IN PSYSMOD_ENUM_ROUTINE Callback, IN OUT PVOID CallbackContext)
 
NTSTATUS NTAPI PsaCaptureSystemModules (OUT PSYSTEM_MODULE_INFORMATION *SystemModules)
 
NTSTATUS NTAPI PsaWalkSystemModules (IN PSYSTEM_MODULE_INFORMATION SystemModules, IN PSYSMOD_ENUM_ROUTINE Callback, IN OUT PVOID CallbackContext)
 
PSYSTEM_MODULE_INFORMATION_ENTRY FASTCALL PsaWalkFirstSystemModule (IN PSYSTEM_MODULE_INFORMATION SystemModules)
 
PSYSTEM_MODULE_INFORMATION_ENTRY FASTCALL PsaWalkNextSystemModule (IN PSYSTEM_MODULE_INFORMATION CurrentSystemModule)
 
NTSTATUS NTAPI PsaEnumerateProcessModules (IN HANDLE ProcessHandle, IN PPROCMOD_ENUM_ROUTINE Callback, IN OUT PVOID CallbackContext)
 
VOID NTAPI PsaFreeCapture (IN PVOID Capture)
 
voidPsaiMalloc (SIZE_T size)
 
voidPsaiRealloc (void *ptr, SIZE_T size)
 
void PsaiFree (void *ptr)
 

Macro Definition Documentation

◆ DEFINE_DBG_MSG

#define DEFINE_DBG_MSG (   __str__)    "PSAPI: " __str__ "\n"

Definition at line 257 of file test.h.

◆ FAILED_WITH_STATUS

#define FAILED_WITH_STATUS   DEFINE_DBG_MSG("%s() failed, status 0x%08X")

Definition at line 95 of file test.h.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 47 of file test.h.

Typedef Documentation

◆ FOO

typedef struct tagFOO FOO

◆ LPFOO

typedef struct tagFOO* LPFOO

◆ PFOO

typedef struct tagFOO * PFOO

◆ PPROC_ENUM_ROUTINE

typedef NTSTATUS NTAPI(* PPROC_ENUM_ROUTINE) (IN PSYSTEM_PROCESSES CurrentProcess, IN OUT PVOID CallbackContext)

Definition at line 69 of file test.h.

◆ PPROCMOD_ENUM_ROUTINE

typedef NTSTATUS NTAPI(* PPROCMOD_ENUM_ROUTINE) (IN HANDLE ProcessHandle, IN PLDR_DATA_TABLE_ENTRY CurrentModule, IN OUT PVOID CallbackContext)

Definition at line 87 of file test.h.

◆ PSYSMOD_ENUM_ROUTINE

typedef NTSTATUS NTAPI(* PSYSMOD_ENUM_ROUTINE) (IN PSYSTEM_MODULE_INFORMATION_ENTRY CurrentModule, IN OUT PVOID CallbackContext)

Definition at line 81 of file test.h.

◆ PTHREAD_ENUM_ROUTINE

typedef NTSTATUS NTAPI(* PTHREAD_ENUM_ROUTINE) (IN PSYSTEM_THREADS CurrentThread, IN OUT PVOID CallbackContext)

Definition at line 75 of file test.h.

Function Documentation

◆ _lfind()

void * _lfind ( const void match,
const void start,
unsigned int array_size,
unsigned int  elem_size,
int(*)(const void *, const void *)  cf 
)

Referenced by _lsearch().

◆ NtCurrentTeb()

static struct _TEB * NtCurrentTeb ( void  )
inlinestatic

Definition at line 25 of file test.h.

26{
27 struct _TEB * pTeb;
28
29 /* FIXME: instead of hardcoded offsets, use offsetof() - if possible */
30 __asm__ __volatile__
31 (
32 "movl %%fs:0x18, %0\n" /* fs:18h == Teb->Tib.Self */
33 : "=r" (pTeb) /* can't have two memory operands */
34 : /* no inputs */
35 );
36
37 return pTeb;
38}
__asm__(".p2align 4, 0x90\n" ".seh_proc __seh2_global_filter_func\n" "__seh2_global_filter_func:\n" "\tsub %rbp, %rax\n" "\tpush %rbp\n" "\t.seh_pushreg %rbp\n" "\tsub $32, %rsp\n" "\t.seh_stackalloc 32\n" "\t.seh_endprologue\n" "\tsub %rax, %rdx\n" "\tmov %rdx, %rbp\n" "\tjmp *%r8\n" "__seh2_global_filter_func_exit:\n" "\t.p2align 4\n" "\tadd $32, %rsp\n" "\tpop %rbp\n" "\tret\n" "\t.seh_endproc")
Definition: compat.h:836

◆ PsaCaptureProcessesAndThreads()

NTSTATUS NTAPI PsaCaptureProcessesAndThreads ( OUT PSYSTEM_PROCESSES ProcessesAndThreads)

◆ PsaCaptureSystemModules()

NTSTATUS NTAPI PsaCaptureSystemModules ( OUT PSYSTEM_MODULE_INFORMATION SystemModules)

◆ PsaEnumerateProcesses()

NTSTATUS NTAPI PsaEnumerateProcesses ( IN PPROC_ENUM_ROUTINE  Callback,
IN OUT PVOID  CallbackContext 
)

Definition at line 218 of file processes.c.

220{
223 NULL,
224 NULL);
225}
#define NULL
Definition: types.h:112
NTSTATUS NTAPI PsaEnumerateProcessesAndThreads(IN PPROC_ENUM_ROUTINE ProcessCallback, IN OUT PVOID ProcessCallbackContext, IN PTHREAD_ENUM_ROUTINE ThreadCallback, IN OUT PVOID ThreadCallbackContext)
Definition: processes.c:153
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR _In_ ULONGLONG _In_ ULONGLONG _In_opt_ PEVENT_FILTER_DESCRIPTOR _Inout_opt_ PVOID CallbackContext
Definition: wmitypes.h:60

◆ PsaEnumerateProcessesAndThreads()

NTSTATUS NTAPI PsaEnumerateProcessesAndThreads ( IN PPROC_ENUM_ROUTINE  ProcessCallback,
IN OUT PVOID  ProcessCallbackContext,
IN PTHREAD_ENUM_ROUTINE  ThreadCallback,
IN OUT PVOID  ThreadCallbackContext 
)

Definition at line 153 of file processes.c.

157{
158 PSYSTEM_PROCESS_INFORMATION pInfoBuffer = NULL;
160
161 if(ProcessCallback == NULL && ThreadCallback == NULL)
162 {
164 }
165
166 /* get the processes and threads list */
168
169 if(!NT_SUCCESS(Status))
170 {
171 goto Bail;
172 }
173
174 /* walk the processes and threads list */
176 ProcessCallback,
177 ProcessCallbackContext,
179 ThreadCallbackContext);
180
181Bail:
182 PsaFreeCapture(pInfoBuffer);
183
184 return Status;
185}
LONG NTSTATUS
Definition: precomp.h:26
@ ThreadCallback
Definition: dbghelp.h:626
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
VOID NTAPI PsaFreeCapture(IN PVOID Capture)
Definition: processes.c:188
NTSTATUS NTAPI PsaWalkProcessesAndThreads(IN PSYSTEM_PROCESS_INFORMATION ProcessesAndThreads, IN PPROC_ENUM_ROUTINE ProcessCallback, IN OUT PVOID ProcessCallbackContext, IN PTHREAD_ENUM_ROUTINE ThreadCallback, IN OUT PVOID ThreadCallbackContext)
Definition: processes.c:94
NTSTATUS NTAPI PsaCaptureProcessesAndThreads(OUT PSYSTEM_PROCESS_INFORMATION *ProcessesAndThreads)
Definition: processes.c:38
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

◆ PsaEnumerateProcessModules()

NTSTATUS NTAPI PsaEnumerateProcessModules ( IN HANDLE  ProcessHandle,
IN PPROCMOD_ENUM_ROUTINE  Callback,
IN OUT PVOID  CallbackContext 
)

Definition at line 30 of file modules.c.

33{
35
36 /* current process - use direct memory copy */
37 /* FIXME - compare process id instead of a handle */
39 {
40 PLIST_ENTRY ListHead, Current;
41
42#if 0
43 __try
44 {
45#endif
46 ListHead = &(NtCurrentPeb()->Ldr->InLoadOrderModuleList);
47 Current = ListHead->Flink;
48
49 while(Current != ListHead)
50 {
51 PLDR_DATA_TABLE_ENTRY LoaderModule = CONTAINING_RECORD(Current, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
52
53 /* return the current module to the callback */
55
56 if(!NT_SUCCESS(Status))
57 {
58 goto Failure;
59 }
60
61 Current = LoaderModule->InLoadOrderLinks.Flink;
62 }
63#if 0
64 }
66 {
67 return GetExceptionCode();
68 }
69#endif
70 }
71 else
72 {
73 PROCESS_BASIC_INFORMATION BasicInformation;
74 PPEB_LDR_DATA LoaderData;
75 LDR_DATA_TABLE_ENTRY LoaderModule;
76 PLIST_ENTRY ListHead, Current;
77
78 /* query the process basic information (includes the PEB address) */
81 &BasicInformation,
82 sizeof(BasicInformation),
83 NULL);
84
85 if(!NT_SUCCESS(Status))
86 {
87 DPRINT(FAILED_WITH_STATUS, "NtQueryInformationProcess", Status);
88 goto Failure;
89 }
90
91 /* get the address of the PE Loader data */
93 &(BasicInformation.PebBaseAddress->Ldr),
94 &LoaderData,
95 sizeof(LoaderData),
96 NULL);
97
98 if(!NT_SUCCESS(Status))
99 {
100 DPRINT(FAILED_WITH_STATUS, "NtReadVirtualMemory", Status);
101 goto Failure;
102 }
103
104 /* head of the module list: the last element in the list will point to this */
105 ListHead = &LoaderData->InLoadOrderModuleList;
106
107 /* get the address of the first element in the list */
109 &(LoaderData->InLoadOrderModuleList.Flink),
110 &Current,
111 sizeof(Current),
112 NULL);
113
114 while(Current != ListHead)
115 {
116 /* read the current module */
118 CONTAINING_RECORD(Current, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks),
119 &LoaderModule,
120 sizeof(LoaderModule),
121 NULL);
122
123 if(!NT_SUCCESS(Status))
124 {
125 DPRINT(FAILED_WITH_STATUS, "NtReadVirtualMemory", Status);
126 goto Failure;
127 }
128
129 /* return the current module to the callback */
130 Status = Callback(ProcessHandle, &LoaderModule, CallbackContext);
131
132 if(!NT_SUCCESS(Status))
133 {
134 goto Failure;
135 }
136
137 /* address of the next module in the list */
138 Current = LoaderModule.InLoadOrderLinks.Flink;
139 }
140 }
141
142 return STATUS_SUCCESS;
143
144Failure:
145 return Status;
146}
#define NtCurrentPeb()
Definition: FLS.c:22
@ ProcessBasicInformation
Definition: winternl.h:394
#define GetExceptionCode
Definition: excpt.h:83
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define FAILED_WITH_STATUS
Definition: test.h:95
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
#define NtCurrentProcess()
Definition: nt_native.h:1657
NTSTATUS NTAPI NtReadVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, OUT PVOID Buffer, IN SIZE_T NumberOfBytesToRead, OUT PSIZE_T NumberOfBytesRead OPTIONAL)
Definition: virtual.c:2816
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
#define __try
Definition: pseh2_64.h:172
#define __except
Definition: pseh2_64.h:173
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
Definition: btrfs_drv.h:1876
LIST_ENTRY InLoadOrderLinks
Definition: ldrtypes.h:138
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY InLoadOrderModuleList
Definition: ldrtypes.h:120
PPEB_LDR_DATA Ldr
Definition: btrfs_drv.h:1912
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

◆ PsaEnumerateSystemModules()

NTSTATUS NTAPI PsaEnumerateSystemModules ( IN PSYSMOD_ENUM_ROUTINE  Callback,
IN OUT PVOID  CallbackContext 
)

Definition at line 21 of file drivers.c.

23{
24 PRTL_PROCESS_MODULES psmModules;
26
27#if 0
28 __try
29 {
30#else
31 do
32 {
33#endif
34 /* capture the system modules */
35 Status = PsaCaptureSystemModules(&psmModules);
36
37 if(!NT_SUCCESS(Status))
38 {
39 break;
40 }
41
42 /* walk the system modules */
44#if 0
45 }
47 {
48#else
49 } while(0);
50#endif
51 /* free the capture */
52 PsaFreeCapture(psmModules);
53#if 0
54 }
55#endif
56
57 return Status;
58}
NTSTATUS NTAPI PsaWalkSystemModules(IN PRTL_PROCESS_MODULES SystemModules, IN PSYSMOD_ENUM_ROUTINE Callback, IN OUT PVOID CallbackContext)
Definition: drivers.c:154
NTSTATUS NTAPI PsaCaptureSystemModules(OUT PRTL_PROCESS_MODULES *SystemModules)
Definition: drivers.c:61
VOID NTAPI PsaFreeCapture(IN PVOID Capture)
Definition: processes.c:188
#define __finally
Definition: pseh2_64.h:174

◆ PsaEnumerateThreads()

NTSTATUS NTAPI PsaEnumerateThreads ( IN PTHREAD_ENUM_ROUTINE  Callback,
IN OUT PVOID  CallbackContext 
)

Definition at line 228 of file processes.c.

230{
232 NULL,
233 Callback,
235}

◆ PsaFreeCapture()

VOID NTAPI PsaFreeCapture ( IN PVOID  Capture)

Definition at line 188 of file processes.c.

189{
191}
struct _Capture Capture
Definition: capture.h:24
void PsaiFree(void *ptr)
Definition: ctm.c:103

Referenced by PerfDataRefresh(), PrintProcess(), PrintProcessList(), and PsaEnumerateSystemModules().

◆ PsaiFree()

void PsaiFree ( void ptr)

Definition at line 103 of file ctm.c.

103{ free(ptr); }
#define free
Definition: debug_ros.c:5
static PVOID ptr
Definition: dispmode.c:27

◆ PsaiMalloc()

void * PsaiMalloc ( SIZE_T  size)

Definition at line 101 of file ctm.c.

101{ return malloc(size); }
#define malloc
Definition: debug_ros.c:4
GLsizeiptr size
Definition: glext.h:5919

◆ PsaiRealloc()

void * PsaiRealloc ( void ptr,
SIZE_T  size 
)

Definition at line 102 of file ctm.c.

102{ return realloc(ptr, size); }
#define realloc
Definition: debug_ros.c:6

◆ PsaWalkFirstProcess()

PSYSTEM_PROCESSES FASTCALL PsaWalkFirstProcess ( IN PSYSTEM_PROCESSES  ProcessesAndThreads)

◆ PsaWalkFirstSystemModule()

PSYSTEM_MODULE_INFORMATION_ENTRY FASTCALL PsaWalkFirstSystemModule ( IN PSYSTEM_MODULE_INFORMATION  SystemModules)

◆ PsaWalkFirstThread()

PSYSTEM_THREADS FASTCALL PsaWalkFirstThread ( IN PSYSTEM_PROCESSES  CurrentProcess)

Referenced by PrintThreads().

◆ PsaWalkNextProcess()

PSYSTEM_PROCESSES FASTCALL PsaWalkNextProcess ( IN PSYSTEM_PROCESSES  CurrentProcess)

◆ PsaWalkNextSystemModule()

PSYSTEM_MODULE_INFORMATION_ENTRY FASTCALL PsaWalkNextSystemModule ( IN PSYSTEM_MODULE_INFORMATION  CurrentSystemModule)

◆ PsaWalkNextThread()

PSYSTEM_THREADS FASTCALL PsaWalkNextThread ( IN PSYSTEM_THREADS  CurrentThread)

Referenced by PrintThreads().

◆ PsaWalkProcesses()

NTSTATUS NTAPI PsaWalkProcesses ( IN PSYSTEM_PROCESSES  ProcessesAndThreads,
IN PPROC_ENUM_ROUTINE  Callback,
IN OUT PVOID  CallbackContext 
)

◆ PsaWalkProcessesAndThreads()

NTSTATUS NTAPI PsaWalkProcessesAndThreads ( IN PSYSTEM_PROCESSES  ProcessesAndThreads,
IN PPROC_ENUM_ROUTINE  ProcessCallback,
IN OUT PVOID  ProcessCallbackContext,
IN PTHREAD_ENUM_ROUTINE  ThreadCallback,
IN OUT PVOID  ThreadCallbackContext 
)

◆ PsaWalkSystemModules()

NTSTATUS NTAPI PsaWalkSystemModules ( IN PSYSTEM_MODULE_INFORMATION  SystemModules,
IN PSYSMOD_ENUM_ROUTINE  Callback,
IN OUT PVOID  CallbackContext 
)

◆ PsaWalkThreads()

NTSTATUS NTAPI PsaWalkThreads ( IN PSYSTEM_PROCESSES  ProcessesAndThreads,
IN PTHREAD_ENUM_ROUTINE  Callback,
IN OUT PVOID  CallbackContext 
)