ReactOS  0.4.15-dev-1386-g5cb9f87
stubs.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Run-Time Library
4  * PURPOSE: AMD64 stubs
5  * FILE: lib/rtl/amd64/stubs.c
6  * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org)
7  */
8 
9 /* INCLUDES *****************************************************************/
10 
11 #include <rtl.h>
12 #define NDEBUG
13 #include <debug.h>
14 #include "amd64/ketypes.h"
15 
16 /* PUBLIC FUNCTIONS **********************************************************/
17 
18 /*
19  * @unimplemented
20  */
21 VOID
22 NTAPI
24  OUT PCONTEXT ThreadContext,
25  IN PVOID ThreadStartParam OPTIONAL,
26  IN PTHREAD_START_ROUTINE ThreadStartAddress,
27  IN PINITIAL_TEB StackBase)
28 {
29 
30  ThreadContext->Rax = 0;
31  ThreadContext->Rbx = 0;
32  ThreadContext->Rcx = (ULONG64)ThreadStartParam;
33  ThreadContext->Rdx = 0;
34  ThreadContext->Rsi = 0;
35  ThreadContext->Rdi = 0;
36  ThreadContext->Rbp = 0;
37  ThreadContext->R8 = 0;
38  ThreadContext->R9 = 0;
39  ThreadContext->R10 = 0;
40  ThreadContext->R11 = 0;
41  ThreadContext->R12 = 0;
42 
43  /* Set the Selectors */
44  if ((LONG64)ThreadStartAddress < 0)
45  {
46  /* Initialize kernel mode segments */
47  ThreadContext->SegCs = KGDT64_R0_CODE;
48  ThreadContext->SegDs = KGDT64_R3_DATA;
49  ThreadContext->SegEs = KGDT64_R3_DATA;
50  ThreadContext->SegFs = KGDT64_R3_CMTEB;
51  ThreadContext->SegGs = KGDT64_R3_DATA;
52  ThreadContext->SegSs = KGDT64_R0_DATA;
53  }
54  else
55  {
56  /* Initialize user mode segments */
57  ThreadContext->SegCs = KGDT64_R3_CODE | RPL_MASK;
58  ThreadContext->SegDs = KGDT64_R3_DATA | RPL_MASK;
59  ThreadContext->SegEs = KGDT64_R3_DATA | RPL_MASK;
60  ThreadContext->SegFs = KGDT64_R3_CMTEB | RPL_MASK;
61  ThreadContext->SegGs = KGDT64_R3_DATA | RPL_MASK;
62  ThreadContext->SegSs = KGDT64_R3_DATA | RPL_MASK;
63  }
64 
65  /* Enable Interrupts */
66  ThreadContext->EFlags = EFLAGS_INTERRUPT_MASK;
67 
68  /* Settings passed */
69  ThreadContext->Rip = (ULONG64)ThreadStartAddress;
70  ThreadContext->Rsp = (ULONG64)StackBase - 6 * sizeof(PVOID);
71 
72  /* Align stack by 16 and substract 8 (unaligned on function entry) */
73  ThreadContext->Rsp &= ~15;
74  ThreadContext->Rsp -= 8;
75 
76  /* Only the basic Context is initialized */
77  ThreadContext->ContextFlags = CONTEXT_CONTROL |
80 
81  return;
82 }
83 
84 /*
85  * @unimplemented
86  */
87 PVOID
88 NTAPI
90 {
92  return NULL;
93 }
94 
95 /*
96  * @unimplemented
97  */
98 BOOLEAN
99 NTAPI
102 {
104  return FALSE;
105 }
106 
107 NTSYSAPI
108 VOID
111  PEXCEPTION_RECORD ExceptionRecord)
112 {
114 }
115 
116 NTSTATUS
117 NTAPI
119  _In_ HANDLE ThreadHandle,
121  _In_opt_ PVOID NormalContext,
124 {
126  return STATUS_NOT_IMPLEMENTED;
127 }
128 
#define KGDT64_R3_CODE
Definition: ketypes.h:76
#define CONTEXT_CONTROL
Definition: nt_native.h:1369
#define IN
Definition: typedefs.h:39
PVOID NTAPI RtlpGetExceptionAddress(VOID)
Definition: stubs.c:89
LONG NTSTATUS
Definition: precomp.h:26
#define KGDT64_R3_CMTEB
Definition: ketypes.h:78
NTSYSAPI VOID RtlRestoreContext(PCONTEXT ContextRecord, PEXCEPTION_RECORD ExceptionRecord)
Definition: stubs.c:109
#define UNIMPLEMENTED
Definition: stubs.c:20
#define NTSYSAPI
Definition: ntoskrnl.h:14
#define CONTEXT_SEGMENTS
Definition: nt_native.h:1371
#define _In_opt_
Definition: no_sal2.h:212
ULONG(NTAPI * PTHREAD_START_ROUTINE)(PVOID Parameter)
Definition: rtltypes.h:564
return STATUS_NOT_IMPLEMENTED
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
#define KGDT64_R3_DATA
Definition: ketypes.h:75
#define RPL_MASK
Definition: ketypes.h:69
unsigned char BOOLEAN
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
int64_t LONG64
Definition: typedefs.h:68
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE ApcRoutine
Definition: iofuncs.h:719
#define KGDT64_R0_CODE
Definition: ketypes.h:72
_IRQL_requires_same_ _In_ PVOID _Inout_ struct _CONTEXT * ContextRecord
Definition: ntbasedef.h:655
unsigned __int64 ULONG64
Definition: imports.h:198
BOOLEAN NTAPI RtlDispatchException(IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT Context)
Definition: stubs.c:100
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
#define _In_
Definition: no_sal2.h:158
VOID NTAPI RtlInitializeContext(IN HANDLE ProcessHandle, OUT PCONTEXT ThreadContext, IN PVOID ThreadStartParam OPTIONAL, IN PTHREAD_START_ROUTINE ThreadStartAddress, IN PINITIAL_TEB StackBase)
Definition: stubs.c:23
#define NULL
Definition: types.h:112
#define OUT
Definition: typedefs.h:40
#define KGDT64_R0_DATA
Definition: ketypes.h:73
#define CONTEXT_INTEGER
Definition: nt_native.h:1370
VOID(NTAPI * PKNORMAL_ROUTINE)(IN PVOID NormalContext OPTIONAL, IN PVOID SystemArgument1 OPTIONAL, IN PVOID SystemArgument2 OPTIONAL)
Definition: ketypes.h:674
NTSTATUS NTAPI RtlQueueApcWow64Thread(_In_ HANDLE ThreadHandle, _In_ PKNORMAL_ROUTINE ApcRoutine, _In_opt_ PVOID NormalContext, _In_opt_ PVOID SystemArgument1, _In_opt_ PVOID SystemArgument2)
Definition: stubs.c:118
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
#define EFLAGS_INTERRUPT_MASK
Definition: ketypes.h:126
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68