#ifndef _NTLDR_H
#if (PHNT_MODE != PHNT_MODE_KERNEL)
// Flags for LdrFindResourceEx_U (LdrpSearchResourceSection_U) and (Win8+) LdrResFindResource/LdrResSearchResource
typedef enum _LDR_RESOURCE_QUERY_FLAGS
{
LDR_RES_SEARCH_PATH_ALT_TYPE = 0x00000001u, // Enables 4-key path mode (requires Count==4)
LDR_RES_SEARCH_PATH_ALLOW_SHORT = 0x00000002u, // Permit PathCount < 3 (else PathCount must be 3 or 4); the result is the IMAGE_RESOURCE_DIRECTORY reached by the path instead of a data entry (forced by LdrResFindResourceDirectory, rejected by LdrResFindResource)
LDR_RES_SEARCH_SKIP_MUI = 0x00000004u, // Skip language fallback chain (parent/thread/UI/system/ultimate languages); only match the exact requested language. LdrFindResourceEx_U fails with STATUS_RESOURCE_LANG_NOT_FOUND on miss
LDR_RES_SEARCH_SKIP_CONFIG = 0x00000008u, // Bypass the RT_VERSION/RT_MANIFEST/"MUI" neutral-language fast-path; always evaluate the MUI RC config via LdrResGetRCConfig. Win8+ rejects it together with LDR_RES_SEARCH_MUI_CONFIG_CHECKED (STATUS_INVALID_PARAMETER_4)
LDR_RES_SEARCH_MUI_CONFIG_CHECKED = 0x00000010u, // MUI configuration already resolved; skips LdrResGetRCConfig and the MUI alternate-module (.mui) search, so only the given module is searched (set internally by the fast-path and on .mun retry)
LDR_RES_SEARCH_MUI_RECURSIVE = 0x00000020u, // Internal; searching inside a MUI alternate module (or fallback list exhausted): accept the first language entry of the directory. With MUI_CONFIG_CHECKED, the fallback language list is not built
LDR_RES_SEARCH_MUI_STRINGS = 0x00000040u, // Enables 4-key path mode for MUI message strings; calls LdrpFindMessageInAlternateModule (requires Count==4)
LDR_RES_SEARCH_FORCE_MUI = 0x00000080u, // Reserved; forwarded by LdrpResSearchResourceMappedFile to LdrResFallbackLangList/LdrLoadAlternateResourceModuleEx but no consumer observed
LDR_RES_INTERNAL_ALT_RETRY = 0x01000000u, // Internal-only; set by loader on alternate resource retry after STATUS_RESOURCE_TYPE_NOT_FOUND (except RT_VERSION/RT_MANIFEST); switches from .mui to .mun extension (callers must not set)
LDR_RES_INTERNAL_NO_ALT_RETRY = 0x02000000u, // Internal-only; LdrpSearchResourceSection_U skips the .mun alternate-module retry (loader passes 0x02000030 for its own MUI/RC-config lookups). Rejected by LdrResSearchResource
// Group masks (base flags)
LDR_RES_SEARCH_PATH_MASK = (LDR_RES_SEARCH_PATH_ALT_TYPE | LDR_RES_SEARCH_PATH_ALLOW_SHORT | LDR_RES_SEARCH_MUI_STRINGS), // 0x00000043
LDR_RES_SEARCH_KEY4_MASK = (LDR_RES_SEARCH_PATH_ALT_TYPE | LDR_RES_SEARCH_MUI_STRINGS),
// Win8+ extended flags for LdrResFindResource, LdrpResGetResourceDirectory, LdrResSearchResource
// (LdrFindResourceEx_U uses LDR_RES_SEARCH_PATH_* and LDR_RES_SEARCH_MUI_* above; it infers load mode from DllHandle LDR_IS_* bits)
// Search load modes (mutually exclusive; Win8+ only)
LDR_RES_SEARCH_LOAD_IMAGE = 0x00000100u, // DllHandle is a normal loaded image or LDR_IS_IMAGEMAPPING (default; added automatically if no mode specified)
LDR_RES_SEARCH_LOAD_DATAFILE = 0x00000200u, // DllHandle is a memory-mapped datafile; bit 0 (LDR_IS_DATAFILE) is set on the address internally
LDR_RES_SEARCH_LOAD_MAPPED = 0x00000400u, // DllHandle is a DOS file path (PCWSTR) opened and mapped read-only as a datafile; validated via LdrpResValidateFilePath under STRICT. Rejected by LdrResFindResource/LdrResFindResourceDirectory
LDR_RES_SEARCH_LOAD_VIEW = 0x00000800u, // DllHandle is an NT file handle (HANDLE) mapped read-only by LdrpResMapFile (handle is not closed); with LDR_RES_SEARCH_MUI_DEPENDENCY the file is read via the handle without mapping. Rejected by LdrResFindResource/LdrResFindResourceDirectory
// Validation behavior flags (apply to all load modes; STRICT is implied unless LENIENT is set)
LDR_RES_SEARCH_STRICT = 0x00001000u, // Default (added unless LENIENT). Bounds-checked PE header/resource directory parsing, validates DllHandle, fails if the mapping size or fallback language list cannot be determined
LDR_RES_SEARCH_LENIENT = 0x00002000u, // Suppress automatic STRICT; continue if mapping size fails; LdrResGetRCConfig also skips MUI RC config structure validation. Mutually exclusive with STRICT
LDR_RES_SEARCH_ALT_FALLBACK = 0x00004000u, // Reserved; behavior not confirmed by code analysis (fallback is unconditional)
// Optimization/Dependency flags
LDR_RES_SEARCH_MUI_DEPENDENCY = 0x00008000u, // Read the resource directly from the file handle (LdrpResSearchResourceHandle) without mapping; requires LDR_RES_SEARCH_LOAD_VIEW and LDR_RES_SEARCH_MUI_CONFIG_CHECKED
// Size override flags
LDR_RES_SEARCH_USE_INPUT_SIZE_MAPPED = 0x00020000u, // *ResourceLength (in, non-zero) is the maximum allowed file size; fails with STATUS_INVALID_VIEW_SIZE if the file is larger. Requires LDR_RES_SEARCH_LOAD_MAPPED
LDR_RES_SEARCH_USE_INPUT_SIZE = 0x00080000u, // Trust *ResourceLength (in, non-zero) as the mapping size instead of querying it; requires IMAGE or DATAFILE mode
// Group masks (Win8+ extended flags)
LDR_RES_SEARCH_LOAD_MODE_MASK = (LDR_RES_SEARCH_LOAD_IMAGE | LDR_RES_SEARCH_LOAD_DATAFILE | LDR_RES_SEARCH_LOAD_MAPPED | LDR_RES_SEARCH_LOAD_VIEW), // 0x00000F00
LDR_RES_SEARCH_BEHAVIOR_MASK = (LDR_RES_SEARCH_STRICT | LDR_RES_SEARCH_LENIENT), // 0x00003000
LDR_RES_SEARCH_SIZE_OVERRIDE_MASK = (LDR_RES_SEARCH_USE_INPUT_SIZE_MAPPED | LDR_RES_SEARCH_USE_INPUT_SIZE), // 0x000A0000
LDR_RES_SEARCH_PUBLIC_MASK = 0x000FFFFFu // LdrResSearchResource rejects bits outside this mask (STATUS_INVALID_PARAMETER_4); LdrFindResourceEx_U does not
} LDR_RESOURCE_QUERY_FLAGS;
View code on GitHubNo description available.