ReactOS  0.4.14-dev-552-g2fad488
libsupp.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for libsupp.c:

Go to the source code of this file.

Classes

struct  _RTL_RANGE_ENTRY
 

Macros

#define NDEBUG
 
#define TAG_ATMT   'TotA' /* Atom table */
 
#define TAG_RTHL   'LHtR' /* Heap Lock */
 
#define TAG_USTR   'RTSU'
 
#define TAG_ASTR   'RTSA'
 
#define TAG_OSTR   'RTSO'
 

Typedefs

typedef struct _RTL_RANGE_ENTRY RTL_RANGE_ENTRY
 
typedef struct _RTL_RANGE_ENTRYPRTL_RANGE_ENTRY
 

Functions

PVOID NTAPI RtlPcToFileHeader (IN PVOID PcValue, OUT PVOID *BaseOfImage)
 
VOID NTAPI RtlInitializeRangeListPackage (VOID)
 
BOOLEAN NTAPI RtlpCheckForActiveDebugger (VOID)
 
BOOLEAN NTAPI RtlpSetInDbgPrint (VOID)
 
VOID NTAPI RtlpClearInDbgPrint (VOID)
 
KPROCESSOR_MODE NTAPI RtlpGetMode (VOID)
 
PVOID NTAPI RtlpAllocateMemory (ULONG Bytes, ULONG Tag)
 
VOID NTAPI RtlpFreeMemory (PVOID Mem, ULONG Tag)
 
VOID NTAPI RtlAcquirePebLock (VOID)
 
VOID NTAPI RtlReleasePebLock (VOID)
 
NTSTATUS NTAPI LdrShutdownThread (VOID)
 
PPEB NTAPI RtlGetCurrentPeb (VOID)
 
NTSTATUS NTAPI RtlDeleteHeapLock (IN OUT PHEAP_LOCK Lock)
 
NTSTATUS NTAPI RtlEnterHeapLock (IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive)
 
BOOLEAN NTAPI RtlTryEnterHeapLock (IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive)
 
NTSTATUS NTAPI RtlInitializeHeapLock (IN OUT PHEAP_LOCK *Lock)
 
NTSTATUS NTAPI RtlLeaveHeapLock (IN OUT PHEAP_LOCK Lock)
 
VOID NTAPI RtlpAddHeapToProcessList (struct _HEAP *Heap)
 
VOID NTAPI RtlpRemoveHeapFromProcessList (struct _HEAP *Heap)
 
VOID RtlInitializeHeapManager (VOID)
 
VOID NTAPI RtlpSetHeapParameters (IN PRTL_HEAP_PARAMETERS Parameters)
 
VOID NTAPI RtlpCheckLogException (IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT ContextRecord, IN PVOID ContextData, IN ULONG Size)
 
BOOLEAN NTAPI RtlpHandleDpcStackException (IN PEXCEPTION_REGISTRATION_RECORD RegistrationFrame, IN ULONG_PTR RegistrationFrameEnd, IN OUT PULONG_PTR StackLow, IN OUT PULONG_PTR StackHigh)
 
BOOLEAN NTAPI RtlpCaptureStackLimits (IN ULONG_PTR Ebp, IN ULONG_PTR *StackBegin, IN ULONG_PTR *StackEnd)
 
ULONG NTAPI RtlWalkFrameChain (OUT PVOID *Callers, IN ULONG Count, IN ULONG Flags)
 
NTSTATUS RtlpInitAtomTableLock (PRTL_ATOM_TABLE AtomTable)
 
VOID RtlpDestroyAtomTableLock (PRTL_ATOM_TABLE AtomTable)
 
BOOLEAN RtlpLockAtomTable (PRTL_ATOM_TABLE AtomTable)
 
VOID RtlpUnlockAtomTable (PRTL_ATOM_TABLE AtomTable)
 
BOOLEAN RtlpCreateAtomHandleTable (PRTL_ATOM_TABLE AtomTable)
 
BOOLEAN NTAPI RtlpCloseHandleCallback (IN PHANDLE_TABLE_ENTRY HandleTableEntry, IN HANDLE Handle, IN PVOID HandleTable)
 
VOID RtlpDestroyAtomHandleTable (PRTL_ATOM_TABLE AtomTable)
 
PRTL_ATOM_TABLE RtlpAllocAtomTable (ULONG Size)
 
VOID RtlpFreeAtomTable (PRTL_ATOM_TABLE AtomTable)
 
PRTL_ATOM_TABLE_ENTRY RtlpAllocAtomTableEntry (ULONG Size)
 
VOID RtlpFreeAtomTableEntry (PRTL_ATOM_TABLE_ENTRY Entry)
 
VOID RtlpFreeAtomHandle (PRTL_ATOM_TABLE AtomTable, PRTL_ATOM_TABLE_ENTRY Entry)
 
BOOLEAN RtlpCreateAtomHandle (PRTL_ATOM_TABLE AtomTable, PRTL_ATOM_TABLE_ENTRY Entry)
 
PRTL_ATOM_TABLE_ENTRY RtlpGetAtomEntry (PRTL_ATOM_TABLE AtomTable, ULONG Index)
 
IMAGE_RESOURCE_DIRECTORYfind_entry_by_name (IMAGE_RESOURCE_DIRECTORY *dir, LPCWSTR name, void *root, int want_dir)
 
IMAGE_RESOURCE_DIRECTORYfind_entry_by_id (IMAGE_RESOURCE_DIRECTORY *dir, USHORT id, void *root, int want_dir)
 
IMAGE_RESOURCE_DIRECTORYfind_first_entry (IMAGE_RESOURCE_DIRECTORY *dir, void *root, int want_dir)
 
NTSTATUS find_entry (PVOID BaseAddress, LDR_RESOURCE_INFO *info, ULONG level, void **ret, int want_dir)
 
NTSTATUS NTAPI RtlpSafeCopyMemory (_Out_writes_bytes_all_(Length) VOID UNALIGNED *Destination, _In_reads_bytes_(Length) CONST VOID UNALIGNED *Source, _In_ SIZE_T Length)
 
BOOLEAN NTAPI RtlCallVectoredExceptionHandlers (_In_ PEXCEPTION_RECORD ExceptionRecord, _In_ PCONTEXT Context)
 
VOID NTAPI RtlCallVectoredContinueHandlers (_In_ PEXCEPTION_RECORD ExceptionRecord, _In_ PCONTEXT Context)
 

Variables

ULONG NtGlobalFlag
 
PAGED_LOOKASIDE_LIST RtlpRangeListEntryLookasideList
 
SIZE_T RtlpAllocDeallocQueryBufferSize = 128
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file libsupp.c.

◆ TAG_ASTR

#define TAG_ASTR   'RTSA'

Definition at line 112 of file libsupp.c.

◆ TAG_ATMT

#define TAG_ATMT   'TotA' /* Atom table */

Definition at line 16 of file libsupp.c.

◆ TAG_OSTR

#define TAG_OSTR   'RTSO'

Definition at line 113 of file libsupp.c.

◆ TAG_RTHL

#define TAG_RTHL   'LHtR' /* Heap Lock */

Definition at line 17 of file libsupp.c.

◆ TAG_USTR

#define TAG_USTR   'RTSU'

Definition at line 111 of file libsupp.c.

Typedef Documentation

◆ PRTL_RANGE_ENTRY

◆ RTL_RANGE_ENTRY

Function Documentation

◆ find_entry()

NTSTATUS find_entry ( PVOID  BaseAddress,
LDR_RESOURCE_INFO info,
ULONG  level,
void **  ret,
int  want_dir 
)

Definition at line 711 of file libsupp.c.

713 {
714  ULONG size;
715  void *root;
716  IMAGE_RESOURCE_DIRECTORY *resdirptr;
717 
720  if (size < sizeof(*resdirptr)) return STATUS_RESOURCE_DATA_NOT_FOUND;
721  resdirptr = root;
722 
723  if (!level--) goto done;
724  if (!(*ret = find_entry_by_name( resdirptr, (LPCWSTR)info->Type, root, want_dir || level )))
726  if (!level--) return STATUS_SUCCESS;
727 
728  resdirptr = *ret;
729  if (!(*ret = find_entry_by_name( resdirptr, (LPCWSTR)info->Name, root, want_dir || level )))
731  if (!level--) return STATUS_SUCCESS;
732  if (level) return STATUS_INVALID_PARAMETER; /* level > 3 */
733 
734  resdirptr = *ret;
735 
736  if ((*ret = find_first_entry( resdirptr, root, want_dir ))) return STATUS_SUCCESS;
737 
739 
740 done:
741  *ret = resdirptr;
742  return STATUS_SUCCESS;
743 }
GLint level
Definition: gl.h:1546
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
IMAGE_RESOURCE_DIRECTORY * find_entry_by_name(IMAGE_RESOURCE_DIRECTORY *dir, LPCWSTR name, void *root, int want_dir)
Definition: res.c:130
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _root root
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
GLsizeiptr size
Definition: glext.h:5919
IMAGE_RESOURCE_DIRECTORY * find_first_entry(IMAGE_RESOURCE_DIRECTORY *dir, void *root, int want_dir)
Definition: res.c:75
int ret
#define STATUS_RESOURCE_DATA_NOT_FOUND
Definition: ntstatus.h:359
#define RtlImageDirectoryEntryToData
Definition: compat.h:468
#define STATUS_RESOURCE_NAME_NOT_FOUND
Definition: ntstatus.h:361
unsigned int ULONG
Definition: retypes.h:1
#define IMAGE_DIRECTORY_ENTRY_RESOURCE
Definition: pedump.c:261
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define STATUS_RESOURCE_TYPE_NOT_FOUND
Definition: ntstatus.h:360

Referenced by LdrFindResource_U(), and LdrFindResourceDirectory_U().

◆ find_entry_by_id()

IMAGE_RESOURCE_DIRECTORY* find_entry_by_id ( IMAGE_RESOURCE_DIRECTORY dir,
USHORT  id,
void root,
int  want_dir 
)

Definition at line 95 of file res.c.

97 {
99  int min, max, pos;
100 
101  entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
102  min = dir->NumberOfNamedEntries;
103  max = min + dir->NumberOfIdEntries - 1;
104  while (min <= max)
105  {
106  pos = (min + max) / 2;
107  if (entry[pos].Id == id)
108  {
109  if (!entry[pos].DataIsDirectory == !want_dir)
110  {
111  DPRINT("root %p dir %p id %04x ret %p\n",
112  root, dir, id, (const char*)root + entry[pos].OffsetToDirectory);
113  return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].OffsetToDirectory);
114  }
115  break;
116  }
117  if (entry[pos].Id > id) max = pos - 1;
118  else min = pos + 1;
119  }
120  DPRINT("root %p dir %p id %04x not found\n", root, dir, id );
121  return NULL;
122 }
#define max(a, b)
Definition: svc.c:63
DWORD Id
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
unsigned int dir
Definition: maze.c:112
uint32_t entry
Definition: isohybrid.c:63
Definition: pedump.c:413
#define min(a, b)
Definition: monoChain.cc:55

Referenced by find_entry_by_name().

◆ find_entry_by_name()

IMAGE_RESOURCE_DIRECTORY* find_entry_by_name ( IMAGE_RESOURCE_DIRECTORY dir,
LPCWSTR  name,
void root,
int  want_dir 
)

Definition at line 130 of file res.c.

133 {
136  int min, max, res, pos;
137  size_t namelen;
138 
139  if (!((ULONG_PTR)name & 0xFFFF0000)) return find_entry_by_id( dir, (ULONG_PTR)name & 0xFFFF, root, want_dir );
140  entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
141  namelen = wcslen(name);
142  min = 0;
143  max = dir->NumberOfNamedEntries - 1;
144  while (min <= max)
145  {
146  pos = (min + max) / 2;
147  str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const char *)root + entry[pos].NameOffset);
148  res = _wcsnicmp( name, str->NameString, str->Length );
149  if (!res && namelen == str->Length)
150  {
151  if (!entry[pos].DataIsDirectory == !want_dir)
152  {
153  DPRINT("root %p dir %p name %ws ret %p\n",
154  root, dir, name, (const char*)root + entry[pos].OffsetToDirectory);
155  return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].OffsetToDirectory);
156  }
157  break;
158  }
159  if (res < 0) max = pos - 1;
160  else min = pos + 1;
161  }
162  DPRINT("root %p dir %p name %ws not found\n", root, dir, name);
163  return NULL;
164 }
#define max(a, b)
Definition: svc.c:63
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
IMAGE_RESOURCE_DIRECTORY * find_entry_by_id(IMAGE_RESOURCE_DIRECTORY *dir, WORD id, void *root, int want_dir)
Definition: res.c:95
GLint namelen
Definition: glext.h:7232
uint32_t ULONG_PTR
Definition: typedefs.h:63
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
unsigned int dir
Definition: maze.c:112
uint32_t entry
Definition: isohybrid.c:63
Definition: pedump.c:413
#define min(a, b)
Definition: monoChain.cc:55
Definition: name.c:38
GLuint res
Definition: glext.h:9613
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ find_first_entry()

IMAGE_RESOURCE_DIRECTORY* find_first_entry ( IMAGE_RESOURCE_DIRECTORY dir,
void root,
int  want_dir 
)

Definition at line 75 of file res.c.

77 {
79  int pos;
80 
81  for (pos = 0; pos < dir->NumberOfNamedEntries + dir->NumberOfIdEntries; pos++)
82  {
83  if (!entry[pos].DataIsDirectory == !want_dir)
84  return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].OffsetToDirectory);
85  }
86  return NULL;
87 }
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
uint32_t entry
Definition: isohybrid.c:63
Definition: pedump.c:413

◆ LdrShutdownThread()

NTSTATUS NTAPI LdrShutdownThread ( VOID  )

Definition at line 145 of file libsupp.c.

146 {
147  return STATUS_SUCCESS;
148 }
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ RtlAcquirePebLock()

VOID NTAPI RtlAcquirePebLock ( VOID  )

Definition at line 129 of file libsupp.c.

130 {
131 
132 }

◆ RtlCallVectoredContinueHandlers()

VOID NTAPI RtlCallVectoredContinueHandlers ( _In_ PEXCEPTION_RECORD  ExceptionRecord,
_In_ PCONTEXT  Context 
)

Definition at line 776 of file libsupp.c.

778 {
779  /* No vectored continue handlers either in kernel mode */
780  return;
781 }

Referenced by RtlDispatchException().

◆ RtlCallVectoredExceptionHandlers()

BOOLEAN NTAPI RtlCallVectoredExceptionHandlers ( _In_ PEXCEPTION_RECORD  ExceptionRecord,
_In_ PCONTEXT  Context 
)

Definition at line 767 of file libsupp.c.

769 {
770  /* In the kernel we don't have vectored exception handlers */
771  return FALSE;
772 }

Referenced by RtlDispatchException().

◆ RtlDeleteHeapLock()

NTSTATUS NTAPI RtlDeleteHeapLock ( IN OUT PHEAP_LOCK  Lock)

Definition at line 160 of file libsupp.c.

161 {
162  ExDeleteResourceLite(&Lock->Resource);
164 
165  return STATUS_SUCCESS;
166 }
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75
#define TAG_RTHL
Definition: libsupp.c:17
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ RtlEnterHeapLock()

NTSTATUS NTAPI RtlEnterHeapLock ( IN OUT PHEAP_LOCK  Lock,
IN BOOLEAN  Exclusive 
)

Definition at line 170 of file libsupp.c.

171 {
173 
174  if (Exclusive)
176  else
178 
179  return STATUS_SUCCESS;
180 }
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ RtlGetCurrentPeb()

PPEB NTAPI RtlGetCurrentPeb ( VOID  )

Definition at line 153 of file libsupp.c.

154 {
155  return ((PEPROCESS)(KeGetCurrentThread()->ApcState.Process))->Peb;
156 }
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1492
#define KeGetCurrentThread
Definition: hal.h:44

◆ RtlInitializeHeapLock()

NTSTATUS NTAPI RtlInitializeHeapLock ( IN OUT PHEAP_LOCK Lock)

Definition at line 202 of file libsupp.c.

203 {
205  sizeof(HEAP_LOCK),
206  TAG_RTHL);
207  if (HeapLock == NULL)
208  return STATUS_NO_MEMORY;
209 
211  *Lock = HeapLock;
212 
213  return STATUS_SUCCESS;
214 }
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI HeapLock(HANDLE hHeap)
Definition: heapmem.c:123
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75
#define TAG_RTHL
Definition: libsupp.c:17
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ RtlInitializeHeapManager()

VOID RtlInitializeHeapManager ( VOID  )

Definition at line 243 of file libsupp.c.

244 {
245 }

◆ RtlInitializeRangeListPackage()

VOID NTAPI RtlInitializeRangeListPackage ( VOID  )

Definition at line 58 of file libsupp.c.

59 {
60  /* Setup the lookaside list for allocations (not used yet) */
62  NULL,
63  NULL,
65  sizeof(RTL_RANGE_ENTRY),
66  'elRR',
67  16);
68 }
PAGED_LOOKASIDE_LIST RtlpRangeListEntryLookasideList
Definition: libsupp.c:27
VOID NTAPI ExInitializePagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:274
#define POOL_COLD_ALLOCATION
Definition: libsupp.c:21
smooth NULL
Definition: ftsmooth.c:416

Referenced by Phase1InitializationDiscard().

◆ RtlLeaveHeapLock()

NTSTATUS NTAPI RtlLeaveHeapLock ( IN OUT PHEAP_LOCK  Lock)

Definition at line 218 of file libsupp.c.

219 {
220  ExReleaseResourceLite(&Lock->Resource);
222 
223  return STATUS_SUCCESS;
224 }
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ RtlpAddHeapToProcessList()

VOID NTAPI RtlpAddHeapToProcessList ( struct _HEAP Heap)

Definition at line 230 of file libsupp.c.

231 {
233 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323

Referenced by RtlCreateHeap().

◆ RtlpAllocateMemory()

PVOID NTAPI RtlpAllocateMemory ( ULONG  Bytes,
ULONG  Tag 
)

Definition at line 102 of file libsupp.c.

104 {
106  (SIZE_T)Bytes,
107  Tag);
108 }
_In_ UINT Bytes
Definition: mmcopy.h:9
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG_PTR SIZE_T
Definition: typedefs.h:78
IN ULONG IN ULONG Tag
Definition: evtlib.h:159

◆ RtlpAllocAtomTable()

PRTL_ATOM_TABLE RtlpAllocAtomTable ( ULONG  Size)

Definition at line 584 of file libsupp.c.

585 {
587  Size,
588  TAG_ATMT);
589  if (Table != NULL)
590  {
592  Size);
593  }
594 
595  return Table;
596 }
ASMGENDATA Table[]
Definition: genincdata.c:61
smooth NULL
Definition: ftsmooth.c:416
#define TAG_ATMT
Definition: libsupp.c:16
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
struct atom_table ** PRTL_ATOM_TABLE
Definition: atom.c:43
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by RtlCreateAtomTable().

◆ RtlpAllocAtomTableEntry()

PRTL_ATOM_TABLE_ENTRY RtlpAllocAtomTableEntry ( ULONG  Size)

Definition at line 605 of file libsupp.c.

606 {
608 
610  if (Entry != NULL)
611  {
613  }
614 
615  return Entry;
616 }
Definition: rtltypes.h:1642
struct _Entry Entry
Definition: kefuncs.h:640
smooth NULL
Definition: ftsmooth.c:416
#define TAG_ATMT
Definition: libsupp.c:16
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
base of all file and directory entries
Definition: entries.h:82

Referenced by RtlAddAtomToAtomTable().

◆ RtlpCaptureStackLimits()

BOOLEAN NTAPI RtlpCaptureStackLimits ( IN ULONG_PTR  Ebp,
IN ULONG_PTR StackBegin,
IN ULONG_PTR StackEnd 
)

Definition at line 321 of file libsupp.c.

324 {
326 
327  /* Don't even try at ISR level or later */
328  if (KeGetCurrentIrql() > DISPATCH_LEVEL) return FALSE;
329 
330  /* Start with defaults */
331  *StackBegin = Thread->StackLimit;
332  *StackEnd = (ULONG_PTR)Thread->StackBase;
333 
334  /* Check if EBP is inside the stack */
335  if ((*StackBegin <= Ebp) && (Ebp <= *StackEnd))
336  {
337  /* Then make the stack start at EBP */
338  *StackBegin = Ebp;
339  }
340  else
341  {
342  /* Now we're going to assume we're on the DPC stack */
343  *StackEnd = (ULONG_PTR)(KeGetPcr()->Prcb->DpcStack);
344  *StackBegin = *StackEnd - KERNEL_STACK_SIZE;
345 
346  /* Check if we seem to be on the DPC stack */
347  if ((*StackEnd) && (*StackBegin < Ebp) && (Ebp <= *StackEnd))
348  {
349  /* We're on the DPC stack */
350  *StackBegin = Ebp;
351  }
352  else
353  {
354  /* We're somewhere else entirely... use EBP for safety */
355  *StackBegin = Ebp;
356  *StackEnd = (ULONG_PTR)PAGE_ALIGN(*StackBegin);
357  }
358  }
359 
360  /* Return success */
361  return TRUE;
362 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define TRUE
Definition: types.h:120
#define KeGetPcr()
Definition: ke.h:25
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define PAGE_ALIGN(Va)
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define KERNEL_STACK_SIZE
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define ULONG_PTR
Definition: config.h:101
#define KeGetCurrentThread
Definition: hal.h:44

◆ RtlpCheckForActiveDebugger()

BOOLEAN NTAPI RtlpCheckForActiveDebugger ( VOID  )

Definition at line 72 of file libsupp.c.

73 {
74  /* This check is meaningless in kernel-mode */
75  return FALSE;
76 }

◆ RtlpCheckLogException()

VOID NTAPI RtlpCheckLogException ( IN PEXCEPTION_RECORD  ExceptionRecord,
IN PCONTEXT  ContextRecord,
IN PVOID  ContextData,
IN ULONG  Size 
)

Definition at line 272 of file libsupp.c.

276 {
277  /* Check the global flag */
279  {
280  /* FIXME: Log this exception */
281  }
282 }
#define FLG_ENABLE_EXCEPTION_LOGGING
Definition: pstypes.h:82
ULONG NtGlobalFlag
Definition: init.c:51

◆ RtlpClearInDbgPrint()

VOID NTAPI RtlpClearInDbgPrint ( VOID  )

Definition at line 88 of file libsupp.c.

89 {
90  /* Nothing to clear in kernel mode */
91 }

◆ RtlpCloseHandleCallback()

BOOLEAN NTAPI RtlpCloseHandleCallback ( IN PHANDLE_TABLE_ENTRY  HandleTableEntry,
IN HANDLE  Handle,
IN PVOID  HandleTable 
)

Definition at line 561 of file libsupp.c.

565 {
566  /* Destroy and unlock the handle entry */
567  return ExDestroyHandle(HandleTable, Handle, HandleTableEntry);
568 }
BOOLEAN NTAPI ExDestroyHandle(IN PHANDLE_TABLE HandleTable, IN HANDLE Handle, IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL)
Definition: handle.c:948
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
_In_ HANDLE Handle
Definition: extypes.h:390

Referenced by RtlpDestroyAtomHandleTable().

◆ RtlpCreateAtomHandle()

BOOLEAN RtlpCreateAtomHandle ( PRTL_ATOM_TABLE  AtomTable,
PRTL_ATOM_TABLE_ENTRY  Entry 
)

Definition at line 633 of file libsupp.c.

634 {
635  HANDLE_TABLE_ENTRY ExEntry;
636  HANDLE Handle;
637  USHORT HandleIndex;
638 
639  /* Initialize ex handle table entry */
640  ExEntry.Object = Entry;
641  ExEntry.GrantedAccess = 0x1; /* FIXME - valid handle */
642 
643  /* Create ex handle */
644  Handle = ExCreateHandle(AtomTable->ExHandleTable,
645  &ExEntry);
646  if (!Handle) return FALSE;
647 
648  /* Calculate HandleIndex (by getting rid of the first two bits) */
649  HandleIndex = (USHORT)((ULONG_PTR)Handle >> 2);
650 
651  /* Index must be less than 0xC000 */
652  if (HandleIndex >= 0xC000)
653  {
654  /* Destroy ex handle */
655  ExDestroyHandle(AtomTable->ExHandleTable,
656  Handle,
657  NULL);
658 
659  /* Return failure */
660  return FALSE;
661  }
662 
663  /* Initialize atom table entry */
664  Entry->HandleIndex = HandleIndex;
665  Entry->Atom = 0xC000 + HandleIndex;
666 
667  /* Return success */
668  return TRUE;
669 }
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI ExDestroyHandle(IN PHANDLE_TABLE HandleTable, IN HANDLE Handle, IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL)
Definition: handle.c:948
struct _Entry Entry
Definition: kefuncs.h:640
uint32_t ULONG_PTR
Definition: typedefs.h:63
HANDLE NTAPI ExCreateHandle(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:791
Definition: extypes.h:595
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE Handle
Definition: extypes.h:390
ULONG GrantedAccess
Definition: extypes.h:606
unsigned short USHORT
Definition: pedump.c:61
PVOID Object
Definition: extypes.h:599
base of all file and directory entries
Definition: entries.h:82

Referenced by RtlAddAtomToAtomTable().

◆ RtlpCreateAtomHandleTable()

BOOLEAN RtlpCreateAtomHandleTable ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 553 of file libsupp.c.

554 {
555  AtomTable->ExHandleTable = ExCreateHandleTable(NULL);
556  return (AtomTable->ExHandleTable != NULL);
557 }
smooth NULL
Definition: ftsmooth.c:416
PHANDLE_TABLE NTAPI ExCreateHandleTable(IN PEPROCESS Process OPTIONAL)
Definition: handle.c:765

Referenced by RtlCreateAtomTable().

◆ RtlPcToFileHeader()

PVOID NTAPI RtlPcToFileHeader ( IN PVOID  PcValue,
OUT PVOID BaseOfImage 
)

Definition at line 34 of file libsupp.c.

37 {
38  PLDR_DATA_TABLE_ENTRY LdrEntry;
39  BOOLEAN InSystem;
40 
41  /* Get the base for this file */
43  {
44  /* We are in kernel */
45  *BaseOfImage = KiPcToFileHeader(PcValue, &LdrEntry, FALSE, &InSystem);
46  }
47  else
48  {
49  /* We are in user land */
50  *BaseOfImage = KiRosPcToUserFileHeader(PcValue, &LdrEntry);
51  }
52 
53  return *BaseOfImage;
54 }
PVOID NTAPI KiPcToFileHeader(IN PVOID Eip, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry, IN BOOLEAN DriversOnly, OUT PBOOLEAN InKernel)
Definition: bug.c:44
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char BOOLEAN
PVOID MmHighestUserAddress
Definition: libsupp.c:23
Definition: btrfs_drv.h:1853
PVOID NTAPI KiRosPcToUserFileHeader(IN PVOID Eip, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry)
Definition: bug.c:109

◆ RtlpDestroyAtomHandleTable()

VOID RtlpDestroyAtomHandleTable ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 571 of file libsupp.c.

572 {
573  if (AtomTable->ExHandleTable)
574  {
575  ExSweepHandleTable(AtomTable->ExHandleTable,
577  AtomTable->ExHandleTable);
578  ExDestroyHandleTable(AtomTable->ExHandleTable, NULL);
579  AtomTable->ExHandleTable = NULL;
580  }
581 }
VOID NTAPI ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable, IN PVOID DestroyHandleProcedure OPTIONAL)
Definition: handle.c:927
BOOLEAN NTAPI RtlpCloseHandleCallback(IN PHANDLE_TABLE_ENTRY HandleTableEntry, IN HANDLE Handle, IN PVOID HandleTable)
Definition: libsupp.c:561
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI ExSweepHandleTable(IN PHANDLE_TABLE HandleTable, IN PEX_SWEEP_HANDLE_CALLBACK EnumHandleProcedure, IN PVOID Context)
Definition: handle.c:1196

Referenced by RtlDestroyAtomTable().

◆ RtlpDestroyAtomTableLock()

VOID RtlpDestroyAtomTableLock ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 534 of file libsupp.c.

535 {
536 }

Referenced by RtlCreateAtomTable(), and RtlDestroyAtomTable().

◆ RtlpFreeAtomHandle()

VOID RtlpFreeAtomHandle ( PRTL_ATOM_TABLE  AtomTable,
PRTL_ATOM_TABLE_ENTRY  Entry 
)

Definition at line 625 of file libsupp.c.

626 {
627  ExDestroyHandle(AtomTable->ExHandleTable,
628  (HANDLE)((ULONG_PTR)Entry->HandleIndex << 2),
629  NULL);
630 }
BOOLEAN NTAPI ExDestroyHandle(IN PHANDLE_TABLE HandleTable, IN HANDLE Handle, IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL)
Definition: handle.c:948
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
base of all file and directory entries
Definition: entries.h:82

Referenced by RtlDeleteAtomFromAtomTable(), and RtlEmptyAtomTable().

◆ RtlpFreeAtomTable()

VOID RtlpFreeAtomTable ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 599 of file libsupp.c.

600 {
601  ExFreePoolWithTag(AtomTable, TAG_ATMT);
602 }
#define TAG_ATMT
Definition: libsupp.c:16
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by RtlCreateAtomTable(), and RtlDestroyAtomTable().

◆ RtlpFreeAtomTableEntry()

VOID RtlpFreeAtomTableEntry ( PRTL_ATOM_TABLE_ENTRY  Entry)

Definition at line 619 of file libsupp.c.

620 {
622 }
#define TAG_ATMT
Definition: libsupp.c:16
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
base of all file and directory entries
Definition: entries.h:82

Referenced by RtlAddAtomToAtomTable(), RtlDeleteAtomFromAtomTable(), RtlDestroyAtomTable(), and RtlEmptyAtomTable().

◆ RtlpFreeMemory()

VOID NTAPI RtlpFreeMemory ( PVOID  Mem,
ULONG  Tag 
)

Definition at line 116 of file libsupp.c.

118 {
119  if (Tag == TAG_ASTR || Tag == TAG_OSTR || Tag == TAG_USTR)
120  ExFreePool(Mem);
121  else
122  ExFreePoolWithTag(Mem, Tag);
123 }
#define TAG_OSTR
Definition: libsupp.c:113
#define TAG_USTR
Definition: libsupp.c:111
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define TAG_ASTR
Definition: libsupp.c:112
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ RtlpGetAtomEntry()

PRTL_ATOM_TABLE_ENTRY RtlpGetAtomEntry ( PRTL_ATOM_TABLE  AtomTable,
ULONG  Index 
)

Definition at line 672 of file libsupp.c.

673 {
674  PHANDLE_TABLE_ENTRY ExEntry;
676 
677  /* NOTE: There's no need to explicitly enter a critical region because it's
678  guaranteed that we're in a critical region right now (as we hold
679  the atom table lock) */
680 
681  ExEntry = ExMapHandleToPointer(AtomTable->ExHandleTable,
682  (HANDLE)((ULONG_PTR)Index << 2));
683  if (ExEntry != NULL)
684  {
685  Entry = ExEntry->Object;
686 
687  ExUnlockHandleTableEntry(AtomTable->ExHandleTable,
688  ExEntry);
689  }
690 
691  return Entry;
692 }
Definition: rtltypes.h:1642
struct _Entry Entry
Definition: kefuncs.h:640
PHANDLE_TABLE_ENTRY NTAPI ExMapHandleToPointer(IN PHANDLE_TABLE HandleTable, IN HANDLE Handle)
Definition: handle.c:1010
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:887
uint32_t ULONG_PTR
Definition: typedefs.h:63
Definition: extypes.h:595
smooth NULL
Definition: ftsmooth.c:416
static const UCHAR Index[8]
Definition: usbohci.c:18
PVOID Object
Definition: extypes.h:599
base of all file and directory entries
Definition: entries.h:82

Referenced by RtlDeleteAtomFromAtomTable(), RtlPinAtomInAtomTable(), and RtlQueryAtomInAtomTable().

◆ RtlpGetMode()

KPROCESSOR_MODE NTAPI RtlpGetMode ( VOID  )

Definition at line 95 of file libsupp.c.

96 {
97  return KernelMode;
98 }

◆ RtlpHandleDpcStackException()

BOOLEAN NTAPI RtlpHandleDpcStackException ( IN PEXCEPTION_REGISTRATION_RECORD  RegistrationFrame,
IN ULONG_PTR  RegistrationFrameEnd,
IN OUT PULONG_PTR  StackLow,
IN OUT PULONG_PTR  StackHigh 
)

Definition at line 286 of file libsupp.c.

290 {
291  PKPRCB Prcb;
292  ULONG_PTR DpcStack;
293 
294  /* Check if we are at DISPATCH or higher */
296  {
297  /* Get the PRCB and DPC Stack */
298  Prcb = KeGetCurrentPrcb();
299  DpcStack = (ULONG_PTR)Prcb->DpcStack;
300 
301  /* Check if we are in a DPC and the stack matches */
302  if ((Prcb->DpcRoutineActive) &&
303  (RegistrationFrameEnd <= DpcStack) &&
304  ((ULONG_PTR)RegistrationFrame >= DpcStack - KERNEL_STACK_SIZE))
305  {
306  /* Update the limits to the DPC Stack's */
307  *StackHigh = DpcStack;
308  *StackLow = DpcStack - KERNEL_STACK_SIZE;
309  return TRUE;
310  }
311  }
312 
313  /* Not in DPC stack */
314  return FALSE;
315 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define TRUE
Definition: types.h:120
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1062
uint32_t ULONG_PTR
Definition: typedefs.h:63
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define KERNEL_STACK_SIZE
UCHAR DpcRoutineActive
Definition: ketypes.h:688
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
PVOID DpcStack
Definition: ketypes.h:677
#define ULONG_PTR
Definition: config.h:101

◆ RtlpInitAtomTableLock()

NTSTATUS RtlpInitAtomTableLock ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 525 of file libsupp.c.

526 {
527  ExInitializeFastMutex(&AtomTable->FastMutex);
528 
529  return STATUS_SUCCESS;
530 }
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by RtlCreateAtomTable().

◆ RtlpLockAtomTable()

BOOLEAN RtlpLockAtomTable ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 540 of file libsupp.c.

541 {
542  ExAcquireFastMutex(&AtomTable->FastMutex);
543  return TRUE;
544 }
#define TRUE
Definition: types.h:120
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23

Referenced by RtlAddAtomToAtomTable(), RtlDeleteAtomFromAtomTable(), RtlDestroyAtomTable(), RtlEmptyAtomTable(), RtlLookupAtomInAtomTable(), RtlPinAtomInAtomTable(), RtlQueryAtomInAtomTable(), and RtlQueryAtomListInAtomTable().

◆ RtlpRemoveHeapFromProcessList()

VOID NTAPI RtlpRemoveHeapFromProcessList ( struct _HEAP Heap)

Definition at line 237 of file libsupp.c.

238 {
240 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323

Referenced by RtlDestroyHeap().

◆ RtlpSafeCopyMemory()

NTSTATUS NTAPI RtlpSafeCopyMemory ( _Out_writes_bytes_all_(Length) VOID UNALIGNED Destination,
_In_reads_bytes_(Length) CONST VOID UNALIGNED Source,
_In_ SIZE_T  Length 
)

Definition at line 747 of file libsupp.c.

751 {
752  _SEH2_TRY
753  {
755  }
757  {
759  }
760  _SEH2_END;
761 
762  return STATUS_SUCCESS;
763 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2891
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_SEH2_END
Definition: create.c:4424
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ RtlpSetHeapParameters()

VOID NTAPI RtlpSetHeapParameters ( IN PRTL_HEAP_PARAMETERS  Parameters)

Definition at line 261 of file libsupp.c.

262 {
263  /* Apply defaults for non-set parameters */
264  if (!Parameters->SegmentCommit) Parameters->SegmentCommit = MmHeapSegmentCommit;
265  if (!Parameters->SegmentReserve) Parameters->SegmentReserve = MmHeapSegmentReserve;
266  if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = MmHeapDeCommitFreeBlockThreshold;
267  if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = MmHeapDeCommitTotalFreeThreshold;
268 }
SIZE_T MmHeapDeCommitTotalFreeThreshold
Definition: mminit.c:368
SIZE_T MmHeapDeCommitFreeBlockThreshold
Definition: mminit.c:369
SIZE_T MmHeapSegmentReserve
Definition: mminit.c:366
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
SIZE_T MmHeapSegmentCommit
Definition: mminit.c:367

◆ RtlpSetInDbgPrint()

BOOLEAN NTAPI RtlpSetInDbgPrint ( VOID  )

Definition at line 80 of file libsupp.c.

81 {
82  /* Nothing to set in kernel mode */
83  return FALSE;
84 }

◆ RtlpUnlockAtomTable()

VOID RtlpUnlockAtomTable ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 547 of file libsupp.c.

548 {
549  ExReleaseFastMutex(&AtomTable->FastMutex);
550 }
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31

Referenced by RtlAddAtomToAtomTable(), RtlDeleteAtomFromAtomTable(), RtlDestroyAtomTable(), RtlEmptyAtomTable(), RtlLookupAtomInAtomTable(), RtlPinAtomInAtomTable(), RtlQueryAtomInAtomTable(), and RtlQueryAtomListInAtomTable().

◆ RtlReleasePebLock()

VOID NTAPI RtlReleasePebLock ( VOID  )

Definition at line 138 of file libsupp.c.

139 {
140 
141 }

◆ RtlTryEnterHeapLock()

BOOLEAN NTAPI RtlTryEnterHeapLock ( IN OUT PHEAP_LOCK  Lock,
IN BOOLEAN  Exclusive 
)

Definition at line 184 of file libsupp.c.

185 {
188 
189  if (Exclusive)
191  else
193 
194  if (!Success)
196 
197  return Success;
198 }
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
unsigned char BOOLEAN
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885

◆ RtlWalkFrameChain()

ULONG NTAPI RtlWalkFrameChain ( OUT PVOID Callers,
IN ULONG  Count,
IN ULONG  Flags 
)

Definition at line 369 of file libsupp.c.

372 {
373  ULONG_PTR Stack, NewStack, StackBegin, StackEnd = 0;
374  ULONG Eip;
375  BOOLEAN Result, StopSearch = FALSE;
376  ULONG i = 0;
378  PTEB Teb;
379  PKTRAP_FRAME TrapFrame;
380 
381  /* Get current EBP */
382 #if defined(_M_IX86)
383 #if defined __GNUC__
384  __asm__("mov %%ebp, %0" : "=r" (Stack) : );
385 #elif defined(_MSC_VER)
386  __asm mov Stack, ebp
387 #endif
388 #elif defined(_M_MIPS)
389  __asm__("move $sp, %0" : "=r" (Stack) : );
390 #elif defined(_M_PPC)
391  __asm__("mr %0,1" : "=r" (Stack) : );
392 #elif defined(_M_ARM)
393  __asm__("mov sp, %0" : "=r"(Stack) : );
394 #else
395 #error Unknown architecture
396 #endif
397 
398  /* Set it as the stack begin limit as well */
399  StackBegin = (ULONG_PTR)Stack;
400 
401  /* Check if we're called for non-logging mode */
402  if (!Flags)
403  {
404  /* Get the actual safe limits */
406  &StackBegin,
407  &StackEnd);
408  if (!Result) return 0;
409  }
410 
411  /* Use a SEH block for maximum protection */
412  _SEH2_TRY
413  {
414  /* Check if we want the user-mode stack frame */
415  if (Flags == 1)
416  {
417  /* Get the trap frame and TEB */
418  TrapFrame = KeGetTrapFrame(&Thread->Tcb);
419  Teb = Thread->Tcb.Teb;
420 
421  /* Make sure we can trust the TEB and trap frame */
422  if (!(Teb) ||
423  (KeIsAttachedProcess()) ||
425  {
426  /* Invalid or unsafe attempt to get the stack */
427  _SEH2_YIELD(return 0;)
428  }
429 
430  /* Get the stack limits */
431  StackBegin = (ULONG_PTR)Teb->NtTib.StackLimit;
432  StackEnd = (ULONG_PTR)Teb->NtTib.StackBase;
433 #ifdef _M_IX86
434  Stack = TrapFrame->Ebp;
435 #elif defined(_M_PPC)
436  Stack = TrapFrame->Gpr1;
437 #else
438 #error Unknown architecture
439 #endif
440 
441  /* Validate them */
442  if (StackEnd <= StackBegin) _SEH2_YIELD(return 0);
443  ProbeForRead((PVOID)StackBegin,
444  StackEnd - StackBegin,
445  sizeof(CHAR));
446  }
447 
448  /* Loop the frames */
449  for (i = 0; i < Count; i++)
450  {
451  /*
452  * Leave if we're past the stack,
453  * if we're before the stack,
454  * or if we've reached ourselves.
455  */
456  if ((Stack >= StackEnd) ||
457  (!i ? (Stack < StackBegin) : (Stack <= StackBegin)) ||
458  ((StackEnd - Stack) < (2 * sizeof(ULONG_PTR))))
459  {
460  /* We're done or hit a bad address */
461  break;
462  }
463 
464  /* Get new stack and EIP */
465  NewStack = *(PULONG_PTR)Stack;
466  Eip = *(PULONG_PTR)(Stack + sizeof(ULONG_PTR));
467 
468  /* Check if the new pointer is above the oldone and past the end */
469  if (!((Stack < NewStack) && (NewStack < StackEnd)))
470  {
471  /* Stop searching after this entry */
472  StopSearch = TRUE;
473  }
474 
475  /* Also make sure that the EIP isn't a stack address */
476  if ((StackBegin < Eip) && (Eip < StackEnd)) break;
477 
478  /* Check if we reached a user-mode address */
479  if (!(Flags) && !(Eip & 0x80000000)) break; // FIXME: 3GB breakage
480 
481  /* Save this frame */
482  Callers[i] = (PVOID)Eip;
483 
484  /* Check if we should continue */
485  if (StopSearch)
486  {
487  /* Return the next index */
488  i++;
489  break;
490  }
491 
492  /* Move to the next stack */
493  Stack = NewStack;
494  }
495  }
497  {
498  /* No index */
499  i = 0;
500  }
501  _SEH2_END;
502 
503  /* Return frames parsed */
504  return i;
505 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define TRUE
Definition: types.h:120
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx eax jnz xchgl ecx incl TEMP esp ecx subl ebx pushl ecx ecx edx ecx ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 mm1 mm5 paddd mm0 paddd mm4 mm0 mm4 packssdw mm0 packssdw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz popl ecx ecx jecxz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 mm1 paddd mm0 mm0 packssdw mm0 movd eax movw edi esi edx esi ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 mm1 mm5 paddd mm1 paddd mm5 mm1 mm5 packssdw mm1 packssdw mm5 psubd mm0 psubd mm4 psubsw mm0 psubsw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 mm1 paddd mm1 mm1 packssdw mm1 psubd mm0 psubsw mm0 movd eax movw edi emms popl ebx popl esi popl edi mov ebp
Definition: synth_sse3d.h:248
char CHAR
Definition: xmlstorage.h:175
KTHREAD Tcb
Definition: pstypes.h:1034
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
BOOLEAN NTAPI KeIsAttachedProcess(VOID)
Definition: procobj.c:690
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
ULONG Gpr1
Definition: ketypes.h:103
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
void * PVOID
Definition: retypes.h:9
BOOLEAN NTAPI RtlpCaptureStackLimits(IN ULONG_PTR Ebp, IN ULONG_PTR *StackBegin, IN ULONG_PTR *StackEnd)
Definition: libsupp.c:211
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
Definition: compat.h:492
_SEH2_END
Definition: create.c:4424
PVOID StackBase
Definition: compat.h:380
PVOID Teb
Definition: ketypes.h:1697
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
uint32_t * PULONG_PTR
Definition: typedefs.h:63
PVOID StackLimit
Definition: compat.h:381
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define KeGetTrapFrame(Thread)
Definition: ke.h:145
NT_TIB NtTib
Definition: ntddk_ex.h:332
ULONG Ebp
Definition: ketypes.h:265

Variable Documentation

◆ NtGlobalFlag

ULONG NtGlobalFlag

Definition at line 51 of file init.c.

Referenced by RtlpCheckLogException().

◆ RtlpAllocDeallocQueryBufferSize

SIZE_T RtlpAllocDeallocQueryBufferSize = 128

Definition at line 28 of file libsupp.c.

Referenced by RtlQueryRegistryValues().

◆ RtlpRangeListEntryLookasideList

PAGED_LOOKASIDE_LIST RtlpRangeListEntryLookasideList

Definition at line 27 of file libsupp.c.

Referenced by RtlInitializeRangeListPackage().