ReactOS 0.4.15-dev-7991-ge77da17
ldrfuncs.h File Reference
#include <umtypes.h>
#include <ldrtypes.h>
Include dependency graph for ldrfuncs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

NTSTATUS NTAPI LdrAccessResource (_In_ PVOID BaseAddress, _In_ PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry, _Out_opt_ PVOID *Resource, _Out_opt_ PULONG Size)
 
NTSTATUS NTAPI LdrFindResource_U (_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Out_ PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry)
 
NTSTATUS NTAPI LdrEnumResources (_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Inout_ ULONG *ResourceCount, _Out_writes_to_(*ResourceCount, *ResourceCount) LDR_ENUM_RESOURCE_INFO *Resources)
 
NTSTATUS NTAPI LdrFindResourceDirectory_U (_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Out_ PIMAGE_RESOURCE_DIRECTORY *ResourceDirectory)
 
NTSTATUS NTAPI LdrLoadAlternateResourceModule (_In_ PVOID Module, _In_ PWSTR Buffer)
 
BOOLEAN NTAPI LdrUnloadAlternateResourceModule (_In_ PVOID BaseAddress)
 
NTSTATUS NTAPI LdrGetProcedureAddress (_In_ PVOID BaseAddress, _In_opt_ _When_(Ordinal==0, _Notnull_) PANSI_STRING Name, _In_opt_ _When_(Name==NULL, _In_range_(>, 0)) ULONG Ordinal, _Out_ PVOID *ProcedureAddress)
 
ULONG NTAPI LdrRelocateImage (_In_ PVOID BaseAddress, _In_opt_ PCSTR LoaderName, _In_ ULONG Success, _In_ ULONG Conflict, _In_ ULONG Invalid)
 
NTSTATUS NTAPI LdrLockLoaderLock (_In_ ULONG Flags, _Out_opt_ PULONG Disposition, _Out_opt_ PULONG_PTR Cookie)
 
NTSTATUS NTAPI LdrUnlockLoaderLock (_In_ ULONG Flags, _In_opt_ ULONG_PTR Cookie)
 
BOOLEAN NTAPI LdrVerifyMappedImageMatchesChecksum (_In_ PVOID BaseAddress, _In_ SIZE_T NumberOfBytes, _In_ ULONG FileLength)
 
PIMAGE_BASE_RELOCATION NTAPI LdrProcessRelocationBlockLongLong (_In_ ULONG_PTR Address, _In_ ULONG Count, _In_ PUSHORT TypeOffset, _In_ LONGLONG Delta)
 
NTSTATUS NTAPI LdrEnumerateLoadedModules (_Reserved_ ULONG ReservedFlag, _In_ PLDR_ENUM_CALLBACK EnumProc, _In_opt_ PVOID Context)
 

Function Documentation

◆ LdrAccessResource()

◆ LdrEnumerateLoadedModules()

NTSTATUS NTAPI LdrEnumerateLoadedModules ( _Reserved_ ULONG  ReservedFlag,
_In_ PLDR_ENUM_CALLBACK  EnumProc,
_In_opt_ PVOID  Context 
)

Definition at line 1090 of file ldrapi.c.

1094{
1095 PLIST_ENTRY ListHead, ListEntry;
1096 PLDR_DATA_TABLE_ENTRY LdrEntry;
1099 BOOLEAN Stop = FALSE;
1100
1101 /* Check parameters */
1102 if ((ReservedFlag) || !(EnumProc)) return STATUS_INVALID_PARAMETER;
1103
1104 /* Acquire the loader lock */
1106 if (!NT_SUCCESS(Status)) return Status;
1107
1108 /* Loop all the modules and call enum proc */
1109 ListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList;
1110 ListEntry = ListHead->Flink;
1111 while (ListHead != ListEntry)
1112 {
1113 /* Get the entry */
1114 LdrEntry = CONTAINING_RECORD(ListEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
1115
1116 /* Call the enumeration proc inside SEH */
1117 _SEH2_TRY
1118 {
1119 EnumProc(LdrEntry, Context, &Stop);
1120 }
1122 {
1123 /* Ignoring the exception */
1124 } _SEH2_END;
1125
1126 /* Break if we were asked to stop enumeration */
1127 if (Stop)
1128 {
1129 break;
1130 }
1131
1132 /* Advance to the next module */
1133 ListEntry = ListEntry->Flink;
1134 }
1135
1136 /* Release loader lock */
1139
1140 /* Reset any successful status to STATUS_SUCCESS,
1141 * but leave failure to the caller */
1142 if (NT_SUCCESS(Status))
1144
1145 /* Return any possible failure status */
1146 return Status;
1147}
#define NtCurrentPeb()
Definition: FLS.c:22
unsigned char BOOLEAN
static BOOL CALLBACK EnumProc(_In_ HWND hWnd, _In_ LPARAM lParam)
Definition: SetParent.c:53
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
NTSTATUS NTAPI LdrUnlockLoaderLock(_In_ ULONG Flags, _In_opt_ ULONG_PTR Cookie)
Definition: ldrapi.c:101
NTSTATUS NTAPI LdrLockLoaderLock(_In_ ULONG Flags, _Out_opt_ PULONG Disposition, _Out_opt_ PULONG_PTR Cookie)
Definition: ldrapi.c:174
_In_opt_ PVOID _Out_ BOOLEAN * Stop
Definition: ldrtypes.h:241
#define ASSERT(a)
Definition: mode.c:44
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: btrfs_drv.h:1876
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_opt_ PVOID _Out_ PLARGE_INTEGER Cookie
Definition: cmfuncs.h:14

Referenced by BasepComputeProcessPath(), and LoadLibraryExW().

◆ LdrEnumResources()

NTSTATUS NTAPI LdrEnumResources ( _In_ PVOID  BaseAddress,
_In_ PLDR_RESOURCE_INFO  ResourceInfo,
_In_ ULONG  Level,
_Inout_ ULONG ResourceCount,
_Out_writes_to_ *, *ResourceCount LDR_ENUM_RESOURCE_INFO Resources 
)

Definition at line 343 of file res.c.

349{
350 PUCHAR ResourceData;
352 ULONG i, j, k;
353 ULONG NumberOfTypeEntries, NumberOfNameEntries, NumberOfLangEntries;
354 ULONG Count, MaxResourceCount;
355 PIMAGE_RESOURCE_DIRECTORY TypeDirectory, NameDirectory, LangDirectory;
356 PIMAGE_RESOURCE_DIRECTORY_ENTRY TypeEntry, NameEntry, LangEntry;
358 ULONG Size;
359 LONG Result;
360
361 /* If the caller wants data, get the maximum count of entries */
362 MaxResourceCount = (Resources != NULL) ? *ResourceCount : 0;
363
364 /* Default to 0 */
365 *ResourceCount = 0;
366
367 /* Locate the resource directory */
368 ResourceData = RtlImageDirectoryEntryToData(ImageBase,
369 TRUE,
371 &Size);
372 if (ResourceData == NULL)
374
375 /* The type directory is at the root, followed by the entries */
376 TypeDirectory = (PIMAGE_RESOURCE_DIRECTORY)ResourceData;
377 TypeEntry = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(TypeDirectory + 1);
378
379 /* Get the number of entries in the type directory */
380 NumberOfTypeEntries = TypeDirectory->NumberOfNamedEntries +
381 TypeDirectory->NumberOfIdEntries;
382
383 /* Start with 0 resources and status success */
385 Count = 0;
386
387 /* Loop all entries in the type directory */
388 for (i = 0; i < NumberOfTypeEntries; ++i, ++TypeEntry)
389 {
390 /* Check if comparison of types is requested */
392 {
393 /* Compare the type with the requested Type */
394 Result = LdrpCompareResourceNames_U(ResourceData,
395 TypeEntry,
396 ResourceInfo->Type);
397
398 /* Not equal, continue with next entry */
399 if (Result != 0) continue;
400 }
401
402 /* The entry must point to the name directory */
403 if (!TypeEntry->DataIsDirectory)
404 {
406 }
407
408 /* Get a pointer to the name subdirectory and it's first entry */
409 NameDirectory = (PIMAGE_RESOURCE_DIRECTORY)(ResourceData +
410 TypeEntry->OffsetToDirectory);
411 NameEntry = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(NameDirectory + 1);
412
413 /* Get the number of entries in the name directory */
414 NumberOfNameEntries = NameDirectory->NumberOfNamedEntries +
415 NameDirectory->NumberOfIdEntries;
416
417 /* Loop all entries in the name directory */
418 for (j = 0; j < NumberOfNameEntries; ++j, ++NameEntry)
419 {
420 /* Check if comparison of names is requested */
422 {
423 /* Compare the name with the requested name */
424 Result = LdrpCompareResourceNames_U(ResourceData,
425 NameEntry,
426 ResourceInfo->Name);
427
428 /* Not equal, continue with next entry */
429 if (Result != 0) continue;
430 }
431
432 /* The entry must point to the language directory */
433 if (!NameEntry->DataIsDirectory)
434 {
436 }
437
438 /* Get a pointer to the language subdirectory and it's first entry */
439 LangDirectory = (PIMAGE_RESOURCE_DIRECTORY)(ResourceData +
440 NameEntry->OffsetToDirectory);
441 LangEntry = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(LangDirectory + 1);
442
443 /* Get the number of entries in the language directory */
444 NumberOfLangEntries = LangDirectory->NumberOfNamedEntries +
445 LangDirectory->NumberOfIdEntries;
446
447 /* Loop all entries in the language directory */
448 for (k = 0; k < NumberOfLangEntries; ++k, ++LangEntry)
449 {
450 /* Check if comparison of languages is requested */
452 {
453 /* Compare the language with the requested language */
454 Result = LdrpCompareResourceNames_U(ResourceData,
455 LangEntry,
456 ResourceInfo->Language);
457
458 /* Not equal, continue with next entry */
459 if (Result != 0) continue;
460 }
461
462 /* This entry must point to data */
463 if (LangEntry->DataIsDirectory)
464 {
466 }
467
468 /* Get a pointer to the data entry */
469 DataEntry = (PIMAGE_RESOURCE_DATA_ENTRY)(ResourceData +
470 LangEntry->OffsetToData);
471
472 /* Check if there is still space to store the data */
473 if (Count < MaxResourceCount)
474 {
475 /* There is, fill the entry */
476 Resources[Count].Type =
477 NAME_FROM_RESOURCE_ENTRY(ResourceData, TypeEntry);
478 Resources[Count].Name =
479 NAME_FROM_RESOURCE_ENTRY(ResourceData, NameEntry);
480 Resources[Count].Language =
481 NAME_FROM_RESOURCE_ENTRY(ResourceData, LangEntry);
482 Resources[Count].Data = (PUCHAR)ImageBase + DataEntry->OffsetToData;
483 Resources[Count].Reserved = 0;
484 Resources[Count].Size = DataEntry->Size;
485 }
486 else
487 {
488 /* There is not enough space, save error status */
490 }
491
492 /* Count this resource */
493 ++Count;
494 }
495 }
496 }
497
498 /* Return the number of matching resources */
500 return Status;
501}
#define TRUE
Definition: types.h:120
#define RtlImageDirectoryEntryToData
Definition: compat.h:809
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
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 GLint GLint j
Definition: glfuncs.h:250
static ULONG ResourceCount
Definition: inbv.c:50
#define RESOURCE_NAME_LEVEL
Definition: ldrtypes.h:31
#define RESOURCE_LANGUAGE_LEVEL
Definition: ldrtypes.h:32
#define RESOURCE_TYPE_LEVEL
Definition: ldrtypes.h:30
int k
Definition: mpi.c:3369
int Count
Definition: noreturn.cpp:7
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:359
#define STATUS_RESOURCE_DATA_NOT_FOUND
Definition: ntstatus.h:373
struct _IMAGE_RESOURCE_DIRECTORY * PIMAGE_RESOURCE_DIRECTORY
struct _IMAGE_RESOURCE_DATA_ENTRY * PIMAGE_RESOURCE_DATA_ENTRY
long LONG
Definition: pedump.c:60
struct _IMAGE_RESOURCE_DIRECTORY_ENTRY * PIMAGE_RESOURCE_DIRECTORY_ENTRY
#define IMAGE_DIRECTORY_ENTRY_RESOURCE
Definition: pedump.c:261
#define NAME_FROM_RESOURCE_ENTRY(RootDirectory, Entry)
Definition: res.c:288
static LONG LdrpCompareResourceNames_U(_In_ PUCHAR ResourceData, _In_ PIMAGE_RESOURCE_DIRECTORY_ENTRY Entry, _In_ ULONG_PTR CompareName)
Definition: res.c:293
Definition: pedump.c:458
DWORD OffsetToData
Definition: pedump.c:459
DWORD Size
Definition: pedump.c:460
Definition: pedump.c:414
DWORD OffsetToData
Definition: pedump.c:416
ULONG OffsetToDirectory
Definition: ntimage.h:194
ULONG DataIsDirectory
Definition: ntimage.h:195
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
_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:409

Referenced by Test_Data(), and Test_Parameters().

◆ LdrFindResource_U()

◆ LdrFindResourceDirectory_U()

◆ LdrGetProcedureAddress()

NTSTATUS NTAPI LdrGetProcedureAddress ( _In_ PVOID  BaseAddress,
_In_opt_ _When_(Ordinal==0, _Notnull_) PANSI_STRING  Name,
_In_opt_ _When_(Name==NULL, _In_range_(>, 0)) ULONG  Ordinal,
_Out_ PVOID ProcedureAddress 
)

Definition at line 789 of file ldrapi.c.

794{
795 /* Call the internal routine and tell it to execute DllInit */
796 return LdrpGetProcedureAddress(BaseAddress, Name, Ordinal, ProcedureAddress, TRUE);
797}
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
NTSTATUS NTAPI LdrpGetProcedureAddress(_In_ PVOID BaseAddress, _In_opt_ _When_(Ordinal==0, _Notnull_) PANSI_STRING Name, _In_opt_ _When_(Name==NULL, _In_range_(>, 0)) ULONG Ordinal, _Out_ PVOID *ProcedureAddress, _In_ BOOLEAN ExecuteInit)
Definition: ldrutils.c:2226

◆ LdrLoadAlternateResourceModule()

NTSTATUS NTAPI LdrLoadAlternateResourceModule ( _In_ PVOID  Module,
_In_ PWSTR  Buffer 
)

Definition at line 1585 of file ldrapi.c.

1588{
1589 /* Is MUI Support enabled? */
1591
1594}
#define UNIMPLEMENTED
Definition: debug.h:115
#define STATUS_MUI_FILE_NOT_FOUND
Definition: ldrapi.c:1578
BOOLEAN NTAPI LdrAlternateResourcesEnabled(VOID)
Definition: ldrapi.c:81

◆ LdrLockLoaderLock()

NTSTATUS NTAPI LdrLockLoaderLock ( _In_ ULONG  Flags,
_Out_opt_ PULONG  Disposition,
_Out_opt_ PULONG_PTR  Cookie 
)

Definition at line 174 of file ldrapi.c.

178{
180 BOOLEAN InInit = LdrpInLdrInit;
181
182 DPRINT("LdrLockLoaderLock(%x %p %p)\n", Flags, Disposition, Cookie);
183
184 /* Zero out the outputs */
186 if (Cookie) *Cookie = 0;
187
188 /* Validate the flags */
191 {
192 /* Flags are invalid, check how to fail */
194 {
195 /* The caller wants us to raise status */
197 }
198
199 /* A normal failure */
201 }
202
203 /* Make sure we got a cookie */
204 if (!Cookie)
205 {
206 /* No cookie check how to fail */
208 {
209 /* The caller wants us to raise status */
211 }
212
213 /* A normal failure */
215 }
216
217 /* If the flag is set, make sure we have a valid pointer to use */
219 {
220 /* No pointer to return the data to */
222 {
223 /* The caller wants us to raise status */
225 }
226
227 /* Fail */
229 }
230
231 /* Return now if we are in the init phase */
232 if (InInit) return STATUS_SUCCESS;
233
234 /* Check what locking semantic to use */
236 {
237 /* Check if we should enter or simply try */
239 {
240 /* Do a try */
242 {
243 /* It's locked */
245 }
246 else
247 {
248 /* It worked */
251 }
252 }
253 else
254 {
255 /* Do a enter */
257
258 /* See if result was requested */
261 }
262 }
263 else
264 {
265 /* Wrap this in SEH, since we're not supposed to raise */
267 {
268 /* Check if we should enter or simply try */
270 {
271 /* Do a try */
273 {
274 /* It's locked */
276 }
277 else
278 {
279 /* It worked */
282 }
283 }
284 else
285 {
286 /* Do an enter */
288
289 /* See if result was requested */
292 }
293 }
295 {
296 /* We should use the LDR Filter instead */
298 }
299 _SEH2_END;
300 }
301
302 /* Return status */
303 return Status;
304}
FORCEINLINE ULONG_PTR LdrpMakeCookie(VOID)
Definition: ldrapi.c:89
#define LDR_LOCK_LOADER_LOCK_DISPOSITION_LOCK_NOT_ACQUIRED
Definition: ldrtypes.h:93
#define LDR_LOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS
Definition: ldrtypes.h:76
#define LDR_LOCK_LOADER_LOCK_FLAG_TRY_ONLY
Definition: ldrtypes.h:77
#define LDR_LOCK_LOADER_LOCK_DISPOSITION_INVALID
Definition: ldrtypes.h:91
#define LDR_LOCK_LOADER_LOCK_DISPOSITION_LOCK_ACQUIRED
Definition: ldrtypes.h:92
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
NTSYSAPI BOOLEAN NTAPI RtlTryEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
DECLSPEC_NORETURN NTSYSAPI VOID NTAPI RtlRaiseStatus(_In_ NTSTATUS Status)
BOOLEAN LdrpInLdrInit
Definition: ldrinit.c:30
RTL_CRITICAL_SECTION LdrpLoaderLock
Definition: ldrinit.c:70
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:477
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define DPRINT
Definition: sndvol32.h:71
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by BasepGetModuleHandleExW(), find_query_actctx(), get_module_filename(), GetModuleFileNameW(), LdrAddRefDll(), LdrDisableThreadCalloutsForDll(), LdrEnumerateLoadedModules(), LdrGetDllHandleEx(), LdrInitShimEngineDynamic(), LdrLoadDll(), and LdrUnloadAlternateResourceModule().

◆ LdrProcessRelocationBlockLongLong()

PIMAGE_BASE_RELOCATION NTAPI LdrProcessRelocationBlockLongLong ( _In_ ULONG_PTR  Address,
_In_ ULONG  Count,
_In_ PUSHORT  TypeOffset,
_In_ LONGLONG  Delta 
)

◆ LdrRelocateImage()

ULONG NTAPI LdrRelocateImage ( _In_ PVOID  BaseAddress,
_In_opt_ PCSTR  LoaderName,
_In_ ULONG  Success,
_In_ ULONG  Conflict,
_In_ ULONG  Invalid 
)

Definition at line 462 of file image.c.

468{
469 return LdrRelocateImageWithBias(BaseAddress, 0, LoaderName, Success, Conflict, Invalid);
470}
@ Invalid
Definition: asmpp.cpp:30
@ Success
Definition: eventcreate.c:712
ULONG NTAPI LdrRelocateImageWithBias(_In_ PVOID BaseAddress, _In_ LONGLONG AdditionalBias, _In_opt_ PCSTR LoaderName, _In_ ULONG Success, _In_ ULONG Conflict, _In_ ULONG Invalid)
Definition: image.c:474

Referenced by ImgpLoadPEImage().

◆ LdrUnloadAlternateResourceModule()

BOOLEAN NTAPI LdrUnloadAlternateResourceModule ( _In_ PVOID  BaseAddress)

Definition at line 1601 of file ldrapi.c.

1603{
1605
1606 /* Acquire the loader lock */
1608
1609 /* Check if there's any alternate resources loaded */
1611 {
1613 }
1614
1615 /* Release the loader lock */
1617
1618 /* All done */
1619 return TRUE;
1620}
ULONG AlternateResourceModuleCount
Definition: ldrapi.c:23
#define LDR_UNLOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS
Definition: ldrtypes.h:82

Referenced by FreeLibrary(), FreeLibraryAndExitThread(), and LdrUnloadDll().

◆ LdrUnlockLoaderLock()

NTSTATUS NTAPI LdrUnlockLoaderLock ( _In_ ULONG  Flags,
_In_opt_ ULONG_PTR  Cookie 
)

Definition at line 101 of file ldrapi.c.

104{
106
107 DPRINT("LdrUnlockLoaderLock(%x %Ix)\n", Flags, Cookie);
108
109 /* Check for valid flags */
111 {
112 /* Flags are invalid, check how to fail */
114 {
115 /* The caller wants us to raise status */
117 }
118
119 /* A normal failure */
121 }
122
123 /* If we don't have a cookie, just return */
124 if (!Cookie) return STATUS_SUCCESS;
125
126 /* Validate the cookie */
127 if ((Cookie & 0xF0000000) ||
128 ((Cookie >> 16) ^ (HandleToUlong(NtCurrentTeb()->RealClientId.UniqueThread) & 0xFFF)))
129 {
130 DPRINT1("LdrUnlockLoaderLock() called with an invalid cookie!\n");
131
132 /* Invalid cookie, check how to fail */
134 {
135 /* The caller wants us to raise status */
137 }
138
139 /* A normal failure */
141 }
142
143 /* Ready to release the lock */
145 {
146 /* Do a direct leave */
148 }
149 else
150 {
151 /* Wrap this in SEH, since we're not supposed to raise */
153 {
154 /* Leave the lock */
156 }
158 {
159 /* We should use the LDR Filter instead */
161 }
162 _SEH2_END;
163 }
164
165 /* All done */
166 return Status;
167}
#define DPRINT1
Definition: precomp.h:8
#define HandleToUlong(h)
Definition: basetsd.h:79
#define NtCurrentTeb
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

Referenced by BasepGetModuleHandleExW(), find_query_actctx(), get_module_filename(), GetModuleFileNameW(), LdrAddRefDll(), LdrDisableThreadCalloutsForDll(), LdrEnumerateLoadedModules(), LdrGetDllHandleEx(), LdrInitShimEngineDynamic(), LdrLoadDll(), and LdrUnloadAlternateResourceModule().

◆ LdrVerifyMappedImageMatchesChecksum()

BOOLEAN NTAPI LdrVerifyMappedImageMatchesChecksum ( _In_ PVOID  BaseAddress,
_In_ SIZE_T  NumberOfBytes,
_In_ ULONG  FileLength 
)