[REACTOS] Usage improvements for some RtlFindMessage invocations (#6023)

Use `RT_MESSAGETABLE` and `MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)`
instead of hardcoding their values.
This commit is contained in:
Hermès Bélusca-Maïto 2023-11-20 23:03:29 +01:00
parent 2f805d7a02
commit 111c8cc62a
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
6 changed files with 41 additions and 28 deletions

View file

@ -31,8 +31,8 @@ PciGetDescriptionMessage(IN ULONG Identifier,
/* Find the message identifier in the message table */ /* Find the message identifier in the message table */
MessageString.Buffer = NULL; MessageString.Buffer = NULL;
Status = RtlFindMessage(PciDriverObject->DriverStart, Status = RtlFindMessage(PciDriverObject->DriverStart,
11, // RT_MESSAGETABLE RT_MESSAGETABLE,
LANG_NEUTRAL, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
Identifier, Identifier,
&Entry); &Entry);
if (!NT_SUCCESS(Status)) return NULL; if (!NT_SUCCESS(Status)) return NULL;

View file

@ -294,10 +294,10 @@ PreloadGlobalMessageTable(IN PVOID ImageBase)
TotalLength = 0; TotalLength = 0;
for (MessageId = 1; MessageId != SAC_MAX_MESSAGES; MessageId++) for (MessageId = 1; MessageId != SAC_MAX_MESSAGES; MessageId++)
{ {
/* Find this message ID in the string table*/ /* Find this message in the message table */
Status2 = RtlFindMessage(ImageBase, Status2 = RtlFindMessage(ImageBase,
11, RT_MESSAGETABLE,
LANG_NEUTRAL, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
MessageId, MessageId,
&MessageEntry); &MessageEntry);
if (NT_SUCCESS(Status2)) if (NT_SUCCESS(Status2))
@ -339,10 +339,10 @@ PreloadGlobalMessageTable(IN PVOID ImageBase)
/* Now loop over our entries again */ /* Now loop over our entries again */
for (i = 0, MessageId = 1; MessageId != SAC_MAX_MESSAGES; MessageId++) for (i = 0, MessageId = 1; MessageId != SAC_MAX_MESSAGES; MessageId++)
{ {
/* Make sure the message is still there...! */ /* Make sure the message is still there! */
Status2 = RtlFindMessage(ImageBase, Status2 = RtlFindMessage(ImageBase,
11, RT_MESSAGETABLE,
LANG_NEUTRAL, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
MessageId, MessageId,
&MessageEntry); &MessageEntry);
if (NT_SUCCESS(Status2)) if (NT_SUCCESS(Status2))

View file

@ -1145,8 +1145,8 @@ ExpInitializeExecutive(IN ULONG Cpu,
{ {
/* Get the service pack string */ /* Get the service pack string */
Status = RtlFindMessage(NtosEntry->DllBase, Status = RtlFindMessage(NtosEntry->DllBase,
11, RT_MESSAGETABLE,
0, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
WINDOWS_NT_CSD_STRING, WINDOWS_NT_CSD_STRING,
&MsgEntry); &MsgEntry);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
@ -1434,8 +1434,8 @@ Phase1InitializationDiscard(IN PVOID Context)
/* Find the banner message */ /* Find the banner message */
MsgStatus = RtlFindMessage(NtosEntry->DllBase, MsgStatus = RtlFindMessage(NtosEntry->DllBase,
11, RT_MESSAGETABLE,
0, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
WINDOWS_NT_BANNER, WINDOWS_NT_BANNER,
&MsgEntry); &MsgEntry);
@ -1623,8 +1623,8 @@ Phase1InitializationDiscard(IN PVOID Context)
/* Get the information string from our resource file */ /* Get the information string from our resource file */
MsgStatus = RtlFindMessage(NtosEntry->DllBase, MsgStatus = RtlFindMessage(NtosEntry->DllBase,
11, RT_MESSAGETABLE,
0, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
KeNumberProcessors > 1 ? KeNumberProcessors > 1 ?
WINDOWS_NT_INFO_STRING_PLURAL : WINDOWS_NT_INFO_STRING_PLURAL :
WINDOWS_NT_INFO_STRING, WINDOWS_NT_INFO_STRING,
@ -1797,8 +1797,8 @@ Phase1InitializationDiscard(IN PVOID Context)
/* Find the message to print out */ /* Find the message to print out */
Status = RtlFindMessage(NtosEntry->DllBase, Status = RtlFindMessage(NtosEntry->DllBase,
11, RT_MESSAGETABLE,
0, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
MessageCode, MessageCode,
&MsgEntry); &MsgEntry);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
@ -1817,8 +1817,8 @@ Phase1InitializationDiscard(IN PVOID Context)
{ {
/* Find the message to print out */ /* Find the message to print out */
Status = RtlFindMessage(NtosEntry->DllBase, Status = RtlFindMessage(NtosEntry->DllBase,
11, RT_MESSAGETABLE,
0, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
BOOTLOG_ENABLED, BOOTLOG_ENABLED,
&MsgEntry); &MsgEntry);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))

View file

@ -344,13 +344,7 @@ C_ASSERT(HEAP_CREATE_VALID_MASK == 0x0007F0FF);
#define RTL_INIT_OBJECT_ATTRIBUTES(n, a) \ #define RTL_INIT_OBJECT_ATTRIBUTES(n, a) \
RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a) RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
#else /* NTOS_MODE_USER */ #endif /* NTOS_MODE_USER */
//
// Message Resource Flag
//
#define MESSAGE_RESOURCE_UNICODE 0x0001
#endif /* !NTOS_MODE_USER */
// //
// RtlImageNtHeaderEx Flags // RtlImageNtHeaderEx Flags
@ -1905,6 +1899,23 @@ typedef struct _RTL_UNICODE_STRING_BUFFER
#ifndef NTOS_MODE_USER #ifndef NTOS_MODE_USER
#ifndef MAKEINTRESOURCE
#define MAKEINTRESOURCE(i) ((ULONG_PTR)(USHORT)(i))
#endif
/* Predefined Resource Types */
#ifndef RT_STRING
#define RT_STRING MAKEINTRESOURCE(6)
#endif
#ifndef RT_MESSAGETABLE
#define RT_MESSAGETABLE MAKEINTRESOURCE(11)
#endif
//
// Message Resource Flag
//
#define MESSAGE_RESOURCE_UNICODE 0x0001
// //
// Message Resource Entry, Block and Data // Message Resource Entry, Block and Data
// //

View file

@ -583,7 +583,7 @@
#define SECTION_MAP_EXECUTE 8 #define SECTION_MAP_EXECUTE 8
#define SECTION_ALL_ACCESS 0xf001f #define SECTION_ALL_ACCESS 0xf001f
#define WRITE_WATCH_FLAG_RESET 0x01 #define WRITE_WATCH_FLAG_RESET 0x01
#define MESSAGE_RESOURCE_UNICODE 1
#define RTL_CRITSECT_TYPE 0 #define RTL_CRITSECT_TYPE 0
#define RTL_RESOURCE_TYPE 1 #define RTL_RESOURCE_TYPE 1
@ -2648,6 +2648,8 @@ typedef struct _MESSAGE_RESOURCE_ENTRY {
BYTE Text[1]; BYTE Text[1];
} MESSAGE_RESOURCE_ENTRY, *PMESSAGE_RESOURCE_ENTRY; } MESSAGE_RESOURCE_ENTRY, *PMESSAGE_RESOURCE_ENTRY;
#define MESSAGE_RESOURCE_UNICODE 1
typedef struct _MESSAGE_RESOURCE_BLOCK { typedef struct _MESSAGE_RESOURCE_BLOCK {
DWORD LowId; DWORD LowId;
DWORD HighId; DWORD HighId;

View file

@ -519,7 +519,7 @@ UserpFormatMessages(
FormatA.Buffer = NULL; FormatA.Buffer = NULL;
Status = RtlFindMessage(GetModuleHandleW(L"ntdll"), Status = RtlFindMessage(GetModuleHandleW(L"ntdll"),
(ULONG_PTR)RT_MESSAGETABLE, (ULONG_PTR)RT_MESSAGETABLE,
LANG_NEUTRAL, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
Message->Status, Message->Status,
&MessageResource); &MessageResource);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
@ -660,7 +660,7 @@ UserpFormatMessages(
/* Retrieve the description of the exception code */ /* Retrieve the description of the exception code */
Status = RtlFindMessage(GetModuleHandleW(L"ntdll"), Status = RtlFindMessage(GetModuleHandleW(L"ntdll"),
(ULONG_PTR)RT_MESSAGETABLE, (ULONG_PTR)RT_MESSAGETABLE,
LANG_NEUTRAL, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
ExceptionCode, ExceptionCode,
&MessageResource); &MessageResource);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))