ReactOS  0.4.15-dev-3181-g4acf100
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)
 
 _IRQL_requires_max_ (PASSIVE_LEVEL)
 Queries information details about a security descriptor. More...
 
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 String)
 
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 1280 of file unicode.c.

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file unicode.c.

Function Documentation

◆ _IRQL_requires_max_()

_IRQL_requires_max_ ( PASSIVE_LEVEL  )

Queries information details about a security descriptor.

Computes the quota size of a security descriptor.

Assigns a security descriptor for a new object.

An extended function that assigns a security descriptor for a new object.

Frees a security descriptor.

An extended function that sets new information data to a security descriptor.

Modifies some information data about a security descriptor.

Parameters
[in]SecurityInformationSecurity information details to be queried from a security descriptor.
[out]SecurityDescriptorThe returned security descriptor with security information data.
[in,out]LengthThe returned length of a security descriptor.
[in,out]ObjectsSecurityDescriptorThe returned object security descriptor.
Returns
Returns STATUS_SUCCESS if the operations have been completed successfully and that the specific information about the security descriptor has been queried. STATUS_BUFFER_TOO_SMALL is returned if the buffer size is too small to contain the queried info about the security descriptor.
Parameters
[in]ObjectIf specified, the function will use this arbitrary object that points to an object security descriptor.
[in]SecurityInformationSecurity information details to be set.
[in]SecurityDescriptorA security descriptor where its info is to be changed.
[in,out]ObjectsSecurityDescriptorThe returned pointer to security descriptor objects.
[in]PoolTypePool type for the new security descriptor to allocate.
[in]GenericMappingThe generic mapping of access rights masks.
Returns
See SeSetSecurityDescriptorInfoEx.
Parameters
[in]ObjectIf specified, the function will use this arbitrary object that points to an object security descriptor.
[in]SecurityInformationSecurity information details to be set.
[in]SecurityDescriptorA security descriptor where its info is to be changed.
[in,out]ObjectsSecurityDescriptorThe returned pointer to security descriptor objects.
[in]AutoInheritFlagsFlags bitmask inheritation, influencing how the security descriptor can be inherited and if it can be in the first place.
[in]PoolTypePool type for the new security descriptor to allocate.
[in]GenericMappingThe generic mapping of access rights masks.
Returns
Returns STATUS_SUCCESS if the operations have been completed without problems and that new info has been set to the security descriptor. STATUS_NO_SECURITY_ON_OBJECT is returned if the object does not have a security descriptor. STATUS_INSUFFICIENT_RESOURCES is returned if memory pool allocation for the new security descriptor with new info set has failed.
Parameters
[in]SecurityDescriptorA security descriptor to be freed from memory.
Returns
Returns STATUS_SUCCESS.
Parameters
[in]_ParentDescriptorA security descriptor of the parent object that is being created.
[in]_ExplicitDescriptorAn explicit security descriptor that is applied to a new object.
[out]NewDescriptorThe new allocated security descriptor.
[in]ObjectTypeThe type of the new object.
[in]IsDirectoryObjectSet this to TRUE if the newly created object is a directory object, otherwise set this to FALSE.
[in]AutoInheritFlagsAutomatic inheritance flags that influence how access control entries within ACLs from security descriptors are inherited.
[in]SubjectContextSecurity subject context of the new object.
[in]GenericMappingGeneric mapping of access mask rights.
[in]PoolTypeThis parameter is unused.
Returns
Returns STATUS_SUCCESS if the operations have been completed successfully and that the security descriptor has been assigned to the new object. STATUS_NO_TOKEN is returned if the caller hasn't supplied a valid argument to a security subject context. STATUS_INVALID_OWNER is returned if the caller hasn't supplied a parent descriptor that belongs to the main user (owner). STATUS_INVALID_PRIMARY_GROUP is returned by the same reason as with the previous NTSTATUS code. The two NTSTATUS codes are returned if the calling thread stated that the owner and/or group is defaulted to the parent descriptor (SEF_DEFAULT_OWNER_FROM_PARENT and/or SEF_DEFAULT_GROUP_FROM_PARENT respectively). STATUS_INSUFFICIENT_RESOURCES is returned if memory pool allocation for the descriptor buffer has failed. A failure NTSTATUS is returned otherwise.
Parameters
[in]ParentDescriptorA security descriptor of the parent object that is being created.
[in]ExplicitDescriptorAn explicit security descriptor that is applied to a new object.
[out]NewDescriptorThe new allocated security descriptor.
[in]IsDirectoryObjectSet this to TRUE if the newly created object is a directory object, otherwise set this to FALSE.
[in]SubjectContextSecurity subject context of the new object.
[in]GenericMappingGeneric mapping of access mask rights.
[in]PoolTypeThis parameter is unused.
Returns
See SeAssignSecurityEx.
Parameters
[in]SecurityDescriptorA security descriptor.
[out]QuotaInfoSizeThe returned quota size of the given security descriptor to the caller. The function may return 0 to this parameter if the descriptor doesn't have a group or a discretionary access control list (DACL) even.
Returns
Returns STATUS_SUCCESS if the quota size of a security descriptor has been computed successfully. STATUS_UNKNOWN_REVISION is returned if the security descriptor has an invalid revision.

Definition at line 1788 of file unicode.c.

1799 {
1800  NTSTATUS Status;
1801  ULONG Length;
1802  ULONG Index;
1803 
1804  PAGED_CODE_RTL();
1805 
1806  /* Calculate size of the string */
1807  Length = RtlUnicodeStringToCountedOemSize(UniSource);
1808 
1809  /* If it's 0 then zero out dest string and return */
1810  if (!Length)
1811  {
1812  RtlZeroMemory(OemDest, sizeof(OEM_STRING));
1813  return STATUS_SUCCESS;
1814  }
1815 
1816  /* Check if length is a sane value */
1818 
1819  /* Store it in dest string */
1820  OemDest->Length = (USHORT)Length;
1821 
1822  /* If we're asked to alloc the string - do so */
1824  {
1825  OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
1826  OemDest->MaximumLength = (USHORT)Length;
1827  if (!OemDest->Buffer) return STATUS_NO_MEMORY;
1828  }
1829  else if (OemDest->Length > OemDest->MaximumLength)
1830  {
1831  return STATUS_BUFFER_OVERFLOW;
1832  }
1833 
1834  /* Do the conversion */
1835  Status = RtlUnicodeToOemN(OemDest->Buffer,
1836  OemDest->Length,
1837  &Index,
1838  UniSource->Buffer,
1839  UniSource->Length);
1840 
1841  /* Check for unmapped character */
1842  if (NT_SUCCESS(Status) && !RtlpDidUnicodeToOemWork(UniSource, OemDest))
1844 
1846  {
1847  /* Conversion failed, free dest string and return status code */
1848  RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
1849  OemDest->Buffer = NULL;
1850  return Status;
1851  }
1852 
1853  return Status;
1854 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define TAG_OSTR
Definition: inbv.c:15
#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)
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
#define RtlpFreeStringMemory
Definition: rtlp.h:141
BOOLEAN NTAPI RtlpDidUnicodeToOemWork(IN PCUNICODE_STRING UnicodeString, IN POEM_STRING OemString)
Definition: unicode.c:472
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define STATUS_UNMAPPABLE_CHARACTER
Definition: ntstatus.h:590
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
#define MAXUSHORT
Definition: typedefs.h:83
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1320

◆ 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
PUSHORT NlsLeadByteInfo
Definition: nls.c:26
LONG NTSTATUS
Definition: precomp.h:26
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
Status
Definition: gdiplustypes.h:24
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define DPRINT
Definition: sndvol32.h:71

◆ 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 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NlsMbCodePageTag
Definition: nls.c:22
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
Status
Definition: gdiplustypes.h:24
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
#define RtlpFreeStringMemory
Definition: rtlp.h:141
#define TAG_USTR
Definition: libsupp.c:118
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
#define MAXUSHORT
Definition: typedefs.h:83
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:1320

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

◆ RtlAppendAsciizToString()

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

Definition at line 2452 of file unicode.c.

2455 {
2456  SIZE_T Size;
2457 
2458  if (Source)
2459  {
2460  Size = strlen(Source);
2461 
2463  {
2464  return STATUS_BUFFER_TOO_SMALL;
2465  }
2466 
2469  }
2470 
2471  return STATUS_SUCCESS;
2472 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2950
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned short USHORT
Definition: pedump.c:61
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ 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:264
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2950
unsigned short USHORT
Definition: pedump.c:61
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ 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:56
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define UNICODE_NULL
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2950
unsigned short USHORT
Definition: pedump.c:61
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ RtlAppendUnicodeToString()

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

Definition at line 2411 of file unicode.c.

2413 {
2414  USHORT Length;
2415  PWCHAR DestBuffer;
2416 
2417  if (Source)
2418  {
2419  UNICODE_STRING UnicodeSource;
2420 
2421  RtlInitUnicodeString(&UnicodeSource, Source);
2422  Length = UnicodeSource.Length;
2423 
2425  {
2426  return STATUS_BUFFER_TOO_SMALL;
2427  }
2428 
2429  DestBuffer = &Destination->Buffer[Destination->Length / sizeof(WCHAR)];
2430  RtlMoveMemory(DestBuffer, Source, Length);
2432 
2433  /* append terminating '\0' if enough space */
2435  {
2436  DestBuffer[Length / sizeof(WCHAR)] = UNICODE_NULL;
2437  }
2438  }
2439 
2440  return STATUS_SUCCESS;
2441 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWCHAR
Definition: typedefs.h:56
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
VOID NTAPI RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString, IN PCWSTR SourceString)
Definition: unicode.c:641
#define UNICODE_NULL
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2950
unsigned short USHORT
Definition: pedump.c:61
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ 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 }
Definition: pdh_main.c:93
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char CHAR
Definition: xmlstorage.h:175
const WCHAR * str
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65

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:2304
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 2199 of file unicode.c.

2203 {
2204  unsigned int len;
2205  LONG ret = 0;
2206  LPCWSTR p1, p2;
2207 
2208  len = min(s1->Length, s2->Length) / sizeof(WCHAR);
2209  p1 = s1->Buffer;
2210  p2 = s2->Buffer;
2211 
2212  if (CaseInsensitive)
2213  {
2214  while (!ret && len--) ret = RtlpUpcaseUnicodeChar(*p1++) - RtlpUpcaseUnicodeChar(*p2++);
2215  }
2216  else
2217  {
2218  while (!ret && len--) ret = *p1++ - *p2++;
2219  }
2220 
2221  if (!ret) ret = s1->Length - s2->Length;
2222 
2223  return ret;
2224 }
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:2304
__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:693

Referenced by RtlEqualUnicodeString().

◆ RtlCopyString()

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

Definition at line 2231 of file unicode.c.

2234 {
2235  ULONG SourceLength;
2236  PCHAR p1, p2;
2237 
2238  /* Check if there was no source given */
2239  if(!SourceString)
2240  {
2241  /* Simply return an empty string */
2243  }
2244  else
2245  {
2246  /* Choose the smallest length */
2247  SourceLength = min(DestinationString->MaximumLength,
2248  SourceString->Length);
2249 
2250  /* Set it */
2251  DestinationString->Length = (USHORT)SourceLength;
2252 
2253  /* Save the pointers to each buffer */
2254  p1 = DestinationString->Buffer;
2255  p2 = SourceString->Buffer;
2256 
2257  /* Loop the buffer */
2258  while (SourceLength)
2259  {
2260  /* Copy the character and move on */
2261  *p1++ = * p2++;
2262  SourceLength--;
2263  }
2264  }
2265 }
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:1868
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1868
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 2272 of file unicode.c.

2275 {
2276  ULONG SourceLength;
2277 
2278  if(SourceString == NULL)
2279  {
2281  }
2282  else
2283  {
2284  SourceLength = min(DestinationString->MaximumLength,
2285  SourceString->Length);
2286  DestinationString->Length = (USHORT)SourceLength;
2287 
2290  SourceLength);
2291 
2293  {
2294  DestinationString->Buffer[SourceLength / sizeof(WCHAR)] = UNICODE_NULL;
2295  }
2296  }
2297 }
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
#define UNICODE_NULL
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1868
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1868
unsigned short USHORT
Definition: pedump.c:61
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
unsigned short MaximumLength
Definition: sprintf.c:452

◆ RtlCreateUnicodeString()

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

Definition at line 2307 of file unicode.c.

2310 {
2311  SIZE_T Size;
2312  PAGED_CODE_RTL();
2313 
2314  Size = (wcslen(Source) + 1) * sizeof(WCHAR);
2315  if (Size > MAXUSHORT) return FALSE;
2316 
2317  UniDest->Buffer = RtlpAllocateStringMemory((ULONG)Size, TAG_USTR);
2318 
2319  if (UniDest->Buffer == NULL) return FALSE;
2320 
2321  RtlCopyMemory(UniDest->Buffer, Source, Size);
2322  UniDest->MaximumLength = (USHORT)Size;
2323  UniDest->Length = (USHORT)Size - sizeof (WCHAR);
2324 
2325  return TRUE;
2326 }
#define TRUE
Definition: types.h:120
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define FALSE
Definition: types.h:117
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define TAG_USTR
Definition: libsupp.c:118
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned short USHORT
Definition: pedump.c:61
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define MAXUSHORT
Definition: typedefs.h:83
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167

◆ RtlCreateUnicodeStringFromAsciiz()

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

Definition at line 2333 of file unicode.c.

2336 {
2338  NTSTATUS Status;
2339 
2341 
2343  &AnsiString,
2344  TRUE);
2345 
2346  return NT_SUCCESS(Status);
2347 }
#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
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2950
VOID NTAPI RtlInitAnsiString(IN OUT PANSI_STRING DestinationString, IN PCSZ SourceString)
Definition: unicode.c:573
_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 2745 of file unicode.c.

2746 {
2747  NTSTATUS Status;
2748  ULONG Length;
2749  ULONG ComputerNameLength;
2750  ULONG ComputerNameOemNLength;
2751  OEM_STRING ComputerNameOem;
2752  CHAR ComputerNameOemN[MAX_COMPUTERNAME_LENGTH + 1];
2753 
2755  ComputerNameLength = DnsHostName->Length;
2756 
2757  /* find the first dot in the dns host name */
2758  for (Length = 0; Length < DnsHostName->Length / sizeof(WCHAR); Length++)
2759  {
2760  if (DnsHostName->Buffer[Length] == L'.')
2761  {
2762  /* dot found, so set the length for the oem translation */
2763  ComputerNameLength = Length * sizeof(WCHAR);
2764  break;
2765  }
2766  }
2767 
2768  /* the computername must have one character */
2769  if (ComputerNameLength > 0)
2770  {
2771  ComputerNameOemNLength = 0;
2772  /* convert to oem string and use uppercase letters */
2773  Status = RtlUpcaseUnicodeToOemN(ComputerNameOemN,
2775  &ComputerNameOemNLength,
2776  DnsHostName->Buffer,
2777  ComputerNameLength);
2778 
2779  /* status STATUS_BUFFER_OVERFLOW is not a problem since the computername shoud only
2780  have MAX_COMPUTERNAME_LENGTH characters */
2781  if ((Status == STATUS_SUCCESS) ||
2783  {
2784  /* set the termination for the oem string */
2785  ComputerNameOemN[MAX_COMPUTERNAME_LENGTH] = 0;
2786  /* set status for the case the next function failed */
2788  /* fillup the oem string structure with the converted computername
2789  and check it for unmapped characters */
2790  ComputerNameOem.Buffer = ComputerNameOemN;
2791  ComputerNameOem.Length = (USHORT)ComputerNameOemNLength;
2792  ComputerNameOem.MaximumLength = (USHORT)(MAX_COMPUTERNAME_LENGTH + 1);
2793 
2794  if (RtlpDidUnicodeToOemWork(DnsHostName, &ComputerNameOem))
2795  {
2796  /* no unmapped character so convert it back to an unicode string */
2797  Status = RtlOemStringToUnicodeString(ComputerName,
2798  &ComputerNameOem,
2799  AllocateComputerNameString);
2800  }
2801  }
2802  }
2803 
2804  return Status;
2805 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
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:1180
STRING OEM_STRING
Definition: umtypes.h:203
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
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
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INVALID_COMPUTER_NAME
Definition: ntstatus.h:526

◆ RtlDowncaseUnicodeString()

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

Definition at line 2359 of file unicode.c.

2363 {
2364  ULONG i;
2365  ULONG StopGap;
2366  PAGED_CODE_RTL();
2367 
2369  {
2370  UniDest->MaximumLength = UniSource->Length;
2371  UniDest->Buffer = RtlpAllocateStringMemory(UniSource->Length, TAG_USTR);
2372  if (UniDest->Buffer == NULL) return STATUS_NO_MEMORY;
2373  }
2374  else if (UniSource->Length > UniDest->MaximumLength)
2375  {
2376  return STATUS_BUFFER_OVERFLOW;
2377  }
2378 
2379  UniDest->Length = UniSource->Length;
2380  StopGap = UniSource->Length / sizeof(WCHAR);
2381 
2382  for (i = 0 ; i < StopGap; i++)
2383  {
2384  if (UniSource->Buffer[i] < L'A')
2385  {
2386  UniDest->Buffer[i] = UniSource->Buffer[i];
2387  }
2388  else if (UniSource->Buffer[i] <= L'Z')
2389  {
2390  UniDest->Buffer[i] = (UniSource->Buffer[i] + (L'a' - L'A'));
2391  }
2392  else
2393  {
2394  UniDest->Buffer[i] = RtlpDowncaseUnicodeChar(UniSource->Buffer[i]);
2395  }
2396  }
2397 
2398  return STATUS_SUCCESS;
2399 }
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
#define TAG_USTR
Definition: libsupp.c:118
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
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 STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
WCHAR NTAPI RtlpDowncaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:89
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1320

◆ RtlDuplicateUnicodeString()

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

Definition at line 2507 of file unicode.c.

2511 {
2512  PAGED_CODE_RTL();
2513 
2514  if (SourceString == NULL || DestinationString == NULL ||
2518  {
2519  return STATUS_INVALID_PARAMETER;
2520  }
2521 
2522 
2523  if ((SourceString->Length == 0) &&
2526  {
2530  }
2531  else
2532  {
2533  UINT DestMaxLength = SourceString->Length;
2534 
2536  DestMaxLength += sizeof(UNICODE_NULL);
2537 
2539 
2540  if (DestinationString->Buffer == NULL)
2541  return STATUS_NO_MEMORY;
2542 
2545  DestinationString->MaximumLength = DestMaxLength;
2546 
2549  }
2550 
2551  return STATUS_SUCCESS;
2552 }
#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
void * Buffer
Definition: sprintf.c:453
#define UNICODE_NULL
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1868
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__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:1868
#define TAG_USTR
Definition: libsupp.c:118
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
unsigned short MaximumLength
Definition: sprintf.c:452

◆ RtlEqualComputerName()

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

Definition at line 1543 of file unicode.c.

1546 {
1547  OEM_STRING OemString1;
1548  OEM_STRING OemString2;
1549  BOOLEAN Result = FALSE;
1550 
1552  ComputerName1,
1553  TRUE)))
1554  {
1556  ComputerName2,
1557  TRUE)))
1558  {
1559  Result = RtlEqualString(&OemString1, &OemString2, FALSE);
1560  RtlFreeOemString(&OemString2);
1561  }
1562 
1563  RtlFreeOemString(&OemString1);
1564  }
1565 
1566  return Result;
1567 }
VOID NTAPI RtlFreeOemString(IN POEM_STRING OemString)
Definition: unicode.c:435
#define TRUE
Definition: types.h:120
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
#define FALSE
Definition: types.h:117
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:2070

Referenced by RtlEqualDomainName().

◆ RtlEqualDomainName()

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

Definition at line 1580 of file unicode.c.

1583 {
1584  return RtlEqualComputerName(DomainName1, DomainName2);
1585 }
BOOLEAN NTAPI RtlEqualComputerName(IN PUNICODE_STRING ComputerName1, IN PUNICODE_STRING ComputerName2)
Definition: unicode.c:1543

◆ 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
#define FALSE
Definition: types.h:117
_In_ const STRING _In_ BOOLEAN CaseInsensitive
Definition: rtlfuncs.h:2304
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:2199
#define FALSE
Definition: types.h:117
_In_ const STRING _In_ BOOLEAN CaseInsensitive
Definition: rtlfuncs.h:2304
struct S1 s1

◆ RtlEraseUnicodeString()

VOID NTAPI RtlEraseUnicodeString ( IN PUNICODE_STRING  String)

Definition at line 1723 of file unicode.c.

1725 {
1726  if (String->Buffer && String->MaximumLength)
1727  {
1728  RtlZeroMemory(String->Buffer, String->MaximumLength);
1729  String->Length = 0;
1730  }
1731 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ RtlFindCharInUnicodeString()

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

Definition at line 2680 of file unicode.c.

2685 {
2686  BOOLEAN Found;
2689  USHORT i, Length;
2690 
2691  DPRINT("RtlFindCharInUnicodeString(%u, '%wZ', '%wZ', %p)\n",
2692  Flags, SearchString, MatchString, Position);
2693 
2694  /* Parameter checks */
2695  if (Position == NULL)
2696  return STATUS_INVALID_PARAMETER;
2697 
2698  *Position = 0;
2699 
2703  return STATUS_INVALID_PARAMETER;
2704 
2705  /* Search */
2706  Length = SearchString->Length / sizeof(WCHAR);
2708  {
2709  for (i = Length - 1; (SHORT)i >= 0; i--)
2710  {
2711  Found = RtlpIsCharInUnicodeString(SearchString->Buffer[i], MatchString, CaseInSensitive);
2712  if (Found == WantToFind)
2713  {
2714  *Position = i * sizeof(WCHAR);
2715  return STATUS_SUCCESS;
2716  }
2717  }
2718  }
2719  else
2720  {
2721  for (i = 0; i < Length; i++)
2722  {
2723  Found = RtlpIsCharInUnicodeString(SearchString->Buffer[i], MatchString, CaseInSensitive);
2724  if (Found == WantToFind)
2725  {
2726  *Position = (i + 1) * sizeof(WCHAR);
2727  return STATUS_SUCCESS;
2728  }
2729  }
2730  }
2731 
2732  return STATUS_NOT_FOUND;
2733 }
#define RTL_FIND_CHAR_IN_UNICODE_STRING_START_AT_END
Definition: rtl.h:25
static BOOLEAN RtlpIsCharInUnicodeString(IN WCHAR Char, IN PCUNICODE_STRING MatchString, IN BOOLEAN CaseInSensitive)
Definition: unicode.c:2652
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static COORD Position
Definition: mouse.c:34
_In_ const STRING _In_ BOOLEAN CaseInSensitive
Definition: rtlfuncs.h:2335
short SHORT
Definition: pedump.c:59
unsigned char BOOLEAN
return Found
Definition: dirsup.c:1270
#define RTL_FIND_CHAR_IN_UNICODE_STRING_COMPLEMENT_CHAR_SET
Definition: rtl.h:26
#define STATUS_NOT_FOUND
Definition: shellext.h:72
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180
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
unsigned short USHORT
Definition: pedump.c:61
#define NULL
Definition: types.h:112
#define RTL_FIND_CHAR_IN_UNICODE_STRING_CASE_INSENSITIVE
Definition: rtl.h:27
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

◆ 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:262
#define TAG_ASTR
Definition: libsupp.c:119

◆ 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:1560
#define TAG_OSTR
Definition: inbv.c:15
#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:118
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ RtlGUIDFromString()

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

Definition at line 1607 of file unicode.c.

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

◆ RtlHashUnicodeString()

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

Definition at line 1738 of file unicode.c.

1743 {
1744  if (String != NULL && HashValue != NULL)
1745  {
1746  switch (HashAlgorithm)
1747  {
1750  {
1751  WCHAR *c, *end;
1752 
1753  *HashValue = 0;
1754  end = String->Buffer + (String->Length / sizeof(WCHAR));
1755 
1756  if (CaseInSensitive)
1757  {
1758  for (c = String->Buffer; c != end; c++)
1759  {
1760  /* only uppercase characters if they are 'a' ... 'z'! */
1761  *HashValue = ((65599 * (*HashValue)) +
1762  (ULONG)(((*c) >= L'a' && (*c) <= L'z') ?
1763  (*c) - L'a' + L'A' : (*c)));
1764  }
1765  }
1766  else
1767  {
1768  for (c = String->Buffer; c != end; c++)
1769  {
1770  *HashValue = ((65599 * (*HashValue)) + (ULONG)(*c));
1771  }
1772  }
1773 
1774  return STATUS_SUCCESS;
1775  }
1776  }
1777  }
1778 
1779  return STATUS_INVALID_PARAMETER;
1780 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ BOOLEAN _In_ ULONG HashAlgorithm
Definition: rtlfuncs.h:2037
_In_ BOOLEAN _In_ ULONG _Out_ PULONG HashValue
Definition: rtlfuncs.h:2037
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
_In_ const STRING _In_ BOOLEAN CaseInSensitive
Definition: rtlfuncs.h:2335
__wchar_t WCHAR
Definition: xmlstorage.h:180
const GLubyte * c
Definition: glext.h:8905
GLuint GLuint end
Definition: gl.h:1545
static const WCHAR L[]
Definition: oid.c:1250
#define HASH_STRING_ALGORITHM_DEFAULT
#define NULL
Definition: types.h:112
#define c
Definition: ke_i.h:80
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define HASH_STRING_ALGORITHM_X65599
Definition: rtlstr.c:33

◆ RtlInitAnsiString()

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

Definition at line 573 of file unicode.c.

575 {
576  SIZE_T Size;
577 
578  if (SourceString)
579  {
581  if (Size > (MAXUSHORT - sizeof(CHAR))) Size = MAXUSHORT - sizeof(CHAR);
584  }
585  else
586  {
589  }
590 
592 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1868
#define PCHAR
Definition: match.c:90
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1868
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned short USHORT
Definition: pedump.c:61
#define MAXUSHORT
Definition: typedefs.h:83
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 596 of file unicode.c.

598 {
599  SIZE_T Size;
600 
601  if (SourceString)
602  {
604  if (Size > (MAXUSHORT - sizeof(CHAR))) return STATUS_NAME_TOO_LONG;
607  }
608  else
609  {
612  }
613 
615  return STATUS_SUCCESS;
616 
617 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1868
#define STATUS_NAME_TOO_LONG
Definition: ntstatus.h:498
#define PCHAR
Definition: match.c:90
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1868
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned short USHORT
Definition: pedump.c:61
#define MAXUSHORT
Definition: typedefs.h:83
#define STATUS_SUCCESS
Definition: shellext.h:65
unsigned short MaximumLength
Definition: sprintf.c:452

◆ RtlInitString()

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

Definition at line 626 of file unicode.c.

629 {
631 }
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1868
VOID NTAPI RtlInitAnsiString(IN OUT PANSI_STRING DestinationString, IN PCSZ SourceString)
Definition: unicode.c:573
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1868

◆ RtlInitUnicodeString()

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

Definition at line 641 of file unicode.c.

644 {
645  SIZE_T Size;
646  CONST SIZE_T MaxSize = (MAXUSHORT & ~1) - sizeof(UNICODE_NULL); // an even number
647 
648  if (SourceString)
649  {
650  Size = wcslen(SourceString) * sizeof(WCHAR);
651  __analysis_assume(Size <= MaxSize);
652 
653  if (Size > MaxSize)
654  Size = MaxSize;
657  }
658  else
659  {
662  }
663 
665 }
#define __analysis_assume(expr)
Definition: ms_sal.h:2893
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
unsigned short Length
Definition: sprintf.c:451
uint16_t * PWCHAR
Definition: typedefs.h:56
void * Buffer
Definition: sprintf.c:453
#define UNICODE_NULL
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1868
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1868
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned short USHORT
Definition: pedump.c:61
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define MAXUSHORT
Definition: typedefs.h:83
unsigned short MaximumLength
Definition: sprintf.c:452
#define CONST
Definition: pedump.c:81

Referenced by RtlAppendUnicodeToString().

◆ RtlInitUnicodeStringEx()

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

Definition at line 672 of file unicode.c.

675 {
676  SIZE_T Size;
677  CONST SIZE_T MaxSize = (MAXUSHORT & ~1) - sizeof(WCHAR); // an even number
678 
679  if (SourceString)
680  {
681  Size = wcslen(SourceString) * sizeof(WCHAR);
682  if (Size > MaxSize) return STATUS_NAME_TOO_LONG;
685  }
686  else
687  {
690  }
691 
693  return STATUS_SUCCESS;
694 }
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
unsigned short Length
Definition: sprintf.c:451
uint16_t * PWCHAR
Definition: typedefs.h:56
void * Buffer
Definition: sprintf.c:453
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1868
#define STATUS_NAME_TOO_LONG
Definition: ntstatus.h:498
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1868
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned short USHORT
Definition: pedump.c:61
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define MAXUSHORT
Definition: typedefs.h:83
#define STATUS_SUCCESS
Definition: shellext.h:65
unsigned short MaximumLength
Definition: sprintf.c:452
#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 853 of file unicode.c.

857 {
858  LARGE_INTEGER LargeInt;
860  CHAR Buffer[65];
862 
863  LargeInt.QuadPart = Value;
864 
865  Status = RtlLargeIntegerToChar(&LargeInt, Base, sizeof(Buffer), Buffer);
866  if (NT_SUCCESS(Status))
867  {
868  AnsiString.Buffer = Buffer;
869  AnsiString.Length = (USHORT)strlen(Buffer);
870  AnsiString.MaximumLength = sizeof(Buffer);
871 
873  }
874 
875  return Status;
876 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2386
NTSTATUS NTAPI RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING UniDest, IN PANSI_STRING AnsiSource, IN BOOLEAN AllocateDestinationString)
Definition: unicode.c:91
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
#define FALSE
Definition: types.h:117
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
Status
Definition: gdiplustypes.h:24
#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:1861
unsigned short USHORT
Definition: pedump.c:61
LONGLONG QuadPart
Definition: typedefs.h:114

◆ RtlIntegerToChar()

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

Definition at line 704 of file unicode.c.

709 {
710  CHAR buffer[33];
711  PCHAR pos;
712  CHAR digit;
713  SIZE_T len;
714 
715  if (base == 0)
716  {
717  base = 10;
718  }
719  else if (base != 2 && base != 8 && base != 10 && base != 16)
720  {
722  }
723 
724  pos = &buffer[32];
725  *pos = '\0';
726 
727  do
728  {
729  pos--;
730  digit = (CHAR)(value % base);
731  value = value / base;
732 
733  if (digit < 10)
734  {
735  *pos = '0' + digit;
736  }
737  else
738  {
739  *pos = 'A' + digit - 10;
740  }
741  }
742  while (value != 0L);
743 
744  len = &buffer[32] - pos;
745 
746  if (len > length)
747  {
748  return STATUS_BUFFER_OVERFLOW;
749  }
750  else if (str == NULL)
751  {
753  }
754  else if (len == length)
755  {
757  }
758  else
759  {
760  RtlCopyMemory(str, pos, len + 1);
761  }
762 
763  return STATUS_SUCCESS;
764 }
signed char * PCHAR
Definition: retypes.h:7
Definition: pdh_main.c:93
#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
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
const WCHAR * str
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define NULL
Definition: types.h:112
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
#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 771 of file unicode.c.

776 {
777  ULONG Radix;
778  WCHAR temp[33];
779  ULONG v = Value;
780  ULONG i;
781  PWCHAR tp;
782  PWCHAR sp;
783 
784  Radix = Base;
785 
786  if (Radix == 0) Radix = 10;
787 
788  if ((Radix != 2) && (Radix != 8) &&
789  (Radix != 10) && (Radix != 16))
790  {
792  }
793 
794  tp = temp;
795 
796  while (v || tp == temp)
797  {
798  i = v % Radix;
799  v = v / Radix;
800 
801  if (i < 10) *tp = (WCHAR)(i + L'0');
802  else *tp = (WCHAR)(i + L'a' - 10);
803 
804  tp++;
805  }
806 
807  if ((ULONG)((ULONG_PTR)tp - (ULONG_PTR)temp) >= Length)
808  {
810  }
811 
812  sp = String;
813 
814  while (tp > temp) *sp++ = *--tp;
815 
816  *sp = 0;
817 
818  return STATUS_SUCCESS;
819 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2386
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2930
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
const GLdouble * v
Definition: gl.h:2040
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
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
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ RtlIntegerToUnicodeString()

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

Definition at line 826 of file unicode.c.

830 {
832  CHAR Buffer[33];
834 
836  if (NT_SUCCESS(Status))
837  {
838  AnsiString.Buffer = Buffer;
839  AnsiString.Length = (USHORT)strlen(Buffer);
840  AnsiString.MaximumLength = sizeof(Buffer);
841 
843  }
844 
845  return Status;
846 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2386
NTSTATUS NTAPI RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING UniDest, IN PANSI_STRING AnsiSource, IN BOOLEAN AllocateDestinationString)
Definition: unicode.c:91
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
#define FALSE
Definition: types.h:117
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI RtlIntegerToChar(ULONG value, ULONG base, ULONG length, PCHAR str)
Definition: unicode.c:704
unsigned short USHORT
Definition: pedump.c:61

◆ RtlIsTextUnicode()

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

Definition at line 1290 of file unicode.c.

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

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;
523 
524  OemChar = NlsUnicodeToMbOemTable[*Char];
525 
526  /* If character has Lead Byte */
527  Offset = NlsOemLeadByteInfo[HIBYTE(OemChar)];
528  if (Offset)
529  {
530  /* Use DBCS table */
531  UnicodeChar = NlsOemLeadByteInfo[Offset + LOBYTE(OemChar)];
532  }
533  else
534  {
535  UnicodeChar = NlsOemToUnicodeTable[OemChar];
536  }
537 
538  /* Upcase */
539  UnicodeChar = RtlpUpcaseUnicodeChar(UnicodeChar);
540 
541  /* Receive OEM character from the table */
542  OemChar = NlsUnicodeToMbOemTable[UnicodeChar];
543  }
544  else
545  {
546  /* Receive Unicode character from the table */
548 
549  /* Receive OEM character from the table */
550  OemChar = NlsUnicodeToOemTable[UnicodeChar];
551  }
552 
553  /* Not valid character, failed */
554  if (OemChar == NlsOemDefaultChar)
555  {
556  DPRINT1("\\u%04x is not valid for OEM\n", *Char);
557  return FALSE;
558  }
559 
560  *Char = UnicodeChar;
561 
562  return TRUE;
563 }
#define LOBYTE(W)
Definition: jmemdos.c:487
#define TRUE
Definition: types.h:120
#define HIBYTE(W)
Definition: jmemdos.c:486
#define FALSE
Definition: types.h:117
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
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
PWCHAR NlsOemToUnicodeTable
Definition: nls.c:30
unsigned short USHORT
Definition: pedump.c:61
WCHAR NTAPI RtlpUpcaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:693
#define DPRINT1
Definition: precomp.h:8
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 1861 of file unicode.c.

1866 {
1867  ULONGLONG Val = Value->QuadPart;
1868  CHAR Buffer[65];
1869  CHAR Digit;
1870  SIZE_T Len;
1871  PCHAR Pos;
1872 
1873  if (Base == 0) Base = 10;
1874 
1875  if ((Base != 2) && (Base != 8) && (Base != 10) && (Base != 16))
1876  {
1877  return STATUS_INVALID_PARAMETER;
1878  }
1879 
1880  Pos = &Buffer[64];
1881  *Pos = '\0';
1882 
1883  do
1884  {
1885  Pos--;
1886  Digit = (CHAR)(Val % Base);
1887  Val = Val / Base;
1888 
1889  if (Digit < 10)
1890  *Pos = '0' + Digit;
1891  else
1892  *Pos = 'A' + Digit - 10;
1893  }
1894  while (Val != 0L);
1895 
1896  Len = &Buffer[64] - Pos;
1897 
1898  if (Len > Length)
1899  return STATUS_BUFFER_OVERFLOW;
1900 
1901  /* If possible, add the 0 termination */
1902  if (Len < Length)
1903  Len += 1;
1904 
1905  /* Copy the string to the target using SEH */
1906  return RtlpSafeCopyMemory(String, Pos, Len);
1907 }
signed char * PCHAR
Definition: retypes.h:7
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char CHAR
Definition: xmlstorage.h:175
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2386
ush Pos
Definition: deflate.h:92
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
uint64_t ULONGLONG
Definition: typedefs.h:67
#define Len
Definition: deflate.h:82
static const WCHAR L[]
Definition: oid.c:1250
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
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 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115

◆ RtlOemStringToCountedUnicodeString()

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

Definition at line 1474 of file unicode.c.

1478 {
1479  NTSTATUS Status;
1480  ULONG Length;
1481  ULONG Index;
1482 
1483  PAGED_CODE_RTL();
1484 
1485  /* Calculate size of the string */
1487 
1488  /* If it's 0 then zero out dest string and return */
1489  if (!Length)
1490  {
1491  RtlZeroMemory(UniDest, sizeof(UNICODE_STRING));
1492  return STATUS_SUCCESS;
1493  }
1494 
1495  /* Check if length is a sane value */
1497 
1498  /* Store it in dest string */
1499  UniDest->Length = (USHORT)Length;
1500 
1501  /* If we're asked to alloc the string - do so */
1503  {
1504  UniDest->Buffer = RtlpAllocateStringMemory(Length, TAG_USTR);
1505  UniDest->MaximumLength = (USHORT)Length;
1506 
1507  if (!UniDest->Buffer) return STATUS_NO_MEMORY;
1508  }
1509  else if (UniDest->Length > UniDest->MaximumLength)
1510  {
1511  return STATUS_BUFFER_OVERFLOW;
1512  }
1513 
1514  /* Do the conversion */
1515  Status = RtlOemToUnicodeN(UniDest->Buffer,
1516  UniDest->Length,
1517  &Index,
1518  OemSource->Buffer,
1519  OemSource->Length);
1520 
1522  {
1523  /* Conversion failed, free dest string and return status code */
1524  RtlpFreeStringMemory(UniDest->Buffer, TAG_USTR);
1525  UniDest->Buffer = NULL;
1526  return Status;
1527  }
1528 
1529  return STATUS_SUCCESS;
1530 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSYSAPI NTSTATUS WINAPI RtlOemToUnicodeN(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 STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
#define RtlpFreeStringMemory
Definition: rtlp.h:141
#define TAG_USTR
Definition: libsupp.c:118
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
#define MAXUSHORT
Definition: typedefs.h:83
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1320
#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 1180 of file unicode.c.

1184 {
1185  NTSTATUS Status;
1186  ULONG Length;
1187  ULONG Index;
1188 
1189  PAGED_CODE_RTL();
1190 
1191  Length = RtlOemStringToUnicodeSize(OemSource);
1192 
1194 
1195  UniDest->Length = (USHORT)Length - sizeof(WCHAR);
1196 
1198  {
1199  UniDest->Buffer = RtlpAllocateStringMemory(Length, TAG_USTR);
1200  UniDest->MaximumLength = (USHORT)Length;
1201 
1202  if (!UniDest->Buffer) return STATUS_NO_MEMORY;
1203  }
1204  else if (UniDest->Length >= UniDest->MaximumLength)
1205  {
1206  return STATUS_BUFFER_OVERFLOW;
1207  }
1208 
1209  Status = RtlOemToUnicodeN(UniDest->Buffer,
1210  UniDest->Length,
1211  &Index,
1212  OemSource->Buffer,
1213  OemSource->Length);
1214 
1216  {
1217  RtlpFreeStringMemory(UniDest->Buffer, TAG_USTR);
1218  UniDest->Buffer = NULL;
1219  return Status;
1220  }
1221 
1222  UniDest->Buffer[Index / sizeof(WCHAR)] = UNICODE_NULL;
1223  return Status;
1224 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSYSAPI NTSTATUS WINAPI RtlOemToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
NTSYSAPI UINT WINAPI RtlOemStringToUnicodeSize(const STRING *)
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define UNICODE_NULL
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
#define RtlpFreeStringMemory
Definition: rtlp.h:141
#define TAG_USTR
Definition: libsupp.c:118
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
#define MAXUSHORT
Definition: typedefs.h:83
unsigned int ULONG
Definition: retypes.h:1
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1320

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:1560
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define TRUE
Definition: types.h:120
USHORT NlsUnicodeDefaultChar
Definition: nls.c:36
#define FALSE
Definition: types.h:117
BOOLEAN NlsMbOemCodePageTag
Definition: nls.c:29
USHORT NlsOemDefaultChar
Definition: nls.c:35
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
unsigned int ULONG
Definition: retypes.h:1

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

◆ RtlpEnsureBufferSize()

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

Definition at line 2590 of file unicode.c.

2594 {
2595  PUCHAR NewBuffer;
2596 
2597  /* Parameter checks */
2598  if (Flags & ~RTL_SKIP_BUFFER_COPY)
2599  return STATUS_INVALID_PARAMETER;
2600  if (Buffer == NULL)
2601  return STATUS_INVALID_PARAMETER;
2602 
2603  /*
2604  * We don't need to grow the buffer if its size
2605  * is already larger than the required size.
2606  */
2607  if (Buffer->Size >= RequiredSize)
2608  return STATUS_SUCCESS;
2609 
2610  /*
2611  * When we are using the static buffer as our buffer, we don't need
2612  * to grow it if its size is already larger than the required size.
2613  * In this case, just keep it but update the current buffer size to
2614  * the one requested.
2615  * (But NEVER EVER modify the size of the static buffer!!)
2616  * Otherwise, we'll need to create a new buffer and use this one instead.
2617  */
2618  if ( (Buffer->Buffer == Buffer->StaticBuffer) &&
2619  (Buffer->StaticSize >= RequiredSize) )
2620  {
2621  Buffer->Size = RequiredSize;
2622  return STATUS_SUCCESS;
2623  }
2624 
2625  /* The buffer we are using is not large enough, try to create a bigger one */
2627  if (NewBuffer == NULL)
2628  return STATUS_NO_MEMORY;
2629 
2630  /* Copy the original content if needed */
2631  if (!(Flags & RTL_SKIP_BUFFER_COPY))
2632  {
2633  RtlMoveMemory(NewBuffer, Buffer->Buffer, Buffer->Size);
2634  }
2635 
2636  /* Free the original buffer only if it's not the static buffer */
2637  if (Buffer->Buffer != Buffer->StaticBuffer)
2638  {
2640  }
2641 
2642  /* Update the members */
2643  Buffer->Buffer = NewBuffer;
2644  Buffer->Size = RequiredSize;
2645 
2646  /* Done */
2647  return STATUS_SUCCESS;
2648 }
#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:264
Definition: bufpool.h:45
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define RtlpFreeStringMemory
Definition: rtlp.h:141
#define TAG_USTR
Definition: libsupp.c:118
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define RTL_SKIP_BUFFER_COPY
Definition: rtlfuncs.h:2398
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ RtlpIsCharInUnicodeString()

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

Definition at line 2652 of file unicode.c.

2656 {
2657  USHORT i;
2658 
2659  if (CaseInSensitive)
2660  Char = RtlpUpcaseUnicodeChar(Char);
2661 
2662  for (i = 0; i < MatchString->Length / sizeof(WCHAR); i++)
2663  {
2664  WCHAR OtherChar = MatchString->Buffer[i];
2665  if (CaseInSensitive)
2666  OtherChar = RtlpUpcaseUnicodeChar(OtherChar);
2667 
2668  if (Char == OtherChar)
2669  return TRUE;
2670  }
2671 
2672  return FALSE;
2673 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_ const STRING _In_ BOOLEAN CaseInSensitive
Definition: rtlfuncs.h:2335
__wchar_t WCHAR
Definition: xmlstorage.h:180
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
unsigned short USHORT
Definition: pedump.c:61
WCHAR NTAPI RtlpUpcaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:693

Referenced by RtlFindCharInUnicodeString().

◆ RtlPrefixString()

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

Definition at line 886 of file unicode.c.

890 {
891  PCHAR pc1;
892  PCHAR pc2;
893  ULONG NumChars;
894 
895  if (String2->Length < String1->Length)
896  return FALSE;
897 
898  NumChars = String1->Length;
899  pc1 = String1->Buffer;
900  pc2 = String2->Buffer;
901 
902  if (pc1 && pc2)
903  {
904  if (CaseInsensitive)
905  {
906  while (NumChars--)
907  {
908  if (RtlUpperChar(*pc1++) != RtlUpperChar(*pc2++))
909  return FALSE;
910  }
911  }
912  else
913  {
914  while (NumChars--)
915  {
916  if (*pc1++ != *pc2++)
917  return FALSE;
918  }
919  }
920 
921  return TRUE;
922  }
923 
924  return FALSE;
925 }
signed char * PCHAR
Definition: retypes.h:7
static const unsigned char pc2[48]
Definition: des.c:68
static const unsigned char pc1[56]
Definition: des.c:54
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_ const STRING _In_ BOOLEAN CaseInsensitive
Definition: rtlfuncs.h:2304
NTSYSAPI CHAR NTAPI RtlUpperChar(CHAR Character)
_In_ const STRING * String2
Definition: rtlfuncs.h:2304
unsigned int ULONG
Definition: retypes.h:1

◆ RtlPrefixUnicodeString()

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

Definition at line 935 of file unicode.c.

939 {
940  PWCHAR pc1;
941  PWCHAR pc2;
942  ULONG NumChars;
943 
944  if (String2->Length < String1->Length)
945  return FALSE;
946 
947  NumChars = String1->Length / sizeof(WCHAR);
948  pc1 = String1->Buffer;
949  pc2 = String2->Buffer;
950 
951  if (pc1 && pc2)
952  {
953  if (CaseInsensitive)
954  {
955  while (NumChars--)
956  {
957  if (RtlpUpcaseUnicodeChar(*pc1++) !=
959  return FALSE;
960  }
961  }
962  else
963  {
964  while (NumChars--)
965  {
966  if (*pc1++ != *pc2++)
967  return FALSE;
968  }
969  }
970 
971  return TRUE;
972  }
973 
974  return FALSE;
975 }
static const unsigned char pc2[48]
Definition: des.c:68
static const unsigned char pc1[56]
Definition: des.c:54
#define TRUE
Definition: types.h:120
uint16_t * PWCHAR
Definition: typedefs.h:56
#define FALSE
Definition: types.h:117
_In_ const STRING _In_ BOOLEAN CaseInsensitive
Definition: rtlfuncs.h:2304
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR NTAPI RtlpUpcaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:693
_In_ const STRING * String2
Definition: rtlfuncs.h:2304
unsigned int ULONG
Definition: retypes.h:1

◆ RtlStringFromGUID()

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

Definition at line 2143 of file unicode.c.

2145 {
2146  /* Setup the string */
2147  GuidString->Length = 38 * sizeof(WCHAR);
2148  GuidString->MaximumLength = GuidString->Length + sizeof(UNICODE_NULL);
2149  GuidString->Buffer = RtlpAllocateStringMemory(GuidString->MaximumLength,
2150  TAG_USTR);
2151  if (!GuidString->Buffer) return STATUS_NO_MEMORY;
2152 
2153  /* Now format the GUID */
2154  swprintf(GuidString->Buffer,
2155  L"{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
2156  Guid->Data1,
2157  Guid->Data2,
2158  Guid->Data3,
2159  Guid->Data4[0],
2160  Guid->Data4[1],
2161  Guid->Data4[2],
2162  Guid->Data4[3],
2163  Guid->Data4[4],
2164  Guid->Data4[5],
2165  Guid->Data4[6],
2166  Guid->Data4[7]);
2167  return STATUS_SUCCESS;
2168 }
static PWSTR GuidString
Definition: apphelp.c:93
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define swprintf
Definition: precomp.h:40
#define UNICODE_NULL
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:760
static const WCHAR L[]
Definition: oid.c:1250
#define TAG_USTR
Definition: libsupp.c:118
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ RtlUnicodeStringToAnsiString()

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

Definition at line 1113 of file unicode.c.

1117 {
1119  NTSTATUS RealStatus;
1120  ULONG Length;
1121  ULONG Index;
1122 
1123  PAGED_CODE_RTL();
1124 
1125  ASSERT(!(UniSource->Length & 1));
1126 
1127  if (NlsMbCodePageTag == FALSE)
1128  {
1129  Length = (UniSource->Length + sizeof(WCHAR)) / sizeof(WCHAR);
1130  }
1131  else
1132  {
1133  Length = RtlxUnicodeStringToAnsiSize(UniSource);
1134  }
1135 
1137 
1138  AnsiDest->Length = (USHORT)Length - sizeof(CHAR);
1139 
1141  {
1142  AnsiDest->Buffer = RtlpAllocateStringMemory(Length, TAG_ASTR);
1143  AnsiDest->MaximumLength = (USHORT)Length;
1144 
1145  if (!AnsiDest->Buffer) return STATUS_NO_MEMORY;
1146  }
1147  else if (AnsiDest->Length >= AnsiDest->MaximumLength)
1148  {
1149  if (!AnsiDest->MaximumLength) return STATUS_BUFFER_OVERFLOW;
1150 
1152  AnsiDest->Length = AnsiDest->MaximumLength - 1;
1153  }
1154 
1155  RealStatus = RtlUnicodeToMultiByteN(AnsiDest->Buffer,
1156  AnsiDest->Length,
1157  &Index,
1158  UniSource->Buffer,
1159  UniSource->Length);
1160 
1161  if (!NT_SUCCESS(RealStatus) && AllocateDestinationString)
1162  {
1163  RtlpFreeStringMemory(AnsiDest->Buffer, TAG_ASTR);
1164  return RealStatus;
1165  }
1166 
1167  AnsiDest->Buffer[Index] = ANSI_NULL;
1168  return Status;
1169 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
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 FALSE
Definition: types.h:117
#define ANSI_NULL
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
#define RtlpFreeStringMemory
Definition: rtlp.h:141
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteN(PCHAR MbString, ULONG MbSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
ULONG NTAPI RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString)
Definition: unicode.c:2178
#define MAXUSHORT
Definition: typedefs.h:83
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1320
#define TAG_ASTR
Definition: libsupp.c:119

◆ RtlUnicodeStringToInteger()

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

Definition at line 982 of file unicode.c.

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

◆ RtlUnicodeStringToOemString()

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

Definition at line 1234 of file unicode.c.

1238 {
1239  NTSTATUS Status;
1240  ULONG Length;
1241  ULONG Index;
1242 
1243  PAGED_CODE_RTL();
1244 
1245  Length = RtlUnicodeStringToOemSize(UniSource);
1246 
1248 
1249  OemDest->Length = (USHORT)Length - sizeof(CHAR);
1250 
1252  {
1253  OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
1254  OemDest->MaximumLength = (USHORT)Length;
1255 
1256  if (!OemDest->Buffer) return STATUS_NO_MEMORY;
1257  }
1258  else if (OemDest->Length >= OemDest->MaximumLength)
1259  {
1260  return STATUS_BUFFER_OVERFLOW;
1261  }
1262 
1263  Status = RtlUnicodeToOemN(OemDest->Buffer,
1264  OemDest->Length,
1265  &Index,
1266  UniSource->Buffer,
1267  UniSource->Length);
1268 
1270  {
1271  RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
1272  OemDest->Buffer = NULL;
1273  return Status;
1274  }
1275 
1276  OemDest->Buffer[Index] = ANSI_NULL;
1277  return Status;
1278 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define TAG_OSTR
Definition: inbv.c:15
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define ANSI_NULL
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToOemN(PCHAR OemString, ULONG OemSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
#define RtlpFreeStringMemory
Definition: rtlp.h:141
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
NTSYSAPI DWORD WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING *)
#define MAXUSHORT
Definition: typedefs.h:83
unsigned int ULONG
Definition: retypes.h:1
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1320

◆ RtlUpcaseUnicodeString()

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

Definition at line 1918 of file unicode.c.

1922 {
1923  ULONG i, j;
1924 
1925  PAGED_CODE_RTL();
1926 
1928  {
1929  UniDest->MaximumLength = UniSource->Length;
1930  UniDest->Buffer = RtlpAllocateStringMemory(UniDest->MaximumLength, TAG_USTR);
1931  if (UniDest->Buffer == NULL) return STATUS_NO_MEMORY;
1932  }
1933  else if (UniSource->Length > UniDest->MaximumLength)
1934  {
1935  return STATUS_BUFFER_OVERFLOW;
1936  }
1937 
1938  j = UniSource->Length / sizeof(WCHAR);
1939 
1940  for (i = 0; i < j; i++)
1941  {
1942  UniDest->Buffer[i] = RtlpUpcaseUnicodeChar(UniSource->Buffer[i]);
1943  }
1944 
1945  UniDest->Length = UniSource->Length;
1946  return STATUS_SUCCESS;
1947 }
#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 GLint GLint j
Definition: glfuncs.h:250
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define TAG_USTR
Definition: libsupp.c:118
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
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 STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
WCHAR NTAPI RtlpUpcaseUnicodeChar(IN WCHAR Source)
Definition: nls.c:693
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1320

◆ RtlUpcaseUnicodeStringToAnsiString()

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

Definition at line 1958 of file unicode.c.

1962 {
1963  NTSTATUS Status;
1964  ULONG Length;
1965  ULONG Index;
1966  PAGED_CODE_RTL();
1967 
1968  Length = RtlUnicodeStringToAnsiSize(UniSource);
1970 
1971  AnsiDest->Length = (USHORT)Length - sizeof(CHAR);
1972 
1974  {
1975  AnsiDest->Buffer = RtlpAllocateStringMemory(Length, TAG_ASTR);
1976  AnsiDest->MaximumLength = (USHORT)Length;
1977  if (!AnsiDest->Buffer) return STATUS_NO_MEMORY;
1978  }
1979  else if (AnsiDest->Length >= AnsiDest->MaximumLength)
1980  {
1981  if (!AnsiDest->MaximumLength) return STATUS_BUFFER_OVERFLOW;
1982  }
1983 
1984  Status = RtlUpcaseUnicodeToMultiByteN(AnsiDest->Buffer,
1985  AnsiDest->Length,
1986  &Index,
1987  UniSource->Buffer,
1988  UniSource->Length);
1989 
1991  {
1992  RtlpFreeStringMemory(AnsiDest->Buffer, TAG_ASTR);
1993  AnsiDest->Buffer = NULL;
1994  return Status;
1995  }
1996 
1997  AnsiDest->Buffer[Index] = ANSI_NULL;
1998  return Status;
1999 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
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:476
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
#define RtlpFreeStringMemory
Definition: rtlp.h:141
NTSYSAPI NTSTATUS NTAPI RtlUpcaseUnicodeToMultiByteN(PCHAR MbString, ULONG MbSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
NTSYSAPI DWORD WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING *)
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
#define MAXUSHORT
Definition: typedefs.h:83
unsigned int ULONG
Definition: retypes.h:1
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1320
#define TAG_ASTR
Definition: libsupp.c:119

◆ RtlUpcaseUnicodeStringToCountedOemString()

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

Definition at line 2010 of file unicode.c.

2014 {
2015  NTSTATUS Status;
2016  ULONG Length;
2017  ULONG Index;
2018  PAGED_CODE_RTL();
2019 
2020  Length = RtlUnicodeStringToCountedOemSize(UniSource);
2021 
2022  if (!Length)
2023  {
2024  RtlZeroMemory(OemDest, sizeof(OEM_STRING));
2025  }
2026 
2028 
2029  OemDest->Length = (USHORT)Length;
2030 
2032  {
2033  OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
2034  OemDest->MaximumLength = (USHORT)Length;
2035  if (!OemDest->Buffer) return STATUS_NO_MEMORY;
2036  }
2037  else if (OemDest->Length > OemDest->MaximumLength)
2038  {
2039  return STATUS_BUFFER_OVERFLOW;
2040  }
2041 
2042  Status = RtlUpcaseUnicodeToOemN(OemDest->Buffer,
2043  OemDest->Length,
2044  &Index,
2045  UniSource->Buffer,
2046  UniSource->Length);
2047 
2048  /* Check for unmapped characters */
2049  if (NT_SUCCESS(Status) && !RtlpDidUnicodeToOemWork(UniSource, OemDest))
2051 
2053  {
2054  RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
2055  OemDest->Buffer = NULL;
2056  return Status;
2057  }
2058 
2059  return Status;
2060 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define TAG_OSTR
Definition: inbv.c:15
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
STRING OEM_STRING
Definition: umtypes.h:203
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
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
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define STATUS_UNMAPPABLE_CHARACTER
Definition: ntstatus.h:590
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
#define MAXUSHORT
Definition: typedefs.h:83
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1320

◆ RtlUpcaseUnicodeStringToOemString()

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

Definition at line 2070 of file unicode.c.

2074 {
2075  NTSTATUS Status;
2076  ULONG Length;
2077  ULONG Index;
2078  PAGED_CODE_RTL();
2079 
2080  Length = RtlUnicodeStringToOemSize(UniSource);
2082 
2083  OemDest->Length = (USHORT)Length - sizeof(CHAR);
2084 
2086  {
2087  OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
2088  OemDest->MaximumLength = (USHORT)Length;
2089  if (!OemDest->Buffer) return STATUS_NO_MEMORY;
2090  }
2091  else if (OemDest->Length >= OemDest->MaximumLength)
2092  {
2093  return STATUS_BUFFER_OVERFLOW;
2094  }
2095 
2096  Status = RtlUpcaseUnicodeToOemN(OemDest->Buffer,
2097  OemDest->Length,
2098  &Index,
2099  UniSource->Buffer,
2100  UniSource->Length);
2101 
2102  /* Check for unmapped characters */
2103  if (NT_SUCCESS(Status) && !RtlpDidUnicodeToOemWork(UniSource, OemDest))
2105 
2107  {
2108  RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
2109  OemDest->Buffer = NULL;
2110  return Status;
2111  }
2112 
2113  OemDest->Buffer[Index] = ANSI_NULL;
2114  return Status;
2115 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define RtlpAllocateStringMemory
Definition: rtlp.h:140
#define TAG_OSTR
Definition: inbv.c:15
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define ANSI_NULL
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
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
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define STATUS_UNMAPPABLE_CHARACTER
Definition: ntstatus.h:590
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
NTSYSAPI DWORD WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING *)
#define MAXUSHORT
Definition: typedefs.h:83
unsigned int ULONG
Definition: retypes.h:1
_In_ PSID _In_ BOOLEAN AllocateDestinationString
Definition: rtlfuncs.h:1320

Referenced by RtlEqualComputerName().

◆ RtlUpperString()

VOID NTAPI RtlUpperString ( PSTRING  DestinationString,
const STRING SourceString 
)

Definition at line 2479 of file unicode.c.

2481 {
2482  USHORT Length;
2483  PCHAR Src, Dest;
2484 
2487 
2488  Src = SourceString->Buffer;
2489  Dest = DestinationString->Buffer;
2491 
2492  while (Length)
2493  {
2494  *Dest++ = RtlUpperChar(*Src++);
2495  Length--;
2496  }
2497 }
signed char * PCHAR
Definition: retypes.h:7
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1868
NTSYSAPI CHAR NTAPI RtlUpperChar(CHAR Character)
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1868
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  String 
)

Definition at line 2559 of file unicode.c.

2562 {
2563  /* In Windows <= 2003 no flags are supported yet! */
2564  if (Flags != 0)
2565  return STATUS_INVALID_PARAMETER;
2566 
2567  /* NOTE: a NULL Unicode string pointer is considered to be a valid one! */
2568  if (String == NULL)
2569  {
2570  return STATUS_SUCCESS;
2571  }
2572  else if (!((String->Buffer == NULL) && (String->Length != 0 || String->MaximumLength != 0)) &&
2573  (String->Length % sizeof(WCHAR) == 0) &&
2574  (String->MaximumLength % sizeof(WCHAR) == 0) &&
2575  (String->Length <= String->MaximumLength))
2576  {
2577  return STATUS_SUCCESS;
2578  }
2579  else
2580  {
2581  return STATUS_INVALID_PARAMETER;
2582  }
2583 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by LsaApLogonUserEx2(), LsapSetLogonSessionData(), MsvpChangePassword(), SeReportSecurityEvent(), and START_TEST().

◆ 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 }
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeSize(DWORD *, LPCSTR, UINT)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned int ULONG
Definition: retypes.h:1

Referenced by RtlAnsiStringToUnicodeString().

◆ RtlxOemStringToUnicodeSize()

ULONG NTAPI RtlxOemStringToUnicodeSize ( IN PCOEM_STRING  OemString)

Definition at line 2125 of file unicode.c.

2126 {
2127  ULONG Size;
2128 
2129  /* Convert the Mb String to Unicode Size */
2131  OemString->Buffer,
2132  OemString->Length);
2133 
2134  /* Return the size + null-char */
2135  return (Size + sizeof(WCHAR));
2136 }
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1560
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeSize(DWORD *, LPCSTR, UINT)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned int ULONG
Definition: retypes.h:1

◆ RtlxUnicodeStringToAnsiSize()

ULONG NTAPI RtlxUnicodeStringToAnsiSize ( IN PCUNICODE_STRING  UnicodeString)

Definition at line 2178 of file unicode.c.

2179 {
2180  ULONG Size;
2181  PAGED_CODE_RTL();
2182 
2183  ASSERT(!(UnicodeString->Length & 1));
2184 
2185  /* Convert the Unicode String to Mb Size */
2187  UnicodeString->Buffer,
2188  UnicodeString->Length);
2189 
2190  /* Return the size + null-char */
2191  return (Size + sizeof(CHAR));
2192 }
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:361
#define PAGED_CODE_RTL()
Definition: rtlp.h:16
#define ASSERT(a)
Definition: mode.c:44
unsigned int ULONG
Definition: retypes.h:1

Referenced by RtlUnicodeStringToAnsiString(), and START_TEST().

◆ RtlxUnicodeStringToOemSize()

ULONG NTAPI RtlxUnicodeStringToOemSize ( IN PCUNICODE_STRING  UnicodeString)

Definition at line 1091 of file unicode.c.

1092 {
1093  ULONG Size;
1094 
1095  /* Convert the Unicode String to Mb Size */
1097  UnicodeString->Buffer,
1098  UnicodeString->Length);
1099 
1100  /* Return the size + the null char */
1101  return (Size + sizeof(CHAR));
1102 }
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:361
unsigned int ULONG
Definition: retypes.h:1

Referenced by Ext2UnicodeToOEMSize(), and START_TEST().

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