ReactOS  0.4.14-dev-554-g2f8d847
libsupp.c File Reference
#include <ntdll.h>
#include <debug.h>
Include dependency graph for libsupp.c:

Go to the source code of this file.

Classes

struct  _RTL_ATOM_HANDLE
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _RTL_ATOM_HANDLE RTL_ATOM_HANDLE
 
typedef struct _RTL_ATOM_HANDLEPRTL_ATOM_HANDLE
 

Functions

BOOLEAN NTAPI RtlpCheckForActiveDebugger (VOID)
 
BOOLEAN NTAPI RtlpSetInDbgPrint (VOID)
 
VOID NTAPI RtlpClearInDbgPrint (VOID)
 
KPROCESSOR_MODE NTAPI RtlpGetMode (VOID)
 
PPEB NTAPI RtlGetCurrentPeb (VOID)
 
VOID NTAPI RtlAcquirePebLock (VOID)
 
VOID NTAPI RtlReleasePebLock (VOID)
 
ULONG NTAPI RtlGetNtGlobalFlags (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)
 
PVOID NTAPI RtlpAllocateMemory (UINT Bytes, ULONG Tag)
 
VOID NTAPI RtlpFreeMemory (PVOID Mem, ULONG Tag)
 
VOID NTAPI RtlpSetHeapParameters (IN PRTL_HEAP_PARAMETERS Parameters)
 
BOOLEAN NTAPI RtlpHandleDpcStackException (IN PEXCEPTION_REGISTRATION_RECORD RegistrationFrame, IN ULONG_PTR RegistrationFrameEnd, IN OUT PULONG_PTR StackLow, IN OUT PULONG_PTR StackHigh)
 
VOID NTAPI RtlpCheckLogException (IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT ContextRecord, IN PVOID ContextData, IN ULONG Size)
 
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)
 
BOOLEAN NTAPI RtlIsThreadWithinLoaderCallout (VOID)
 
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)
 
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, WORD id, void *root, int want_dir)
 
IMAGE_RESOURCE_DIRECTORYfind_first_entry (IMAGE_RESOURCE_DIRECTORY *dir, void *root, int want_dir)
 
int push_language (USHORT *list, ULONG pos, WORD lang)
 
NTSTATUS find_entry (PVOID BaseAddress, LDR_RESOURCE_INFO *info, ULONG level, void **ret, int want_dir)
 
PVOID NTAPI RtlPcToFileHeader (IN PVOID PcValue, PVOID *BaseOfImage)
 
NTSTATUS get_buffer (LPWSTR *buffer, SIZE_T needed, PUNICODE_STRING CallerBuffer, BOOLEAN bAllocateBuffer)
 
NTSTATUS find_actctx_dll (PUNICODE_STRING pnameW, LPWSTR *fullname, PUNICODE_STRING CallerBuffer, BOOLEAN bAllocateBuffer)
 
NTSYSAPI NTSTATUS NTAPI RtlDosApplyFileIsolationRedirection_Ustr (IN ULONG Flags, IN PUNICODE_STRING OriginalName, IN PUNICODE_STRING Extension, IN OUT PUNICODE_STRING StaticString, IN OUT PUNICODE_STRING DynamicString, IN OUT PUNICODE_STRING *NewName, IN PULONG NewFlags, IN PSIZE_T FileNameSize, IN PSIZE_T RequiredLength)
 
NTSYSAPI NTSTATUS NTAPI RtlWow64EnableFsRedirection (IN BOOLEAN Wow64FsEnableRedirection)
 
NTSYSAPI NTSTATUS NTAPI RtlWow64EnableFsRedirectionEx (IN PVOID Wow64FsEnableRedirection, OUT PVOID *OldFsRedirectionLevel)
 
NTSYSAPI NTSTATUS NTAPI RtlComputeImportTableHash (IN HANDLE FileHandle, OUT PCHAR Hash, IN ULONG ImportTableHashSize)
 
NTSTATUS NTAPI RtlpSafeCopyMemory (_Out_writes_bytes_all_(Length) VOID UNALIGNED *Destination, _In_reads_bytes_(Length) CONST VOID UNALIGNED *Source, _In_ SIZE_T Length)
 
ULONG NTAPI RtlGetTickCount (VOID)
 

Variables

SIZE_T RtlpAllocDeallocQueryBufferSize = PAGE_SIZE
 
PTEB LdrpTopLevelDllBeingLoadedTeb = NULL
 
PVOID MmHighestUserAddress = (PVOID)MI_HIGHEST_USER_ADDRESS
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file libsupp.c.

Typedef Documentation

◆ PRTL_ATOM_HANDLE

◆ RTL_ATOM_HANDLE

Function Documentation

◆ find_actctx_dll()

NTSTATUS find_actctx_dll ( PUNICODE_STRING  pnameW,
LPWSTR fullname,
PUNICODE_STRING  CallerBuffer,
BOOLEAN  bAllocateBuffer 
)

Definition at line 672 of file libsupp.c.

673 {
674  static const WCHAR winsxsW[] = {'\\','w','i','n','s','x','s','\\'};
675  static const WCHAR dotManifestW[] = {'.','m','a','n','i','f','e','s','t',0};
676 
677  ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *info;
678  ACTCTX_SECTION_KEYED_DATA data;
680  SIZE_T needed, size = 1024;
681  WCHAR *p;
682 
683  data.cbSize = sizeof(data);
684  status = RtlFindActivationContextSectionString( FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
685  ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
686  pnameW, &data );
687  if (status != STATUS_SUCCESS)
688  {
689  //DPRINT1("RtlFindActivationContextSectionString returned 0x%x for %wZ\n", status, pnameW);
690  return status;
691  }
692 
693  for (;;)
694  {
695  if (!(info = RtlAllocateHeap( RtlGetProcessHeap(), 0, size )))
696  {
698  goto done;
699  }
700  status = RtlQueryInformationActivationContext( 0, data.hActCtx, &data.ulAssemblyRosterIndex,
701  AssemblyDetailedInformationInActivationContext,
702  info, size, &needed );
703  if (status == STATUS_SUCCESS) break;
704  if (status != STATUS_BUFFER_TOO_SMALL) goto done;
705  RtlFreeHeap( RtlGetProcessHeap(), 0, info );
706  size = needed;
707  }
708 
709  DPRINT("manifestpath === %S\n", info->lpAssemblyManifestPath);
710  DPRINT("DirectoryName === %S\n", info->lpAssemblyDirectoryName);
711  if (!info->lpAssemblyManifestPath /*|| !info->lpAssemblyDirectoryName*/)
712  {
714  goto done;
715  }
716 
717  if ((p = wcsrchr( info->lpAssemblyManifestPath, '\\' )))
718  {
719  DWORD dirlen = info->ulAssemblyDirectoryNameLength / sizeof(WCHAR);
720 
721  p++;
722  if (!info->lpAssemblyDirectoryName || _wcsnicmp( p, info->lpAssemblyDirectoryName, dirlen ) || wcsicmp( p + dirlen, dotManifestW ))
723  {
724  /* manifest name does not match directory name, so it's not a global
725  * windows/winsxs manifest; use the manifest directory name instead */
726  dirlen = p - info->lpAssemblyManifestPath;
727  needed = (dirlen + 1) * sizeof(WCHAR) + pnameW->Length;
728 
729  status = get_buffer(fullname, needed, CallerBuffer, bAllocateBuffer);
730  if (!NT_SUCCESS(status))
731  goto done;
732 
733  p = *fullname;
734 
735  memcpy( p, info->lpAssemblyManifestPath, dirlen * sizeof(WCHAR) );
736  p += dirlen;
737  memcpy( p, pnameW->Buffer, pnameW->Length);
738  p += (pnameW->Length / sizeof(WCHAR));
739  *p = L'\0';
740 
741  goto done;
742  }
743  }
744 
745  needed = (wcslen(SharedUserData->NtSystemRoot) * sizeof(WCHAR) +
746  sizeof(winsxsW) + info->ulAssemblyDirectoryNameLength + pnameW->Length + 2*sizeof(WCHAR));
747 
748  status = get_buffer(fullname, needed, CallerBuffer, bAllocateBuffer);
749  if (!NT_SUCCESS(status))
750  goto done;
751 
752  p = *fullname;
753 
754  wcscpy( p, SharedUserData->NtSystemRoot );
755  p += wcslen(p);
756  memcpy( p, winsxsW, sizeof(winsxsW) );
757  p += sizeof(winsxsW) / sizeof(WCHAR);
758  memcpy( p, info->lpAssemblyDirectoryName, info->ulAssemblyDirectoryNameLength );
759  p += info->ulAssemblyDirectoryNameLength / sizeof(WCHAR);
760  *p++ = L'\\';
761  memcpy( p, pnameW->Buffer, pnameW->Length);
762  p += (pnameW->Length / sizeof(WCHAR));
763  *p = L'\0';
764 
765 done:
766  RtlFreeHeap( RtlGetProcessHeap(), 0, info );
768  DPRINT("%S\n", fullname);
769  return status;
770 }
NTSYSAPI void WINAPI RtlReleaseActivationContext(HANDLE)
Definition: actctx.c:5272
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
_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)
#define STATUS_SXS_KEY_NOT_FOUND
Definition: ntstatus.h:1170
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
struct _test_info info[]
Definition: SetCursorPos.c:19
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define SharedUserData
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
NTSYSAPI NTSTATUS WINAPI RtlFindActivationContextSectionString(ULONG, const GUID *, ULONG, const UNICODE_STRING *, PVOID)
Definition: actctx.c:5743
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define wcsicmp
Definition: string.h:1152
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
NTSYSAPI NTSTATUS WINAPI RtlQueryInformationActivationContext(ULONG, HANDLE, PVOID, ULONG, PVOID, SIZE_T, SIZE_T *)
Definition: actctx.c:5443
NTSTATUS get_buffer(LPWSTR *buffer, SIZE_T needed, PUNICODE_STRING CallerBuffer, BOOLEAN bAllocateBuffer)
Definition: libsupp.c:645
static const WCHAR dotManifestW[]
Definition: actctx.c:707
GLfloat GLfloat p
Definition: glext.h:8902
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
Definition: ps.c:97

Referenced by RtlDosApplyFileIsolationRedirection_Ustr().

◆ find_entry()

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

Definition at line 527 of file libsupp.c.

529 {
530  ULONG size;
531  void *root;
532  IMAGE_RESOURCE_DIRECTORY *resdirptr;
533  USHORT list[9]; /* list of languages to try */
534  int i, pos = 0;
535  LCID user_lcid, system_lcid;
536 
539  if (size < sizeof(*resdirptr)) return STATUS_RESOURCE_DATA_NOT_FOUND;
540  resdirptr = root;
541 
542  if (!level--) goto done;
543  if (!(*ret = find_entry_by_name( resdirptr, (LPCWSTR)info->Type, root, want_dir || level )))
545  if (!level--) return STATUS_SUCCESS;
546 
547  resdirptr = *ret;
548  if (!(*ret = find_entry_by_name( resdirptr, (LPCWSTR)info->Name, root, want_dir || level )))
550  if (!level--) return STATUS_SUCCESS;
551  if (level) return STATUS_INVALID_PARAMETER; /* level > 3 */
552 
553  /* 1. specified language */
554  pos = push_language( list, pos, info->Language );
555 
556  /* 2. specified language with neutral sublanguage */
558 
559  /* 3. neutral language with neutral sublanguage */
561 
562  /* if no explicitly specified language, try some defaults */
563  if (PRIMARYLANGID(info->Language) == LANG_NEUTRAL)
564  {
565  /* user defaults, unless SYS_DEFAULT sublanguage specified */
566  if (SUBLANGID(info->Language) != SUBLANG_SYS_DEFAULT)
567  {
568  /* 4. current thread locale language */
569  pos = push_language( list, pos, LANGIDFROMLCID(NtCurrentTeb()->CurrentLocale) );
570 
571  if (NT_SUCCESS(NtQueryDefaultLocale(TRUE, &user_lcid)))
572  {
573  /* 5. user locale language */
574  pos = push_language( list, pos, LANGIDFROMLCID(user_lcid) );
575 
576  /* 6. user locale language with neutral sublanguage */
578  }
579  }
580 
581  /* now system defaults */
582 
583  if (NT_SUCCESS(NtQueryDefaultLocale(FALSE, &system_lcid)))
584  {
585  /* 7. system locale language */
586  pos = push_language( list, pos, LANGIDFROMLCID( system_lcid ) );
587 
588  /* 8. system locale language with neutral sublanguage */
590  }
591 
592  /* 9. English */
594  }
595 
596  resdirptr = *ret;
597  for (i = 0; i < pos; i++)
598  if ((*ret = find_entry_by_id( resdirptr, list[i], root, want_dir ))) return STATUS_SUCCESS;
599 
600  /* if no explicitly specified language, return the first entry */
601  if (PRIMARYLANGID(info->Language) == LANG_NEUTRAL)
602  {
603  if ((*ret = find_first_entry( resdirptr, root, want_dir ))) return STATUS_SUCCESS;
604  }
606 
607 done:
608  *ret = resdirptr;
609  return STATUS_SUCCESS;
610 }
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
#define LANG_NEUTRAL
Definition: nls.h:22
struct _root root
#define SUBLANG_DEFAULT
Definition: nls.h:168
DWORD LCID
Definition: nls.h:13
#define SUBLANG_NEUTRAL
Definition: nls.h:167
#define SUBLANG_SYS_DEFAULT
Definition: nls.h:169
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
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
GLsizeiptr size
Definition: glext.h:5919
IMAGE_RESOURCE_DIRECTORY * find_entry_by_id(IMAGE_RESOURCE_DIRECTORY *dir, WORD id, void *root, int want_dir)
Definition: res.c:95
IMAGE_RESOURCE_DIRECTORY * find_first_entry(IMAGE_RESOURCE_DIRECTORY *dir, void *root, int want_dir)
Definition: res.c:75
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define LANG_ENGLISH
Definition: nls.h:52
int ret
#define STATUS_RESOURCE_DATA_NOT_FOUND
Definition: ntstatus.h:359
#define RtlImageDirectoryEntryToData
Definition: compat.h:468
#define LANGIDFROMLCID(l)
Definition: nls.h:18
Definition: _list.h:228
int push_language(USHORT *list, ULONG pos, WORD lang)
Definition: res.c:61
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define STATUS_RESOURCE_LANG_NOT_FOUND
Definition: ntstatus.h:634
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_RESOURCE_NAME_NOT_FOUND
Definition: ntstatus.h:361
NTSTATUS NTAPI NtQueryDefaultLocale(IN BOOLEAN UserProfile, OUT PLCID DefaultLocaleId)
Definition: locale.c:162
unsigned int ULONG
Definition: retypes.h:1
#define MAKELANGID(p, s)
Definition: nls.h:15
#define IMAGE_DIRECTORY_ENTRY_RESOURCE
Definition: pedump.c:261
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define STATUS_RESOURCE_TYPE_NOT_FOUND
Definition: ntstatus.h:360
#define SUBLANGID(l)
Definition: nls.h:17

◆ find_entry_by_id()

IMAGE_RESOURCE_DIRECTORY* find_entry_by_id ( IMAGE_RESOURCE_DIRECTORY dir,
WORD  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().

◆ 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)

Referenced by find_entry().

◆ 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

Referenced by find_entry().

◆ get_buffer()

NTSTATUS get_buffer ( LPWSTR buffer,
SIZE_T  needed,
PUNICODE_STRING  CallerBuffer,
BOOLEAN  bAllocateBuffer 
)

Definition at line 645 of file libsupp.c.

646 {
647  WCHAR *p;
648 
649  if (CallerBuffer && CallerBuffer->MaximumLength > needed)
650  {
651  p = CallerBuffer->Buffer;
652  CallerBuffer->Length = needed - sizeof(WCHAR);
653  }
654  else
655  {
656  if (!bAllocateBuffer)
658 
659  if (CallerBuffer)
660  CallerBuffer->Buffer[0] = 0;
661 
662  p = RtlAllocateHeap(RtlGetProcessHeap(), 0, needed );
663  if (!p)
664  return STATUS_NO_MEMORY;
665  }
666  *buffer = p;
667 
668  return STATUS_SUCCESS;
669 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
GLuint buffer
Definition: glext.h:5915
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
GLfloat GLfloat p
Definition: glext.h:8902
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by find_actctx_dll(), jpeg_fill_bit_buffer(), jpeg_huff_decode(), and RtlDosApplyFileIsolationRedirection_Ustr().

◆ push_language()

int push_language ( USHORT list,
ULONG  pos,
WORD  lang 
)

Definition at line 61 of file res.c.

62 {
63  ULONG i;
64  for (i = 0; i < pos; i++) if (list[i] == lang) return pos;
65  list[pos++] = lang;
66  return pos;
67 }
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
static const WCHAR lang[]
Definition: wbemdisp.c:287
Definition: _list.h:228
unsigned int ULONG
Definition: retypes.h:1

Referenced by find_entry().

◆ RtlAcquirePebLock()

◆ RtlComputeImportTableHash()

NTSYSAPI NTSTATUS NTAPI RtlComputeImportTableHash ( IN HANDLE  FileHandle,
OUT PCHAR  Hash,
IN ULONG  ImportTableHashSize 
)

Definition at line 984 of file libsupp.c.

987 {
989  return STATUS_NOT_IMPLEMENTED;
990 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by BasepCheckWebBladeHashes().

◆ RtlDeleteHeapLock()

NTSTATUS NTAPI RtlDeleteHeapLock ( IN OUT PHEAP_LOCK  Lock)

Definition at line 101 of file libsupp.c.

102 {
103  return RtlDeleteCriticalSection(&Lock->CriticalSection);
104 }
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
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

Referenced by RtlDestroyHeap(), and RtlpPageHeapDestroy().

◆ RtlDosApplyFileIsolationRedirection_Ustr()

NTSYSAPI NTSTATUS NTAPI RtlDosApplyFileIsolationRedirection_Ustr ( IN ULONG  Flags,
IN PUNICODE_STRING  OriginalName,
IN PUNICODE_STRING  Extension,
IN OUT PUNICODE_STRING  StaticString,
IN OUT PUNICODE_STRING  DynamicString,
IN OUT PUNICODE_STRING NewName,
IN PULONG  NewFlags,
IN PSIZE_T  FileNameSize,
IN PSIZE_T  RequiredLength 
)

Definition at line 778 of file libsupp.c.

787 {
789  LPWSTR fullname;
791  UNICODE_STRING localStr, localStr2, *pstrParam;
792  WCHAR *p;
793  BOOLEAN GotExtension;
794  WCHAR c;
795  C_ASSERT(sizeof(UNICODE_NULL) == sizeof(WCHAR));
796 
797 
798  /* Check for invalid parameters */
799  if (!OriginalName)
800  {
802  }
803 
804  if (!DynamicString && !StaticString)
805  {
807  }
808 
809  if ((DynamicString) && (StaticString) && !(NewName))
810  {
812  }
813 
814  if (!OriginalName->Buffer || OriginalName->Length == 0)
815  {
817  }
818 
819  if (StaticString && (OriginalName == StaticString || OriginalName->Buffer == StaticString->Buffer))
820  {
822  }
823 
824  if (NtCurrentPeb()->ProcessParameters &&
825  (NtCurrentPeb()->ProcessParameters->Flags & RTL_USER_PROCESS_PARAMETERS_PRIVATE_DLL_PATH))
826  {
827  UNICODE_STRING RealName, LocalName;
828  WCHAR RealNameBuf[MAX_PATH], LocalNameBuf[MAX_PATH];
829 
830  RtlInitEmptyUnicodeString(&RealName, RealNameBuf, sizeof(RealNameBuf));
831  RtlInitEmptyUnicodeString(&LocalName, LocalNameBuf, sizeof(LocalNameBuf));
832 
833  Status = RtlComputePrivatizedDllName_U(OriginalName, &RealName, &LocalName);
834  if (!NT_SUCCESS(Status))
835  {
836  DPRINT1("RtlComputePrivatizedDllName_U failed for %wZ: 0x%lx\n", OriginalName, Status);
837  return Status;
838  }
839 
840  if (RtlDoesFileExists_UStr(&LocalName))
841  {
842  Status = get_buffer(&fullname, LocalName.Length + sizeof(UNICODE_NULL), StaticString, DynamicString != NULL);
843  if (NT_SUCCESS(Status))
844  {
845  RtlCopyMemory(fullname, LocalName.Buffer, LocalName.Length + sizeof(UNICODE_NULL));
846  }
847  else
848  {
849  DPRINT1("Error while retrieving buffer for %wZ: 0x%lx\n", OriginalName, Status);
850  }
851  }
852  else if (RtlDoesFileExists_UStr(&RealName))
853  {
854  Status = get_buffer(&fullname, RealName.Length + sizeof(UNICODE_NULL), StaticString, DynamicString != NULL);
855  if (NT_SUCCESS(Status))
856  {
857  RtlCopyMemory(fullname, RealName.Buffer, RealName.Length + sizeof(UNICODE_NULL));
858  }
859  else
860  {
861  DPRINT1("Error while retrieving buffer for %wZ: 0x%lx\n", OriginalName, Status);
862  }
863  }
864  else
865  {
867  }
868 
869  if (RealName.Buffer != RealNameBuf)
870  RtlFreeUnicodeString(&RealName);
871  if (LocalName.Buffer != LocalNameBuf)
872  RtlFreeUnicodeString(&LocalName);
873 
874  if (NT_SUCCESS(Status))
875  {
876  DPRINT("Redirecting %wZ to %S\n", OriginalName, fullname);
877  if (!StaticString || StaticString->Buffer != fullname)
878  {
881  }
882  else
883  {
885  }
886  return Status;
887  }
888  }
889 
890  pstrParam = OriginalName;
891 
892  /* Get the file name with an extension */
893  p = OriginalName->Buffer + OriginalName->Length / sizeof(WCHAR) - 1;
894  GotExtension = FALSE;
895  while (p >= OriginalName->Buffer)
896  {
897  c = *p--;
898  if (c == L'.')
899  {
900  GotExtension = TRUE;
901  }
902  else if (c == L'\\')
903  {
904  localStr.Buffer = p + 2;
905  localStr.Length = OriginalName->Length - ((ULONG_PTR)localStr.Buffer - (ULONG_PTR)OriginalName->Buffer);
906  localStr.MaximumLength = OriginalName->MaximumLength - ((ULONG_PTR)localStr.Buffer - (ULONG_PTR)OriginalName->Buffer);
907  pstrParam = &localStr;
908  break;
909  }
910  }
911 
912  if (!GotExtension)
913  {
914  if (!Extension)
915  {
917  }
918 
919  if (pstrParam->Length + Extension->Length > sizeof(buffer))
920  {
921  //FIXME!
922  return STATUS_NO_MEMORY;
923  }
924 
925  RtlInitEmptyUnicodeString(&localStr2, buffer, sizeof(buffer));
926  RtlAppendUnicodeStringToString(&localStr2, pstrParam);
928  pstrParam = &localStr2;
929  }
930 
931  /* Use wine's function as long as we use wine's sxs implementation in ntdll */
932  Status = find_actctx_dll(pstrParam, &fullname, StaticString, DynamicString != NULL);
933  if (!NT_SUCCESS(Status))
934  {
935  return Status;
936  }
937 
938  DPRINT("Redirecting %wZ to %S\n", OriginalName, fullname);
939 
940  if (!StaticString || StaticString->Buffer != fullname)
941  {
944  }
945  else
946  {
948  }
949 
950  return Status;
951 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS find_actctx_dll(PUNICODE_STRING pnameW, LPWSTR *fullname, PUNICODE_STRING CallerBuffer, BOOLEAN bAllocateBuffer)
Definition: libsupp.c:672
GLuint buffer
Definition: glext.h:5915
#define STATUS_SXS_KEY_NOT_FOUND
Definition: ntstatus.h:1170
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define UNICODE_NULL
#define RTL_USER_PROCESS_PARAMETERS_PRIVATE_DLL_PATH
Definition: rtltypes.h:52
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define C_ASSERT(e)
Definition: intsafe.h:79
NTSYSAPI NTSTATUS NTAPI RtlComputePrivatizedDllName_U(_In_ PUNICODE_STRING DllName, _Inout_ PUNICODE_STRING RealName, _Inout_ PUNICODE_STRING LocalName)
Definition: path.c:467
#define STATUS_NOT_FOUND
Definition: shellext.h:72
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
const GLubyte * c
Definition: glext.h:8905
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define NtCurrentPeb()
Definition: FLS.c:20
BOOLEAN NTAPI RtlDoesFileExists_UStr(IN PUNICODE_STRING FileName)
Definition: path.c:1384
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define DPRINT1
Definition: precomp.h:8
_In_ PUNICODE_STRING NewName
Definition: zwfuncs.h:1203
#define c
Definition: ke_i.h:80
NTSTATUS get_buffer(LPWSTR *buffer, SIZE_T needed, PUNICODE_STRING CallerBuffer, BOOLEAN bAllocateBuffer)
Definition: libsupp.c:645
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ULONG_PTR
Definition: config.h:101
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
IN PUNICODE_STRING StaticString
IN PUNICODE_STRING IN PUNICODE_STRING DynamicString

Referenced by LdrGetDllHandleEx(), LdrLoadDll(), LdrpLoadImportModule(), LdrpSnapThunk(), LdrpUpdateLoadCount3(), RtlDosSearchPath_Ustr(), TestBuffers(), and TestRedirection().

◆ RtlEnterHeapLock()

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

Definition at line 108 of file libsupp.c.

109 {
110  UNREFERENCED_PARAMETER(Exclusive);
111 
112  return RtlEnterCriticalSection(&Lock->CriticalSection);
113 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
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

Referenced by RtlAllocateHeap(), RtlDebugAllocateHeap(), RtlDebugFreeHeap(), RtlDebugGetUserInfoHeap(), RtlDebugReAllocateHeap(), RtlDebugSetUserFlagsHeap(), RtlDebugSetUserValueHeap(), RtlDebugSizeHeap(), RtlFreeHeap(), RtlGetUserInfoHeap(), RtlLockHeap(), RtlpDphEnterCriticalSection(), RtlpDphFreeDelayedBlocksFromHeap(), RtlpPageHeapCreate(), RtlpPageHeapDestroy(), RtlReAllocateHeap(), RtlSetUserFlagsHeap(), RtlSetUserValueHeap(), and RtlValidateHeap().

◆ RtlGetCurrentPeb()

◆ RtlGetNtGlobalFlags()

ULONG NTAPI RtlGetNtGlobalFlags ( VOID  )

Definition at line 93 of file libsupp.c.

94 {
95  PPEB pPeb = NtCurrentPeb();
96  return pPeb->NtGlobalFlag;
97 }
ULONG NtGlobalFlag
Definition: ntddk_ex.h:270
#define NtCurrentPeb()
Definition: FLS.c:20

Referenced by RtlCreateHeap(), and RtlCreateUserProcess().

◆ RtlGetTickCount()

ULONG NTAPI RtlGetTickCount ( VOID  )

Definition at line 1015 of file libsupp.c.

1016 {
1017  ULARGE_INTEGER TickCount;
1018 
1019 #ifdef _WIN64
1020  TickCount.QuadPart = *((volatile ULONG64*)&SharedUserData->TickCount);
1021 #else
1022  while (TRUE)
1023  {
1024  TickCount.HighPart = (ULONG)SharedUserData->TickCount.High1Time;
1025  TickCount.LowPart = SharedUserData->TickCount.LowPart;
1026 
1027  if (TickCount.HighPart == (ULONG)SharedUserData->TickCount.High2Time)
1028  break;
1029 
1030  YieldProcessor();
1031  }
1032 #endif
1033 
1034  return (ULONG)((UInt32x32To64(TickCount.LowPart,
1035  SharedUserData->TickCountMultiplier) >> 24) +
1036  UInt32x32To64((TickCount.HighPart << 8) & 0xFFFFFFFF,
1037  SharedUserData->TickCountMultiplier));
1038 }
#define TRUE
Definition: types.h:120
$ULONG LowPart
Definition: ntbasedef.h:576
FORCEINLINE VOID YieldProcessor(VOID)
Definition: ke.h:32
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
$ULONG HighPart
Definition: ntbasedef.h:577
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned __int64 ULONG64
Definition: imports.h:198
#define SharedUserData
unsigned int ULONG
Definition: retypes.h:1
#define UInt32x32To64(a, b)
Definition: intsafe.h:258

◆ RtlInitializeHeapLock()

NTSTATUS NTAPI RtlInitializeHeapLock ( IN OUT PHEAP_LOCK Lock)

Definition at line 126 of file libsupp.c.

127 {
128  return RtlInitializeCriticalSection(&(*Lock)->CriticalSection);
129 }
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

Referenced by RtlpDphInitializeDelayedFreeQueue(), RtlpDphProcessStartupInitialization(), RtlpInitializeHeap(), and RtlpPageHeapCreate().

◆ RtlIsThreadWithinLoaderCallout()

BOOLEAN NTAPI RtlIsThreadWithinLoaderCallout ( VOID  )

Definition at line 348 of file libsupp.c.

349 {
351 }
PTEB LdrpTopLevelDllBeingLoadedTeb
Definition: libsupp.c:18
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

Referenced by ForceResetUserApiHook(), and LoadUserApiHook().

◆ RtlLeaveHeapLock()

NTSTATUS NTAPI RtlLeaveHeapLock ( IN OUT PHEAP_LOCK  Lock)

Definition at line 133 of file libsupp.c.

134 {
135  return RtlLeaveCriticalSection(&Lock->CriticalSection);
136 }
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
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

Referenced by RtlAllocateHeap(), RtlDebugAllocateHeap(), RtlDebugFreeHeap(), RtlDebugGetUserInfoHeap(), RtlDebugReAllocateHeap(), RtlDebugSetUserFlagsHeap(), RtlDebugSetUserValueHeap(), RtlDebugSizeHeap(), RtlFreeHeap(), RtlGetUserInfoHeap(), RtlpAllocateNonDedicated(), RtlpDphFreeDelayedBlocksFromHeap(), RtlpDphLeaveCriticalSection(), RtlpPageHeapCreate(), RtlpPageHeapDestroy(), RtlReAllocateHeap(), RtlSetUserFlagsHeap(), RtlSetUserValueHeap(), RtlUnlockHeap(), and RtlValidateHeap().

◆ RtlpAllocateMemory()

PVOID NTAPI RtlpAllocateMemory ( UINT  Bytes,
ULONG  Tag 
)

Definition at line 140 of file libsupp.c.

142 {
144 
145  return RtlAllocateHeap(RtlGetProcessHeap(),
146  0,
147  Bytes);
148 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
_In_ UINT Bytes
Definition: mmcopy.h:9
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
IN ULONG IN ULONG Tag
Definition: evtlib.h:159

◆ RtlpAllocAtomTable()

PRTL_ATOM_TABLE RtlpAllocAtomTable ( ULONG  Size)

Definition at line 410 of file libsupp.c.

411 {
412  return (PRTL_ATOM_TABLE)RtlAllocateHeap(RtlGetProcessHeap(),
414  Size);
415 }
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
struct atom_table ** PRTL_ATOM_TABLE
Definition: atom.c:43
#define HEAP_ZERO_MEMORY
Definition: compat.h:123

◆ RtlpAllocAtomTableEntry()

PRTL_ATOM_TABLE_ENTRY RtlpAllocAtomTableEntry ( ULONG  Size)

Definition at line 426 of file libsupp.c.

427 {
428  return (PRTL_ATOM_TABLE_ENTRY)RtlAllocateHeap(RtlGetProcessHeap(),
430  Size);
431 }
Definition: rtltypes.h:1642
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define HEAP_ZERO_MEMORY
Definition: compat.h:123

◆ RtlpCaptureStackLimits()

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

Definition at line 211 of file libsupp.c.

214 {
215  /* FIXME: Verify */
216  *StackBegin = (ULONG_PTR)NtCurrentTeb()->NtTib.StackLimit;
217  *StackEnd = (ULONG_PTR)NtCurrentTeb()->NtTib.StackBase;
218  return TRUE;
219 }
#define TRUE
Definition: types.h:120
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define ULONG_PTR
Definition: config.h:101

Referenced by RtlWalkFrameChain().

◆ RtlpCheckForActiveDebugger()

BOOLEAN NTAPI RtlpCheckForActiveDebugger ( VOID  )

Definition at line 25 of file libsupp.c.

26 {
27  /* Return the flag in the PEB */
28  return NtCurrentPeb()->BeingDebugged;
29 }
#define NtCurrentPeb()
Definition: FLS.c:20

Referenced by RtlRaiseException(), RtlRaiseStatus(), and vDbgPrintExWithPrefixInternal().

◆ RtlpCheckLogException()

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

Definition at line 201 of file libsupp.c.

205 {
206  /* Exception logging is not done in user-mode */
207 }

Referenced by RtlDispatchException().

◆ RtlpClearInDbgPrint()

VOID NTAPI RtlpClearInDbgPrint ( VOID  )

Definition at line 45 of file libsupp.c.

46 {
47  /* Clear the flag */
48  NtCurrentTeb()->InDbgPrint = FALSE;
49 }
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

Referenced by vDbgPrintExWithPrefixInternal().

◆ RtlpCreateAtomHandle()

BOOLEAN RtlpCreateAtomHandle ( PRTL_ATOM_TABLE  AtomTable,
PRTL_ATOM_TABLE_ENTRY  Entry 
)

Definition at line 456 of file libsupp.c.

457 {
458  ULONG HandleIndex;
459  PRTL_HANDLE_TABLE_ENTRY RtlHandle;
460 
461  RtlHandle = RtlAllocateHandle(&AtomTable->RtlHandleTable,
462  &HandleIndex);
463  if (RtlHandle != NULL)
464  {
465  PRTL_ATOM_HANDLE AtomHandle = (PRTL_ATOM_HANDLE)RtlHandle;
466 
467  /* FIXME - Handle Indexes >= 0xC000 ?! */
468  if (HandleIndex < 0xC000)
469  {
470  Entry->HandleIndex = (USHORT)HandleIndex;
471  Entry->Atom = 0xC000 + (USHORT)HandleIndex;
472 
473  AtomHandle->AtomEntry = Entry;
474  AtomHandle->Handle.Flags = RTL_HANDLE_VALID;
475 
476  return TRUE;
477  }
478  else
479  {
480  /* set the valid flag, otherwise RtlFreeHandle will fail! */
481  AtomHandle->Handle.Flags = RTL_HANDLE_VALID;
482 
483  RtlFreeHandle(&AtomTable->RtlHandleTable,
484  RtlHandle);
485  }
486  }
487 
488  return FALSE;
489 }
#define RTL_HANDLE_VALID
Definition: rtltypes.h:372
struct _RTL_ATOM_HANDLE * PRTL_ATOM_HANDLE
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
smooth NULL
Definition: ftsmooth.c:416
PRTL_ATOM_TABLE_ENTRY AtomEntry
Definition: libsupp.c:358
NTSYSAPI PRTL_HANDLE_TABLE_ENTRY NTAPI RtlAllocateHandle(_In_ PRTL_HANDLE_TABLE HandleTable, _Inout_ PULONG Index)
NTSYSAPI BOOLEAN NTAPI RtlFreeHandle(_In_ PRTL_HANDLE_TABLE HandleTable, _In_ PRTL_HANDLE_TABLE_ENTRY Handle)
unsigned short USHORT
Definition: pedump.c:61
ULONG Flags
Definition: rtltypes.h:1244
unsigned int ULONG
Definition: retypes.h:1
Definition: rtltypes.h:1240
RTL_HANDLE_TABLE_ENTRY Handle
Definition: libsupp.c:357
base of all file and directory entries
Definition: entries.h:82

◆ RtlpCreateAtomHandleTable()

BOOLEAN RtlpCreateAtomHandleTable ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 394 of file libsupp.c.

395 {
397  sizeof(RTL_ATOM_HANDLE),
398  &AtomTable->RtlHandleTable);
399 
400  return TRUE;
401 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlInitializeHandleTable(_In_ ULONG TableSize, _In_ ULONG HandleSize, _In_ PRTL_HANDLE_TABLE HandleTable)

◆ RtlPcToFileHeader()

PVOID NTAPI RtlPcToFileHeader ( IN PVOID  PcValue,
PVOID BaseOfImage 
)

Definition at line 616 of file libsupp.c.

618 {
621  PLDR_DATA_TABLE_ENTRY Module;
622  PVOID ImageBase = NULL;
623 
624  RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock);
625  ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList;
627  while (Entry != ModuleListHead)
628  {
629  Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
630 
631  if ((ULONG_PTR)PcValue >= (ULONG_PTR)Module->DllBase &&
632  (ULONG_PTR)PcValue < (ULONG_PTR)Module->DllBase + Module->SizeOfImage)
633  {
634  ImageBase = Module->DllBase;
635  break;
636  }
637  Entry = Entry->Flink;
638  }
639  RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock);
640 
641  *BaseOfImage = ImageBase;
642  return ImageBase;
643 }
struct _Entry Entry
Definition: kefuncs.h:640
ULONG SizeOfImage
Definition: ldrtypes.h:143
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
uint32_t ULONG_PTR
Definition: typedefs.h:63
PVOID DllBase
Definition: btrfs_drv.h:1857
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
Definition: btrfs_drv.h:1853
Definition: typedefs.h:117
#define NtCurrentPeb()
Definition: FLS.c:20
LIST_ENTRY * ModuleListHead
Definition: kdpacket.c:23
base of all file and directory entries
Definition: entries.h:82

Referenced by BasepGetModuleHandleExW(), RtlLookupFunctionTable(), and SeiGetModuleFromAddress().

◆ RtlpDestroyAtomHandleTable()

VOID RtlpDestroyAtomHandleTable ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 404 of file libsupp.c.

405 {
406  RtlDestroyHandleTable(&AtomTable->RtlHandleTable);
407 }
NTSYSAPI VOID NTAPI RtlDestroyHandleTable(_Inout_ PRTL_HANDLE_TABLE HandleTable)

◆ RtlpDestroyAtomTableLock()

VOID RtlpDestroyAtomTableLock ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 370 of file libsupp.c.

371 {
372  RtlDeleteCriticalSection(&AtomTable->CriticalSection);
373 }
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

◆ RtlpFreeAtomHandle()

VOID RtlpFreeAtomHandle ( PRTL_ATOM_TABLE  AtomTable,
PRTL_ATOM_TABLE_ENTRY  Entry 
)

Definition at line 442 of file libsupp.c.

443 {
444  PRTL_HANDLE_TABLE_ENTRY RtlHandleEntry;
445 
446  if (RtlIsValidIndexHandle(&AtomTable->RtlHandleTable,
447  (ULONG)Entry->HandleIndex,
448  &RtlHandleEntry))
449  {
450  RtlFreeHandle(&AtomTable->RtlHandleTable,
451  RtlHandleEntry);
452  }
453 }
NTSYSAPI BOOLEAN NTAPI RtlFreeHandle(_In_ PRTL_HANDLE_TABLE HandleTable, _In_ PRTL_HANDLE_TABLE_ENTRY Handle)
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI BOOLEAN WINAPI RtlIsValidIndexHandle(const RTL_HANDLE_TABLE *, ULONG Index, RTL_HANDLE **)
Definition: rtltypes.h:1240
base of all file and directory entries
Definition: entries.h:82

◆ RtlpFreeAtomTable()

VOID RtlpFreeAtomTable ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 418 of file libsupp.c.

419 {
420  RtlFreeHeap(RtlGetProcessHeap(),
421  0,
422  AtomTable);
423 }
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606

◆ RtlpFreeAtomTableEntry()

VOID RtlpFreeAtomTableEntry ( PRTL_ATOM_TABLE_ENTRY  Entry)

Definition at line 434 of file libsupp.c.

435 {
436  RtlFreeHeap(RtlGetProcessHeap(),
437  0,
438  Entry);
439 }
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
base of all file and directory entries
Definition: entries.h:82

◆ RtlpFreeMemory()

VOID NTAPI RtlpFreeMemory ( PVOID  Mem,
ULONG  Tag 
)

Definition at line 153 of file libsupp.c.

155 {
157 
158  RtlFreeHeap(RtlGetProcessHeap(),
159  0,
160  Mem);
161 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
IN ULONG IN ULONG Tag
Definition: evtlib.h:159

◆ RtlpGetAtomEntry()

PRTL_ATOM_TABLE_ENTRY RtlpGetAtomEntry ( PRTL_ATOM_TABLE  AtomTable,
ULONG  Index 
)

Definition at line 492 of file libsupp.c.

493 {
494  PRTL_HANDLE_TABLE_ENTRY RtlHandle;
495 
496  if (RtlIsValidIndexHandle(&AtomTable->RtlHandleTable,
497  Index,
498  &RtlHandle))
499  {
500  PRTL_ATOM_HANDLE AtomHandle = (PRTL_ATOM_HANDLE)RtlHandle;
501 
502  return AtomHandle->AtomEntry;
503  }
504 
505  return NULL;
506 }
struct _RTL_ATOM_HANDLE * PRTL_ATOM_HANDLE
smooth NULL
Definition: ftsmooth.c:416
PRTL_ATOM_TABLE_ENTRY AtomEntry
Definition: libsupp.c:358
static const UCHAR Index[8]
Definition: usbohci.c:18
NTSYSAPI BOOLEAN WINAPI RtlIsValidIndexHandle(const RTL_HANDLE_TABLE *, ULONG Index, RTL_HANDLE **)
Definition: rtltypes.h:1240

◆ RtlpGetMode()

KPROCESSOR_MODE NTAPI RtlpGetMode ( VOID  )

Definition at line 53 of file libsupp.c.

54 {
55  return UserMode;
56 }

Referenced by RtlCreateHeap(), RtlCreateProcessParameters(), RtlDestroyHeap(), RtlFreeHeap(), RtlpExtendHeap(), and RtlpInitializeHeap().

◆ 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 190 of file libsupp.c.

194 {
195  /* There's no such thing as a DPC stack in user-mode */
196  return FALSE;
197 }

Referenced by RtlDispatchException(), and RtlUnwind().

◆ RtlpInitAtomTableLock()

NTSTATUS RtlpInitAtomTableLock ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 362 of file libsupp.c.

363 {
364  RtlInitializeCriticalSection(&AtomTable->CriticalSection);
365  return STATUS_SUCCESS;
366 }
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ RtlpLockAtomTable()

BOOLEAN RtlpLockAtomTable ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 377 of file libsupp.c.

378 {
379  RtlEnterCriticalSection(&AtomTable->CriticalSection);
380  return TRUE;
381 }
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

◆ 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 994 of file libsupp.c.

998 {
999  _SEH2_TRY
1000  {
1002  }
1004  {
1006  }
1007  _SEH2_END;
1008 
1009  return STATUS_SUCCESS;
1010 }
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 174 of file libsupp.c.

175 {
176  PPEB Peb;
177 
178  /* Get PEB */
179  Peb = RtlGetCurrentPeb();
180 
181  /* Apply defaults for non-set parameters */
182  if (!Parameters->SegmentCommit) Parameters->SegmentCommit = Peb->HeapSegmentCommit;
183  if (!Parameters->SegmentReserve) Parameters->SegmentReserve = Peb->HeapSegmentReserve;
184  if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = Peb->HeapDeCommitFreeBlockThreshold;
185  if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = Peb->HeapDeCommitTotalFreeThreshold;
186 }
ULONG HeapSegmentReserve
Definition: ntddk_ex.h:275
PPEB Peb
Definition: dllmain.c:27
ULONG HeapDeCommitFreeBlockThreshold
Definition: ntddk_ex.h:278
ULONG HeapSegmentCommit
Definition: ntddk_ex.h:276
PPEB NTAPI RtlGetCurrentPeb(VOID)
Definition: libsupp.c:63
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
ULONG HeapDeCommitTotalFreeThreshold
Definition: ntddk_ex.h:277

Referenced by RtlCreateHeap().

◆ RtlpSetInDbgPrint()

BOOLEAN NTAPI RtlpSetInDbgPrint ( VOID  )

Definition at line 33 of file libsupp.c.

34 {
35  /* Check if it's already set and return TRUE if so */
36  if (NtCurrentTeb()->InDbgPrint) return TRUE;
37 
38  /* Set it and return */
39  NtCurrentTeb()->InDbgPrint = TRUE;
40  return FALSE;
41 }
#define TRUE
Definition: types.h:120
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

Referenced by vDbgPrintExWithPrefixInternal().

◆ RtlpUnlockAtomTable()

VOID RtlpUnlockAtomTable ( PRTL_ATOM_TABLE  AtomTable)

Definition at line 385 of file libsupp.c.

386 {
387  RtlLeaveCriticalSection(&AtomTable->CriticalSection);
388 }
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

◆ RtlReleasePebLock()

◆ RtlTryEnterHeapLock()

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

Definition at line 117 of file libsupp.c.

118 {
119  UNREFERENCED_PARAMETER(Exclusive);
120 
121  return RtlTryEnterCriticalSection(&Lock->CriticalSection);
122 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
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
NTSYSAPI BOOLEAN NTAPI RtlTryEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

Referenced by RtlpDphEnterCriticalSection().

◆ RtlWalkFrameChain()

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

Definition at line 227 of file libsupp.c.

230 {
231  ULONG_PTR Stack, NewStack, StackBegin, StackEnd = 0;
232  ULONG Eip;
233  BOOLEAN Result, StopSearch = FALSE;
234  ULONG i = 0;
235 
236  /* Get current EBP */
237 #if defined(_M_IX86)
238 #if defined __GNUC__
239  __asm__("mov %%ebp, %0" : "=r" (Stack) : );
240 #elif defined(_MSC_VER)
241  __asm mov Stack, ebp
242 #endif
243 #elif defined(_M_MIPS)
244  __asm__("move $sp, %0" : "=r" (Stack) : );
245 #elif defined(_M_PPC)
246  __asm__("mr %0,1" : "=r" (Stack) : );
247 #elif defined(_M_ARM)
248 #if defined __GNUC__
249  __asm__("mov sp, %0" : "=r"(Stack) : );
250 #elif defined(_MSC_VER)
251  // FIXME: Hack. Probably won't work if this ever actually manages to run someday.
252  Stack = (ULONG_PTR)&Stack;
253 #endif
254 #else
255 #error Unknown architecture
256 #endif
257 
258  /* Set it as the stack begin limit as well */
259  StackBegin = (ULONG_PTR)Stack;
260 
261  /* Check if we're called for non-logging mode */
262  if (!Flags)
263  {
264  /* Get the actual safe limits */
266  &StackBegin,
267  &StackEnd);
268  if (!Result) return 0;
269  }
270 
271  /* Use a SEH block for maximum protection */
272  _SEH2_TRY
273  {
274  /* Loop the frames */
275  for (i = 0; i < Count; i++)
276  {
277  /*
278  * Leave if we're past the stack,
279  * if we're before the stack,
280  * or if we've reached ourselves.
281  */
282  if ((Stack >= StackEnd) ||
283  (!i ? (Stack < StackBegin) : (Stack <= StackBegin)) ||
284  ((StackEnd - Stack) < (2 * sizeof(ULONG_PTR))))
285  {
286  /* We're done or hit a bad address */
287  break;
288  }
289 
290  /* Get new stack and EIP */
291  NewStack = *(PULONG_PTR)Stack;
292  Eip = *(PULONG_PTR)(Stack + sizeof(ULONG_PTR));
293 
294  /* Check if the new pointer is above the oldone and past the end */
295  if (!((Stack < NewStack) && (NewStack < StackEnd)))
296  {
297  /* Stop searching after this entry */
298  StopSearch = TRUE;
299  }
300 
301  /* Also make sure that the EIP isn't a stack address */
302  if ((StackBegin < Eip) && (Eip < StackEnd)) break;
303 
304  /* FIXME: Check that EIP is inside a loaded module */
305 
306  /* Save this frame */
307  Callers[i] = (PVOID)Eip;
308 
309  /* Check if we should continue */
310  if (StopSearch)
311  {
312  /* Return the next index */
313  i++;
314  break;
315  }
316 
317  /* Move to the next stack */
318  Stack = NewStack;
319  }
320  }
322  {
323  /* No index */
324  i = 0;
325  }
326  _SEH2_END;
327 
328  /* Return frames parsed */
329  return i;
330 }
#define TRUE
Definition: types.h:120
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
_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")
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
_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
_SEH2_END
Definition: create.c:4424
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
uint32_t * PULONG_PTR
Definition: typedefs.h:63
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by KeRosCaptureUserStackBackTrace(), lie_about_fs_type(), RtlCaptureStackBackTrace(), and TestStackWalk4().

◆ RtlWow64EnableFsRedirection()

NTSYSAPI NTSTATUS NTAPI RtlWow64EnableFsRedirection ( IN BOOLEAN  Wow64FsEnableRedirection)

Definition at line 959 of file libsupp.c.

960 {
961  /* This is what Windows returns on x86 */
962  return STATUS_NOT_IMPLEMENTED;
963 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

Referenced by Wow64EnableWow64FsRedirection().

◆ RtlWow64EnableFsRedirectionEx()

NTSYSAPI NTSTATUS NTAPI RtlWow64EnableFsRedirectionEx ( IN PVOID  Wow64FsEnableRedirection,
OUT PVOID OldFsRedirectionLevel 
)

Definition at line 971 of file libsupp.c.

973 {
974  /* This is what Windows returns on x86 */
975  return STATUS_NOT_IMPLEMENTED;
976 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

Referenced by Wow64DisableWow64FsRedirection(), and Wow64RevertWow64FsRedirection().

Variable Documentation

◆ LdrpTopLevelDllBeingLoadedTeb

PTEB LdrpTopLevelDllBeingLoadedTeb = NULL

Definition at line 18 of file libsupp.c.

Referenced by LdrpRunInitializeRoutines(), and RtlIsThreadWithinLoaderCallout().

◆ MmHighestUserAddress

PVOID MmHighestUserAddress = (PVOID)MI_HIGHEST_USER_ADDRESS

Definition at line 19 of file libsupp.c.

◆ RtlpAllocDeallocQueryBufferSize

SIZE_T RtlpAllocDeallocQueryBufferSize = PAGE_SIZE

Definition at line 17 of file libsupp.c.