ReactOS 0.4.16-dev-197-g92996da
resource.c File Reference
#include "bl.h"
Include dependency graph for resource.c:

Go to the source code of this file.

Functions

NTSTATUS ResSelectLocale (_In_ BOOLEAN Primary)
 
PIMAGE_RESOURCE_DIRECTORY_ENTRY ResFindDirectoryEntry (_In_ PIMAGE_RESOURCE_DIRECTORY Directory, _In_opt_ PUSHORT Id, _In_opt_ PWCHAR Name, _In_ ULONG_PTR SectionStart)
 
NTSTATUS ResFindDataEntryFromImage (_In_opt_ PVOID ImageBase, _In_opt_ ULONG ImageSize, _In_ USHORT DirectoryId, _In_ PUSHORT EntryId, _In_ PWCHAR Name, _Out_ PIMAGE_RESOURCE_DATA_ENTRY *DataEntryOut, _Out_ PVOID *ResourceOut)
 
PWCHAR BlResourceFindHtml (VOID)
 
PWCHAR BlResourceFindMessage (_In_ ULONG MsgId)
 
NTSTATUS BlpResourceInitialize (VOID)
 

Variables

PVOID ResPeImageBase
 
PVOID ResPeImageEnd
 
PVOID ResRootDirectory
 
PVOID ResPeImageBasePrimary
 
PVOID ResPeImageEndPrimary
 
PVOID ResRootDirectoryPrimary
 
ULONG_PTR ResRootDirectoryPrimaryOffset
 
ULONG_PTR ResRootDirectoryOffset
 
ULONG_PTR ResRootDirectoryFallbackOffset
 
PVOID ResPeImageBaseFallback
 
PVOID ResPeImageEndFallback
 
PVOID ResRootDirectoryFallback
 
BOOLEAN ResLoadedFontFiles
 
PVOID ResMuiImageBase
 
ULONG_PTR ResMuiImageSize
 
PWCHAR ResLocale
 

Function Documentation

◆ BlpResourceInitialize()

NTSTATUS BlpResourceInitialize ( VOID  )

Definition at line 478 of file resource.c.

481{
483 PIMAGE_SECTION_HEADER ResourceSection;
484 PVOID ImageBase;
485 ULONG ImageSize, VRes, HRes;
486 BOOLEAN UsePrimary;
487
488 /* Default to using fallback */
489 UsePrimary = FALSE;
490
491 /* Initialize all globals */
492 ResMuiImageBase = 0;
493 ResMuiImageSize = 0;
504 ResPeImageBase = 0;
505 ResPeImageEnd = 0;
507
508 /* Check if we had allocated a locale already */
509 if (ResLocale)
510 {
511 /* Free it and reset */
513 ResLocale = 0;
514 }
515
516 /* Get our base address and size*/
517 Status = BlGetApplicationBaseAndSize(&ImageBase, &ImageSize);
518 if (!NT_SUCCESS(Status))
519 {
520 return Status;
521 }
522
523 /* Find our resource section */
524 ResourceSection = BlImgFindSection(ImageBase, ImageSize);
525 if (ResourceSection)
526 {
527 /* The resource section will be our fallback. Save down its details */
529 ResPeImageBaseFallback = ImageBase;
530 ResPeImageEndFallback = (PVOID)((ULONG_PTR)ImageBase + ImageSize);
533 }
534
535 /* Get the current screen resolution and check if we're in graphics mode */
536 Status = BlDisplayGetScreenResolution(&HRes, &VRes);
537 if ((NT_SUCCESS(Status)) && ((HRes != 640) || (VRes != 200)))
538 {
539 /* We are... we should load MUI data */
540 Status = STATUS_NOT_IMPLEMENTED;//ResInitializeMuiResources();
541 if (NT_SUCCESS(Status))
542 {
543 /* And not rely on the fallback */
544 UsePrimary = TRUE;
545 }
546 }
547
548 /* Load the locale resources */
549 return ResSelectLocale(UsePrimary);
550}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS BlDisplayGetScreenResolution(_Out_ PULONG HRes, _Out_ PULONG Vres)
Definition: display.c:680
PIMAGE_SECTION_HEADER BlImgFindSection(_In_ PVOID ImageBase, _In_ ULONG ImageSize)
Definition: image.c:611
NTSTATUS BlGetApplicationBaseAndSize(_Out_ PVOID *ImageBase, _Out_ PULONG ImageSize)
Definition: bootlib.c:424
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
ULONG_PTR ResRootDirectoryFallbackOffset
Definition: resource.c:24
PVOID ResPeImageBase
Definition: resource.c:15
PWCHAR ResLocale
Definition: resource.c:33
ULONG_PTR ResRootDirectoryOffset
Definition: resource.c:23
PVOID ResMuiImageBase
Definition: resource.c:30
NTSTATUS ResSelectLocale(_In_ BOOLEAN Primary)
Definition: resource.c:38
PVOID ResRootDirectoryFallback
Definition: resource.c:27
ULONG_PTR ResRootDirectoryPrimaryOffset
Definition: resource.c:22
PVOID ResPeImageEndFallback
Definition: resource.c:26
PVOID ResRootDirectory
Definition: resource.c:17
BOOLEAN ResLoadedFontFiles
Definition: resource.c:29
PVOID ResPeImageEnd
Definition: resource.c:16
PVOID ResPeImageBasePrimary
Definition: resource.c:19
PVOID ResPeImageBaseFallback
Definition: resource.c:25
ULONG_PTR ResMuiImageSize
Definition: resource.c:31
PVOID ResRootDirectoryPrimary
Definition: resource.c:21
PVOID ResPeImageEndPrimary
Definition: resource.c:20
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
struct _IMAGE_RESOURCE_DIRECTORY * PIMAGE_RESOURCE_DIRECTORY
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59

Referenced by BlInitializeLibrary(), and InitializeLibrary().

◆ BlResourceFindHtml()

PWCHAR BlResourceFindHtml ( VOID  )

Definition at line 305 of file resource.c.

308{
310 PIMAGE_RESOURCE_DATA_ENTRY HtmlDataEntry;
311 PWCHAR Stylesheet;
312
313 /* Assume failure */
314 Stylesheet = NULL;
315
316 /* Look for an RT_HTML resource called BOOTMGR.XSL */
318 0,
319 23,
320 NULL,
321 L"BOOTMGR.XSL",
322 &HtmlDataEntry,
323 (PVOID*)&Stylesheet);
324 if (!NT_SUCCESS(Status))
325 {
326 return Stylesheet;
327 }
328
329 /* Check for Unicode BOM */
330 if (*Stylesheet == 0xFEFF)
331 {
332 /* Overwrite it, and NULL-terminate */
333 RtlMoveMemory(Stylesheet,
334 Stylesheet + 1,
335 HtmlDataEntry->Size - sizeof(WCHAR));
336 Stylesheet[(HtmlDataEntry->Size / sizeof(WCHAR)) - 1] = UNICODE_NULL;
337 }
338 else if (Stylesheet[(HtmlDataEntry->Size / sizeof(WCHAR)) - 1] != UNICODE_NULL)
339 {
340 /* If it's not NULL-terminated, fail */
341 Stylesheet = NULL;
342 }
343
344 /* Return it back */
345 return Stylesheet;
346}
NTSTATUS ResFindDataEntryFromImage(_In_opt_ PVOID ImageBase, _In_opt_ ULONG ImageSize, _In_ USHORT DirectoryId, _In_ PUSHORT EntryId, _In_ PWCHAR Name, _Out_ PIMAGE_RESOURCE_DATA_ENTRY *DataEntryOut, _Out_ PVOID *ResourceOut)
Definition: resource.c:154
#define NULL
Definition: types.h:112
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
Definition: pedump.c:458
DWORD Size
Definition: pedump.c:460
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
uint16_t * PWCHAR
Definition: typedefs.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by BmMain().

◆ BlResourceFindMessage()

PWCHAR BlResourceFindMessage ( _In_ ULONG  MsgId)

Definition at line 349 of file resource.c.

352{
354 PIMAGE_RESOURCE_DIRECTORY ResourceDir;
358 ULONG i, j;
359 USHORT Id;
360 PVOID MsgEnd;
362
363 /* Bail out if there's no resource directory */
364 Message = NULL;
365 if (!ResRootDirectory)
366 {
367 return Message;
368 }
369
370 /* Check if we've loaded fonts already */
372 {
373 /* Nope, load them now */
375 if (!NT_SUCCESS(Status))
376 {
377 /* We failed to load fonts, fallback to fallback locale */
379 if (NT_SUCCESS(Status))
380 {
381 /* Try fonts now */
383 if (!NT_SUCCESS(Status))
384 {
385 /* Still didn't work -- fallback to text mode */
386 EfiPrintf(L"Font loading failed, falling back to text mode\r\n");
388 if (!NT_SUCCESS(Status))
389 {
390 /* That didn't work either. F*ck it. */
391 return Message;
392 }
393 }
394 }
395 }
396
397 /* Now we have a resource directory, and fonts are loaded */
400 }
401
402 /* Go look for RT_MESSAGETABLE */
403 Id = 11;
405 &Id,
406 NULL,
408 if (!ResourceDir)
409 {
410 return Message;
411 }
412
413 /* Go look for the first directory in the table */
414 Id = 1;
415 ResourceDir = (PIMAGE_RESOURCE_DIRECTORY)ResFindDirectoryEntry(ResourceDir,
416 &Id,
417 NULL,
419 if (!ResourceDir)
420 {
421 return Message;
422 }
423
424 /* Go look for any language entry in the table */
425 Id = -1;
426 DataEntry = (PIMAGE_RESOURCE_DATA_ENTRY)ResFindDirectoryEntry(ResourceDir,
427 &Id,
428 NULL,
430 if (!DataEntry)
431 {
432 return Message;
433 }
434
435 /* Get the message data*/
437 DataEntry->OffsetToData -
439
440 /* Loop through the message blocks */
441 for (j = 0; j < MsgData->NumberOfBlocks; j++)
442 {
443 /* Check if the ID is within this range */
444 if ((MsgId >= MsgData->Blocks[j].LowId) &&
445 (MsgId <= MsgData->Blocks[j].HighId))
446 {
447 /* Get the first entry */
448 MsgEntry = (PMESSAGE_RESOURCE_ENTRY)((ULONG_PTR)MsgData +
449 MsgData->Blocks[j].OffsetToEntries);
450
451 /* Loop till we find the right one */
452 for (i = MsgId - MsgData->Blocks[j].LowId; i; --i)
453 {
454 MsgEntry = (PMESSAGE_RESOURCE_ENTRY)((ULONG_PTR)MsgEntry +
455 MsgEntry->Length);
456 }
457
458 /* Find where this message ends */
459 MsgEnd = (PVOID)((ULONG_PTR)MsgEntry + MsgEntry->Length);
460
461 /* Now make sure that the message is within bounds */
462 if ((MsgEnd >= (PVOID)MsgEntry) &&
463 ((PVOID)MsgEntry >= ResPeImageBase) &&
464 (MsgEnd <= ResPeImageEnd))
465 {
466 /* If so, read the text associated with it */
467 Message = (PWCHAR)MsgEntry->Text;
468 break;
469 }
470 }
471 }
472
473 /* Return the text, if one was found */
474 return Message;
475}
DWORD Id
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
NTSTATUS BfLoadDeferredFontFiles(VOID)
Definition: font.c:99
NTSTATUS BlDisplaySetScreenResolution(VOID)
Definition: display.c:646
PIMAGE_RESOURCE_DIRECTORY_ENTRY ResFindDirectoryEntry(_In_ PIMAGE_RESOURCE_DIRECTORY Directory, _In_opt_ PUSHORT Id, _In_opt_ PWCHAR Name, _In_ ULONG_PTR SectionStart)
Definition: resource.c:81
static const WCHAR Message[]
Definition: register.c:74
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
struct _MESSAGE_RESOURCE_DATA * PMESSAGE_RESOURCE_DATA
struct _MESSAGE_RESOURCE_ENTRY * PMESSAGE_RESOURCE_ENTRY
struct _IMAGE_RESOURCE_DATA_ENTRY * PIMAGE_RESOURCE_DATA_ENTRY
unsigned short USHORT
Definition: pedump.c:61
DWORD OffsetToData
Definition: pedump.c:459
MESSAGE_RESOURCE_BLOCK Blocks[ANYSIZE_ARRAY]
Definition: rtltypes.h:1912
Definition: rtltypes.h:1896
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1899
USHORT Length
Definition: rtltypes.h:1897
#define NT_ASSERT
Definition: rtlfuncs.h:3324

Referenced by BmpErrorLog().

◆ ResFindDataEntryFromImage()

NTSTATUS ResFindDataEntryFromImage ( _In_opt_ PVOID  ImageBase,
_In_opt_ ULONG  ImageSize,
_In_ USHORT  DirectoryId,
_In_ PUSHORT  EntryId,
_In_ PWCHAR  Name,
_Out_ PIMAGE_RESOURCE_DATA_ENTRY DataEntryOut,
_Out_ PVOID ResourceOut 
)

Definition at line 154 of file resource.c.

163{
165 PIMAGE_SECTION_HEADER ResourceSection;
166 PIMAGE_RESOURCE_DIRECTORY ResourceDir, RootDir;
169 PVOID Data, DataEnd, ImageEnd;
170 BOOLEAN UseFallbackDirectory;
171
172 /* Assume nothing found */
173 UseFallbackDirectory = TRUE;
175
176 /* Are we looking at a particular image? */
177 if (ImageBase)
178 {
179 /* Then make sure we know its size */
180 if (!ImageSize)
181 {
182 return Status;
183 }
184
185 /* Find the resource section for it */
186 ResourceSection = BlImgFindSection(ImageBase, ImageSize);
187 if (!ResourceSection)
188 {
190 }
191
192 /* Remember how big the image is, and find the resource directory */
193 ImageEnd = (PVOID)((ULONG_PTR)ImageBase + ImageSize);
194 RootDir = (PIMAGE_RESOURCE_DIRECTORY)((ULONG_PTR)ImageBase +
195 ResourceSection->VirtualAddress);
196 if ((PVOID)RootDir < ImageBase)
197 {
198 /* It's out of bounds, so bail out */
200 }
201
202 /* We have a valid directory, don't use fallback for now */
203 UseFallbackDirectory = FALSE;
204 }
205 else
206 {
207 /* We are using the current library settings instead */
208 ImageBase = ResPeImageBase;
209 RootDir = ResRootDirectory;
210 ImageEnd = ResPeImageEnd;
211 }
212
213 /* If we don't have a resource directory, there's nothing to find */
214 if (!RootDir)
215 {
216 return Status;
217 }
218
219 /* Try two loops, once for primary, once for fallback */
220 while (1)
221 {
222 /* Find the directory first */
224 &DirectoryId,
225 NULL,
226 (ULONG_PTR)RootDir);
227 if (ResourceDir)
228 {
229 break;
230 }
231
232 /* We didn't find it -- is it time to use the fallback? */
233 if (UseFallbackDirectory)
234 {
235 /* Were were not using the fallback already? */
236 if (RootDir != ResRootDirectoryFallback)
237 {
238 /* Then attempt with the fallback instead*/
239 RootDir = ResRootDirectoryFallback;
240 ImageBase = ResPeImageBaseFallback;
241 ImageEnd = ResPeImageEndFallback;
242
243 /* Making sure we have one... */
244 if (RootDir)
245 {
246 continue;
247 }
248 }
249 }
250
251 /* Otherwise, return failure here */
252 return Status;
253 }
254
255 /* Now that we are in the right directory, lookup the resource */
256 ResourceDir = (PIMAGE_RESOURCE_DIRECTORY)ResFindDirectoryEntry(ResourceDir,
257 EntryId,
258 Name,
259 (ULONG_PTR)RootDir);
260 if (!ResourceDir)
261 {
262 return Status;
263 }
264
265 /* The entry is right after */
266 DirEntry = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(ResourceDir + 1);
267 if ((PVOID)DirEntry < (PVOID)ResourceDir)
268 {
270 }
271
272 /* Get the data entry for it */
273 DataEntry = (PIMAGE_RESOURCE_DATA_ENTRY)((ULONG_PTR)RootDir +
274 DirEntry->OffsetToData);
275
276 /* Check if the data entry is out of bounds */
277 if (((PVOID)DataEntry < ImageBase) || ((PVOID)DataEntry > ImageEnd))
278 {
280 }
281
282 /* Finally read the data offset */
283 Data = (PVOID)((ULONG_PTR)ImageBase + DataEntry->OffsetToData);
284
285 /* Check if the data is out of bounds */
286 if (((PVOID)Data < ImageBase) || ((PVOID)Data > ImageEnd))
287 {
289 }
290
291 /* Make sure the data end isn't out of bounds either */
292 DataEnd = (PVOID)((ULONG_PTR)Data + DataEntry->Size);
293 if (((PVOID)DataEnd < ImageBase) || ((PVOID)DataEnd > ImageEnd))
294 {
296 }
297
298 /* We finally made it. Return the entry and the raw data */
299 *DataEntryOut = DataEntry;
300 *ResourceOut = Data;
301 return STATUS_SUCCESS;
302}
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:359
struct _IMAGE_RESOURCE_DIRECTORY_ENTRY * PIMAGE_RESOURCE_DIRECTORY_ENTRY
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_NOT_FOUND
Definition: shellext.h:72
Definition: pedump.c:414
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by BlResourceFindHtml().

◆ ResFindDirectoryEntry()

PIMAGE_RESOURCE_DIRECTORY_ENTRY ResFindDirectoryEntry ( _In_ PIMAGE_RESOURCE_DIRECTORY  Directory,
_In_opt_ PUSHORT  Id,
_In_opt_ PWCHAR  Name,
_In_ ULONG_PTR  SectionStart 
)

Definition at line 81 of file resource.c.

87{
88 PIMAGE_RESOURCE_DIRECTORY_ENTRY EntryTable, IdEntryTable;
89 ULONG i;
90 SIZE_T NameLength;
92
93 /* Are we looking by ID or name? */
94 if (Id)
95 {
96 /* By ID, so were we passed a name? */
97 if (Name)
98 {
99 /* That doesn't make sense */
100 return NULL;
101 }
102 }
103 else if (!Name)
104 {
105 /* By name, but we weren't given one. Also bad. */
106 return NULL;
107 }
108
109 /* Get the table of names */
110 EntryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(Directory + 1);
111
112 /* Check if we are doing ID lookup instead */
113 if (Id)
114 {
115 /* The IDs come after the names */
116 IdEntryTable = &EntryTable[Directory->NumberOfNamedEntries];
117
118 /* Parse them */
119 for (i = 0; i < Directory->NumberOfIdEntries; i++)
120 {
121 /* Check if the ID matches, or if the wildcard is being used*/
122 if ((IdEntryTable[i].Id == *Id) || (*Id == 0xFFFF))
123 {
124 /* Return a pointer to the data */
125 return (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(SectionStart + IdEntryTable[i].OffsetToDirectory);
126 }
127 }
128
129 /* ID was not found */
130 return NULL;
131 }
132
133 /* Searching by name, so parse them */
134 for (i = 0; i < Directory->NumberOfNamedEntries; i++)
135 {
136 /* Get the name itself and count its length */
137 NameString = (PIMAGE_RESOURCE_DIRECTORY_STRING)(SectionStart + EntryTable[i].NameOffset);
138 NameLength = wcslen(Name);
139
140 /* If the length matches, compare the bytes */
141 if ((NameLength == NameString->Length) &&
142 (RtlCompareMemory(NameString->NameString, Name, NameLength) == NameLength))
143 {
144 /* They both match, so this is our entry. Return it */
145 return (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(SectionStart + EntryTable[i].OffsetToDirectory);
146 }
147 }
148
149 /* Name was not found */
150 return NULL;
151}
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
struct _IMAGE_RESOURCE_DIRECTORY_STRING * PIMAGE_RESOURCE_DIRECTORY_STRING
base for all directory entries
Definition: entries.h:138
ULONG OffsetToDirectory
Definition: ntimage.h:194
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by BlResourceFindMessage(), and ResFindDataEntryFromImage().

◆ ResSelectLocale()

NTSTATUS ResSelectLocale ( _In_ BOOLEAN  Primary)

Definition at line 38 of file resource.c.

41{
43
44 /* Check if we're using the primary (MUI) or fallback resources */
45 if (Primary)
46 {
47 /* Use the primary ones */
52
53 /* Register the locale with the display */
55 }
56
57 /* Check if that failed, or if we're using fallback */
58 if (!(Primary) || !(NT_SUCCESS(Status)))
59 {
60 /* Set the fallback pointers */
65
66 /* Register the fallback (America baby!) locale */
68 if (!NT_SUCCESS(Status))
69 {
70 /* Fallback to text mode (yes, this is the API...) */
72 }
73 }
74
75 /* No fonts loaded -- return failure code */
77 return Status;
78}
NTSTATUS BlpDisplayRegisterLocale(_In_ PWCHAR Locale)
Definition: display.c:177

Referenced by BlpResourceInitialize(), and BlResourceFindMessage().

Variable Documentation

◆ ResLoadedFontFiles

BOOLEAN ResLoadedFontFiles

Definition at line 29 of file resource.c.

Referenced by BlpResourceInitialize(), BlResourceFindMessage(), and ResSelectLocale().

◆ ResLocale

PWCHAR ResLocale

Definition at line 33 of file resource.c.

Referenced by BlpResourceInitialize(), and ResSelectLocale().

◆ ResMuiImageBase

PVOID ResMuiImageBase

Definition at line 30 of file resource.c.

Referenced by BlpResourceInitialize().

◆ ResMuiImageSize

ULONG_PTR ResMuiImageSize

Definition at line 31 of file resource.c.

Referenced by BlpResourceInitialize().

◆ ResPeImageBase

PVOID ResPeImageBase

◆ ResPeImageBaseFallback

PVOID ResPeImageBaseFallback

Definition at line 25 of file resource.c.

Referenced by BlpResourceInitialize(), ResFindDataEntryFromImage(), and ResSelectLocale().

◆ ResPeImageBasePrimary

PVOID ResPeImageBasePrimary

Definition at line 19 of file resource.c.

Referenced by BlpResourceInitialize(), and ResSelectLocale().

◆ ResPeImageEnd

PVOID ResPeImageEnd

◆ ResPeImageEndFallback

PVOID ResPeImageEndFallback

Definition at line 26 of file resource.c.

Referenced by BlpResourceInitialize(), ResFindDataEntryFromImage(), and ResSelectLocale().

◆ ResPeImageEndPrimary

PVOID ResPeImageEndPrimary

Definition at line 20 of file resource.c.

Referenced by BlpResourceInitialize(), and ResSelectLocale().

◆ ResRootDirectory

PVOID ResRootDirectory

◆ ResRootDirectoryFallback

PVOID ResRootDirectoryFallback

Definition at line 27 of file resource.c.

Referenced by BlpResourceInitialize(), ResFindDataEntryFromImage(), and ResSelectLocale().

◆ ResRootDirectoryFallbackOffset

ULONG_PTR ResRootDirectoryFallbackOffset

Definition at line 24 of file resource.c.

Referenced by BlpResourceInitialize(), and ResSelectLocale().

◆ ResRootDirectoryOffset

ULONG_PTR ResRootDirectoryOffset

Definition at line 23 of file resource.c.

Referenced by BlpResourceInitialize(), BlResourceFindMessage(), and ResSelectLocale().

◆ ResRootDirectoryPrimary

PVOID ResRootDirectoryPrimary

Definition at line 21 of file resource.c.

Referenced by BlpResourceInitialize(), and ResSelectLocale().

◆ ResRootDirectoryPrimaryOffset

ULONG_PTR ResRootDirectoryPrimaryOffset

Definition at line 22 of file resource.c.

Referenced by BlpResourceInitialize(), and ResSelectLocale().