2006-05-10 17:47:44 +00:00
|
|
|
/*++ NDK Version: 0098
|
2005-11-22 04:57:45 +00:00
|
|
|
|
|
|
|
Copyright (c) Alex Ionescu. All rights reserved.
|
|
|
|
|
|
|
|
Header Name:
|
|
|
|
|
|
|
|
ldrtypes.h
|
|
|
|
|
|
|
|
Abstract:
|
|
|
|
|
|
|
|
Type definitions for the Loader.
|
|
|
|
|
|
|
|
Author:
|
|
|
|
|
2006-05-10 17:47:44 +00:00
|
|
|
Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
|
2005-11-22 04:57:45 +00:00
|
|
|
|
|
|
|
--*/
|
|
|
|
|
2005-06-18 23:33:40 +00:00
|
|
|
#ifndef _LDRTYPES_H
|
|
|
|
#define _LDRTYPES_H
|
|
|
|
|
2005-11-22 04:57:45 +00:00
|
|
|
//
|
|
|
|
// Dependencies
|
|
|
|
//
|
2005-11-25 00:17:40 +00:00
|
|
|
#include <umtypes.h>
|
2005-11-22 04:57:45 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Resource Type Levels
|
|
|
|
//
|
2006-05-10 17:47:44 +00:00
|
|
|
#define RESOURCE_TYPE_LEVEL 0
|
|
|
|
#define RESOURCE_NAME_LEVEL 1
|
|
|
|
#define RESOURCE_LANGUAGE_LEVEL 2
|
|
|
|
#define RESOURCE_DATA_LEVEL 3
|
2005-11-22 04:57:45 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Loader Data Table Entry Flags
|
|
|
|
//
|
2006-05-10 17:47:44 +00:00
|
|
|
#define LDRP_STATIC_LINK 0x00000002
|
|
|
|
#define LDRP_IMAGE_DLL 0x00000004
|
|
|
|
#define LDRP_LOAD_IN_PROGRESS 0x00001000
|
|
|
|
#define LDRP_UNLOAD_IN_PROGRESS 0x00002000
|
|
|
|
#define LDRP_ENTRY_PROCESSED 0x00004000
|
|
|
|
#define LDRP_ENTRY_INSERTED 0x00008000
|
|
|
|
#define LDRP_CURRENT_LOAD 0x00010000
|
|
|
|
#define LDRP_FAILED_BUILTIN_LOAD 0x00020000
|
|
|
|
#define LDRP_DONT_CALL_FOR_THREADS 0x00040000
|
|
|
|
#define LDRP_PROCESS_ATTACH_CALLED 0x00080000
|
|
|
|
#define LDRP_DEBUG_SYMBOLS_LOADED 0x00100000
|
|
|
|
#define LDRP_IMAGE_NOT_AT_BASE 0x00200000
|
|
|
|
#define LDRP_COR_IMAGE 0x00400000
|
|
|
|
#define LDR_COR_OWNS_UNMAP 0x00800000
|
2007-02-22 20:55:02 +00:00
|
|
|
#define LDRP_SYSTEM_MAPPED 0x01000000
|
|
|
|
#define LDRP_IMAGE_VERIFYING 0x02000000
|
|
|
|
#define LDRP_DRIVER_DEPENDENT_DLL 0x04000000
|
2009-11-08 01:13:49 +00:00
|
|
|
#define LDRP_ENTRY_NATIVE 0x08000000
|
2006-05-10 17:47:44 +00:00
|
|
|
#define LDRP_REDIRECTED 0x10000000
|
2007-02-22 20:55:02 +00:00
|
|
|
#define LDRP_NON_PAGED_DEBUG_INFO 0x20000000
|
|
|
|
#define LDRP_MM_LOADED 0x40000000
|
|
|
|
#define LDRP_COMPAT_DATABASE_PROCESSED 0x80000000
|
2006-05-10 17:47:44 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Dll Characteristics for LdrLoadDll
|
|
|
|
//
|
|
|
|
#define LDR_IGNORE_CODE_AUTHZ_LEVEL 0x00001000
|
|
|
|
|
|
|
|
//
|
|
|
|
// LdrAddRef Flags
|
|
|
|
//
|
|
|
|
#define LDR_PIN_MODULE 0x00000001
|
|
|
|
|
|
|
|
//
|
|
|
|
// LdrLockLoaderLock Flags
|
|
|
|
//
|
2011-04-04 19:35:24 +00:00
|
|
|
#define LDR_LOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS 0x00000001
|
|
|
|
#define LDR_LOCK_LOADER_LOCK_FLAG_TRY_ONLY 0x00000002
|
|
|
|
|
|
|
|
#define LDR_LOCK_LOADER_LOCK_DISPOSITION_INVALID 0
|
|
|
|
#define LDR_LOCK_LOADER_LOCK_DISPOSITION_LOCK_ACQUIRED 1
|
|
|
|
#define LDR_LOCK_LOADER_LOCK_DISPOSITION_LOCK_NOT_ACQUIRED 2
|
2005-11-22 04:57:45 +00:00
|
|
|
|
2006-10-25 18:23:45 +00:00
|
|
|
//
|
|
|
|
// FIXME: THIS SHOULD *NOT* BE USED!
|
|
|
|
//
|
|
|
|
#define IMAGE_SCN_TYPE_NOLOAD 0x00000002
|
|
|
|
|
2011-04-03 21:46:42 +00:00
|
|
|
//
|
|
|
|
// Loader datafile/imagemapping macros
|
|
|
|
//
|
|
|
|
#define LDR_IS_DATAFILE(handle) (((ULONG_PTR)(handle)) & (ULONG_PTR)1)
|
|
|
|
#define LDR_IS_IMAGEMAPPING(handle) (((ULONG_PTR)(handle)) & (ULONG_PTR)2)
|
|
|
|
#define LDR_IS_RESOURCE(handle) (LDR_IS_IMAGEMAPPING(handle) || LDR_IS_DATAFILE(handle))
|
|
|
|
|
2005-11-22 04:57:45 +00:00
|
|
|
//
|
|
|
|
// Loader Data stored in the PEB
|
|
|
|
//
|
2005-06-18 23:33:40 +00:00
|
|
|
typedef struct _PEB_LDR_DATA
|
|
|
|
{
|
2005-11-22 04:57:45 +00:00
|
|
|
ULONG Length;
|
|
|
|
BOOLEAN Initialized;
|
|
|
|
PVOID SsHandle;
|
|
|
|
LIST_ENTRY InLoadOrderModuleList;
|
|
|
|
LIST_ENTRY InMemoryOrderModuleList;
|
|
|
|
LIST_ENTRY InInitializationOrderModuleList;
|
|
|
|
PVOID EntryInProgress;
|
2005-06-18 23:33:40 +00:00
|
|
|
} PEB_LDR_DATA, *PPEB_LDR_DATA;
|
|
|
|
|
2005-11-22 04:57:45 +00:00
|
|
|
//
|
|
|
|
// Loader Data Table Entry
|
|
|
|
//
|
2005-06-21 02:08:42 +00:00
|
|
|
typedef struct _LDR_DATA_TABLE_ENTRY
|
|
|
|
{
|
2006-05-10 17:47:44 +00:00
|
|
|
LIST_ENTRY InLoadOrderLinks;
|
2005-06-21 02:08:42 +00:00
|
|
|
LIST_ENTRY InMemoryOrderModuleList;
|
|
|
|
LIST_ENTRY InInitializationOrderModuleList;
|
|
|
|
PVOID DllBase;
|
|
|
|
PVOID EntryPoint;
|
|
|
|
ULONG SizeOfImage;
|
|
|
|
UNICODE_STRING FullDllName;
|
|
|
|
UNICODE_STRING BaseDllName;
|
|
|
|
ULONG Flags;
|
2005-06-26 16:06:32 +00:00
|
|
|
USHORT LoadCount;
|
|
|
|
USHORT TlsIndex;
|
2005-07-19 20:55:13 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
LIST_ENTRY HashLinks;
|
2009-11-08 01:13:49 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
PVOID SectionPointer;
|
|
|
|
ULONG CheckSum;
|
|
|
|
};
|
2005-07-19 20:55:13 +00:00
|
|
|
};
|
|
|
|
union
|
|
|
|
{
|
|
|
|
ULONG TimeDateStamp;
|
|
|
|
PVOID LoadedImports;
|
|
|
|
};
|
2005-06-21 02:08:42 +00:00
|
|
|
PVOID EntryPointActivationContext;
|
2005-06-21 04:52:46 +00:00
|
|
|
PVOID PatchInformation;
|
2005-06-21 02:08:42 +00:00
|
|
|
} LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;
|
2005-06-18 23:33:40 +00:00
|
|
|
|
2007-02-22 00:01:52 +00:00
|
|
|
//
|
|
|
|
// Loaded Imports Reference Counting in Kernel
|
|
|
|
//
|
|
|
|
typedef struct _LOAD_IMPORTS
|
|
|
|
{
|
|
|
|
SIZE_T Count;
|
|
|
|
PLDR_DATA_TABLE_ENTRY Entry[1];
|
|
|
|
} LOAD_IMPORTS, *PLOAD_IMPORTS;
|
|
|
|
|
2005-11-22 04:57:45 +00:00
|
|
|
//
|
|
|
|
// Loader Resource Information
|
|
|
|
//
|
2005-06-26 01:08:55 +00:00
|
|
|
typedef struct _LDR_RESOURCE_INFO
|
2005-06-18 23:33:40 +00:00
|
|
|
{
|
2008-08-25 14:51:22 +00:00
|
|
|
ULONG_PTR Type;
|
|
|
|
ULONG_PTR Name;
|
2005-06-18 23:33:40 +00:00
|
|
|
ULONG Language;
|
|
|
|
} LDR_RESOURCE_INFO, *PLDR_RESOURCE_INFO;
|
|
|
|
|
2006-01-12 04:31:37 +00:00
|
|
|
//
|
2006-05-10 17:47:44 +00:00
|
|
|
// DLL Notifications
|
2006-01-12 04:31:37 +00:00
|
|
|
//
|
2006-05-10 17:47:44 +00:00
|
|
|
typedef struct _LDR_DLL_LOADED_NOTIFICATION_DATA
|
|
|
|
{
|
|
|
|
ULONG Flags;
|
|
|
|
PUNICODE_STRING FullDllName;
|
|
|
|
PUNICODE_STRING BaseDllName;
|
|
|
|
PVOID DllBase;
|
|
|
|
ULONG SizeOfImage;
|
|
|
|
} LDR_DLL_LOADED_NOTIFICATION_DATA, *PLDR_DLL_LOADED_NOTIFICATION_DATA;
|
|
|
|
|
|
|
|
typedef VOID
|
2009-08-20 12:09:16 +00:00
|
|
|
(NTAPI *PLDR_DLL_LOADED_NOTIFICATION_CALLBACK)(
|
2006-05-10 17:47:44 +00:00
|
|
|
IN BOOLEAN Type,
|
|
|
|
IN struct _LDR_DLL_LOADED_NOTIFICATION_DATA *Data
|
|
|
|
);
|
|
|
|
|
|
|
|
typedef struct _LDR_DLL_LOADED_NOTIFICATION_ENTRY
|
|
|
|
{
|
|
|
|
LIST_ENTRY NotificationListEntry;
|
|
|
|
PLDR_DLL_LOADED_NOTIFICATION_CALLBACK Callback;
|
|
|
|
} LDR_DLL_LOADED_NOTIFICATION_ENTRY, *PLDR_DLL_LOADED_NOTIFICATION_ENTRY;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Alternate Resources Support
|
|
|
|
//
|
|
|
|
typedef struct _ALT_RESOURCE_MODULE
|
|
|
|
{
|
|
|
|
LANGID LangId;
|
|
|
|
PVOID ModuleBase;
|
|
|
|
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
|
|
|
|
PVOID ModuleManifest;
|
|
|
|
#endif
|
|
|
|
PVOID AlternateModule;
|
|
|
|
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
|
|
|
|
HANDLE AlternateFileHandle;
|
|
|
|
ULONG ModuleCheckSum;
|
|
|
|
ULONG ErrorCode;
|
|
|
|
#endif
|
|
|
|
} ALT_RESOURCE_MODULE, *PALT_RESOURCE_MODULE;
|
2006-01-12 04:31:37 +00:00
|
|
|
|
2011-03-30 21:33:57 +00:00
|
|
|
//
|
|
|
|
// Callback function for LdrEnumerateLoadedModules
|
|
|
|
//
|
2011-04-01 12:18:54 +00:00
|
|
|
typedef VOID (NTAPI LDR_ENUM_CALLBACK)(IN PLDR_DATA_TABLE_ENTRY ModuleInformation, IN PVOID Parameter, OUT BOOLEAN *Stop);
|
2011-03-30 21:33:57 +00:00
|
|
|
typedef LDR_ENUM_CALLBACK *PLDR_ENUM_CALLBACK;
|
|
|
|
|
2005-06-18 23:33:40 +00:00
|
|
|
#endif
|