ReactOS  0.4.12-dev-712-ge6be187
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  */
22 NTAPI
25  IN ULONG Type,
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  */
129 NTSTATUS
130 NTAPI
132  IN PWSTR Message,
133  IN ULONG MaxWidth OPTIONAL,
134  IN BOOLEAN IgnoreInserts,
135  IN BOOLEAN ArgumentsAreAnsi,
136  IN BOOLEAN ArgumentsAreAnArray,
137  IN va_list* Arguments,
138  OUT PWSTR Buffer,
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 
149  return STATUS_NOT_IMPLEMENTED;
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  */
173 NTSTATUS
174 NTAPI
176  IN PWSTR Message,
177  IN ULONG MaxWidth OPTIONAL,
178  IN BOOLEAN IgnoreInserts,
179  IN BOOLEAN ArgumentsAreAnsi,
180  IN BOOLEAN ArgumentsAreAnArray,
181  IN va_list* Arguments,
182  OUT PWSTR Buffer,
185 {
186  /* Call the extended API */
188  MaxWidth,
189  IgnoreInserts,
190  ArgumentsAreAnsi,
191  ArgumentsAreAnArray,
192  Arguments,
193  Buffer,
194  BufferSize,
195  ReturnLength,
196  0);
197 }
198 
199 /* EOF */
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
#define IN
Definition: typedefs.h:38
Definition: rtltypes.h:1827
Type
Definition: Type.h:6
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
uint16_t * PWSTR
Definition: typedefs.h:54
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
USHORT Flags
Definition: rtltypes.h:1830
ULONG_PTR Type
Definition: ldrtypes.h:179
struct _MESSAGE_RESOURCE_ENTRY * PMESSAGE_RESOURCE_ENTRY
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
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)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
unsigned char BOOLEAN
ULONG_PTR Name
Definition: ldrtypes.h:180
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
void DPRINT(...)
Definition: polytest.cpp:61
Definition: pedump.c:457
Definition: bufpool.h:45
NTSTATUS NTAPI LdrFindResource_U(_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Out_ PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry)
NTSTATUS NTAPI LdrAccessResource(_In_ PVOID BaseAddress, _In_ PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry, _Out_opt_ PVOID *Resource, _Out_opt_ PULONG Size)
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
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1831
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define BufferSize
Definition: classpnp.h:419
CHAR Message[80]
Definition: alive.c:5
USHORT Length
Definition: rtltypes.h:1829
Status
Definition: gdiplustypes.h:24
#define RESOURCE_DATA_LEVEL
Definition: ldrtypes.h:33
unsigned int * PULONG
Definition: retypes.h:1
#define DPRINT1
Definition: precomp.h:8
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
ULONG_PTR Language
Definition: ldrtypes.h:181
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:114
NTSTATUS NTAPI RtlFindMessage(IN PVOID BaseAddress, IN ULONG Type, IN ULONG Language, IN ULONG MessageId, OUT PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry)
Definition: message.c:23
#define STATUS_MESSAGE_NOT_FOUND
Definition: ntstatus.h:487
return STATUS_SUCCESS
Definition: btrfs.c:2725
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68