Skip to content

Commit 111c8cc

Browse files
committed
[REACTOS] Usage improvements for some RtlFindMessage invocations (reactos#6023)
Use `RT_MESSAGETABLE` and `MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)` instead of hardcoding their values.
1 parent 2f805d7 commit 111c8cc

File tree

6 files changed

+41
-28
lines changed

6 files changed

+41
-28
lines changed

drivers/bus/pcix/pci/id.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ PciGetDescriptionMessage(IN ULONG Identifier,
3131
/* Find the message identifier in the message table */
3232
MessageString.Buffer = NULL;
3333
Status = RtlFindMessage(PciDriverObject->DriverStart,
34-
11, // RT_MESSAGETABLE
35-
LANG_NEUTRAL,
34+
RT_MESSAGETABLE,
35+
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
3636
Identifier,
3737
&Entry);
3838
if (!NT_SUCCESS(Status)) return NULL;

drivers/sac/driver/util.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,10 @@ PreloadGlobalMessageTable(IN PVOID ImageBase)
294294
TotalLength = 0;
295295
for (MessageId = 1; MessageId != SAC_MAX_MESSAGES; MessageId++)
296296
{
297-
/* Find this message ID in the string table*/
297+
/* Find this message in the message table */
298298
Status2 = RtlFindMessage(ImageBase,
299-
11,
300-
LANG_NEUTRAL,
299+
RT_MESSAGETABLE,
300+
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
301301
MessageId,
302302
&MessageEntry);
303303
if (NT_SUCCESS(Status2))
@@ -339,10 +339,10 @@ PreloadGlobalMessageTable(IN PVOID ImageBase)
339339
/* Now loop over our entries again */
340340
for (i = 0, MessageId = 1; MessageId != SAC_MAX_MESSAGES; MessageId++)
341341
{
342-
/* Make sure the message is still there...! */
342+
/* Make sure the message is still there! */
343343
Status2 = RtlFindMessage(ImageBase,
344-
11,
345-
LANG_NEUTRAL,
344+
RT_MESSAGETABLE,
345+
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
346346
MessageId,
347347
&MessageEntry);
348348
if (NT_SUCCESS(Status2))

ntoskrnl/ex/init.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,8 +1145,8 @@ ExpInitializeExecutive(IN ULONG Cpu,
11451145
{
11461146
/* Get the service pack string */
11471147
Status = RtlFindMessage(NtosEntry->DllBase,
1148-
11,
1149-
0,
1148+
RT_MESSAGETABLE,
1149+
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
11501150
WINDOWS_NT_CSD_STRING,
11511151
&MsgEntry);
11521152
if (NT_SUCCESS(Status))
@@ -1434,8 +1434,8 @@ Phase1InitializationDiscard(IN PVOID Context)
14341434

14351435
/* Find the banner message */
14361436
MsgStatus = RtlFindMessage(NtosEntry->DllBase,
1437-
11,
1438-
0,
1437+
RT_MESSAGETABLE,
1438+
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
14391439
WINDOWS_NT_BANNER,
14401440
&MsgEntry);
14411441

@@ -1623,8 +1623,8 @@ Phase1InitializationDiscard(IN PVOID Context)
16231623

16241624
/* Get the information string from our resource file */
16251625
MsgStatus = RtlFindMessage(NtosEntry->DllBase,
1626-
11,
1627-
0,
1626+
RT_MESSAGETABLE,
1627+
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
16281628
KeNumberProcessors > 1 ?
16291629
WINDOWS_NT_INFO_STRING_PLURAL :
16301630
WINDOWS_NT_INFO_STRING,
@@ -1797,8 +1797,8 @@ Phase1InitializationDiscard(IN PVOID Context)
17971797

17981798
/* Find the message to print out */
17991799
Status = RtlFindMessage(NtosEntry->DllBase,
1800-
11,
1801-
0,
1800+
RT_MESSAGETABLE,
1801+
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
18021802
MessageCode,
18031803
&MsgEntry);
18041804
if (NT_SUCCESS(Status))
@@ -1817,8 +1817,8 @@ Phase1InitializationDiscard(IN PVOID Context)
18171817
{
18181818
/* Find the message to print out */
18191819
Status = RtlFindMessage(NtosEntry->DllBase,
1820-
11,
1821-
0,
1820+
RT_MESSAGETABLE,
1821+
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
18221822
BOOTLOG_ENABLED,
18231823
&MsgEntry);
18241824
if (NT_SUCCESS(Status))

sdk/include/ndk/rtltypes.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,7 @@ C_ASSERT(HEAP_CREATE_VALID_MASK == 0x0007F0FF);
344344
#define RTL_INIT_OBJECT_ATTRIBUTES(n, a) \
345345
RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
346346

347-
#else /* NTOS_MODE_USER */
348-
//
349-
// Message Resource Flag
350-
//
351-
#define MESSAGE_RESOURCE_UNICODE 0x0001
352-
353-
#endif /* !NTOS_MODE_USER */
347+
#endif /* NTOS_MODE_USER */
354348

355349
//
356350
// RtlImageNtHeaderEx Flags
@@ -1905,6 +1899,23 @@ typedef struct _RTL_UNICODE_STRING_BUFFER
19051899

19061900
#ifndef NTOS_MODE_USER
19071901

1902+
#ifndef MAKEINTRESOURCE
1903+
#define MAKEINTRESOURCE(i) ((ULONG_PTR)(USHORT)(i))
1904+
#endif
1905+
1906+
/* Predefined Resource Types */
1907+
#ifndef RT_STRING
1908+
#define RT_STRING MAKEINTRESOURCE(6)
1909+
#endif
1910+
#ifndef RT_MESSAGETABLE
1911+
#define RT_MESSAGETABLE MAKEINTRESOURCE(11)
1912+
#endif
1913+
1914+
//
1915+
// Message Resource Flag
1916+
//
1917+
#define MESSAGE_RESOURCE_UNICODE 0x0001
1918+
19081919
//
19091920
// Message Resource Entry, Block and Data
19101921
//

sdk/include/xdk/winnt_old.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@
583583
#define SECTION_MAP_EXECUTE 8
584584
#define SECTION_ALL_ACCESS 0xf001f
585585
#define WRITE_WATCH_FLAG_RESET 0x01
586-
#define MESSAGE_RESOURCE_UNICODE 1
586+
587587
#define RTL_CRITSECT_TYPE 0
588588
#define RTL_RESOURCE_TYPE 1
589589

@@ -2648,6 +2648,8 @@ typedef struct _MESSAGE_RESOURCE_ENTRY {
26482648
BYTE Text[1];
26492649
} MESSAGE_RESOURCE_ENTRY, *PMESSAGE_RESOURCE_ENTRY;
26502650

2651+
#define MESSAGE_RESOURCE_UNICODE 1
2652+
26512653
typedef struct _MESSAGE_RESOURCE_BLOCK {
26522654
DWORD LowId;
26532655
DWORD HighId;

win32ss/user/winsrv/usersrv/harderror.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ UserpFormatMessages(
519519
FormatA.Buffer = NULL;
520520
Status = RtlFindMessage(GetModuleHandleW(L"ntdll"),
521521
(ULONG_PTR)RT_MESSAGETABLE,
522-
LANG_NEUTRAL,
522+
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
523523
Message->Status,
524524
&MessageResource);
525525
if (NT_SUCCESS(Status))
@@ -660,7 +660,7 @@ UserpFormatMessages(
660660
/* Retrieve the description of the exception code */
661661
Status = RtlFindMessage(GetModuleHandleW(L"ntdll"),
662662
(ULONG_PTR)RT_MESSAGETABLE,
663-
LANG_NEUTRAL,
663+
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
664664
ExceptionCode,
665665
&MessageResource);
666666
if (NT_SUCCESS(Status))

0 commit comments

Comments
 (0)