ReactOS 0.4.15-dev-7889-g76290a6
message.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/rtl/message.c
5 * PURPOSE: Message table functions
6 * PROGRAMMERS: Eric Kohl
7 */
8
9/* INCLUDES *****************************************************************/
10
11#include <rtl.h>
12
13#define NDEBUG
14#include <debug.h>
15
16/* FUNCTIONS *****************************************************************/
17
18/*
19 * @implemented
20 */
26 IN ULONG Language,
27 IN ULONG MessageId,
28 OUT PMESSAGE_RESOURCE_ENTRY* MessageResourceEntry)
29{
30 LDR_RESOURCE_INFO ResourceInfo;
31 PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry;
32 PMESSAGE_RESOURCE_DATA MessageTable;
34 ULONG EntryOffset = 0, IdOffset = 0;
35 PMESSAGE_RESOURCE_ENTRY MessageEntry;
36 ULONG i;
37
38 DPRINT("RtlFindMessage()\n");
39
40 ResourceInfo.Type = Type;
41 ResourceInfo.Name = 1;
42 ResourceInfo.Language = Language;
43
45 &ResourceInfo,
47 &ResourceDataEntry);
48 if (!NT_SUCCESS(Status))
49 {
50 return Status;
51 }
52
53 DPRINT("ResourceDataEntry: %p\n", ResourceDataEntry);
54
56 ResourceDataEntry,
57 (PVOID*)&MessageTable,
58 NULL);
59 if (!NT_SUCCESS(Status))
60 {
61 return Status;
62 }
63
64 DPRINT("MessageTable: %p\n", MessageTable);
65
66 DPRINT("NumberOfBlocks %lu\n", MessageTable->NumberOfBlocks);
67 for (i = 0; i < MessageTable->NumberOfBlocks; i++)
68 {
69 DPRINT("LoId 0x%08lx HiId 0x%08lx Offset 0x%08lx\n",
70 MessageTable->Blocks[i].LowId,
71 MessageTable->Blocks[i].HighId,
72 MessageTable->Blocks[i].OffsetToEntries);
73 }
74
75 for (i = 0; i < MessageTable->NumberOfBlocks; i++)
76 {
77 if ((MessageId >= MessageTable->Blocks[i].LowId) &&
78 (MessageId <= MessageTable->Blocks[i].HighId))
79 {
80 EntryOffset = MessageTable->Blocks[i].OffsetToEntries;
81 IdOffset = MessageId - MessageTable->Blocks[i].LowId;
82 break;
83 }
84
85 if (MessageId < MessageTable->Blocks[i].LowId)
86 {
88 }
89 }
90
91 if (MessageTable->NumberOfBlocks <= i)
92 {
94 }
95
96 MessageEntry = (PMESSAGE_RESOURCE_ENTRY)
97 ((PUCHAR)MessageTable + MessageTable->Blocks[i].OffsetToEntries);
98
99 DPRINT("EntryOffset 0x%08lx\n", EntryOffset);
100 DPRINT("IdOffset 0x%08lx\n", IdOffset);
101
102 DPRINT("MessageEntry: %p\n", MessageEntry);
103 for (i = 0; i < IdOffset; i++)
104 {
105 MessageEntry = (PMESSAGE_RESOURCE_ENTRY)
106 ((PUCHAR)MessageEntry + (ULONG)MessageEntry->Length);
107 }
108
109 if (MessageEntry->Flags == 0)
110 {
111 DPRINT("AnsiText: %s\n", MessageEntry->Text);
112 }
113 else
114 {
115 DPRINT("UnicodeText: %S\n", (PWSTR)MessageEntry->Text);
116 }
117
118 if (MessageResourceEntry != NULL)
119 {
120 *MessageResourceEntry = MessageEntry;
121 }
122
123 return STATUS_SUCCESS;
124}
125
126/*
127 * @unimplemented
128 */
130NTAPI
133 IN ULONG MaxWidth OPTIONAL,
134 IN BOOLEAN IgnoreInserts,
135 IN BOOLEAN ArgumentsAreAnsi,
136 IN BOOLEAN ArgumentsAreAnArray,
137 IN va_list* Arguments,
141 IN ULONG Flags)
142{
143 DPRINT1("RtlFormatMessage(%S, %lu, %s, %s, %s, %p, %p, %lu, %p, %lx)\n",
144 Message, MaxWidth, IgnoreInserts ? "TRUE" : "FALSE", ArgumentsAreAnsi ? "TRUE" : "FALSE",
145 ArgumentsAreAnArray ? "TRUE" : "FALSE", Arguments, Buffer, BufferSize,
147
150}
151
152/**********************************************************************
153 * RtlFormatMessage (NTDLL.@)
154 *
155 * Formats a message (similar to sprintf).
156 *
157 * PARAMS
158 * Message [I] Message to format.
159 * MaxWidth [I] Maximum width in characters of each output line (optional).
160 * IgnoreInserts [I] Whether to copy the message without processing inserts.
161 * ArgumentsAreAnsi [I] Whether Arguments may have ANSI strings.
162 * ArgumentsAreAnArray [I] Whether Arguments is actually an array rather than a va_list *.
163 * Arguments [I]
164 * Buffer [O] Buffer to store processed message in.
165 * BufferSize [I] Size of Buffer (in bytes).
166 * ReturnLength [O] Size of the formatted message (in bytes; optional).
167 *
168 * RETURNS
169 * NTSTATUS code.
170 *
171 * @implemented
172 */
174NTAPI
177 IN ULONG MaxWidth OPTIONAL,
178 IN BOOLEAN IgnoreInserts,
179 IN BOOLEAN ArgumentsAreAnsi,
180 IN BOOLEAN ArgumentsAreAnArray,
181 IN va_list* Arguments,
185{
186 /* Call the extended API */
188 MaxWidth,
189 IgnoreInserts,
190 ArgumentsAreAnsi,
191 ArgumentsAreAnArray,
192 Arguments,
193 Buffer,
196 0);
197}
198
199/* EOF */
unsigned char BOOLEAN
Type
Definition: Type.h:7
char * va_list
Definition: acmsvcex.h:78
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: debug.h:115
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR Message[]
Definition: register.c:74
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
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 i
Definition: glfuncs.h:248
NTSTATUS NTAPI LdrAccessResource(_In_ PVOID BaseAddress, _In_ PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry, _Out_opt_ PVOID *Resource, _Out_opt_ PULONG Size)
NTSTATUS NTAPI LdrFindResource_U(_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Out_ PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry)
#define RESOURCE_DATA_LEVEL
Definition: ldrtypes.h:33
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
struct _MESSAGE_RESOURCE_ENTRY * PMESSAGE_RESOURCE_ENTRY
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_MESSAGE_NOT_FOUND
Definition: ntstatus.h:501
NTSTATUS NTAPI RtlFormatMessage(IN PWSTR Message, IN ULONG MaxWidth OPTIONAL, IN BOOLEAN IgnoreInserts, IN BOOLEAN ArgumentsAreAnsi, IN BOOLEAN ArgumentsAreAnArray, IN va_list *Arguments, OUT PWSTR Buffer, IN ULONG BufferSize, OUT PULONG ReturnLength OPTIONAL)
Definition: message.c:175
NTSTATUS NTAPI RtlFindMessage(IN PVOID BaseAddress, IN ULONG Type, IN ULONG Language, IN ULONG MessageId, OUT PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry)
Definition: message.c:23
NTSTATUS NTAPI RtlFormatMessageEx(IN PWSTR Message, IN ULONG MaxWidth OPTIONAL, IN BOOLEAN IgnoreInserts, IN BOOLEAN ArgumentsAreAnsi, IN BOOLEAN ArgumentsAreAnArray, IN va_list *Arguments, OUT PWSTR Buffer, IN ULONG BufferSize, OUT PULONG ReturnLength OPTIONAL, IN ULONG Flags)
Definition: message.c:131
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
Definition: pedump.c:458
ULONG_PTR Language
Definition: ldrtypes.h:183
ULONG_PTR Name
Definition: ldrtypes.h:182
ULONG_PTR Type
Definition: ldrtypes.h:181
MESSAGE_RESOURCE_BLOCK Blocks[ANYSIZE_ARRAY]
Definition: rtltypes.h:1912
Definition: rtltypes.h:1896
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1899
USHORT Flags
Definition: rtltypes.h:1898
USHORT Length
Definition: rtltypes.h:1897
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170