ReactOS 0.4.16-dev-2104-gb84fa49
res.c File Reference
#include <rtl.h>
#include <debug.h>
Include dependency graph for res.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define NAME_FROM_RESOURCE_ENTRY(RootDirectory, Entry)    ((Entry)->NameIsString ? (ULONG_PTR)(RootDirectory) + (Entry)->NameOffset : (Entry)->Id)
 

Functions

NTSTATUS find_entry (PVOID BaseAddress, LDR_RESOURCE_INFO *info, ULONG level, void **ret, int want_dir)
 
int page_fault (ULONG ExceptionCode)
 
static int is_data_file_module (PVOID BaseAddress)
 
int push_language (USHORT *list, ULONG pos, WORD lang)
 
IMAGE_RESOURCE_DIRECTORYfind_first_entry (IMAGE_RESOURCE_DIRECTORY *dir, void *root, int want_dir)
 
IMAGE_RESOURCE_DIRECTORYfind_entry_by_id (IMAGE_RESOURCE_DIRECTORY *dir, WORD id, void *root, int want_dir)
 
static int CompareResourceString (const wchar_t *SearchString, const IMAGE_RESOURCE_DIR_STRING_U *ResourceString)
 
IMAGE_RESOURCE_DIRECTORYfind_entry_by_name (IMAGE_RESOURCE_DIRECTORY *dir, LPCWSTR name, void *root, int want_dir)
 
static NTSTATUS LdrpAccessResource (PVOID BaseAddress, IMAGE_RESOURCE_DATA_ENTRY *entry, void **ptr, ULONG *size)
 
NTSTATUS NTAPI LdrFindResource_U (PVOID BaseAddress, PLDR_RESOURCE_INFO ResourceInfo, ULONG Level, PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry)
 
NTSTATUS NTAPI LdrAccessResource (IN PVOID BaseAddress, IN PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry, OUT PVOID *Resource OPTIONAL, OUT PULONG Size OPTIONAL)
 
NTSTATUS NTAPI LdrFindResourceDirectory_U (IN PVOID BaseAddress, IN PLDR_RESOURCE_INFO info, IN ULONG level, OUT PIMAGE_RESOURCE_DIRECTORY *addr)
 
static LONG LdrpCompareResourceNames_U (_In_ PUCHAR ResourceData, _In_ PIMAGE_RESOURCE_DIRECTORY_ENTRY Entry, _In_ ULONG_PTR CompareName)
 
NTSTATUS NTAPI LdrEnumResources (_In_ PVOID ImageBase, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Inout_ ULONG *ResourceCount, _Out_writes_to_(*ResourceCount, *ResourceCount) LDR_ENUM_RESOURCE_INFO *Resources)
 

Macro Definition Documentation

◆ NAME_FROM_RESOURCE_ENTRY

#define NAME_FROM_RESOURCE_ENTRY (   RootDirectory,
  Entry 
)     ((Entry)->NameIsString ? (ULONG_PTR)(RootDirectory) + (Entry)->NameOffset : (Entry)->Id)

Definition at line 333 of file res.c.

◆ NDEBUG

#define NDEBUG

Definition at line 29 of file res.c.

Function Documentation

◆ CompareResourceString()

static int CompareResourceString ( const wchar_t SearchString,
const IMAGE_RESOURCE_DIR_STRING_U ResourceString 
)
static

Definition at line 133 of file res.c.

136{
137 wchar_t const* p1 = SearchString;
138 wchar_t const* p2 = ResourceString->NameString;
139 size_t remaining = ResourceString->Length;
140 wchar_t chr1, chr2;
141
142 while (remaining-- != 0)
143 {
144 chr1 = *p1++;
145 chr2 = *p2++;
146
147 /* Quick direct comparison first */
148 if (chr1 != chr2)
149 {
150 /* No direct match, upcase both characters */
151 if ((chr1 >= 'a') && (chr1 <= 'z'))
152 chr1 -= ('a' - 'A');
153 if ((chr2 >= 'a') && (chr2 <= 'z'))
154 chr2 -= ('a' - 'A');
155
156 /* Compare again, if they don't match, return the difference */
157 if (chr1 != chr2)
158 return chr1 - chr2;
159 }
160 }
161
162 /* All characters matched, check if the search string ends here */
163 if (*p1 != 0)
164 {
165 /* The search string is longer, return a positive result */
166 return 1;
167 }
168
169 return 0;
170}

Referenced by find_entry_by_name().

◆ find_entry()

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

Definition at line 569 of file libsupp.c.

571{
572 ULONG size;
573 void *root;
574 IMAGE_RESOURCE_DIRECTORY *resdirptr;
575 USHORT list[9]; /* list of languages to try */
576 int i, pos = 0;
578
581 if (size < sizeof(*resdirptr)) return STATUS_RESOURCE_DATA_NOT_FOUND;
582 resdirptr = root;
583
584 if (!level--) goto done;
585 if (!(*ret = find_entry_by_name( resdirptr, (LPCWSTR)info->Type, root, want_dir || level )))
587 if (!level--) return STATUS_SUCCESS;
588
589 resdirptr = *ret;
590 if (!(*ret = find_entry_by_name( resdirptr, (LPCWSTR)info->Name, root, want_dir || level )))
592 if (!level--) return STATUS_SUCCESS;
593 if (level) return STATUS_INVALID_PARAMETER; /* level > 3 */
594
595 /* 1. specified language */
596 pos = push_language( list, pos, info->Language );
597
598 /* 2. specified language with neutral sublanguage */
600
601 /* 3. neutral language with neutral sublanguage */
603
604 /* if no explicitly specified language, try some defaults */
605 if (PRIMARYLANGID(info->Language) == LANG_NEUTRAL)
606 {
607 /* user defaults, unless SYS_DEFAULT sublanguage specified */
608 if (SUBLANGID(info->Language) != SUBLANG_SYS_DEFAULT)
609 {
610 /* 4. current thread locale language */
611 pos = push_language( list, pos, LANGIDFROMLCID(NtCurrentTeb()->CurrentLocale) );
612
614 {
615 /* 5. user locale language */
617
618 /* 6. user locale language with neutral sublanguage */
620 }
621 }
622
623 /* now system defaults */
624
626 {
627 /* 7. system locale language */
629
630 /* 8. system locale language with neutral sublanguage */
632 }
633
634 /* 9. English */
636 }
637
638 resdirptr = *ret;
639 for (i = 0; i < pos; i++)
640 if ((*ret = find_entry_by_id( resdirptr, list[i], root, want_dir ))) return STATUS_SUCCESS;
641
642 /* if no explicitly specified language, return the first entry */
643 if (PRIMARYLANGID(info->Language) == LANG_NEUTRAL)
644 {
645 if ((*ret = find_first_entry( resdirptr, root, want_dir ))) return STATUS_SUCCESS;
646 }
648
649done:
650 *ret = resdirptr;
651 return STATUS_SUCCESS;
652}
struct _root root
Definition: list.h:37
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
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_entry_by_name(IMAGE_RESOURCE_DIRECTORY *dir, LPCWSTR name, void *root, int want_dir)
Definition: res.c:177
int push_language(USHORT *list, ULONG pos, WORD lang)
Definition: res.c:61
IMAGE_RESOURCE_DIRECTORY * find_first_entry(IMAGE_RESOURCE_DIRECTORY *dir, void *root, int want_dir)
Definition: res.c:75
#define RtlImageDirectoryEntryToData
Definition: compat.h:809
static LCID system_lcid
Definition: locale.c:306
static LCID user_lcid
Definition: locale.c:307
return ret
Definition: mutex.c:146
GLint level
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
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
#define NtCurrentTeb
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
NTSTATUS NTAPI NtQueryDefaultLocale(IN BOOLEAN UserProfile, OUT PLCID DefaultLocaleId)
Definition: locale.c:396
#define STATUS_RESOURCE_LANG_NOT_FOUND
Definition: ntstatus.h:770
#define STATUS_RESOURCE_NAME_NOT_FOUND
Definition: ntstatus.h:469
#define STATUS_RESOURCE_TYPE_NOT_FOUND
Definition: ntstatus.h:468
#define STATUS_RESOURCE_DATA_NOT_FOUND
Definition: ntstatus.h:467
unsigned short USHORT
Definition: pedump.c:61
#define IMAGE_DIRECTORY_ENTRY_RESOURCE
Definition: pedump.c:261
#define LANG_NEUTRAL
Definition: nls.h:22
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANGID(l)
Definition: nls.h:17
#define LANG_ENGLISH
Definition: nls.h:52
#define LANGIDFROMLCID(l)
Definition: nls.h:18
#define SUBLANG_NEUTRAL
Definition: nls.h:167
#define SUBLANG_DEFAULT
Definition: nls.h:168
DWORD LCID
Definition: nls.h:13
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define SUBLANG_SYS_DEFAULT
Definition: nls.h:169
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by LdrFindResource_U(), and LdrFindResourceDirectory_U().

◆ 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
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}
DWORD Id
unsigned int dir
Definition: maze.c:112
#define NULL
Definition: types.h:112
uint32_t entry
Definition: isohybrid.c:63
#define min(a, b)
Definition: monoChain.cc:55
#define DPRINT
Definition: sndvol32.h:73
Definition: pedump.c:414
#define max(a, b)
Definition: svc.c:63

Referenced by find_entry(), and find_entry_by_name().

◆ 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 177 of file res.c.

180{
183 int min, max, res, pos;
184
185 if (!((ULONG_PTR)name & 0xFFFF0000)) return find_entry_by_id( dir, (ULONG_PTR)name & 0xFFFF, root, want_dir );
187 min = 0;
188 max = dir->NumberOfNamedEntries - 1;
189 while (min <= max)
190 {
191 pos = (min + max) / 2;
192 str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const char *)root + entry[pos].NameOffset);
194 if (!res)
195 {
196 if (!entry[pos].DataIsDirectory == !want_dir)
197 {
198 DPRINT("root %p dir %p name %ws ret %p\n",
199 root, dir, name, (const char*)root + entry[pos].OffsetToDirectory);
200 return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].OffsetToDirectory);
201 }
202 break;
203 }
204 if (res < 0) max = pos - 1;
205 else min = pos + 1;
206 }
207 DPRINT("root %p dir %p name %ws not found\n", root, dir, name);
208 return NULL;
209}
GLuint res
Definition: glext.h:9613
const WCHAR * str
IMAGE_RESOURCE_DIRECTORY * find_entry_by_id(IMAGE_RESOURCE_DIRECTORY *dir, WORD id, void *root, int want_dir)
Definition: res.c:95
static int CompareResourceString(const wchar_t *SearchString, const IMAGE_RESOURCE_DIR_STRING_U *ResourceString)
Definition: res.c:133
Definition: name.c:39
uint32_t ULONG_PTR
Definition: typedefs.h:65

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}

Referenced by find_entry().

◆ is_data_file_module()

static int is_data_file_module ( PVOID  BaseAddress)
static

Definition at line 50 of file res.c.

51{
52 return (ULONG_PTR)BaseAddress & 1;
53}

Referenced by LdrpAccessResource().

◆ LdrAccessResource()

NTSTATUS NTAPI LdrAccessResource ( IN PVOID  BaseAddress,
IN PIMAGE_RESOURCE_DATA_ENTRY  ResourceDataEntry,
OUT PVOID *Resource  OPTIONAL,
OUT PULONG Size  OPTIONAL 
)

Definition at line 289 of file res.c.

293{
294 return LdrpAccessResource( BaseAddress, ResourceDataEntry, Resource, Size );
295}
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
static NTSTATUS LdrpAccessResource(PVOID BaseAddress, IMAGE_RESOURCE_DATA_ENTRY *entry, void **ptr, ULONG *size)
Definition: res.c:215
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539

◆ LdrEnumResources()

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

Definition at line 388 of file res.c.

394{
395 PUCHAR ResourceData;
397 ULONG i, j, k;
398 ULONG NumberOfTypeEntries, NumberOfNameEntries, NumberOfLangEntries;
399 ULONG Count, MaxResourceCount;
400 PIMAGE_RESOURCE_DIRECTORY TypeDirectory, NameDirectory, LangDirectory;
401 PIMAGE_RESOURCE_DIRECTORY_ENTRY TypeEntry, NameEntry, LangEntry;
403 ULONG Size;
404 LONG Result;
405
406 /* If the caller wants data, get the maximum count of entries */
407 MaxResourceCount = (Resources != NULL) ? *ResourceCount : 0;
408
409 /* Default to 0 */
410 *ResourceCount = 0;
411
412 /* Locate the resource directory */
413 ResourceData = RtlImageDirectoryEntryToData(ImageBase,
414 TRUE,
416 &Size);
417 if (ResourceData == NULL)
419
420 /* The type directory is at the root, followed by the entries */
421 TypeDirectory = (PIMAGE_RESOURCE_DIRECTORY)ResourceData;
422 TypeEntry = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(TypeDirectory + 1);
423
424 /* Get the number of entries in the type directory */
425 NumberOfTypeEntries = TypeDirectory->NumberOfNamedEntries +
426 TypeDirectory->NumberOfIdEntries;
427
428 /* Start with 0 resources and status success */
430 Count = 0;
431
432 /* Loop all entries in the type directory */
433 for (i = 0; i < NumberOfTypeEntries; ++i, ++TypeEntry)
434 {
435 /* Check if comparison of types is requested */
437 {
438 /* Compare the type with the requested Type */
439 Result = LdrpCompareResourceNames_U(ResourceData,
440 TypeEntry,
441 ResourceInfo->Type);
442
443 /* Not equal, continue with next entry */
444 if (Result != 0) continue;
445 }
446
447 /* The entry must point to the name directory */
448 if (!TypeEntry->DataIsDirectory)
449 {
451 }
452
453 /* Get a pointer to the name subdirectory and it's first entry */
454 NameDirectory = (PIMAGE_RESOURCE_DIRECTORY)(ResourceData +
455 TypeEntry->OffsetToDirectory);
456 NameEntry = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(NameDirectory + 1);
457
458 /* Get the number of entries in the name directory */
459 NumberOfNameEntries = NameDirectory->NumberOfNamedEntries +
460 NameDirectory->NumberOfIdEntries;
461
462 /* Loop all entries in the name directory */
463 for (j = 0; j < NumberOfNameEntries; ++j, ++NameEntry)
464 {
465 /* Check if comparison of names is requested */
467 {
468 /* Compare the name with the requested name */
469 Result = LdrpCompareResourceNames_U(ResourceData,
470 NameEntry,
471 ResourceInfo->Name);
472
473 /* Not equal, continue with next entry */
474 if (Result != 0) continue;
475 }
476
477 /* The entry must point to the language directory */
478 if (!NameEntry->DataIsDirectory)
479 {
481 }
482
483 /* Get a pointer to the language subdirectory and it's first entry */
484 LangDirectory = (PIMAGE_RESOURCE_DIRECTORY)(ResourceData +
485 NameEntry->OffsetToDirectory);
486 LangEntry = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(LangDirectory + 1);
487
488 /* Get the number of entries in the language directory */
489 NumberOfLangEntries = LangDirectory->NumberOfNamedEntries +
490 LangDirectory->NumberOfIdEntries;
491
492 /* Loop all entries in the language directory */
493 for (k = 0; k < NumberOfLangEntries; ++k, ++LangEntry)
494 {
495 /* Check if comparison of languages is requested */
497 {
498 /* Compare the language with the requested language */
499 Result = LdrpCompareResourceNames_U(ResourceData,
500 LangEntry,
501 ResourceInfo->Language);
502
503 /* Not equal, continue with next entry */
504 if (Result != 0) continue;
505 }
506
507 /* This entry must point to data */
508 if (LangEntry->DataIsDirectory)
509 {
511 }
512
513 /* Get a pointer to the data entry */
514 DataEntry = (PIMAGE_RESOURCE_DATA_ENTRY)(ResourceData +
515 LangEntry->OffsetToData);
516
517 /* Check if there is still space to store the data */
518 if (Count < MaxResourceCount)
519 {
520 /* There is, fill the entry */
521 Resources[Count].Type =
522 NAME_FROM_RESOURCE_ENTRY(ResourceData, TypeEntry);
523 Resources[Count].Name =
524 NAME_FROM_RESOURCE_ENTRY(ResourceData, NameEntry);
525 Resources[Count].Language =
526 NAME_FROM_RESOURCE_ENTRY(ResourceData, LangEntry);
527 Resources[Count].Data = (PUCHAR)ImageBase + DataEntry->OffsetToData;
528 Resources[Count].Reserved = 0;
529 Resources[Count].Size = DataEntry->Size;
530 }
531 else
532 {
533 /* There is not enough space, save error status */
535 }
536
537 /* Count this resource */
538 ++Count;
539 }
540 }
541 }
542
543 /* Return the number of matching resources */
545 return Status;
546}
LONG NTSTATUS
Definition: precomp.h:26
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 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:453
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 NAME_FROM_RESOURCE_ENTRY(RootDirectory, Entry)
Definition: res.c:333
static LONG LdrpCompareResourceNames_U(_In_ PUCHAR ResourceData, _In_ PIMAGE_RESOURCE_DIRECTORY_ENTRY Entry, _In_ ULONG_PTR CompareName)
Definition: res.c:338
Definition: pedump.c:458
DWORD OffsetToData
Definition: pedump.c:459
DWORD Size
Definition: pedump.c:460
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
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_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()

NTSTATUS NTAPI LdrFindResource_U ( PVOID  BaseAddress,
PLDR_RESOURCE_INFO  ResourceInfo,
ULONG  Level,
PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry 
)

Definition at line 254 of file res.c.

258{
259 void *res;
261
263 {
264 if (ResourceInfo)
265 {
266 DPRINT( "module %p type %lx name %lx lang %04lx level %lu\n",
267 BaseAddress, ResourceInfo->Type,
268 Level > 1 ? ResourceInfo->Name : 0,
269 Level > 2 ? ResourceInfo->Language : 0, Level );
270 }
271
272 status = find_entry( BaseAddress, ResourceInfo, Level, &res, FALSE );
273 if (NT_SUCCESS(status))
274 *ResourceDataEntry = res;
275 }
277 {
279 }
280 _SEH2_END;
281 return status;
282}
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
int page_fault(ULONG ExceptionCode)
Definition: res.c:37
NTSTATUS find_entry(PVOID BaseAddress, LDR_RESOURCE_INFO *info, ULONG level, void **ret, int want_dir)
Definition: libsupp.c:569
ULONG_PTR Language
Definition: ldrtypes.h:187
ULONG_PTR Name
Definition: ldrtypes.h:186
ULONG_PTR Type
Definition: ldrtypes.h:185
Definition: ps.c:97

◆ LdrFindResourceDirectory_U()

NTSTATUS NTAPI LdrFindResourceDirectory_U ( IN PVOID  BaseAddress,
IN PLDR_RESOURCE_INFO  info,
IN ULONG  level,
OUT PIMAGE_RESOURCE_DIRECTORY addr 
)

Definition at line 302 of file res.c.

306{
307 void *res;
309
311 {
312 if (info)
313 {
314 DPRINT( "module %p type %ws name %ws lang %04lx level %lu\n",
315 BaseAddress, (LPCWSTR)info->Type,
316 level > 1 ? (LPCWSTR)info->Name : L"",
317 level > 2 ? info->Language : 0, level );
318 }
319
321 if (NT_SUCCESS(status))
322 *addr = res;
323 }
325 {
327 }
328 _SEH2_END;
329 return status;
330}
#define L(x)
Definition: resources.c:13
GLenum const GLvoid * addr
Definition: glext.h:9621

◆ LdrpAccessResource()

static NTSTATUS LdrpAccessResource ( PVOID  BaseAddress,
IMAGE_RESOURCE_DATA_ENTRY entry,
void **  ptr,
ULONG size 
)
static

Definition at line 215 of file res.c.

218{
220
222 {
223 ULONG dirsize;
224
227 else
228 {
229 if (ptr)
230 {
232 {
234 *ptr = RtlImageRvaToVa( RtlImageNtHeader(mod), mod, entry->OffsetToData, NULL );
235 }
236 else *ptr = (char *)BaseAddress + entry->OffsetToData;
237 }
238 if (size) *size = entry->Size;
239 }
240 }
242 {
244 }
245 _SEH2_END;
246 return status;
247}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:66
#define RtlImageRvaToVa
Definition: compat.h:807
#define RtlImageNtHeader
Definition: compat.h:806
static PVOID ptr
Definition: dispmode.c:27
static int is_data_file_module(PVOID BaseAddress)
Definition: res.c:50
void * PVOID
Definition: typedefs.h:50

Referenced by LdrAccessResource().

◆ LdrpCompareResourceNames_U()

static LONG LdrpCompareResourceNames_U ( _In_ PUCHAR  ResourceData,
_In_ PIMAGE_RESOURCE_DIRECTORY_ENTRY  Entry,
_In_ ULONG_PTR  CompareName 
)
static

Definition at line 338 of file res.c.

342{
343 PIMAGE_RESOURCE_DIR_STRING_U ResourceString;
344 PWSTR String1, String2;
345 USHORT ResourceStringLength;
346 WCHAR Char1, Char2;
347
348 /* Check if the resource name is an ID */
349 if (CompareName <= USHRT_MAX)
350 {
351 /* Just compare the 2 IDs */
352 return (CompareName - Entry->Id);
353 }
354 else
355 {
356 /* Get the resource string */
357 ResourceString = (PIMAGE_RESOURCE_DIR_STRING_U)(ResourceData +
358 Entry->NameOffset);
359
360 /* Get the string length */
361 ResourceStringLength = ResourceString->Length;
362
363 String1 = ResourceString->NameString;
365
366 /* Loop all characters of the resource string */
367 while (ResourceStringLength--)
368 {
369 /* Get the next characters */
370 Char1 = *String1++;
371 Char2 = *String2++;
372
373 /* Check if they don't match, or if the compare string ends */
374 if ((Char1 != Char2) || (Char2 == 0))
375 {
376 /* They don't match, fail */
377 return Char2 - Char1;
378 }
379 }
380
381 /* All characters match, check if the compare string ends here */
382 return (*String2 == 0) ? 0 : 1;
383 }
384}
static BOOL CompareName(LPCWSTR pszName1, LPCWSTR pszName2)
Definition: find.c:60
#define USHRT_MAX
Definition: limits.h:23
_In_ const STRING * String2
Definition: rtlfuncs.h:2404
struct _IMAGE_RESOURCE_DIR_STRING_U * PIMAGE_RESOURCE_DIR_STRING_U
base of all file and directory entries
Definition: entries.h:83
uint16_t * PWSTR
Definition: typedefs.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by LdrEnumResources().

◆ page_fault()

int page_fault ( ULONG  ExceptionCode)

Definition at line 37 of file res.c.

38{
43}
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1774
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:91
#define EXCEPTION_ACCESS_VIOLATION
Definition: minwinbase.h:44
#define EXCEPTION_PRIV_INSTRUCTION
Definition: minwinbase.h:58

Referenced by LdrFindResource_U(), LdrFindResourceDirectory_U(), and LdrpAccessResource().

◆ 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}
static const WCHAR lang[]
Definition: wbemdisp.c:287

Referenced by find_entry().