ReactOS  0.4.14-dev-297-g23e575c
unicode.c File Reference
#include <rtl.h>
#include <debug.h>
#include <wine/unicode.h>
Include dependency graph for unicode.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define ITU_IMPLEMENTED_TESTS   (IS_TEXT_UNICODE_ODD_LENGTH|IS_TEXT_UNICODE_SIGNATURE)
 

Functions

NTSTATUS NTAPI RtlMultiAppendUnicodeStringBuffer (OUT PRTL_UNICODE_STRING_BUFFER StringBuffer, IN ULONG NumberOfAddends, IN PCUNICODE_STRING Addends)
 
WCHAR NTAPI RtlAnsiCharToUnicodeChar (IN OUT PUCHAR *AnsiChar)
 
NTSTATUS NTAPI RtlAnsiStringToUnicodeString (IN OUT PUNICODE_STRING UniDest, IN PANSI_STRING AnsiSource, IN BOOLEAN AllocateDestinationString)
 
ULONG NTAPI RtlxAnsiStringToUnicodeSize (IN PCANSI_STRING AnsiString)
 
NTSTATUS NTAPI RtlAppendStringToString (IN PSTRING Destination, IN const STRING *Source)
 
NTSTATUS NTAPI RtlAppendUnicodeStringToString (IN OUT PUNICODE_STRING Destination, IN PCUNICODE_STRING Source)
 
NTSTATUS NTAPI RtlCharToInteger (PCSZ str, ULONG base, PULONG value)
 
LONG NTAPI RtlCompareString (IN const STRING *s1, IN const STRING *s2, IN BOOLEAN CaseInsensitive)
 
BOOLEAN NTAPI RtlEqualString (IN const STRING *s1, IN const STRING *s2, IN BOOLEAN CaseInsensitive)
 
BOOLEAN NTAPI RtlEqualUnicodeString (IN CONST UNICODE_STRING *s1, IN CONST UNICODE_STRING *s2, IN BOOLEAN CaseInsensitive)
 
VOID NTAPI RtlFreeAnsiString (IN PANSI_STRING AnsiString)
 
VOID NTAPI RtlFreeOemString (IN POEM_STRING OemString)
 
VOID NTAPI RtlFreeUnicodeString (IN PUNICODE_STRING UnicodeString)
 
BOOLEAN NTAPI RtlpDidUnicodeToOemWork (IN PCUNICODE_STRING UnicodeString, IN POEM_STRING OemString)
 
BOOLEAN NTAPI RtlIsValidOemCharacter (IN PWCHAR Char)
 
VOID NTAPI RtlInitAnsiString (IN OUT PANSI_STRING DestinationString, IN PCSZ SourceString)
 
NTSTATUS NTAPI RtlInitAnsiStringEx (IN OUT PANSI_STRING DestinationString, IN PCSZ SourceString)
 
VOID NTAPI RtlInitString (IN OUT PSTRING DestinationString, IN PCSZ SourceString)
 
VOID NTAPI RtlInitUnicodeString (IN OUT PUNICODE_STRING DestinationString, IN PCWSTR SourceString)
 
NTSTATUS NTAPI RtlInitUnicodeStringEx (OUT PUNICODE_STRING DestinationString, IN PCWSTR SourceString)
 
NTSTATUS NTAPI RtlIntegerToChar (ULONG value, ULONG base, ULONG length, PCHAR str)
 
NTSTATUS NTAPI RtlIntegerToUnicode (IN ULONG Value, IN ULONG Base OPTIONAL, IN ULONG Length OPTIONAL, IN OUT LPWSTR String)
 
NTSTATUS NTAPI RtlIntegerToUnicodeString (IN ULONG Value, IN ULONG Base OPTIONAL, IN OUT PUNICODE_STRING String)
 
NTSTATUS NTAPI RtlInt64ToUnicodeString (IN ULONGLONG Value, IN ULONG Base OPTIONAL, IN OUT PUNICODE_STRING String)
 
BOOLEAN NTAPI RtlPrefixString (const STRING *String1, const STRING *String2, BOOLEAN CaseInsensitive)
 
BOOLEAN NTAPI RtlPrefixUnicodeString (PCUNICODE_STRING String1, PCUNICODE_STRING String2, BOOLEAN CaseInsensitive)
 
NTSTATUS NTAPI RtlUnicodeStringToInteger (const UNICODE_STRING *str, ULONG base, ULONG *value)
 
ULONG NTAPI RtlxUnicodeStringToOemSize (IN PCUNICODE_STRING UnicodeString)
 
NTSTATUS NTAPI RtlUnicodeStringToAnsiString (IN OUT PANSI_STRING AnsiDest, IN PCUNICODE_STRING UniSource, IN BOOLEAN AllocateDestinationString)
 
NTSTATUS NTAPI RtlOemStringToUnicodeString (IN OUT PUNICODE_STRING UniDest, IN PCOEM_STRING OemSource, IN BOOLEAN AllocateDestinationString)
 
NTSTATUS NTAPI RtlUnicodeStringToOemString (IN OUT POEM_STRING OemDest, IN PCUNICODE_STRING UniSource, IN BOOLEAN AllocateDestinationString)
 
BOOLEAN NTAPI RtlIsTextUnicode (CONST VOID *buf, INT len, INT *pf)
 
NTSTATUS NTAPI RtlOemStringToCountedUnicodeString (IN OUT PUNICODE_STRING UniDest, IN PCOEM_STRING OemSource, IN BOOLEAN AllocateDestinationString)
 
BOOLEAN NTAPI RtlEqualComputerName (IN PUNICODE_STRING ComputerName1, IN PUNICODE_STRING ComputerName2)
 
BOOLEAN NTAPI RtlEqualDomainName (IN PUNICODE_STRING DomainName1, IN PUNICODE_STRING DomainName2)
 
NTSTATUS NTAPI RtlGUIDFromString (IN UNICODE_STRING *str, OUT GUID *guid)
 
VOID NTAPI RtlEraseUnicodeString (IN PUNICODE_STRING String)
 
NTSTATUS NTAPI RtlHashUnicodeString (IN CONST UNICODE_STRING *String, IN BOOLEAN CaseInSensitive, IN ULONG HashAlgorithm, OUT PULONG HashValue)
 
NTSTATUS NTAPI RtlUnicodeStringToCountedOemString (IN OUT POEM_STRING OemDest, IN PCUNICODE_STRING UniSource, IN BOOLEAN AllocateDestinationString)
 
NTSTATUS NTAPI RtlLargeIntegerToChar (IN PLARGE_INTEGER Value, IN ULONG Base, IN ULONG Length, IN OUT PCHAR String)
 
NTSTATUS NTAPI RtlUpcaseUnicodeString (IN OUT PUNICODE_STRING UniDest, IN PCUNICODE_STRING UniSource, IN BOOLEAN AllocateDestinationString)
 
NTSTATUS NTAPI RtlUpcaseUnicodeStringToAnsiString (IN OUT PANSI_STRING AnsiDest, IN PCUNICODE_STRING UniSource, IN BOOLEAN AllocateDestinationString)
 
NTSTATUS NTAPI RtlUpcaseUnicodeStringToCountedOemString (IN OUT POEM_STRING OemDest, IN PCUNICODE_STRING UniSource, IN BOOLEAN AllocateDestinationString)
 
NTSTATUS NTAPI RtlUpcaseUnicodeStringToOemString (IN OUT POEM_STRING OemDest, IN PCUNICODE_STRING UniSource, IN BOOLEAN AllocateDestinationString)
 
ULONG NTAPI RtlxOemStringToUnicodeSize (IN PCOEM_STRING OemString)
 
NTSTATUS NTAPI RtlStringFromGUID (IN REFGUID Guid, OUT PUNICODE_STRING GuidString)
 
ULONG NTAPI RtlxUnicodeStringToAnsiSize (IN PCUNICODE_STRING UnicodeString)
 
LONG NTAPI RtlCompareUnicodeString (IN PCUNICODE_STRING s1, IN PCUNICODE_STRING s2, IN BOOLEAN CaseInsensitive)
 
VOID NTAPI RtlCopyString (IN OUT PSTRING DestinationString, IN const STRING *SourceString OPTIONAL)
 
VOID NTAPI RtlCopyUnicodeString (IN OUT PUNICODE_STRING DestinationString, IN PCUNICODE_STRING SourceString)
 
BOOLEAN NTAPI RtlCreateUnicodeString (IN OUT PUNICODE_STRING UniDest, IN PCWSTR Source)
 
BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz (OUT PUNICODE_STRING Destination, IN PCSZ Source)
 
NTSTATUS NTAPI RtlDowncaseUnicodeString (IN OUT PUNICODE_STRING UniDest, IN PCUNICODE_STRING UniSource, IN BOOLEAN AllocateDestinationString)
 
NTSTATUS NTAPI RtlAppendUnicodeToString (IN OUT PUNICODE_STRING Destination, IN PCWSTR Source)
 
NTSTATUS NTAPI RtlAppendAsciizToString (IN OUT PSTRING Destination, IN PCSZ Source)
 
VOID NTAPI RtlUpperString (PSTRING DestinationString, const STRING *SourceString)
 
NTSTATUS NTAPI RtlDuplicateUnicodeString (IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
 
NTSTATUS NTAPI RtlValidateUnicodeString (IN ULONG Flags, IN PCUNICODE_STRING UnicodeString)
 
NTSTATUS NTAPI RtlpEnsureBufferSize (IN ULONG Flags, IN OUT PRTL_BUFFER Buffer, IN SIZE_T RequiredSize)
 
static BOOLEAN RtlpIsCharInUnicodeString (IN WCHAR Char, IN PCUNICODE_STRING MatchString, IN BOOLEAN CaseInSensitive)
 
NTSTATUS NTAPI RtlFindCharInUnicodeString (IN ULONG Flags, IN PCUNICODE_STRING SearchString, IN PCUNICODE_STRING MatchString, OUT PUSHORT Position)
 
NTSTATUS NTAPI RtlDnsHostNameToComputerName (PUNICODE_STRING ComputerName, PUNICODE_STRING DnsHostName, BOOLEAN AllocateComputerNameString)
 

Variables

BOOLEAN NlsMbCodePageTag
 
BOOLEAN NlsMbOemCodePageTag
 
PUSHORT NlsLeadByteInfo
 
USHORT NlsOemDefaultChar
 
USHORT NlsUnicodeDefaultChar
 
PUSHORT NlsOemLeadByteInfo
 
PWCHAR NlsOemToUnicodeTable
 
PCHAR NlsUnicodeToOemTable
 
PUSHORT NlsUnicodeToMbOemTable
 

Macro Definition Documentation

◆ ITU_IMPLEMENTED_TESTS

Definition at line 1269 of file unicode.c.

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file unicode.c.

Function Documentation

◆ RtlAnsiCharToUnicodeChar()

WCHAR NTAPI RtlAnsiCharToUnicodeChar ( IN OUT PUCHAR AnsiChar)

Definition at line 50 of file unicode.c.

51 {
52  ULONG Size;
54  WCHAR UnicodeChar = L' ';
56 
57  if (NlsLeadByteInfo)
58  {
59  Size = (NlsLeadByteInfo[**AnsiChar] == 0) ? 1 : 2;
60  }
61  else
62  {
63  DPRINT("HACK::Shouldn't have happened! Consider fixing Usetup and registry entries it creates on install\n");
64  Size = 1;
65  }
66 
67  Status = RtlMultiByteToUnicodeN(&UnicodeChar,
68  sizeof(WCHAR),
69  NULL,
70  (PCHAR)*AnsiChar,
71  Size);
72 
73  if (!NT_SUCCESS(Status))
74  {
75  UnicodeChar = L' ';
76  }
77 
78  *AnsiChar += Size;
79  return UnicodeChar;
80 }
signed char * PCHAR
Definition: retypes.h:7
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
PUSHORT NlsLeadByteInfo
Definition: nls.c:26
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1

◆ RtlAnsiStringToUnicodeString()

NTSTATUS NTAPI RtlAnsiStringToUnicodeString ( IN OUT PUNICODE_STRING  UniDest,
IN PANSI_STRING  AnsiSource,
IN BOOLEAN  AllocateDestinationString 
)

Definition at line 91 of file unicode.c.

95 {
97  ULONG Length;
98  ULONG Index;
99 
100  PAGED_CODE_RTL();
101 
102  if (NlsMbCodePageTag == FALSE)
103  {
104  Length = AnsiSource->Length * 2 + sizeof(WCHAR);
105  }
106  else
107  {
108  Length = RtlxAnsiStringToUnicodeSize(AnsiSource);
109  }
111  UniDest->Length = (USHORT)Length - sizeof(WCHAR);
112 
114  {
115  UniDest->Buffer = RtlpAllocateStringMemory(Length, TAG_USTR);
116  UniDest->MaximumLength = (USHORT)Length;
117  if (!UniDest->Buffer) return STATUS_NO_MEMORY;
118  }
119  else if (UniDest->Length >= UniDest->MaximumLength)
120  {
121  return STATUS_BUFFER_OVERFLOW;
122  }
123 
124  /* UniDest->MaximumLength must be even due to sizeof(WCHAR) being 2 */
125  ASSERT(!(UniDest->MaximumLength & 1) && UniDest->Length <= UniDest->MaximumLength);
126 
127  Status = RtlMultiByteToUnicodeN(UniDest->Buffer,
128  UniDest->Length,
129  &Index,
130  AnsiSource->Buffer,
131  AnsiSource->Length);
132 
133  if (!NT_SUCCESS(Status))
134  {
136  {
137  RtlpFreeStringMemory(UniDest->Buffer, TAG_USTR);
138  UniDest->Buffer = NULL;
139  }
140 
141  return Status;
142  }
143 
144  UniDest->Buffer[Index / sizeof(WCHAR)] = UNICODE_NULL;
145  return Status;
146 }
BOOLEAN NlsMbCodePageTag
Definition: nls.c:22
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define RtlpFreeStringMemory
Definition: rtlp.h:141
#define TAG_USTR
Definition: libsupp.c:111
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MAXUSHORT
Definition: typedefs.h:81
unsigned int ULONG
Definition: retypes.h:1
ULONG NTAPI RtlxAnsiStringToUnicodeSize(IN PCANSI_STRING AnsiString)
Definition: unicode.c:156
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1321

Referenced by RtlCreateUnicodeStringFromAsciiz(), RtlInt64ToUnicodeString(), and RtlIntegerToUnicodeString().

◆ RtlAppendAsciizToString()

NTSTATUS NTAPI RtlAppendAsciizToString ( IN OUT PSTRING  Destination,
IN PCSZ  Source 
)

Definition at line 2437 of file unicode.c.

2440 {
2441  SIZE_T Size;
2442 
2443  if (Source)
2444  {
2445  Size = strlen(Source);
2446 
2448  {
2449  return STATUS_BUFFER_TOO_SMALL;
2450  }
2451 
2454  }
2455 
2456  return STATUS_SUCCESS;
2457 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2891
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned short USHORT
Definition: pedump.c:61
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlAppendStringToString()

NTSTATUS NTAPI RtlAppendStringToString ( IN PSTRING  Destination,
IN const STRING Source 
)

Definition at line 179 of file unicode.c.

181 {
182  USHORT SourceLength = Source->Length;
183 
184  if (SourceLength)
185  {
186  if (Destination->Length + SourceLength > Destination->MaximumLength)
187  {
189  }
190 
192  Source->Buffer,
193  SourceLength);
194 
195  Destination->Length += SourceLength;
196  }
197 
198  return STATUS_SUCCESS;
199 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2891
unsigned short USHORT
Definition: pedump.c:61
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlAppendUnicodeStringToString()

NTSTATUS NTAPI RtlAppendUnicodeStringToString ( IN OUT PUNICODE_STRING  Destination,
IN PCUNICODE_STRING  Source 
)

Definition at line 211 of file unicode.c.

214 {
215  USHORT SourceLength = Source->Length;
217 
218  if (SourceLength)
219  {
220  if ((SourceLength + Destination->Length) > Destination->MaximumLength)
221  {
223  }
224 
225  RtlMoveMemory(Buffer, Source->Buffer, SourceLength);
226  Destination->Length += SourceLength;
227 
228  /* append terminating '\0' if enough space */
230  {
231  Buffer[SourceLength / sizeof(WCHAR)] = UNICODE_NULL;
232  }
233  }
234 
235  return STATUS_SUCCESS;
236 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWCHAR
Definition: typedefs.h:54
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define UNICODE_NULL
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2891
unsigned short USHORT
Definition: pedump.c:61
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlAppendUnicodeToString()

NTSTATUS NTAPI RtlAppendUnicodeToString ( IN OUT PUNICODE_STRING  Destination,
IN PCWSTR  Source 
)

Definition at line 2396 of file unicode.c.

2398 {
2399  USHORT Length;
2400  PWCHAR DestBuffer;
2401 
2402  if (Source)
2403  {
2404  UNICODE_STRING UnicodeSource;
2405 
2406  RtlInitUnicodeString(&UnicodeSource, Source);
2407  Length = UnicodeSource.Length;
2408 
2410  {
2411  return STATUS_BUFFER_TOO_SMALL;
2412  }
2413 
2414  DestBuffer = &Destination->Buffer[Destination->Length / sizeof(WCHAR)];
2415  RtlMoveMemory(DestBuffer, Source, Length);
2417 
2418  /* append terminating '\0' if enough space */
2420  {
2421  DestBuffer[Length / sizeof(WCHAR)] = UNICODE_NULL;
2422  }
2423  }
2424 
2425  return STATUS_SUCCESS;
2426 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWCHAR
Definition: typedefs.h:54
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
VOID NTAPI RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString, IN PCWSTR SourceString)
Definition: unicode.c:630
#define UNICODE_NULL
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2891
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned short USHORT
Definition: pedump.c:61
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlCharToInteger()

NTSTATUS NTAPI RtlCharToInteger ( PCSZ  str,
ULONG  base,
PULONG  value 
)

Definition at line 261 of file unicode.c.

265 {
266  CHAR chCurrent;
267  int digit;
268  ULONG RunningTotal = 0;
269  char bMinus = 0;
270 
271  /* skip leading whitespaces */
272  while (*str != '\0' && *str <= ' ') str++;
273 
274  /* Check for +/- */
275  if (*str == '+')
276  {
277  str++;
278  }
279  else if (*str == '-')
280  {
281  bMinus = 1;
282  str++;
283  }
284 
285  /* base = 0 means autobase */
286  if (base == 0)
287  {
288  base = 10;
289 
290  if (str[0] == '0')
291  {
292  if (str[1] == 'b')
293  {
294  str += 2;
295  base = 2;
296  }
297  else if (str[1] == 'o')
298  {
299  str += 2;
300  base = 8;
301  }
302  else if (str[1] == 'x')
303  {
304  str += 2;
305  base = 16;
306  }
307  }
308  }
309  else if (base != 2 && base != 8 && base != 10 && base != 16)
310  {
312  }
313 
314  if (value == NULL) return STATUS_ACCESS_VIOLATION;
315 
316  while (*str != '\0')
317  {
318  chCurrent = *str;
319 
320  if (chCurrent >= '0' && chCurrent <= '9')
321  {
322  digit = chCurrent - '0';
323  }
324  else if (chCurrent >= 'A' && chCurrent <= 'Z')
325  {
326  digit = chCurrent - 'A' + 10;
327  }
328  else if (chCurrent >= 'a' && chCurrent <= 'z')
329  {
330  digit = chCurrent - 'a' + 10;
331  }
332  else
333  {
334  digit = -1;
335  }
336 
337  if (digit < 0 || digit >= (int)base) break;
338 
339  RunningTotal = RunningTotal * base + digit;
340  str++;
341  }
342 
343  *value = bMinus ? (0 - RunningTotal) : RunningTotal;
344  return STATUS_SUCCESS;
345 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char CHAR
Definition: xmlstorage.h:175
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by CsrParseServerCommandLine(), CsrSrvCreateSharedSection(), ExtractFont(), get_res_nameA(), and LdrpSnapThunk().

◆ RtlCompareString()

LONG NTAPI RtlCompareString ( IN const STRING s1,
IN const STRING s2,
IN BOOLEAN  CaseInsensitive 
)

Definition at line 352 of file unicode.c.

356 {
357  unsigned int len;
358  LONG ret = 0;
359  LPCSTR p1, p2;
360 
361  len = min(s1->Length, s2->Length);
362  p1 = s1->Buffer;
363  p2 = s2->Buffer;
364 
365  if (CaseInsensitive)
366  {
367  while (!ret && len--)
368  ret = RtlUpperChar(*p1++) - RtlUpperChar(*p2++);
369  }
370  else
371  {
372  while (!ret && len--) ret = *p1++ - *p2++;
373  }
374 
375  if (!ret) ret = s1->Length - s2->Length;
376 
377  return ret;
378 }
struct S2 s2
long LONG
Definition: pedump.c:60
_In_ const STRING _In_ BOOLEAN CaseInsensitive
Definition: rtlfuncs.h:2261
const char * LPCSTR
Definition: xmlstorage.h:183
struct S1 s1
NTSYSAPI CHAR NTAPI RtlUpperChar(CHAR Character)
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define min(a, b)
Definition: monoChain.cc:55

Referenced by RtlEqualString().

◆ RtlCompareUnicodeString()

LONG NTAPI RtlCompareUnicodeString ( IN PCUNICODE_STRING  s1,
IN PCUNICODE_STRING  s2,
IN BOOLEAN  CaseInsensitive 
)

Definition at line 2184 of file unicode.c.

2188 {
2189  unsigned int len;
2190  LONG ret = 0;
2191  LPCWSTR p1, p2;
2192 
2193  len = min(s1->Length, s2->Length) / sizeof(WCHAR);
2194  p1 = s1->Buffer;
2195  p2 = s2->Buffer;
2196 
2197  if (CaseInsensitive)
2198  {
2199  while (!ret && len--) ret = RtlpUpcaseUnicodeChar(*p1++) - RtlpUpcaseUnicodeChar(*p2++);
2200  }
2201  else
2202  {
2203  while (!ret && len--) ret = *p1++ - *p2++;
2204  }
2205 
2206  if (!ret) ret = s1->Length - s2->Length;
2207 
2208  return ret;
2209 }
struct S2 s2
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
long LONG
Definition: pedump.c:60
_In_ const STRING _In_ BOOLEAN CaseInsensitive
Definition: rtlfuncs.h:2261
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct S1 s1
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define min(a, b)
Definition: monoChain.cc:55
WCHAR NTAPI RtlpUpcaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:715

Referenced by RtlEqualUnicodeString().

◆ RtlCopyString()

VOID NTAPI RtlCopyString ( IN OUT PSTRING  DestinationString,
IN const STRING *SourceString  OPTIONAL 
)

Definition at line 2216 of file unicode.c.

2219 {
2220  ULONG SourceLength;
2221  PCHAR p1, p2;
2222 
2223  /* Check if there was no source given */
2224  if(!SourceString)
2225  {
2226  /* Simply return an empty string */
2228  }
2229  else
2230  {
2231  /* Choose the smallest length */
2232  SourceLength = min(DestinationString->MaximumLength,
2233  SourceString->Length);
2234 
2235  /* Set it */
2236  DestinationString->Length = (USHORT)SourceLength;
2237 
2238  /* Save the pointers to each buffer */
2239  p1 = DestinationString->Buffer;
2240  p2 = SourceString->Buffer;
2241 
2242  /* Loop the buffer */
2243  while (SourceLength)
2244  {
2245  /* Copy the character and move on */
2246  *p1++ = * p2++;
2247  SourceLength--;
2248  }
2249  }
2250 }
signed char * PCHAR
Definition: retypes.h:7
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1869
unsigned short USHORT
Definition: pedump.c:61
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
unsigned short MaximumLength
Definition: sprintf.c:452

◆ RtlCopyUnicodeString()

VOID NTAPI RtlCopyUnicodeString ( IN OUT PUNICODE_STRING  DestinationString,
IN PCUNICODE_STRING  SourceString 
)

Definition at line 2257 of file unicode.c.

2260 {
2261  ULONG SourceLength;
2262 
2263  if(SourceString == NULL)
2264  {
2266  }
2267  else
2268  {
2269  SourceLength = min(DestinationString->MaximumLength,
2270  SourceString->Length);
2271  DestinationString->Length = (USHORT)SourceLength;
2272 
2275  SourceLength);
2276 
2278  {
2279  DestinationString->Buffer[SourceLength / sizeof(WCHAR)] = UNICODE_NULL;
2280  }
2281  }
2282 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
#define UNICODE_NULL
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1869
unsigned short USHORT
Definition: pedump.c:61
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
unsigned short MaximumLength
Definition: sprintf.c:452

◆ RtlCreateUnicodeString()

BOOLEAN NTAPI RtlCreateUnicodeString ( IN OUT PUNICODE_STRING  UniDest,
IN PCWSTR  Source 
)

Definition at line 2292 of file unicode.c.

2295 {
2296  SIZE_T Size;
2297  PAGED_CODE_RTL();
2298 
2299  Size = (wcslen(Source) + 1) * sizeof(WCHAR);
2300  if (Size > MAXUSHORT) return FALSE;
2301 
2302  UniDest->Buffer = RtlpAllocateStringMemory((ULONG)Size, TAG_USTR);
2303 
2304  if (UniDest->Buffer == NULL) return FALSE;
2305 
2306  RtlCopyMemory(UniDest->Buffer, Source, Size);
2307  UniDest->MaximumLength = (USHORT)Size;
2308  UniDest->Length = (USHORT)Size - sizeof (WCHAR);
2309 
2310  return TRUE;
2311 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define TAG_USTR
Definition: libsupp.c:111
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned short USHORT
Definition: pedump.c:61
#define MAXUSHORT
Definition: typedefs.h:81
unsigned int ULONG
Definition: retypes.h:1
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ RtlCreateUnicodeStringFromAsciiz()

BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz ( OUT PUNICODE_STRING  Destination,
IN PCSZ  Source 
)

Definition at line 2318 of file unicode.c.

2321 {
2323  NTSTATUS Status;
2324 
2326 
2328  &AnsiString,
2329  TRUE);
2330 
2331  return NT_SUCCESS(Status);
2332 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING UniDest, IN PANSI_STRING AnsiSource, IN BOOLEAN AllocateDestinationString)
Definition: unicode.c:91
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2891
VOID NTAPI RtlInitAnsiString(IN OUT PANSI_STRING DestinationString, IN PCSZ SourceString)
Definition: unicode.c:562
Status
Definition: gdiplustypes.h:24
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167

◆ RtlDnsHostNameToComputerName()

NTSTATUS NTAPI RtlDnsHostNameToComputerName ( PUNICODE_STRING  ComputerName,
PUNICODE_STRING  DnsHostName,
BOOLEAN  AllocateComputerNameString 
)

Definition at line 2728 of file unicode.c.

2729 {
2730  NTSTATUS Status;
2731  ULONG Length;
2732  ULONG ComputerNameLength;
2733  ULONG ComputerNameOemNLength;
2734  OEM_STRING ComputerNameOem;
2735  CHAR ComputerNameOemN[MAX_COMPUTERNAME_LENGTH + 1];
2736 
2738  ComputerNameLength = DnsHostName->Length;
2739 
2740  /* find the first dot in the dns host name */
2741  for (Length = 0; Length < DnsHostName->Length / sizeof(WCHAR); Length++)
2742  {
2743  if (DnsHostName->Buffer[Length] == L'.')
2744  {
2745  /* dot found, so set the length for the oem translation */
2746  ComputerNameLength = Length * sizeof(WCHAR);
2747  break;
2748  }
2749  }
2750 
2751  /* the computername must have one character */
2752  if (ComputerNameLength > 0)
2753  {
2754  ComputerNameOemNLength = 0;
2755  /* convert to oem string and use uppercase letters */
2756  Status = RtlUpcaseUnicodeToOemN(ComputerNameOemN,
2758  &ComputerNameOemNLength,
2759  DnsHostName->Buffer,
2760  ComputerNameLength);
2761 
2762  /* status STATUS_BUFFER_OVERFLOW is not a problem since the computername shoud only
2763  have MAX_COMPUTERNAME_LENGTH characters */
2764  if ((Status == STATUS_SUCCESS) ||
2766  {
2767  /* set the termination for the oem string */
2768  ComputerNameOemN[MAX_COMPUTERNAME_LENGTH] = 0;
2769  /* set status for the case the next function failed */
2771  /* fillup the oem string structure with the converted computername
2772  and check it for unmapped characters */
2773  ComputerNameOem.Buffer = ComputerNameOemN;
2774  ComputerNameOem.Length = (USHORT)ComputerNameOemNLength;
2775  ComputerNameOem.MaximumLength = (USHORT)(MAX_COMPUTERNAME_LENGTH + 1);
2776 
2777  if (RtlpDidUnicodeToOemWork(DnsHostName, &ComputerNameOem))
2778  {
2779  /* no unmapped character so convert it back to an unicode string */
2780  Status = RtlOemStringToUnicodeString(ComputerName,
2781  &ComputerNameOem,
2782  AllocateComputerNameString);
2783  }
2784  }
2785  }
2786 
2787  return Status;
2788 }
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI RtlOemStringToUnicodeString(IN OUT PUNICODE_STRING UniDest, IN PCOEM_STRING OemSource, IN BOOLEAN AllocateDestinationString)
Definition: unicode.c:1169
STRING OEM_STRING
Definition: umtypes.h:203
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSYSAPI NTSTATUS NTAPI RtlUpcaseUnicodeToOemN(PCHAR OemString, ULONG OemSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN NTAPI RtlpDidUnicodeToOemWork(IN PCUNICODE_STRING UnicodeString, IN POEM_STRING OemString)
Definition: unicode.c:472
Status
Definition: gdiplustypes.h:24
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define STATUS_INVALID_COMPUTER_NAME
Definition: ntstatus.h:512

◆ RtlDowncaseUnicodeString()

NTSTATUS NTAPI RtlDowncaseUnicodeString ( IN OUT PUNICODE_STRING  UniDest,
IN PCUNICODE_STRING  UniSource,
IN BOOLEAN  AllocateDestinationString 
)

Definition at line 2344 of file unicode.c.

2348 {
2349  ULONG i;
2350  ULONG StopGap;
2351  PAGED_CODE_RTL();
2352 
2354  {
2355  UniDest->MaximumLength = UniSource->Length;
2356  UniDest->Buffer = RtlpAllocateStringMemory(UniSource->Length, TAG_USTR);
2357  if (UniDest->Buffer == NULL) return STATUS_NO_MEMORY;
2358  }
2359  else if (UniSource->Length > UniDest->MaximumLength)
2360  {
2361  return STATUS_BUFFER_OVERFLOW;
2362  }
2363 
2364  UniDest->Length = UniSource->Length;
2365  StopGap = UniSource->Length / sizeof(WCHAR);
2366 
2367  for (i = 0 ; i < StopGap; i++)
2368  {
2369  if (UniSource->Buffer[i] < L'A')
2370  {
2371  UniDest->Buffer[i] = UniSource->Buffer[i];
2372  }
2373  else if (UniSource->Buffer[i] <= L'Z')
2374  {
2375  UniDest->Buffer[i] = (UniSource->Buffer[i] + (L'a' - L'A'));
2376  }
2377  else
2378  {
2379  UniDest->Buffer[i] = RtlpDowncaseUnicodeChar(UniSource->Buffer[i]);
2380  }
2381  }
2382 
2383  return STATUS_SUCCESS;
2384 }
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
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
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
#define TAG_USTR
Definition: libsupp.c:111
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
unsigned int ULONG
Definition: retypes.h:1
WCHAR NTAPI RtlpDowncaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:89
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1321
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlDuplicateUnicodeString()

NTSTATUS NTAPI RtlDuplicateUnicodeString ( IN ULONG  Flags,
IN PCUNICODE_STRING  SourceString,
OUT PUNICODE_STRING  DestinationString 
)

Definition at line 2492 of file unicode.c.

2496 {
2497  PAGED_CODE_RTL();
2498 
2499  if (SourceString == NULL || DestinationString == NULL ||
2503  {
2504  return STATUS_INVALID_PARAMETER;
2505  }
2506 
2507 
2508  if ((SourceString->Length == 0) &&
2511  {
2515  }
2516  else
2517  {
2518  UINT DestMaxLength = SourceString->Length;
2519 
2521  DestMaxLength += sizeof(UNICODE_NULL);
2522 
2524 
2525  if (DestinationString->Buffer == NULL)
2526  return STATUS_NO_MEMORY;
2527 
2530  DestinationString->MaximumLength = DestMaxLength;
2531 
2534  }
2535 
2536  return STATUS_SUCCESS;
2537 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING
Definition: green.h:16
unsigned short Length
Definition: sprintf.c:451
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
void * Buffer
Definition: sprintf.c:453
#define UNICODE_NULL
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1869
#define TAG_USTR
Definition: libsupp.c:111
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
unsigned int UINT
Definition: ndis.h:50
return STATUS_SUCCESS
Definition: btrfs.c:2966
unsigned short MaximumLength
Definition: sprintf.c:452

◆ RtlEqualComputerName()

BOOLEAN NTAPI RtlEqualComputerName ( IN PUNICODE_STRING  ComputerName1,
IN PUNICODE_STRING  ComputerName2 
)

Definition at line 1532 of file unicode.c.

1535 {
1536  OEM_STRING OemString1;
1537  OEM_STRING OemString2;
1538  BOOLEAN Result = FALSE;
1539 
1541  ComputerName1,
1542  TRUE)))
1543  {
1545  ComputerName2,
1546  TRUE)))
1547  {
1548  Result = RtlEqualString(&OemString1, &OemString2, FALSE);
1549  RtlFreeOemString(&OemString2);
1550  }
1551 
1552  RtlFreeOemString(&OemString1);
1553  }
1554 
1555  return Result;
1556 }
#define TRUE
Definition: types.h:120
VOID NTAPI RtlFreeOemString(IN POEM_STRING OemString)
Definition: unicode.c:435
STRING OEM_STRING
Definition: umtypes.h:203
BOOLEAN NTAPI RtlEqualString(IN const STRING *s1, IN const STRING *s2, IN BOOLEAN CaseInsensitive)
Definition: unicode.c:388
unsigned char BOOLEAN
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI RtlUpcaseUnicodeStringToOemString(IN OUT POEM_STRING OemDest, IN PCUNICODE_STRING UniSource, IN BOOLEAN AllocateDestinationString)
Definition: unicode.c:2055

Referenced by RtlEqualDomainName().

◆ RtlEqualDomainName()

BOOLEAN NTAPI RtlEqualDomainName ( IN PUNICODE_STRING  DomainName1,
IN PUNICODE_STRING  DomainName2 
)

Definition at line 1569 of file unicode.c.

1572 {
1573  return RtlEqualComputerName(DomainName1, DomainName2);
1574 }
BOOLEAN NTAPI RtlEqualComputerName(IN PUNICODE_STRING ComputerName1, IN PUNICODE_STRING ComputerName2)
Definition: unicode.c:1532

◆ RtlEqualString()

BOOLEAN NTAPI RtlEqualString ( IN const STRING s1,
IN const STRING s2,
IN BOOLEAN  CaseInsensitive 
)

Definition at line 388 of file unicode.c.

392 {
393  if (s1->Length != s2->Length) return FALSE;
395 }
struct S2 s2
_In_ const STRING _In_ BOOLEAN CaseInsensitive
Definition: rtlfuncs.h:2261
struct S1 s1
LONG NTAPI RtlCompareString(IN const STRING *s1, IN const STRING *s2, IN BOOLEAN CaseInsensitive)
Definition: unicode.c:352

Referenced by RtlEqualComputerName().

◆ RtlEqualUnicodeString()

BOOLEAN NTAPI RtlEqualUnicodeString ( IN CONST UNICODE_STRING s1,
IN CONST UNICODE_STRING s2,
IN BOOLEAN  CaseInsensitive 
)

Definition at line 405 of file unicode.c.

409 {
410  if (s1->Length != s2->Length) return FALSE;
412 }
struct S2 s2
LONG NTAPI RtlCompareUnicodeString(IN PCUNICODE_STRING s1, IN PCUNICODE_STRING s2, IN BOOLEAN CaseInsensitive)
Definition: unicode.c:2184
_In_ const STRING _In_ BOOLEAN CaseInsensitive
Definition: rtlfuncs.h:2261
struct S1 s1

◆ RtlEraseUnicodeString()

VOID NTAPI RtlEraseUnicodeString ( IN PUNICODE_STRING  String)

Definition at line 1712 of file unicode.c.

1714 {
1715  if (String->Buffer && String->MaximumLength)
1716  {
1717  RtlZeroMemory(String->Buffer, String->MaximumLength);
1718  String->Length = 0;
1719  }
1720 }
static WCHAR String[]
Definition: stringtable.c:55
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

◆ RtlFindCharInUnicodeString()

NTSTATUS NTAPI RtlFindCharInUnicodeString ( IN ULONG  Flags,
IN PCUNICODE_STRING  SearchString,
IN PCUNICODE_STRING  MatchString,
OUT PUSHORT  Position 
)

Definition at line 2663 of file unicode.c.

2668 {
2669  BOOLEAN Found;
2670  const BOOLEAN WantToFind = (Flags & RTL_FIND_CHAR_IN_UNICODE_STRING_COMPLEMENT_CHAR_SET) == 0;
2671  const BOOLEAN CaseInSensitive = (Flags & RTL_FIND_CHAR_IN_UNICODE_STRING_CASE_INSENSITIVE) != 0;
2672  USHORT i, Length;
2673 
2674  DPRINT("RtlFindCharInUnicodeString(%u, '%wZ', '%wZ', %p)\n",
2675  Flags, SearchString, MatchString, Position);
2676 
2677  /* Parameter checks */
2678  if (Position == NULL)
2679  return STATUS_INVALID_PARAMETER;
2680 
2681  *Position = 0;
2682 
2683  if (Flags & ~(RTL_FIND_CHAR_IN_UNICODE_STRING_START_AT_END |
2684  RTL_FIND_CHAR_IN_UNICODE_STRING_COMPLEMENT_CHAR_SET |
2685  RTL_FIND_CHAR_IN_UNICODE_STRING_CASE_INSENSITIVE))
2686  return STATUS_INVALID_PARAMETER;
2687 
2688  /* Search */
2689  Length = SearchString->Length / sizeof(WCHAR);
2690  if (Flags & RTL_FIND_CHAR_IN_UNICODE_STRING_START_AT_END)
2691  {
2692  for (i = Length - 1; (SHORT)i >= 0; i--)
2693  {
2694  Found = RtlpIsCharInUnicodeString(SearchString->Buffer[i], MatchString, CaseInSensitive);
2695  if (Found == WantToFind)
2696  {
2697  *Position = i * sizeof(WCHAR);
2698  return STATUS_SUCCESS;
2699  }
2700  }
2701  }
2702  else
2703  {
2704  for (i = 0; i < Length; i++)
2705  {
2706  Found = RtlpIsCharInUnicodeString(SearchString->Buffer[i], MatchString, CaseInSensitive);
2707  if (Found == WantToFind)
2708  {
2709  *Position = (i + 1) * sizeof(WCHAR);
2710  return STATUS_SUCCESS;
2711  }
2712  }
2713  }
2714 
2715  return STATUS_NOT_FOUND;
2716 }
static BOOLEAN RtlpIsCharInUnicodeString(IN WCHAR Char, IN PCUNICODE_STRING MatchString, IN BOOLEAN CaseInSensitive)
Definition: unicode.c:2635
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static COORD Position
Definition: mouse.c:34
_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
_In_ const STRING _In_ BOOLEAN CaseInSensitive
Definition: rtlfuncs.h:2292
short SHORT
Definition: pedump.c:59
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
return Found
Definition: dirsup.c:1270
#define STATUS_NOT_FOUND
Definition: shellext.h:67
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned short USHORT
Definition: pedump.c:61
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlFreeAnsiString()

VOID NTAPI RtlFreeAnsiString ( IN PANSI_STRING  AnsiString)

Definition at line 419 of file unicode.c.

420 {
421  PAGED_CODE_RTL();
422 
423  if (AnsiString->Buffer)
424  {
427  }
428 }
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define RtlpFreeStringMemory
Definition: rtlp.h:141
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define TAG_ASTR
Definition: libsupp.c:112

◆ RtlFreeOemString()

VOID NTAPI RtlFreeOemString ( IN POEM_STRING  OemString)

Definition at line 435 of file unicode.c.

436 {
437  PAGED_CODE_RTL();
438 
439  if (OemString->Buffer) RtlpFreeStringMemory(OemString->Buffer, TAG_OSTR);
440 }
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1561
#define TAG_OSTR
Definition: inbv.c:13
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define RtlpFreeStringMemory
Definition: rtlp.h:141

Referenced by RtlEqualComputerName().

◆ RtlFreeUnicodeString()

VOID NTAPI RtlFreeUnicodeString ( IN PUNICODE_STRING  UnicodeString)

Definition at line 447 of file unicode.c.

448 {
449  PAGED_CODE_RTL();
450 
451  if (UnicodeString->Buffer)
452  {
455  }
456 }
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define RtlpFreeStringMemory
Definition: rtlp.h:141
#define TAG_USTR
Definition: libsupp.c:111
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

◆ RtlGUIDFromString()

NTSTATUS NTAPI RtlGUIDFromString ( IN UNICODE_STRING str,
OUT GUID guid 
)

Definition at line 1596 of file unicode.c.

1599 {
1600  int i = 0;
1601  const WCHAR *lpszCLSID = str->Buffer;
1602  BYTE* lpOut = (BYTE*)guid;
1603 
1604  //TRACE("(%s,%p)\n", debugstr_us(str), guid);
1605 
1606  /* Convert string: {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
1607  * to memory: DWORD... WORD WORD BYTES............
1608  */
1609  while (i <= 37)
1610  {
1611  switch (i)
1612  {
1613  case 0:
1614  if (*lpszCLSID != '{')
1615  return STATUS_INVALID_PARAMETER;
1616  break;
1617 
1618  case 9:
1619  case 14:
1620  case 19:
1621  case 24:
1622  if (*lpszCLSID != '-')
1623  return STATUS_INVALID_PARAMETER;
1624  break;
1625 
1626  case 37:
1627  if (*lpszCLSID != '}')
1628  return STATUS_INVALID_PARAMETER;
1629 
1630  break;
1631 
1632  default:
1633  {
1634  WCHAR ch = *lpszCLSID, ch2 = lpszCLSID[1];
1635  unsigned char byte;
1636 
1637  /* Read two hex digits as a byte value */
1638  if (ch >= '0' && ch <= '9')
1639  ch = ch - '0';
1640  else if (ch >= 'a' && ch <= 'f')
1641  ch = ch - 'a' + 10;
1642  else if (ch >= 'A' && ch <= 'F')
1643  ch = ch - 'A' + 10;
1644  else
1645  return STATUS_INVALID_PARAMETER;
1646 
1647  if (ch2 >= '0' && ch2 <= '9')
1648  ch2 = ch2 - '0';
1649  else if (ch2 >= 'a' && ch2 <= 'f')
1650  ch2 = ch2 - 'a' + 10;
1651  else if (ch2 >= 'A' && ch2 <= 'F')
1652  ch2 = ch2 - 'A' + 10;
1653  else
1654  return STATUS_INVALID_PARAMETER;
1655 
1656  byte = ch << 4 | ch2;
1657 
1658  switch (i)
1659  {
1660 #ifndef WORDS_BIGENDIAN
1661  /* For Big Endian machines, we store the data such that the
1662  * dword/word members can be read as DWORDS and WORDS correctly. */
1663  /* Dword */
1664  case 1:
1665  lpOut[3] = byte;
1666  break;
1667  case 3:
1668  lpOut[2] = byte;
1669  break;
1670  case 5:
1671  lpOut[1] = byte;
1672  break;
1673  case 7:
1674  lpOut[0] = byte;
1675  lpOut += 4;
1676  break;
1677  /* Word */
1678  case 10:
1679  case 15:
1680  lpOut[1] = byte;
1681  break;
1682  case 12:
1683  case 17:
1684  lpOut[0] = byte;
1685  lpOut += 2;
1686  break;
1687 #endif
1688  /* Byte */
1689  default:
1690  lpOut[0] = byte;
1691  lpOut++;
1692  break;
1693  }
1694 
1695  lpszCLSID++; /* Skip 2nd character of byte */
1696  i++;
1697  }
1698  }
1699 
1700  lpszCLSID++;
1701  i++;
1702  }
1703 
1704  return STATUS_SUCCESS;
1705 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
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
const GUID * guid
const WCHAR * str
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: mem.h:68
#define byte(x, n)
Definition: tomcrypt.h:118
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlHashUnicodeString()

NTSTATUS NTAPI RtlHashUnicodeString ( IN CONST UNICODE_STRING String,
IN BOOLEAN  CaseInSensitive,
IN ULONG  HashAlgorithm,
OUT PULONG  HashValue 
)

Definition at line 1727 of file unicode.c.

1732 {
1733  if (String != NULL && HashValue != NULL)
1734  {
1735  switch (HashAlgorithm)
1736  {
1739  {
1740  WCHAR *c, *end;
1741 
1742  *HashValue = 0;
1743  end = String->Buffer + (String->Length / sizeof(WCHAR));
1744 
1745  if (CaseInSensitive)
1746  {
1747  for (c = String->Buffer; c != end; c++)
1748  {
1749  /* only uppercase characters if they are 'a' ... 'z'! */
1750  *HashValue = ((65599 * (*HashValue)) +
1751  (ULONG)(((*c) >= L'a' && (*c) <= L'z') ?
1752  (*c) - L'a' + L'A' : (*c)));
1753  }
1754  }
1755  else
1756  {
1757  for (c = String->Buffer; c != end; c++)
1758  {
1759  *HashValue = ((65599 * (*HashValue)) + (ULONG)(*c));
1760  }
1761  }
1762 
1763  return STATUS_SUCCESS;
1764  }
1765  }
1766  }
1767 
1768  return STATUS_INVALID_PARAMETER;
1769 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ BOOLEAN _In_ ULONG HashAlgorithm
Definition: rtlfuncs.h:2039
_In_ BOOLEAN _In_ ULONG _Out_ PULONG HashValue
Definition: rtlfuncs.h:2039
static WCHAR String[]
Definition: stringtable.c:55
GLuint GLuint end
Definition: gl.h:1545
_In_ const STRING _In_ BOOLEAN CaseInSensitive
Definition: rtlfuncs.h:2292
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
const GLubyte * c
Definition: glext.h:8905
static const WCHAR L[]
Definition: oid.c:1250
#define HASH_STRING_ALGORITHM_DEFAULT
#define c
Definition: ke_i.h:80
unsigned int ULONG
Definition: retypes.h:1
#define HASH_STRING_ALGORITHM_X65599
Definition: rtlstr.c:33
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlInitAnsiString()

VOID NTAPI RtlInitAnsiString ( IN OUT PANSI_STRING  DestinationString,
IN PCSZ  SourceString 
)

Definition at line 562 of file unicode.c.

564 {
565  SIZE_T Size;
566 
567  if (SourceString)
568  {
570  if (Size > (MAXUSHORT - sizeof(CHAR))) Size = MAXUSHORT - sizeof(CHAR);
573  }
574  else
575  {
578  }
579 
581 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
#define PCHAR
Definition: match.c:90
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1869
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned short USHORT
Definition: pedump.c:61
#define MAXUSHORT
Definition: typedefs.h:81
unsigned short MaximumLength
Definition: sprintf.c:452
#define CHAR(Char)

Referenced by RtlCreateUnicodeStringFromAsciiz(), and RtlInitString().

◆ RtlInitAnsiStringEx()

NTSTATUS NTAPI RtlInitAnsiStringEx ( IN OUT PANSI_STRING  DestinationString,
IN PCSZ  SourceString 
)

Definition at line 585 of file unicode.c.

587 {
588  SIZE_T Size;
589 
590  if (SourceString)
591  {
593  if (Size > (MAXUSHORT - sizeof(CHAR))) return STATUS_NAME_TOO_LONG;
596  }
597  else
598  {
601  }
602 
604  return STATUS_SUCCESS;
605 
606 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
#define STATUS_NAME_TOO_LONG
Definition: ntstatus.h:484
#define PCHAR
Definition: match.c:90
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1869
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned short USHORT
Definition: pedump.c:61
#define MAXUSHORT
Definition: typedefs.h:81
return STATUS_SUCCESS
Definition: btrfs.c:2966
unsigned short MaximumLength
Definition: sprintf.c:452

◆ RtlInitString()

VOID NTAPI RtlInitString ( IN OUT PSTRING  DestinationString,
IN PCSZ  SourceString 
)

Definition at line 615 of file unicode.c.

618 {
620 }
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
VOID NTAPI RtlInitAnsiString(IN OUT PANSI_STRING DestinationString, IN PCSZ SourceString)
Definition: unicode.c:562
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1869

◆ RtlInitUnicodeString()

VOID NTAPI RtlInitUnicodeString ( IN OUT PUNICODE_STRING  DestinationString,
IN PCWSTR  SourceString 
)

Definition at line 630 of file unicode.c.

633 {
634  SIZE_T Size;
635  CONST SIZE_T MaxSize = (MAXUSHORT & ~1) - sizeof(UNICODE_NULL); // an even number
636 
637  if (SourceString)
638  {
639  Size = wcslen(SourceString) * sizeof(WCHAR);
640  __analysis_assume(Size <= MaxSize);
641 
642  if (Size > MaxSize)
643  Size = MaxSize;
646  }
647  else
648  {
651  }
652 
654 }
unsigned short Length
Definition: sprintf.c:451
uint16_t * PWCHAR
Definition: typedefs.h:54
void * Buffer
Definition: sprintf.c:453
#define UNICODE_NULL
#define __analysis_assume(expr)
Definition: sal.h:2893
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1869
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned short USHORT
Definition: pedump.c:61
#define MAXUSHORT
Definition: typedefs.h:81
unsigned short MaximumLength
Definition: sprintf.c:452
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define CONST
Definition: pedump.c:81

Referenced by RtlAppendUnicodeToString().

◆ RtlInitUnicodeStringEx()

NTSTATUS NTAPI RtlInitUnicodeStringEx ( OUT PUNICODE_STRING  DestinationString,
IN PCWSTR  SourceString 
)

Definition at line 661 of file unicode.c.

664 {
665  SIZE_T Size;
666  CONST SIZE_T MaxSize = (MAXUSHORT & ~1) - sizeof(WCHAR); // an even number
667 
668  if (SourceString)
669  {
670  Size = wcslen(SourceString) * sizeof(WCHAR);
671  if (Size > MaxSize) return STATUS_NAME_TOO_LONG;
674  }
675  else
676  {
679  }
680 
682  return STATUS_SUCCESS;
683 }
unsigned short Length
Definition: sprintf.c:451
uint16_t * PWCHAR
Definition: typedefs.h:54
void * Buffer
Definition: sprintf.c:453
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
#define STATUS_NAME_TOO_LONG
Definition: ntstatus.h:484
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1869
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned short USHORT
Definition: pedump.c:61
#define MAXUSHORT
Definition: typedefs.h:81
return STATUS_SUCCESS
Definition: btrfs.c:2966
unsigned short MaximumLength
Definition: sprintf.c:452
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define CONST
Definition: pedump.c:81

◆ RtlInt64ToUnicodeString()

NTSTATUS NTAPI RtlInt64ToUnicodeString ( IN ULONGLONG  Value,
IN ULONG Base  OPTIONAL,
IN OUT PUNICODE_STRING  String 
)

Definition at line 842 of file unicode.c.

846 {
847  LARGE_INTEGER LargeInt;
849  CHAR Buffer[65];
851 
852  LargeInt.QuadPart = Value;
853 
854  Status = RtlLargeIntegerToChar(&LargeInt, Base, sizeof(Buffer), Buffer);
855  if (NT_SUCCESS(Status))
856  {
857  AnsiString.Buffer = Buffer;
858  AnsiString.Length = (USHORT)strlen(Buffer);
859  AnsiString.MaximumLength = sizeof(Buffer);
860 
862  }
863 
864  return Status;
865 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2343
static WCHAR String[]
Definition: stringtable.c:55
NTSTATUS NTAPI RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING UniDest, IN PANSI_STRING AnsiSource, IN BOOLEAN AllocateDestinationString)
Definition: unicode.c:91
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI RtlLargeIntegerToChar(IN PLARGE_INTEGER Value, IN ULONG Base, IN ULONG Length, IN OUT PCHAR String)
Definition: unicode.c:1846
Status
Definition: gdiplustypes.h:24
unsigned short USHORT
Definition: pedump.c:61
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
LONGLONG QuadPart
Definition: typedefs.h:112

◆ RtlIntegerToChar()

NTSTATUS NTAPI RtlIntegerToChar ( ULONG  value,
ULONG  base,
ULONG  length,
PCHAR  str 
)

Definition at line 693 of file unicode.c.

698 {
699  CHAR buffer[33];
700  PCHAR pos;
701  CHAR digit;
702  SIZE_T len;
703 
704  if (base == 0)
705  {
706  base = 10;
707  }
708  else if (base != 2 && base != 8 && base != 10 && base != 16)
709  {
711  }
712 
713  pos = &buffer[32];
714  *pos = '\0';
715 
716  do
717  {
718  pos--;
719  digit = (CHAR)(value % base);
720  value = value / base;
721 
722  if (digit < 10)
723  {
724  *pos = '0' + digit;
725  }
726  else
727  {
728  *pos = 'A' + digit - 10;
729  }
730  }
731  while (value != 0L);
732 
733  len = &buffer[32] - pos;
734 
735  if (len > length)
736  {
737  return STATUS_BUFFER_OVERFLOW;
738  }
739  else if (str == NULL)
740  {
742  }
743  else if (len == length)
744  {
746  }
747  else
748  {
749  RtlCopyMemory(str, pos, len + 1);
750  }
751 
752  return STATUS_SUCCESS;
753 }
signed char * PCHAR
Definition: retypes.h:7
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char CHAR
Definition: xmlstorage.h:175
GLuint buffer
Definition: glext.h:5915
GLuint base
Definition: 3dtext.c:35
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define CHAR(Char)

Referenced by RtlIntegerToUnicodeString().

◆ RtlIntegerToUnicode()

NTSTATUS NTAPI RtlIntegerToUnicode ( IN ULONG  Value,
IN ULONG Base  OPTIONAL,
IN ULONG Length  OPTIONAL,
IN OUT LPWSTR  String 
)

Definition at line 760 of file unicode.c.

765 {
766  ULONG Radix;
767  WCHAR temp[33];
768  ULONG v = Value;
769  ULONG i;
770  PWCHAR tp;
771  PWCHAR sp;
772 
773  Radix = Base;
774 
775  if (Radix == 0) Radix = 10;
776 
777  if ((Radix != 2) && (Radix != 8) &&
778  (Radix != 10) && (Radix != 16))
779  {
781  }
782 
783  tp = temp;
784 
785  while (v || tp == temp)
786  {
787  i = v % Radix;
788  v = v / Radix;
789 
790  if (i < 10) *tp = (WCHAR)(i + L'0');
791  else *tp = (WCHAR)(i + L'a' - 10);
792 
793  tp++;
794  }
795 
796  if ((ULONG)((ULONG_PTR)tp - (ULONG_PTR)temp) >= Length)
797  {
799  }
800 
801  sp = String;
802 
803  while (tp > temp) *sp++ = *--tp;
804 
805  *sp = 0;
806 
807  return STATUS_SUCCESS;
808 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2343
static WCHAR String[]
Definition: stringtable.c:55
uint16_t * PWCHAR
Definition: typedefs.h:54
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
uint32_t ULONG_PTR
Definition: typedefs.h:63
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
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2883
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static const WCHAR L[]
Definition: oid.c:1250
const GLdouble * v
Definition: gl.h:2040
static calc_node_t temp
Definition: rpn_ieee.c:38
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
static const WCHAR sp[]
Definition: suminfo.c:288
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlIntegerToUnicodeString()

NTSTATUS NTAPI RtlIntegerToUnicodeString ( IN ULONG  Value,
IN ULONG Base  OPTIONAL,
IN OUT PUNICODE_STRING  String 
)

Definition at line 815 of file unicode.c.

819 {
821  CHAR Buffer[33];
823 
825  if (NT_SUCCESS(Status))
826  {
827  AnsiString.Buffer = Buffer;
828  AnsiString.Length = (USHORT)strlen(Buffer);
829  AnsiString.MaximumLength = sizeof(Buffer);
830 
832  }
833 
834  return Status;
835 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2343
static WCHAR String[]
Definition: stringtable.c:55
NTSTATUS NTAPI RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING UniDest, IN PANSI_STRING AnsiSource, IN BOOLEAN AllocateDestinationString)
Definition: unicode.c:91
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI RtlIntegerToChar(ULONG value, ULONG base, ULONG length, PCHAR str)
Definition: unicode.c:693
unsigned short USHORT
Definition: pedump.c:61
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ RtlIsTextUnicode()

BOOLEAN NTAPI RtlIsTextUnicode ( CONST VOID buf,
INT  len,
INT pf 
)

Definition at line 1279 of file unicode.c.

1280 {
1281  static const WCHAR std_control_chars[] = {'\r', '\n', '\t', ' ', 0x3000, 0};
1282  static const WCHAR byterev_control_chars[] = {0x0d00, 0x0a00, 0x0900, 0x2000, 0};
1283  const WCHAR *s = buf;
1284  int i;
1285  unsigned int flags = MAXULONG, out_flags = 0;
1286  UCHAR last_lo_byte = 0;
1287  UCHAR last_hi_byte = 0;
1288  ULONG hi_byte_diff = 0;
1289  ULONG lo_byte_diff = 0;
1290  ULONG weight = 3;
1291  ULONG lead_byte = 0;
1292 
1293  if (len < sizeof(WCHAR))
1294  {
1295  /* FIXME: MSDN documents IS_TEXT_UNICODE_BUFFER_TOO_SMALL but there is no such thing... */
1296  if (pf) *pf = 0;
1297 
1298  return FALSE;
1299  }
1300 
1301  if (pf)
1302  flags = *pf;
1303 
1304  /*
1305  * Apply various tests to the text string. According to the
1306  * docs, each test "passed" sets the corresponding flag in
1307  * the output flags. But some of the tests are mutually
1308  * exclusive, so I don't see how you could pass all tests ...
1309  */
1310 
1311  /* Check for an odd length ... pass if even. */
1312  if (len & 1) out_flags |= IS_TEXT_UNICODE_ODD_LENGTH;
1313 
1314  if (((char *)buf)[len - 1] == 0)
1315  len--; /* Windows seems to do something like that to avoid e.g. false IS_TEXT_UNICODE_NULL_BYTES */
1316 
1317  len /= sizeof(WCHAR);
1318 
1319  /* Windows only checks the first 256 characters */
1320  if (len > 256) len = 256;
1321 
1322  /* Check for the special byte order unicode marks. */
1323  if (*s == 0xFEFF) out_flags |= IS_TEXT_UNICODE_SIGNATURE;
1324  if (*s == 0xFFFE) out_flags |= IS_TEXT_UNICODE_REVERSE_SIGNATURE;
1325 
1326  for (i = 0; i < len; i++)
1327  {
1328  UCHAR lo_byte = LOBYTE(s[i]);
1329  UCHAR hi_byte = HIBYTE(s[i]);
1330 
1331  lo_byte_diff += max(lo_byte, last_lo_byte) - min(lo_byte, last_lo_byte);
1332  hi_byte_diff += max(hi_byte, last_hi_byte) - min(hi_byte, last_hi_byte);
1333 
1334  last_lo_byte = lo_byte;
1335  last_hi_byte = hi_byte;
1336 
1337  switch (s[i])
1338  {
1339  case 0xFFFE: /* Reverse BOM */
1340  case UNICODE_NULL:
1341  case 0x0A0D: /* ASCII CRLF (packed into one word) */
1342  case 0xFFFF: /* Unicode 0xFFFF */
1343  out_flags |= IS_TEXT_UNICODE_ILLEGAL_CHARS;
1344  break;
1345  }
1346  }
1347 
1348  if (NlsMbCodePageTag)
1349  {
1350  for (i = 0; i < len; i++)
1351  {
1352  if (NlsLeadByteInfo[s[i]])
1353  {
1354  ++lead_byte;
1355  ++i;
1356  }
1357  }
1358 
1359  if (lead_byte)
1360  {
1361  weight = (len / 2) - 1;
1362 
1363  if (lead_byte < (weight / 3))
1364  weight = 3;
1365  else if (lead_byte < ((weight * 2) / 3))
1366  weight = 2;
1367  else
1368  weight = 1;
1369 
1370  if (pf && (*pf & IS_TEXT_UNICODE_DBCS_LEADBYTE))
1371  out_flags |= IS_TEXT_UNICODE_DBCS_LEADBYTE;
1372  }
1373  }
1374 
1375  if (lo_byte_diff < 127 && !hi_byte_diff)
1376  {
1377  out_flags |= IS_TEXT_UNICODE_ASCII16;
1378  }
1379 
1380  if (hi_byte_diff && !lo_byte_diff)
1381  {
1382  out_flags |= IS_TEXT_UNICODE_REVERSE_ASCII16;
1383  }
1384 
1385  if ((weight * lo_byte_diff) < hi_byte_diff)
1386  {
1388  }
1389 
1390  /* apply some statistical analysis */
1392  ((weight * hi_byte_diff) < lo_byte_diff))
1393  {
1394  out_flags |= IS_TEXT_UNICODE_STATISTICS;
1395  }
1396 
1397  /* Check for unicode NULL chars */
1399  {
1400  for (i = 0; i < len; i++)
1401  {
1402  if (!(s[i] & 0xff) || !(s[i] >> 8))
1403  {
1404  out_flags |= IS_TEXT_UNICODE_NULL_BYTES;
1405  break;
1406  }
1407  }
1408  }
1409 
1411  {
1412  for (i = 0; i < len; i++)
1413  {
1414  if (strchrW(std_control_chars, s[i]))
1415  {
1416  out_flags |= IS_TEXT_UNICODE_CONTROLS;
1417  break;
1418  }
1419  }
1420  }
1421 
1423  {
1424  for (i = 0; i < len; i++)
1425  {
1426  if (strchrW(byterev_control_chars, s[i]))
1427  {
1428  out_flags |= IS_TEXT_UNICODE_REVERSE_CONTROLS;
1429  break;
1430  }
1431  }
1432  }
1433 
1434  if (pf)
1435  {
1436  out_flags &= *pf;
1437  *pf = out_flags;
1438  }
1439 
1440  /* check for flags that indicate it's definitely not valid Unicode */
1442 
1443  /* now check for invalid ASCII, and assume Unicode if so */
1444  if (out_flags & IS_TEXT_UNICODE_NOT_ASCII_MASK) return TRUE;
1445 
1446  /* now check for Unicode flags */
1447  if (out_flags & IS_TEXT_UNICODE_UNICODE_MASK) return TRUE;
1448 
1449  /* no flags set */
1450  return FALSE;
1451 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define IS_TEXT_UNICODE_DBCS_LEADBYTE
Definition: winnt_old.h:929
BOOLEAN NlsMbCodePageTag
Definition: nls.c:22
#define LOBYTE(W)
Definition: jmemdos.c:487
#define IS_TEXT_UNICODE_REVERSE_STATISTICS
Definition: winnt_old.h:922
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
PUSHORT NlsLeadByteInfo
Definition: nls.c:26
#define IS_TEXT_UNICODE_NOT_ASCII_MASK
Definition: winnt_old.h:934
#define HIBYTE(W)
Definition: jmemdos.c:486
#define IS_TEXT_UNICODE_SIGNATURE
Definition: winnt_old.h:925
GLuint GLuint GLfloat weight
Definition: glext.h:11719
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
#define UNICODE_NULL
#define IS_TEXT_UNICODE_STATISTICS
Definition: winnt_old.h:921
#define IS_TEXT_UNICODE_REVERSE_ASCII16
Definition: winnt_old.h:920
#define IS_TEXT_UNICODE_REVERSE_SIGNATURE
Definition: winnt_old.h:926
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IS_TEXT_UNICODE_ODD_LENGTH
Definition: winnt_old.h:928
GLbitfield flags
Definition: glext.h:7161
unsigned char UCHAR
Definition: xmlstorage.h:181
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
#define IS_TEXT_UNICODE_REVERSE_CONTROLS
Definition: winnt_old.h:924
#define IS_TEXT_UNICODE_CONTROLS
Definition: winnt_old.h:923
#define IS_TEXT_UNICODE_ILLEGAL_CHARS
Definition: winnt_old.h:927
#define MAXULONG
Definition: typedefs.h:250
#define min(a, b)
Definition: monoChain.cc:55
#define IS_TEXT_UNICODE_REVERSE_MASK
Definition: winnt_old.h:932
unsigned int ULONG
Definition: retypes.h:1
#define IS_TEXT_UNICODE_ASCII16
Definition: winnt_old.h:919
#define IS_TEXT_UNICODE_NULL_BYTES
Definition: winnt_old.h:930
#define IS_TEXT_UNICODE_UNICODE_MASK
Definition: winnt_old.h:931
#define IS_TEXT_UNICODE_NOT_UNICODE_MASK
Definition: winnt_old.h:933

Referenced by IsTextUnicode().

◆ RtlIsValidOemCharacter()

BOOLEAN NTAPI RtlIsValidOemCharacter ( IN PWCHAR  Char)

Definition at line 514 of file unicode.c.

515 {
516  WCHAR UnicodeChar;
517  WCHAR OemChar;
518 
519  /* If multi-byte code page present */
521  {
522  USHORT Offset = 0;
523 
524  OemChar = NlsUnicodeToMbOemTable[*Char];
525 
526  /* If character has Lead Byte */
527  if (NlsOemLeadByteInfo[HIBYTE(OemChar)])
528  Offset = NlsOemLeadByteInfo[HIBYTE(OemChar)];
529 
530  /* Receive Unicode character from the table */
531  UnicodeChar = RtlpUpcaseUnicodeChar(NlsOemToUnicodeTable[LOBYTE(OemChar) + Offset]);
532 
533  /* Receive OEM character from the table */
534  OemChar = NlsUnicodeToMbOemTable[UnicodeChar];
535  }
536  else
537  {
538  /* Receive Unicode character from the table */
540 
541  /* Receive OEM character from the table */
542  OemChar = NlsUnicodeToOemTable[UnicodeChar];
543  }
544 
545  /* Not valid character, failed */
546  if (OemChar == NlsOemDefaultChar)
547  return FALSE;
548 
549  *Char = UnicodeChar;
550 
551  return TRUE;
552 }
#define TRUE
Definition: types.h:120
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
PCHAR NlsUnicodeToOemTable
Definition: nls.c:31
BOOLEAN NlsMbOemCodePageTag
Definition: nls.c:29
__wchar_t WCHAR
Definition: xmlstorage.h:180
USHORT NlsOemDefaultChar
Definition: nls.c:35
unsigned char UCHAR
Definition: xmlstorage.h:181
PUSHORT NlsOemLeadByteInfo
Definition: nls.c:33
PWCHAR NlsOemToUnicodeTable
Definition: nls.c:30
unsigned short USHORT
Definition: pedump.c:61
WCHAR NTAPI RtlpUpcaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:715
PUSHORT NlsUnicodeToMbOemTable
Definition: nls.c:32

Referenced by RtlGenerate8dot3Name(), and START_TEST().

◆ RtlLargeIntegerToChar()

NTSTATUS NTAPI RtlLargeIntegerToChar ( IN PLARGE_INTEGER  Value,
IN ULONG  Base,
IN ULONG  Length,
IN OUT PCHAR  String 
)

Definition at line 1846 of file unicode.c.

1851 {
1852  ULONGLONG Val = Value->QuadPart;
1853  CHAR Buffer[65];
1854  CHAR Digit;
1855  SIZE_T Len;
1856  PCHAR Pos;
1857 
1858  if (Base == 0) Base = 10;
1859 
1860  if ((Base != 2) && (Base != 8) && (Base != 10) && (Base != 16))
1861  {
1862  return STATUS_INVALID_PARAMETER;
1863  }
1864 
1865  Pos = &Buffer[64];
1866  *Pos = '\0';
1867 
1868  do
1869  {
1870  Pos--;
1871  Digit = (CHAR)(Val % Base);
1872  Val = Val / Base;
1873 
1874  if (Digit < 10)
1875  *Pos = '0' + Digit;
1876  else
1877  *Pos = 'A' + Digit - 10;
1878  }
1879  while (Val != 0L);
1880 
1881  Len = &Buffer[64] - Pos;
1882 
1883  if (Len > Length)
1884  return STATUS_BUFFER_OVERFLOW;
1885 
1886  /* If possible, add the 0 termination */
1887  if (Len < Length)
1888  Len += 1;
1889 
1890  /* Copy the string to the target using SEH */
1891  return RtlpSafeCopyMemory(String, Pos, Len);
1892 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
signed char * PCHAR
Definition: retypes.h:7
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char CHAR
Definition: xmlstorage.h:175
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2343
ush Pos
Definition: deflate.h:92
static WCHAR String[]
Definition: stringtable.c:55
Definition: bufpool.h:45
uint64_t ULONGLONG
Definition: typedefs.h:65
#define Len
Definition: deflate.h:82
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static const WCHAR L[]
Definition: oid.c:1250
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
NTSTATUS NTAPI RtlpSafeCopyMemory(_Out_writes_bytes_all_(Length) VOID UNALIGNED *Destination, _In_reads_bytes_(Length) CONST VOID UNALIGNED *Source, _In_ SIZE_T Length)
Definition: rtlcompat.c:56
#define CHAR(Char)

Referenced by RtlInt64ToUnicodeString().

◆ RtlMultiAppendUnicodeStringBuffer()

NTSTATUS NTAPI RtlMultiAppendUnicodeStringBuffer ( OUT PRTL_UNICODE_STRING_BUFFER  StringBuffer,
IN ULONG  NumberOfAddends,
IN PCUNICODE_STRING  Addends 
)

Definition at line 37 of file unicode.c.

40 {
43 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED
Definition: debug.h:114

◆ RtlOemStringToCountedUnicodeString()

NTSTATUS NTAPI RtlOemStringToCountedUnicodeString ( IN OUT PUNICODE_STRING  UniDest,
IN PCOEM_STRING  OemSource,
IN BOOLEAN  AllocateDestinationString 
)

Definition at line 1463 of file unicode.c.

1467 {
1468  NTSTATUS Status;
1469  ULONG Length;
1470  ULONG Index;
1471 
1472  PAGED_CODE_RTL();
1473 
1474  /* Calculate size of the string */
1476 
1477  /* If it's 0 then zero out dest string and return */
1478  if (!Length)
1479  {
1480  RtlZeroMemory(UniDest, sizeof(UNICODE_STRING));
1481  return STATUS_SUCCESS;
1482  }
1483 
1484  /* Check if length is a sane value */
1486 
1487  /* Store it in dest string */
1488  UniDest->Length = (USHORT)Length;
1489 
1490  /* If we're asked to alloc the string - do so */
1492  {
1493  UniDest->Buffer = RtlpAllocateStringMemory(Length, TAG_USTR);
1494  UniDest->MaximumLength = (USHORT)Length;
1495 
1496  if (!UniDest->Buffer) return STATUS_NO_MEMORY;
1497  }
1498  else if (UniDest->Length > UniDest->MaximumLength)
1499  {
1500  return STATUS_BUFFER_OVERFLOW;
1501  }
1502 
1503  /* Do the conversion */
1504  Status = RtlOemToUnicodeN(UniDest->Buffer,
1505  UniDest->Length,
1506  &Index,
1507  OemSource->Buffer,
1508  OemSource->Length);
1509 
1511  {
1512  /* Conversion failed, free dest string and return status code */
1513  RtlpFreeStringMemory(UniDest->Buffer, TAG_USTR);
1514  UniDest->Buffer = NULL;
1515  return Status;
1516  }
1517 
1518  return STATUS_SUCCESS;
1519 }
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI NTSTATUS WINAPI RtlOemToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define RtlpFreeStringMemory
Definition: rtlp.h:141
#define TAG_USTR
Definition: libsupp.c:111
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MAXUSHORT
Definition: typedefs.h:81
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1321
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define RtlOemStringToCountedUnicodeSize(STRING)

Referenced by _Requires_lock_held_(), FatQueryShortNameInfo(), FatSearchBufferForLabel(), FatSetFsLabelInfo(), and FatTunnelFcbOrDcb().

◆ RtlOemStringToUnicodeString()

NTSTATUS NTAPI RtlOemStringToUnicodeString ( IN OUT PUNICODE_STRING  UniDest,
IN PCOEM_STRING  OemSource,
IN BOOLEAN  AllocateDestinationString 
)

Definition at line 1169 of file unicode.c.

1173 {
1174  NTSTATUS Status;
1175  ULONG Length;
1176  ULONG Index;
1177 
1178  PAGED_CODE_RTL();
1179 
1180  Length = RtlOemStringToUnicodeSize(OemSource);
1181 
1183 
1184  UniDest->Length = (USHORT)Length - sizeof(WCHAR);
1185 
1187  {
1188  UniDest->Buffer = RtlpAllocateStringMemory(Length, TAG_USTR);
1189  UniDest->MaximumLength = (USHORT)Length;
1190 
1191  if (!UniDest->Buffer) return STATUS_NO_MEMORY;
1192  }
1193  else if (UniDest->Length >= UniDest->MaximumLength)
1194  {
1195  return STATUS_BUFFER_OVERFLOW;
1196  }
1197 
1198  Status = RtlOemToUnicodeN(UniDest->Buffer,
1199  UniDest->Length,
1200  &Index,
1201  OemSource->Buffer,
1202  OemSource->Length);
1203 
1205  {
1206  RtlpFreeStringMemory(UniDest->Buffer, TAG_USTR);
1207  UniDest->Buffer = NULL;
1208  return Status;
1209  }
1210 
1211  UniDest->Buffer[Index / sizeof(WCHAR)] = UNICODE_NULL;
1212  return Status;
1213 }
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI NTSTATUS WINAPI RtlOemToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define RtlpFreeStringMemory
Definition: rtlp.h:141
#define TAG_USTR
Definition: libsupp.c:111
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MAXUSHORT
Definition: typedefs.h:81
unsigned int ULONG
Definition: retypes.h:1
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1321
NTSYSAPI UINT WINAPI RtlOemStringToUnicodeSize(const STRING *)

Referenced by RtlDnsHostNameToComputerName().

◆ RtlpDidUnicodeToOemWork()

BOOLEAN NTAPI RtlpDidUnicodeToOemWork ( IN PCUNICODE_STRING  UnicodeString,
IN POEM_STRING  OemString 
)

Definition at line 472 of file unicode.c.

474 {
475  ULONG i = 0;
476 
477  if (NlsMbOemCodePageTag == FALSE)
478  {
479  /* single-byte code page */
480  /* Go through all characters of a string */
481  while (i < OemString->Length)
482  {
483  /* Check if it got translated into a default char,
484  * but source char wasn't a default char equivalent
485  */
486  if ((OemString->Buffer[i] == NlsOemDefaultChar) &&
487  (UnicodeString->Buffer[i] != NlsUnicodeDefaultChar))
488  {
489  /* Yes, it means unmappable characters were found */
490  return FALSE;
491  }
492 
493  /* Move to the next char */
494  i++;
495  }
496 
497  /* All chars were translated successfuly */
498  return TRUE;
499  }
500  else
501  {
502  /* multibyte code page */
503 
504  /* FIXME */
505  return TRUE;
506  }
507 }
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1561
#define TRUE
Definition: types.h:120
USHORT NlsUnicodeDefaultChar
Definition: nls.c:36
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
BOOLEAN NlsMbOemCodePageTag
Definition: nls.c:29
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
USHORT NlsOemDefaultChar
Definition: nls.c:35
unsigned int ULONG
Definition: retypes.h:1

Referenced by RtlDnsHostNameToComputerName(), RtlUnicodeStringToCountedOemString(), RtlUpcaseUnicodeStringToCountedOemString(), and RtlUpcaseUnicodeStringToOemString().

◆ RtlpEnsureBufferSize()

NTSTATUS NTAPI RtlpEnsureBufferSize ( IN ULONG  Flags,
IN OUT PRTL_BUFFER  Buffer,
IN SIZE_T  RequiredSize 
)

Definition at line 2573 of file unicode.c.

2577 {
2578  PUCHAR NewBuffer;
2579 
2580  /* Parameter checks */
2581  if (Flags & ~RTL_SKIP_BUFFER_COPY)
2582  return STATUS_INVALID_PARAMETER;
2583  if (Buffer == NULL)
2584  return STATUS_INVALID_PARAMETER;
2585 
2586  /*
2587  * We don't need to grow the buffer if its size
2588  * is already larger than the required size.
2589  */
2590  if (Buffer->Size >= RequiredSize)
2591  return STATUS_SUCCESS;
2592 
2593  /*
2594  * When we are using the static buffer as our buffer, we don't need
2595  * to grow it if its size is already larger than the required size.
2596  * In this case, just keep it but update the current buffer size to
2597  * the one requested.
2598  * (But NEVER EVER modify the size of the static buffer!!)
2599  * Otherwise, we'll need to create a new buffer and use this one instead.
2600  */
2601  if ( (Buffer->Buffer == Buffer->StaticBuffer) &&
2602  (Buffer->StaticSize >= RequiredSize) )
2603  {
2604  Buffer->Size = RequiredSize;
2605  return STATUS_SUCCESS;
2606  }
2607 
2608  /* The buffer we are using is not large enough, try to create a bigger one */
2610  if (NewBuffer == NULL)
2611  return STATUS_NO_MEMORY;
2612 
2613  /* Copy the original content if needed */
2614  if (!(Flags & RTL_SKIP_BUFFER_COPY))
2615  {
2616  RtlMoveMemory(NewBuffer, Buffer->Buffer, Buffer->Size);
2617  }
2618 
2619  /* Free the original buffer only if it's not the static buffer */
2620  if (Buffer->Buffer != Buffer->StaticBuffer)
2621  {
2623  }
2624 
2625  /* Update the members */
2626  Buffer->Buffer = NewBuffer;
2627  Buffer->Size = RequiredSize;
2628 
2629  /* Done */
2630  return STATUS_SUCCESS;
2631 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define RtlpFreeStringMemory
Definition: rtlp.h:141
#define TAG_USTR
Definition: libsupp.c:111
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define RTL_SKIP_BUFFER_COPY
Definition: rtlfuncs.h:2355
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlpIsCharInUnicodeString()

static BOOLEAN RtlpIsCharInUnicodeString ( IN WCHAR  Char,
IN PCUNICODE_STRING  MatchString,
IN BOOLEAN  CaseInSensitive 
)
static

Definition at line 2635 of file unicode.c.

2639 {
2640  USHORT i;
2641 
2642  if (CaseInSensitive)
2643  Char = RtlpUpcaseUnicodeChar(Char);
2644 
2645  for (i = 0; i < MatchString->Length / sizeof(WCHAR); i++)
2646  {
2647  WCHAR OtherChar = MatchString->Buffer[i];
2648  if (CaseInSensitive)
2649  OtherChar = RtlpUpcaseUnicodeChar(OtherChar);
2650 
2651  if (Char == OtherChar)
2652  return TRUE;
2653  }
2654 
2655  return FALSE;
2656 }
#define TRUE
Definition: types.h:120
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
_In_ const STRING _In_ BOOLEAN CaseInSensitive
Definition: rtlfuncs.h:2292
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned short USHORT
Definition: pedump.c:61
WCHAR NTAPI RtlpUpcaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:715

Referenced by RtlFindCharInUnicodeString().

◆ RtlPrefixString()

BOOLEAN NTAPI RtlPrefixString ( const STRING String1,
const STRING String2,
BOOLEAN  CaseInsensitive 
)

Definition at line 875 of file unicode.c.

879 {
880  PCHAR pc1;
881  PCHAR pc2;
882  ULONG NumChars;
883 
884  if (String2->Length < String1->Length)
885  return FALSE;
886 
887  NumChars = String1->Length;
888  pc1 = String1->Buffer;
889  pc2 = String2->Buffer;
890 
891  if (pc1 && pc2)
892  {
893  if (CaseInsensitive)
894  {
895  while (NumChars--)
896  {
897  if (RtlUpperChar(*pc1++) != RtlUpperChar(*pc2++))
898  return FALSE;
899  }
900  }
901  else
902  {
903  while (NumChars--)
904  {
905  if (*pc1++ != *pc2++)
906  return FALSE;
907  }
908  }
909 
910  return TRUE;
911  }
912 
913  return FALSE;
914 }
signed char * PCHAR
Definition: retypes.h:7
static const unsigned char pc2[48]
Definition: des.c:68
#define TRUE
Definition: types.h:120
static const unsigned char pc1[56]
Definition: des.c:54
_In_ const STRING _In_ BOOLEAN CaseInsensitive
Definition: rtlfuncs.h:2261
NTSYSAPI CHAR NTAPI RtlUpperChar(CHAR Character)
_In_ const STRING * String2
Definition: rtlfuncs.h:2261
unsigned int ULONG
Definition: retypes.h:1

◆ RtlPrefixUnicodeString()

BOOLEAN NTAPI RtlPrefixUnicodeString ( PCUNICODE_STRING  String1,
PCUNICODE_STRING  String2,
BOOLEAN  CaseInsensitive 
)

Definition at line 924 of file unicode.c.

928 {
929  PWCHAR pc1;
930  PWCHAR pc2;
931  ULONG NumChars;
932 
933  if (String2->Length < String1->Length)
934  return FALSE;
935 
936  NumChars = String1->Length / sizeof(WCHAR);
937  pc1 = String1->Buffer;
938  pc2 = String2->Buffer;
939 
940  if (pc1 && pc2)
941  {
942  if (CaseInsensitive)
943  {
944  while (NumChars--)
945  {
946  if (RtlpUpcaseUnicodeChar(*pc1++) !=
948  return FALSE;
949  }
950  }
951  else
952  {
953  while (NumChars--)
954  {
955  if (*pc1++ != *pc2++)
956  return FALSE;
957  }
958  }
959 
960  return TRUE;
961  }
962 
963  return FALSE;
964 }
static const unsigned char pc2[48]
Definition: des.c:68
#define TRUE
Definition: types.h:120
static const unsigned char pc1[56]
Definition: des.c:54
uint16_t * PWCHAR
Definition: typedefs.h:54
_In_ const STRING _In_ BOOLEAN CaseInsensitive
Definition: rtlfuncs.h:2261
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR NTAPI RtlpUpcaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:715
_In_ const STRING * String2
Definition: rtlfuncs.h:2261
unsigned int ULONG
Definition: retypes.h:1

◆ RtlStringFromGUID()

NTSTATUS NTAPI RtlStringFromGUID ( IN REFGUID  Guid,
OUT PUNICODE_STRING  GuidString 
)

Definition at line 2128 of file unicode.c.

2130 {
2131  /* Setup the string */
2132  GuidString->Length = 38 * sizeof(WCHAR);
2133  GuidString->MaximumLength = GuidString->Length + sizeof(UNICODE_NULL);
2134  GuidString->Buffer = RtlpAllocateStringMemory(GuidString->MaximumLength,
2135  TAG_USTR);
2136  if (!GuidString->Buffer) return STATUS_NO_MEMORY;
2137 
2138  /* Now format the GUID */
2139  swprintf(GuidString->Buffer,
2140  L"{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
2141  Guid->Data1,
2142  Guid->Data2,
2143  Guid->Data3,
2144  Guid->Data4[0],
2145  Guid->Data4[1],
2146  Guid->Data4[2],
2147  Guid->Data4[3],
2148  Guid->Data4[4],
2149  Guid->Data4[5],
2150  Guid->Data4[6],
2151  Guid->Data4[7]);
2152  return STATUS_SUCCESS;
2153 }
static PWSTR GuidString
Definition: apphelp.c:91
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define UNICODE_NULL
static GUID * Guid
Definition: apphelp.c:93
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const WCHAR L[]
Definition: oid.c:1250
#define TAG_USTR
Definition: libsupp.c:111
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlUnicodeStringToAnsiString()

NTSTATUS NTAPI RtlUnicodeStringToAnsiString ( IN OUT PANSI_STRING  AnsiDest,
IN PCUNICODE_STRING  UniSource,
IN BOOLEAN  AllocateDestinationString 
)

Definition at line 1102 of file unicode.c.

1106 {
1108  NTSTATUS RealStatus;
1109  ULONG Length;
1110  ULONG Index;
1111 
1112  PAGED_CODE_RTL();
1113 
1114  ASSERT(!(UniSource->Length & 1));
1115 
1116  if (NlsMbCodePageTag == FALSE)
1117  {
1118  Length = (UniSource->Length + sizeof(WCHAR)) / sizeof(WCHAR);
1119  }
1120  else
1121  {
1122  Length = RtlxUnicodeStringToAnsiSize(UniSource);
1123  }
1124 
1126 
1127  AnsiDest->Length = (USHORT)Length - sizeof(CHAR);
1128 
1130  {
1131  AnsiDest->Buffer = RtlpAllocateStringMemory(Length, TAG_ASTR);
1132  AnsiDest->MaximumLength = (USHORT)Length;
1133 
1134  if (!AnsiDest->Buffer) return STATUS_NO_MEMORY;
1135  }
1136  else if (AnsiDest->Length >= AnsiDest->MaximumLength)
1137  {
1138  if (!AnsiDest->MaximumLength) return STATUS_BUFFER_OVERFLOW;
1139 
1141  AnsiDest->Length = AnsiDest->MaximumLength - 1;
1142  }
1143 
1144  RealStatus = RtlUnicodeToMultiByteN(AnsiDest->Buffer,
1145  AnsiDest->Length,
1146  &Index,
1147  UniSource->Buffer,
1148  UniSource->Length);
1149 
1150  if (!NT_SUCCESS(RealStatus) && AllocateDestinationString)
1151  {
1152  RtlpFreeStringMemory(AnsiDest->Buffer, TAG_ASTR);
1153  return RealStatus;
1154  }
1155 
1156  AnsiDest->Buffer[Index] = ANSI_NULL;
1157  return Status;
1158 }
BOOLEAN NlsMbCodePageTag
Definition: nls.c:22
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define ANSI_NULL
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define RtlpFreeStringMemory
Definition: rtlp.h:141
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteN(PCHAR MbString, ULONG MbSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
ULONG NTAPI RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString)
Definition: unicode.c:2163
#define MAXUSHORT
Definition: typedefs.h:81
unsigned int ULONG
Definition: retypes.h:1
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1321
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define TAG_ASTR
Definition: libsupp.c:112

◆ RtlUnicodeStringToCountedOemString()

NTSTATUS NTAPI RtlUnicodeStringToCountedOemString ( IN OUT POEM_STRING  OemDest,
IN PCUNICODE_STRING  UniSource,
IN BOOLEAN  AllocateDestinationString 
)

Definition at line 1780 of file unicode.c.

1784 {
1785  NTSTATUS Status;
1786  ULONG Length;
1787  ULONG Index;
1788 
1789  PAGED_CODE_RTL();
1790 
1791  /* Calculate size of the string */
1792  Length = RtlUnicodeStringToCountedOemSize(UniSource);
1793 
1794  /* If it's 0 then zero out dest string and return */
1795  if (!Length)
1796  {
1797  RtlZeroMemory(OemDest, sizeof(OEM_STRING));
1798  return STATUS_SUCCESS;
1799  }
1800 
1801  /* Check if length is a sane value */
1803 
1804  /* Store it in dest string */
1805  OemDest->Length = (USHORT)Length;
1806 
1807  /* If we're asked to alloc the string - do so */
1809  {
1810  OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
1811  OemDest->MaximumLength = (USHORT)Length;
1812  if (!OemDest->Buffer) return STATUS_NO_MEMORY;
1813  }
1814  else if (OemDest->Length > OemDest->MaximumLength)
1815  {
1816  return STATUS_BUFFER_OVERFLOW;
1817  }
1818 
1819  /* Do the conversion */
1820  Status = RtlUnicodeToOemN(OemDest->Buffer,
1821  OemDest->Length,
1822  &Index,
1823  UniSource->Buffer,
1824  UniSource->Length);
1825 
1826  /* Check for unmapped character */
1827  if (NT_SUCCESS(Status) && !RtlpDidUnicodeToOemWork(UniSource, OemDest))
1829 
1831  {
1832  /* Conversion failed, free dest string and return status code */
1833  RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
1834  OemDest->Buffer = NULL;
1835  return Status;
1836  }
1837 
1838  return Status;
1839 }
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define TAG_OSTR
Definition: inbv.c:13
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
STRING OEM_STRING
Definition: umtypes.h:203
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToOemN(PCHAR OemString, ULONG OemSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define RtlpFreeStringMemory
Definition: rtlp.h:141
BOOLEAN NTAPI RtlpDidUnicodeToOemWork(IN PCUNICODE_STRING UnicodeString, IN POEM_STRING OemString)
Definition: unicode.c:472
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define STATUS_UNMAPPABLE_CHARACTER
Definition: ntstatus.h:576
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MAXUSHORT
Definition: typedefs.h:81
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1321
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by CdIs8dot3Name().

◆ RtlUnicodeStringToInteger()

NTSTATUS NTAPI RtlUnicodeStringToInteger ( const UNICODE_STRING str,
ULONG  base,
ULONG value 
)

Definition at line 971 of file unicode.c.

975 {
976  LPWSTR lpwstr = str->Buffer;
977  USHORT CharsRemaining = str->Length / sizeof(WCHAR);
978  WCHAR wchCurrent;
979  int digit;
980  ULONG RunningTotal = 0;
981  char bMinus = 0;
982 
983  while (CharsRemaining >= 1 && *lpwstr <= ' ')
984  {
985  lpwstr++;
986  CharsRemaining--;
987  }
988 
989  if (CharsRemaining >= 1)
990  {
991  if (*lpwstr == '+')
992  {
993  lpwstr++;
994  CharsRemaining--;
995  }
996  else if (*lpwstr == '-')
997  {
998  bMinus = 1;
999  lpwstr++;
1000  CharsRemaining--;
1001  }
1002  }
1003 
1004  if (base == 0)
1005  {
1006  base = 10;
1007 
1008  if (CharsRemaining >= 2 && lpwstr[0] == '0')
1009  {
1010  if (lpwstr[1] == 'b')
1011  {
1012  lpwstr += 2;
1013  CharsRemaining -= 2;
1014  base = 2;
1015  }
1016  else if (lpwstr[1] == 'o')
1017  {
1018  lpwstr += 2;
1019  CharsRemaining -= 2;
1020  base = 8;
1021  }
1022  else if (lpwstr[1] == 'x')
1023  {
1024  lpwstr += 2;
1025  CharsRemaining -= 2;
1026  base = 16;
1027  }
1028  }
1029  }
1030  else if (base != 2 && base != 8 && base != 10 && base != 16)
1031  {
1032  return STATUS_INVALID_PARAMETER;
1033  }
1034 
1035  if (value == NULL)
1036  {
1037  return STATUS_ACCESS_VIOLATION;
1038  }
1039 
1040  while (CharsRemaining >= 1)
1041  {
1042  wchCurrent = *lpwstr;
1043 
1044  if (wchCurrent >= '0' && wchCurrent <= '9')
1045  {
1046  digit = wchCurrent - '0';
1047  }
1048  else if (wchCurrent >= 'A' && wchCurrent <= 'Z')
1049  {
1050  digit = wchCurrent - 'A' + 10;
1051  }
1052  else if (wchCurrent >= 'a' && wchCurrent <= 'z')
1053  {
1054  digit = wchCurrent - 'a' + 10;
1055  }
1056  else
1057  {
1058  digit = -1;
1059  }
1060 
1061  if (digit < 0 || (ULONG)digit >= base) break;
1062 
1063  RunningTotal = RunningTotal * base + digit;
1064  lpwstr++;
1065  CharsRemaining--;
1066  }
1067 
1068  *value = bMinus ? (0 - RunningTotal) : RunningTotal;
1069  return STATUS_SUCCESS;
1070 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
GLuint base
Definition: 3dtext.c:35
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlUnicodeStringToOemString()

NTSTATUS NTAPI RtlUnicodeStringToOemString ( IN OUT POEM_STRING  OemDest,
IN PCUNICODE_STRING  UniSource,
IN BOOLEAN  AllocateDestinationString 
)

Definition at line 1223 of file unicode.c.

1227 {
1228  NTSTATUS Status;
1229  ULONG Length;
1230  ULONG Index;
1231 
1232  PAGED_CODE_RTL();
1233 
1234  Length = RtlUnicodeStringToOemSize(UniSource);
1235 
1237 
1238  OemDest->Length = (USHORT)Length - sizeof(CHAR);
1239 
1241  {
1242  OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
1243  OemDest->MaximumLength = (USHORT)Length;
1244 
1245  if (!OemDest->Buffer) return STATUS_NO_MEMORY;
1246  }
1247  else if (OemDest->Length >= OemDest->MaximumLength)
1248  {
1249  return STATUS_BUFFER_OVERFLOW;
1250  }
1251 
1252  Status = RtlUnicodeToOemN(OemDest->Buffer,
1253  OemDest->Length,
1254  &Index,
1255  UniSource->Buffer,
1256  UniSource->Length);
1257 
1259  {
1260  RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
1261  OemDest->Buffer = NULL;
1262  return Status;
1263  }
1264 
1265  OemDest->Buffer[Index] = ANSI_NULL;
1266  return Status;
1267 }
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define TAG_OSTR
Definition: inbv.c:13
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
NTSYSAPI DWORD WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING *)
#define ANSI_NULL
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToOemN(PCHAR OemString, ULONG OemSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define RtlpFreeStringMemory
Definition: rtlp.h:141
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MAXUSHORT
Definition: typedefs.h:81
unsigned int ULONG
Definition: retypes.h:1
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1321

◆ RtlUpcaseUnicodeString()

NTSTATUS NTAPI RtlUpcaseUnicodeString ( IN OUT PUNICODE_STRING  UniDest,
IN PCUNICODE_STRING  UniSource,
IN BOOLEAN  AllocateDestinationString 
)

Definition at line 1903 of file unicode.c.

1907 {
1908  ULONG i, j;
1909 
1910  PAGED_CODE_RTL();
1911 
1913  {
1914  UniDest->MaximumLength = UniSource->Length;
1915  UniDest->Buffer = RtlpAllocateStringMemory(UniDest->MaximumLength, TAG_USTR);
1916  if (UniDest->Buffer == NULL) return STATUS_NO_MEMORY;
1917  }
1918  else if (UniSource->Length > UniDest->MaximumLength)
1919  {
1920  return STATUS_BUFFER_OVERFLOW;
1921  }
1922 
1923  j = UniSource->Length / sizeof(WCHAR);
1924 
1925  for (i = 0; i < j; i++)
1926  {
1927  UniDest->Buffer[i] = RtlpUpcaseUnicodeChar(UniSource->Buffer[i]);
1928  }
1929 
1930  UniDest->Length = UniSource->Length;
1931  return STATUS_SUCCESS;
1932 }
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
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
smooth NULL
Definition: ftsmooth.c:416
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define TAG_USTR
Definition: libsupp.c:111
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
WCHAR NTAPI RtlpUpcaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:715
unsigned int ULONG
Definition: retypes.h:1
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1321
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlUpcaseUnicodeStringToAnsiString()

NTSTATUS NTAPI RtlUpcaseUnicodeStringToAnsiString ( IN OUT PANSI_STRING  AnsiDest,
IN PCUNICODE_STRING  UniSource,
IN BOOLEAN  AllocateDestinationString 
)

Definition at line 1943 of file unicode.c.

1947 {
1948  NTSTATUS Status;
1949  ULONG Length;
1950  ULONG Index;
1951  PAGED_CODE_RTL();
1952 
1953  Length = RtlUnicodeStringToAnsiSize(UniSource);
1955 
1956  AnsiDest->Length = (USHORT)Length - sizeof(CHAR);
1957 
1959  {
1960  AnsiDest->Buffer = RtlpAllocateStringMemory(Length, TAG_ASTR);
1961  AnsiDest->MaximumLength = (USHORT)Length;
1962  if (!AnsiDest->Buffer) return STATUS_NO_MEMORY;
1963  }
1964  else if (AnsiDest->Length >= AnsiDest->MaximumLength)
1965  {
1966  if (!AnsiDest->MaximumLength) return STATUS_BUFFER_OVERFLOW;
1967  }
1968 
1969  Status = RtlUpcaseUnicodeToMultiByteN(AnsiDest->Buffer,
1970  AnsiDest->Length,
1971  &Index,
1972  UniSource->Buffer,
1973  UniSource->Length);
1974 
1976  {
1977  RtlpFreeStringMemory(AnsiDest->Buffer, TAG_ASTR);
1978  AnsiDest->Buffer = NULL;
1979  return Status;
1980  }
1981 
1982  AnsiDest->Buffer[Index] = ANSI_NULL;
1983  return Status;
1984 }
NTSYSAPI DWORD WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING *)
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define ANSI_NULL
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define RtlpFreeStringMemory
Definition: rtlp.h:141
NTSYSAPI NTSTATUS NTAPI RtlUpcaseUnicodeToMultiByteN(PCHAR MbString, ULONG MbSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MAXUSHORT
Definition: typedefs.h:81
unsigned int ULONG
Definition: retypes.h:1
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1321
#define TAG_ASTR
Definition: libsupp.c:112

◆ RtlUpcaseUnicodeStringToCountedOemString()

NTSTATUS NTAPI RtlUpcaseUnicodeStringToCountedOemString ( IN OUT POEM_STRING  OemDest,
IN PCUNICODE_STRING  UniSource,
IN BOOLEAN  AllocateDestinationString 
)

Definition at line 1995 of file unicode.c.

1999 {
2000  NTSTATUS Status;
2001  ULONG Length;
2002  ULONG Index;
2003  PAGED_CODE_RTL();
2004 
2005  Length = RtlUnicodeStringToCountedOemSize(UniSource);
2006 
2007  if (!Length)
2008  {
2009  RtlZeroMemory(OemDest, sizeof(OEM_STRING));
2010  }
2011 
2013 
2014  OemDest->Length = (USHORT)Length;
2015 
2017  {
2018  OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
2019  OemDest->MaximumLength = (USHORT)Length;
2020  if (!OemDest->Buffer) return STATUS_NO_MEMORY;
2021  }
2022  else if (OemDest->Length > OemDest->MaximumLength)
2023  {
2024  return STATUS_BUFFER_OVERFLOW;
2025  }
2026 
2027  Status = RtlUpcaseUnicodeToOemN(OemDest->Buffer,
2028  OemDest->Length,
2029  &Index,
2030  UniSource->Buffer,
2031  UniSource->Length);
2032 
2033  /* Check for unmapped characters */
2034  if (NT_SUCCESS(Status) && !RtlpDidUnicodeToOemWork(UniSource, OemDest))
2036 
2038  {
2039  RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
2040  OemDest->Buffer = NULL;
2041  return Status;
2042  }
2043 
2044  return Status;
2045 }
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define TAG_OSTR
Definition: inbv.c:13
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
STRING OEM_STRING
Definition: umtypes.h:203
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSYSAPI NTSTATUS NTAPI RtlUpcaseUnicodeToOemN(PCHAR OemString, ULONG OemSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
#define RtlpFreeStringMemory
Definition: rtlp.h:141
BOOLEAN NTAPI RtlpDidUnicodeToOemWork(IN PCUNICODE_STRING UnicodeString, IN POEM_STRING OemString)
Definition: unicode.c:472
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define STATUS_UNMAPPABLE_CHARACTER
Definition: ntstatus.h:576
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MAXUSHORT
Definition: typedefs.h:81
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1321

◆ RtlUpcaseUnicodeStringToOemString()

NTSTATUS NTAPI RtlUpcaseUnicodeStringToOemString ( IN OUT POEM_STRING  OemDest,
IN PCUNICODE_STRING  UniSource,
IN BOOLEAN  AllocateDestinationString 
)

Definition at line 2055 of file unicode.c.

2059 {
2060  NTSTATUS Status;
2061  ULONG Length;
2062  ULONG Index;
2063  PAGED_CODE_RTL();
2064 
2065  Length = RtlUnicodeStringToOemSize(UniSource);
2067 
2068  OemDest->Length = (USHORT)Length - sizeof(CHAR);
2069 
2071  {
2072  OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
2073  OemDest->MaximumLength = (USHORT)Length;
2074  if (!OemDest->Buffer) return STATUS_NO_MEMORY;
2075  }
2076  else if (OemDest->Length >= OemDest->MaximumLength)
2077  {
2078  return STATUS_BUFFER_OVERFLOW;
2079  }
2080 
2081  Status = RtlUpcaseUnicodeToOemN(OemDest->Buffer,
2082  OemDest->Length,
2083  &Index,
2084  UniSource->Buffer,
2085  UniSource->Length);
2086 
2087  /* Check for unmapped characters */
2088  if (NT_SUCCESS(Status) && !RtlpDidUnicodeToOemWork(UniSource, OemDest))
2090 
2092  {
2093  RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
2094  OemDest->Buffer = NULL;
2095  return Status;
2096  }
2097 
2098  OemDest->Buffer[Index] = ANSI_NULL;
2099  return Status;
2100 }
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define TAG_OSTR
Definition: inbv.c:13
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
NTSYSAPI DWORD WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING *)
#define ANSI_NULL
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSYSAPI NTSTATUS NTAPI RtlUpcaseUnicodeToOemN(PCHAR OemString, ULONG OemSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
#define RtlpFreeStringMemory
Definition: rtlp.h:141
BOOLEAN NTAPI RtlpDidUnicodeToOemWork(IN PCUNICODE_STRING UnicodeString, IN POEM_STRING OemString)
Definition: unicode.c:472
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define STATUS_UNMAPPABLE_CHARACTER
Definition: ntstatus.h:576
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MAXUSHORT
Definition: typedefs.h:81
unsigned int ULONG
Definition: retypes.h:1
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1321

Referenced by RtlEqualComputerName().

◆ RtlUpperString()

VOID NTAPI RtlUpperString ( PSTRING  DestinationString,
const STRING SourceString 
)

Definition at line 2464 of file unicode.c.

2466 {
2467  USHORT Length;
2468  PCHAR Src, Dest;
2469 
2472 
2473  Src = SourceString->Buffer;
2474  Dest = DestinationString->Buffer;
2476 
2477  while (Length)
2478  {
2479  *Dest++ = RtlUpperChar(*Src++);
2480  Length--;
2481  }
2482 }
signed char * PCHAR
Definition: retypes.h:7
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSYSAPI CHAR NTAPI RtlUpperChar(CHAR Character)
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1869
unsigned short USHORT
Definition: pedump.c:61
#define min(a, b)
Definition: monoChain.cc:55
unsigned short MaximumLength
Definition: sprintf.c:452

◆ RtlValidateUnicodeString()

NTSTATUS NTAPI RtlValidateUnicodeString ( IN ULONG  Flags,
IN PCUNICODE_STRING  UnicodeString 
)

Definition at line 2544 of file unicode.c.

2546 {
2547  /* currently no flags are supported! */
2548  ASSERT(Flags == 0);
2549 
2550  if ((Flags == 0) &&
2551  ((UnicodeString == NULL) ||
2552  ((UnicodeString->Length != 0) &&
2553  (UnicodeString->Buffer != NULL) &&
2554  ((UnicodeString->Length % sizeof(WCHAR)) == 0) &&
2555  ((UnicodeString->MaximumLength % sizeof(WCHAR)) == 0) &&
2556  (UnicodeString->MaximumLength >= UnicodeString->Length))))
2557  {
2558  /* a NULL pointer as a unicode string is considered to be a valid unicode
2559  string! */
2560  return STATUS_SUCCESS;
2561  }
2562  else
2563  {
2564  return STATUS_INVALID_PARAMETER;
2565  }
2566 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ RtlxAnsiStringToUnicodeSize()

ULONG NTAPI RtlxAnsiStringToUnicodeSize ( IN PCANSI_STRING  AnsiString)

Definition at line 156 of file unicode.c.

157 {
158  ULONG Size;
159  PAGED_CODE_RTL();
160 
161  /* Convert from Mb String to Unicode Size */
163  AnsiString->Buffer,
164  AnsiString->Length);
165 
166  /* Return the size plus the null-char */
167  return(Size + sizeof(WCHAR));
168 }
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
__wchar_t WCHAR
Definition: xmlstorage.h:180
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeSize(DWORD *, LPCSTR, UINT)
unsigned int ULONG
Definition: retypes.h:1

Referenced by RtlAnsiStringToUnicodeString().

◆ RtlxOemStringToUnicodeSize()

ULONG NTAPI RtlxOemStringToUnicodeSize ( IN PCOEM_STRING  OemString)

Definition at line 2110 of file unicode.c.

2111 {
2112  ULONG Size;
2113 
2114  /* Convert the Mb String to Unicode Size */
2116  OemString->Buffer,
2117  OemString->Length);
2118 
2119  /* Return the size + null-char */
2120  return (Size + sizeof(WCHAR));
2121 }
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1561
__wchar_t WCHAR
Definition: xmlstorage.h:180
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeSize(DWORD *, LPCSTR, UINT)
unsigned int ULONG
Definition: retypes.h:1

◆ RtlxUnicodeStringToAnsiSize()

ULONG NTAPI RtlxUnicodeStringToAnsiSize ( IN PCUNICODE_STRING  UnicodeString)

Definition at line 2163 of file unicode.c.

2164 {
2165  ULONG Size;
2166  PAGED_CODE_RTL();
2167 
2168  ASSERT(!(UnicodeString->Length & 1));
2169 
2170  /* Convert the Unicode String to Mb Size */
2172  UnicodeString->Buffer,
2173  UnicodeString->Length);
2174 
2175  /* Return the size + null-char */
2176  return (Size + sizeof(CHAR));
2177 }
char CHAR
Definition: xmlstorage.h:175
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteSize(PULONG MbSize, PCWCH UnicodeString, ULONG UnicodeSize)
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
unsigned int ULONG
Definition: retypes.h:1

Referenced by RtlUnicodeStringToAnsiString().

◆ RtlxUnicodeStringToOemSize()

ULONG NTAPI RtlxUnicodeStringToOemSize ( IN PCUNICODE_STRING  UnicodeString)

Definition at line 1080 of file unicode.c.

1081 {
1082  ULONG Size;
1083 
1084  /* Convert the Unicode String to Mb Size */
1086  UnicodeString->Buffer,
1087  UnicodeString->Length);
1088 
1089  /* Return the size + the null char */
1090  return (Size + sizeof(CHAR));
1091 }
char CHAR
Definition: xmlstorage.h:175
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteSize(PULONG MbSize, PCWCH UnicodeString, ULONG UnicodeSize)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
unsigned int ULONG
Definition: retypes.h:1

Referenced by Ext2UnicodeToOEMSize(), FFSSetRenameInfo(), FFSv1AllocateFcb(), FFSv2AllocateFcb(), and RfsdUnicodeToOEMSize().

Variable Documentation

◆ NlsLeadByteInfo

◆ NlsMbCodePageTag

◆ NlsMbOemCodePageTag

◆ NlsOemDefaultChar

USHORT NlsOemDefaultChar

Definition at line 35 of file nls.c.

Referenced by RtlIsValidOemCharacter(), RtlpDidUnicodeToOemWork(), and RtlResetRtlTranslations().

◆ NlsOemLeadByteInfo

PUSHORT NlsOemLeadByteInfo

Definition at line 33 of file nls.c.

Referenced by RtlIsValidOemCharacter(), RtlOemToUnicodeN(), and RtlResetRtlTranslations().

◆ NlsOemToUnicodeTable

PWCHAR NlsOemToUnicodeTable

Definition at line 30 of file nls.c.

Referenced by RtlIsValidOemCharacter(), RtlOemToUnicodeN(), and RtlResetRtlTranslations().

◆ NlsUnicodeDefaultChar

USHORT NlsUnicodeDefaultChar

Definition at line 36 of file nls.c.

Referenced by RtlpDidUnicodeToOemWork(), and RtlResetRtlTranslations().

◆ NlsUnicodeToMbOemTable

PUSHORT NlsUnicodeToMbOemTable

◆ NlsUnicodeToOemTable

PCHAR NlsUnicodeToOemTable