ReactOS  0.4.14-dev-52-g6116262
psldt.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: ntoskrnl/ps/i386/psldt.c
5  * PURPOSE: LDT support for x86
6  * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* FUNCTIONS *****************************************************************/
16 
17 VOID
18 NTAPI
20 {
21  /* FIXME - LdtInformation must be null as long as we don't implement VDMs */
22  ASSERT(Process->LdtInformation == NULL);
23 }
24 
25 VOID
26 NTAPI
28 {
29  /* If there are no VDM objects, just exit */
30  if (Process->VdmObjects == NULL)
31  return;
32 
33  /* FIXME: Need to do more than just freeing the main VdmObjects member! */
35 
36  /* Free VDM objects */
37  ExFreePoolWithTag(Process->VdmObjects, ' eK');
38  Process->VdmObjects = NULL;
39 }
40 
42 NTAPI
44  IN PVOID ThreadInformation,
47 {
48  DESCRIPTOR_TABLE_ENTRY DescriptorEntry;
51  PAGED_CODE();
52 
53  /* Verify the size */
54  if (ThreadInformationLength != sizeof(DESCRIPTOR_TABLE_ENTRY))
55  {
56  /* Fail */
58  }
59 
60  /* Enter SEH for the copy */
61  _SEH2_TRY
62  {
63  /* Get the descriptor */
64  RtlCopyMemory(&DescriptorEntry,
65  ThreadInformation,
66  sizeof(DESCRIPTOR_TABLE_ENTRY));
67  }
69  {
70  /* Return the exception code */
72  }
73  _SEH2_END;
74 
75  /* Check if this is a GDT selector */
76  if (!(DescriptorEntry.Selector & 0x4))
77  {
78  /* Get the GDT entry */
80  DescriptorEntry.Selector & 0xFFFFFFF8,
82  if (!NT_SUCCESS(Status)) return Status;
83 
84  /* Enter SEH for the copy */
85  _SEH2_TRY
86  {
87  /* Copy the GDT entry to caller */
88  RtlCopyMemory(&((PDESCRIPTOR_TABLE_ENTRY)ThreadInformation)->
89  Descriptor,
90  &Descriptor,
91  sizeof(LDT_ENTRY));
92  if (ReturnLength) *ReturnLength = sizeof(LDT_ENTRY);
93  }
95  {
96  /* Return the exception code */
98  }
99  _SEH2_END;
100 
101  /* Success */
103  }
104  else
105  {
106  /* This is only supported for VDM, which we don't implement */
107  ASSERT(Thread->ThreadsProcess->LdtInformation == NULL);
109  }
110 
111  /* Return status to caller */
112  return Status;
113 }
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
#define IN
Definition: typedefs.h:38
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
VOID NTAPI PspDeleteVdmObjects(PEPROCESS Process)
Definition: psldt.c:27
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define LDT_ENTRY
Definition: ketypes.h:291
LONG NTSTATUS
Definition: precomp.h:26
KTHREAD Tcb
Definition: pstypes.h:1034
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
NTSTATUS NTAPI PspQueryDescriptorThread(IN PETHREAD Thread, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: psldt.c:43
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_NO_LDT
Definition: ntstatus.h:501
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
VOID NTAPI PspDeleteLdt(PEPROCESS Process)
Definition: psldt.c:19
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS NTAPI Ke386GetGdtEntryThread(IN PKTHREAD Thread, IN ULONG Offset, IN PKGDTENTRY Descriptor)
Definition: ldt.c:26
Status
Definition: gdiplustypes.h:24
Definition: compat.h:428
_SEH2_END
Definition: create.c:4424
_In_ THREADINFOCLASS _In_ ULONG ThreadInformationLength
Definition: psfuncs.h:835
unsigned int * PULONG
Definition: retypes.h:1
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:114
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2966
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68