ReactOS 0.4.15-dev-5666-gc548b97
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_ PANSI_STRING Name, _In_ ULONG Ordinal, _Out_ PVOID *ProcedureAddress)
 
ULONG NTAPI LdrRelocateImage (_In_ PVOID NewBase, _In_ PCCH 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 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 (_In_ BOOLEAN ReservedFlag, _In_ PLDR_ENUM_CALLBACK EnumProc, _In_ PVOID Context)
 

Function Documentation

◆ LdrAccessResource()

◆ LdrEnumerateLoadedModules()

NTSTATUS NTAPI LdrEnumerateLoadedModules ( _In_ BOOLEAN  ReservedFlag,
_In_ PLDR_ENUM_CALLBACK  EnumProc,
_In_ PVOID  Context 
)

◆ 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}
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define RtlImageDirectoryEntryToData
Definition: compat.h:809
Status
Definition: gdiplustypes.h:25
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
unsigned char * PUCHAR
Definition: retypes.h:3
unsigned int ULONG
Definition: retypes.h:1
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
#define STATUS_SUCCESS
Definition: shellext.h:65
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
#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:426

Referenced by Test_Data(), and Test_Parameters().

◆ LdrFindResource_U()

◆ LdrFindResourceDirectory_U()

◆ LdrGetProcedureAddress()

NTSTATUS NTAPI LdrGetProcedureAddress ( _In_ PVOID  BaseAddress,
_In_ PANSI_STRING  Name,
_In_ ULONG  Ordinal,
_Out_ PVOID ProcedureAddress 
)

◆ LdrLoadAlternateResourceModule()

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

◆ LdrLockLoaderLock()

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

◆ 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  NewBase,
_In_ PCCH  LoaderName,
_In_ ULONG  Success,
_In_ ULONG  Conflict,
_In_ ULONG  Invalid 
)

Referenced by ImgpLoadPEImage().

◆ LdrUnloadAlternateResourceModule()

BOOLEAN NTAPI LdrUnloadAlternateResourceModule ( _In_ PVOID  BaseAddress)

◆ LdrUnlockLoaderLock()

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

◆ LdrVerifyMappedImageMatchesChecksum()

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