ReactOS  0.4.15-dev-3295-gaa8fc87
thread.c File Reference
#include <rtl.h>
#include "i386/ketypes.h"
#include <debug.h>
Include dependency graph for thread.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI RtlInitializeContext (IN HANDLE ProcessHandle, OUT PCONTEXT ThreadContext, IN PVOID ThreadStartParam OPTIONAL, IN PTHREAD_START_ROUTINE ThreadStartAddress, IN PINITIAL_TEB InitialTeb)
 
NTSTATUS NTAPI RtlQueueApcWow64Thread (_In_ HANDLE ThreadHandle, _In_ PKNORMAL_ROUTINE ApcRoutine, _In_opt_ PVOID NormalContext, _In_opt_ PVOID SystemArgument1, _In_opt_ PVOID SystemArgument2)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 17 of file thread.c.

Function Documentation

◆ RtlInitializeContext()

VOID NTAPI RtlInitializeContext ( IN HANDLE  ProcessHandle,
OUT PCONTEXT  ThreadContext,
IN PVOID ThreadStartParam  OPTIONAL,
IN PTHREAD_START_ROUTINE  ThreadStartAddress,
IN PINITIAL_TEB  InitialTeb 
)

Definition at line 27 of file thread.c.

32 {
33  DPRINT("RtlInitializeContext: (hProcess: %p, ThreadContext: %p, Teb: %p\n",
34  ProcessHandle, ThreadContext, InitialTeb);
35 
36  /*
37  * Set the Initial Registers
38  * This is based on NT's default values -- crazy apps might expect this...
39  */
40  ThreadContext->Ebp = 0;
41  ThreadContext->Eax = 0;
42  ThreadContext->Ebx = 1;
43  ThreadContext->Ecx = 2;
44  ThreadContext->Edx = 3;
45  ThreadContext->Esi = 4;
46  ThreadContext->Edi = 5;
47 
48  /* Set the Selectors */
49  ThreadContext->SegGs = 0;
50  ThreadContext->SegFs = KGDT_R3_TEB;
51  ThreadContext->SegEs = KGDT_R3_DATA;
52  ThreadContext->SegDs = KGDT_R3_DATA;
53  ThreadContext->SegSs = KGDT_R3_DATA;
54  ThreadContext->SegCs = KGDT_R3_CODE;
55 
56  /* Enable Interrupts */
57  ThreadContext->EFlags = EFLAGS_INTERRUPT_MASK;
58 
59  /* Settings passed */
60  ThreadContext->Eip = (ULONG)ThreadStartAddress;
61  ThreadContext->Esp = (ULONG)InitialTeb;
62 
63  /* Only the basic Context is initialized */
64  ThreadContext->ContextFlags = CONTEXT_CONTROL |
67 
68  /* Set up ESP to the right value */
69  ThreadContext->Esp -= sizeof(PVOID);
71  (PVOID)ThreadContext->Esp,
72  (PVOID)&ThreadStartParam,
73  sizeof(PVOID),
74  NULL);
75 
76  /* Push it down one more notch for RETEIP */
77  ThreadContext->Esp -= sizeof(PVOID);
78 }
static ULONG
Definition: thread.c:78
#define CONTEXT_CONTROL
Definition: nt_native.h:1369
static PVOID
Definition: thread.c:78
#define CONTEXT_SEGMENTS
Definition: nt_native.h:1371
#define KGDT_R3_DATA
Definition: ketypes.h:78
NTSYSAPI NTSTATUS NTAPI ZwWriteVirtualMemory(_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _In_ PVOID Buffer, _In_ SIZE_T NumberOfBytesToWrite, _Out_opt_ PSIZE_T NumberOfBytesWritten)
#define KGDT_R3_TEB
Definition: ketypes.h:81
#define NULL
Definition: types.h:112
#define KGDT_R3_CODE
Definition: ketypes.h:77
#define CONTEXT_INTEGER
Definition: nt_native.h:1370
#define DPRINT
Definition: sndvol32.h:71
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
#define EFLAGS_INTERRUPT_MASK
Definition: ketypes.h:126

Referenced by RtlCreateUserThread().

◆ RtlQueueApcWow64Thread()

NTSTATUS NTAPI RtlQueueApcWow64Thread ( _In_ HANDLE  ThreadHandle,
_In_ PKNORMAL_ROUTINE  ApcRoutine,
_In_opt_ PVOID  NormalContext,
_In_opt_ PVOID  SystemArgument1,
_In_opt_ PVOID  SystemArgument2 
)

Definition at line 82 of file thread.c.

88 {
89  return NtQueueApcThread(ThreadHandle,
90  ApcRoutine,
91  NormalContext,
94 }
NTSTATUS NTAPI NtQueueApcThread(IN HANDLE ThreadHandle, IN PKNORMAL_ROUTINE ApcRoutine, IN PVOID NormalContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: state.c:600
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE ApcRoutine
Definition: iofuncs.h:719
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675