1999-03-09 18:47:51 +01:00
|
|
|
/*
|
2000-08-26 00:12:42 +02:00
|
|
|
* Rtl string functions
|
1999-03-09 18:47:51 +01:00
|
|
|
*
|
2000-08-26 00:12:42 +02:00
|
|
|
* Copyright (C) 1996-1998 Marcus Meissner
|
|
|
|
* Copyright (C) 2000 Alexandre Julliard
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
|
1999-03-12 18:28:09 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-12-05 23:14:57 +01:00
|
|
|
#include <assert.h>
|
1999-03-09 18:47:51 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
2001-12-05 23:14:57 +01:00
|
|
|
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.h"
|
2000-06-12 03:16:11 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2001-12-05 23:14:57 +01:00
|
|
|
UINT NlsAnsiCodePage = 1252;
|
|
|
|
BYTE NlsMbCodePageTag = 0;
|
|
|
|
BYTE NlsMbOemCodePageTag = 0;
|
|
|
|
|
|
|
|
static const union cptable *ansi_table;
|
|
|
|
static const union cptable *oem_table;
|
|
|
|
|
|
|
|
inline static const union cptable *get_ansi_table(void)
|
|
|
|
{
|
|
|
|
if (!ansi_table) ansi_table = cp_get_table( 1252 );
|
|
|
|
return ansi_table;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static const union cptable *get_oem_table(void)
|
|
|
|
{
|
|
|
|
if (!oem_table) oem_table = cp_get_table( 437 );
|
|
|
|
return oem_table;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* __wine_init_codepages (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Set the code page once kernel32 is loaded. Should be done differently.
|
|
|
|
*/
|
|
|
|
void __wine_init_codepages( const union cptable *ansi, const union cptable *oem )
|
|
|
|
{
|
|
|
|
ansi_table = ansi;
|
|
|
|
oem_table = oem;
|
|
|
|
NlsAnsiCodePage = ansi->info.codepage;
|
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlInitAnsiString (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
void WINAPI RtlInitAnsiString( PSTRING target, LPCSTR source)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
if ((target->Buffer = (LPSTR)source))
|
|
|
|
{
|
|
|
|
target->Length = strlen(source);
|
|
|
|
target->MaximumLength = target->Length + 1;
|
|
|
|
}
|
|
|
|
else target->Length = target->MaximumLength = 0;
|
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlInitString (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI RtlInitString( PSTRING target, LPCSTR source )
|
|
|
|
{
|
2002-07-03 03:20:07 +02:00
|
|
|
RtlInitAnsiString( target, source );
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlFreeAnsiString (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI RtlFreeAnsiString( PSTRING str )
|
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
if (str->Buffer) RtlFreeHeap( GetProcessHeap(), 0, str->Buffer );
|
2000-08-26 00:12:42 +02:00
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlFreeOemString (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
void WINAPI RtlFreeOemString( PSTRING str )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
RtlFreeAnsiString( str );
|
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlCopyString (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI RtlCopyString( STRING *dst, const STRING *src )
|
|
|
|
{
|
|
|
|
if (src)
|
|
|
|
{
|
|
|
|
unsigned int len = min( src->Length, dst->MaximumLength );
|
|
|
|
memcpy( dst->Buffer, src->Buffer, len );
|
|
|
|
dst->Length = len;
|
|
|
|
}
|
|
|
|
else dst->Length = 0;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlInitUnicodeString (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
void WINAPI RtlInitUnicodeString( PUNICODE_STRING target, LPCWSTR source )
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
if ((target->Buffer = (LPWSTR)source))
|
|
|
|
{
|
|
|
|
target->Length = strlenW(source) * sizeof(WCHAR);
|
|
|
|
target->MaximumLength = target->Length + sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
else target->Length = target->MaximumLength = 0;
|
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlCreateUnicodeString (NTDLL.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlCreateUnicodeString( PUNICODE_STRING target, LPCWSTR src )
|
|
|
|
{
|
|
|
|
int len = (strlenW(src) + 1) * sizeof(WCHAR);
|
2001-12-05 23:14:57 +01:00
|
|
|
if (!(target->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, len ))) return FALSE;
|
2000-08-26 00:12:42 +02:00
|
|
|
memcpy( target->Buffer, src, len );
|
|
|
|
target->MaximumLength = len;
|
2002-08-13 20:18:38 +02:00
|
|
|
target->Length = len - sizeof(WCHAR);
|
2000-08-26 00:12:42 +02:00
|
|
|
return TRUE;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlCreateUnicodeStringFromAsciiz (NTDLL.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlCreateUnicodeStringFromAsciiz( PUNICODE_STRING target, LPCSTR src )
|
|
|
|
{
|
|
|
|
STRING ansi;
|
|
|
|
RtlInitAnsiString( &ansi, src );
|
|
|
|
return !RtlAnsiStringToUnicodeString( target, &ansi, TRUE );
|
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlFreeUnicodeString (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
void WINAPI RtlFreeUnicodeString( PUNICODE_STRING str )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
if (str->Buffer) RtlFreeHeap( GetProcessHeap(), 0, str->Buffer );
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlCopyUnicodeString (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
void WINAPI RtlCopyUnicodeString( UNICODE_STRING *dst, const UNICODE_STRING *src )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
if (src)
|
|
|
|
{
|
|
|
|
unsigned int len = min( src->Length, dst->MaximumLength );
|
|
|
|
memcpy( dst->Buffer, src->Buffer, len );
|
|
|
|
dst->Length = len;
|
|
|
|
/* append terminating NULL if enough space */
|
|
|
|
if (len < dst->MaximumLength) dst->Buffer[len / sizeof(WCHAR)] = 0;
|
|
|
|
}
|
|
|
|
else dst->Length = 0;
|
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlEraseUnicodeString (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI RtlEraseUnicodeString( UNICODE_STRING *str )
|
|
|
|
{
|
|
|
|
if (str->Buffer)
|
|
|
|
{
|
|
|
|
memset( str->Buffer, 0, str->MaximumLength );
|
|
|
|
str->Length = 0;
|
|
|
|
}
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/*
|
2000-08-26 00:12:42 +02:00
|
|
|
COMPARISON FUNCTIONS
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RtlCompareString (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
LONG WINAPI RtlCompareString( const STRING *s1, const STRING *s2, BOOLEAN CaseInsensitive )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
unsigned int len;
|
|
|
|
LONG ret = 0;
|
|
|
|
LPCSTR p1, p2;
|
|
|
|
|
|
|
|
len = min(s1->Length, s2->Length);
|
|
|
|
p1 = s1->Buffer;
|
|
|
|
p2 = s2->Buffer;
|
|
|
|
|
|
|
|
if (CaseInsensitive)
|
|
|
|
{
|
|
|
|
while (!ret && len--) ret = toupper(*p1++) - toupper(*p2++);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (!ret && len--) ret = *p1++ - *p2++;
|
|
|
|
}
|
|
|
|
if (!ret) ret = s1->Length - s2->Length;
|
|
|
|
return ret;
|
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RtlCompareUnicodeString (NTDLL.@)
|
|
|
|
*/
|
|
|
|
LONG WINAPI RtlCompareUnicodeString( const UNICODE_STRING *s1, const UNICODE_STRING *s2,
|
|
|
|
BOOLEAN CaseInsensitive )
|
|
|
|
{
|
|
|
|
unsigned int len;
|
|
|
|
LONG ret = 0;
|
|
|
|
LPCWSTR p1, p2;
|
|
|
|
|
|
|
|
len = min(s1->Length, s2->Length) / sizeof(WCHAR);
|
|
|
|
p1 = s1->Buffer;
|
|
|
|
p2 = s2->Buffer;
|
|
|
|
|
|
|
|
if (CaseInsensitive)
|
|
|
|
{
|
|
|
|
while (!ret && len--) ret = toupperW(*p1++) - toupperW(*p2++);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (!ret && len--) ret = *p1++ - *p2++;
|
|
|
|
}
|
|
|
|
if (!ret) ret = s1->Length - s2->Length;
|
|
|
|
return ret;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* RtlEqualString (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
BOOLEAN WINAPI RtlEqualString( const STRING *s1, const STRING *s2, BOOLEAN CaseInsensitive )
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
if (s1->Length != s2->Length) return FALSE;
|
|
|
|
return !RtlCompareString( s1, s2, CaseInsensitive );
|
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlEqualUnicodeString (NTDLL.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlEqualUnicodeString( const UNICODE_STRING *s1, const UNICODE_STRING *s2,
|
|
|
|
BOOLEAN CaseInsensitive )
|
|
|
|
{
|
|
|
|
if (s1->Length != s2->Length) return FALSE;
|
|
|
|
return !RtlCompareUnicodeString( s1, s2, CaseInsensitive );
|
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlPrefixString (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Test if s1 is a prefix in s2
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlPrefixString( const STRING *s1, const STRING *s2, BOOLEAN ignore_case )
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (s1->Length > s2->Length) return FALSE;
|
|
|
|
if (ignore_case)
|
|
|
|
{
|
|
|
|
for (i = 0; i < s1->Length; i++)
|
|
|
|
if (toupper(s1->Buffer[i]) != toupper(s2->Buffer[i])) return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < s1->Length; i++)
|
|
|
|
if (s1->Buffer[i] != s2->Buffer[i]) return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* RtlPrefixUnicodeString (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Test if s1 is a prefix in s2
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlPrefixUnicodeString( const UNICODE_STRING *s1,
|
|
|
|
const UNICODE_STRING *s2,
|
|
|
|
BOOLEAN ignore_case )
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (s1->Length > s2->Length) return FALSE;
|
|
|
|
if (ignore_case)
|
|
|
|
{
|
|
|
|
for (i = 0; i < s1->Length / sizeof(WCHAR); i++)
|
|
|
|
if (toupper(s1->Buffer[i]) != toupper(s2->Buffer[i])) return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < s1->Length / sizeof(WCHAR); i++)
|
|
|
|
if (s1->Buffer[i] != s2->Buffer[i]) return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/*
|
|
|
|
COPY BETWEEN ANSI_STRING or UNICODE_STRING
|
|
|
|
there is no parameter checking, it just crashes
|
|
|
|
*/
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlAnsiStringToUnicodeString (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
* writes terminating 0
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2002-09-13 00:07:02 +02:00
|
|
|
NTSTATUS WINAPI RtlAnsiStringToUnicodeString( PUNICODE_STRING uni,
|
|
|
|
PCANSI_STRING ansi,
|
2000-08-26 00:12:42 +02:00
|
|
|
BOOLEAN doalloc )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
DWORD total = RtlAnsiStringToUnicodeSize( ansi );
|
2000-08-26 00:12:42 +02:00
|
|
|
|
|
|
|
if (total > 0xffff) return STATUS_INVALID_PARAMETER_2;
|
2001-12-05 23:14:57 +01:00
|
|
|
uni->Length = total - sizeof(WCHAR);
|
2000-08-26 00:12:42 +02:00
|
|
|
if (doalloc)
|
|
|
|
{
|
|
|
|
uni->MaximumLength = total;
|
2001-12-05 23:14:57 +01:00
|
|
|
if (!(uni->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, total ))) return STATUS_NO_MEMORY;
|
2000-08-26 00:12:42 +02:00
|
|
|
}
|
|
|
|
else if (total > uni->MaximumLength) return STATUS_BUFFER_OVERFLOW;
|
|
|
|
|
2001-12-05 23:14:57 +01:00
|
|
|
RtlMultiByteToUnicodeN( uni->Buffer, uni->Length, NULL, ansi->Buffer, ansi->Length );
|
|
|
|
uni->Buffer[uni->Length / sizeof(WCHAR)] = 0;
|
2000-08-26 00:12:42 +02:00
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlOemStringToUnicodeString (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
2000-08-26 00:12:42 +02:00
|
|
|
* NOTES
|
|
|
|
* writes terminating 0
|
|
|
|
* if resulting length > 0xffff it returns STATUS_INVALID_PARAMETER_2
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS WINAPI RtlOemStringToUnicodeString( UNICODE_STRING *uni,
|
|
|
|
const STRING *oem,
|
|
|
|
BOOLEAN doalloc )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
DWORD total = RtlOemStringToUnicodeSize( oem );
|
2000-08-26 00:12:42 +02:00
|
|
|
|
|
|
|
if (total > 0xffff) return STATUS_INVALID_PARAMETER_2;
|
2001-12-05 23:14:57 +01:00
|
|
|
uni->Length = total - sizeof(WCHAR);
|
2000-08-26 00:12:42 +02:00
|
|
|
if (doalloc)
|
|
|
|
{
|
|
|
|
uni->MaximumLength = total;
|
2001-12-05 23:14:57 +01:00
|
|
|
if (!(uni->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, total ))) return STATUS_NO_MEMORY;
|
2000-08-26 00:12:42 +02:00
|
|
|
}
|
|
|
|
else if (total > uni->MaximumLength) return STATUS_BUFFER_OVERFLOW;
|
|
|
|
|
2001-12-05 23:14:57 +01:00
|
|
|
RtlOemToUnicodeN( uni->Buffer, uni->Length, NULL, oem->Buffer, oem->Length );
|
|
|
|
uni->Buffer[uni->Length / sizeof(WCHAR)] = 0;
|
2000-08-26 00:12:42 +02:00
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlUnicodeStringToAnsiString (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* writes terminating 0
|
2000-08-26 00:12:42 +02:00
|
|
|
* copies a part if the buffer is too small
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS WINAPI RtlUnicodeStringToAnsiString( STRING *ansi,
|
|
|
|
const UNICODE_STRING *uni,
|
|
|
|
BOOLEAN doalloc )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS ret = STATUS_SUCCESS;
|
|
|
|
DWORD len = RtlUnicodeStringToAnsiSize( uni );
|
|
|
|
|
2002-04-02 04:43:53 +02:00
|
|
|
ansi->Length = len - 1;
|
2000-08-26 00:12:42 +02:00
|
|
|
if (doalloc)
|
|
|
|
{
|
2002-04-02 04:43:53 +02:00
|
|
|
ansi->MaximumLength = len;
|
|
|
|
if (!(ansi->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, len ))) return STATUS_NO_MEMORY;
|
2000-08-26 00:12:42 +02:00
|
|
|
}
|
2002-04-02 04:43:53 +02:00
|
|
|
else if (ansi->MaximumLength < len)
|
2000-08-26 00:12:42 +02:00
|
|
|
{
|
|
|
|
if (!ansi->MaximumLength) return STATUS_BUFFER_OVERFLOW;
|
|
|
|
ansi->Length = ansi->MaximumLength - 1;
|
|
|
|
ret = STATUS_BUFFER_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
2001-12-05 23:14:57 +01:00
|
|
|
RtlUnicodeToMultiByteN( ansi->Buffer, ansi->Length, NULL, uni->Buffer, uni->Length );
|
2000-08-26 00:12:42 +02:00
|
|
|
ansi->Buffer[ansi->Length] = 0;
|
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlUnicodeStringToOemString (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* allocates uni->Length+1
|
|
|
|
* writes terminating 0
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS WINAPI RtlUnicodeStringToOemString( STRING *oem,
|
|
|
|
const UNICODE_STRING *uni,
|
|
|
|
BOOLEAN doalloc )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS ret = STATUS_SUCCESS;
|
|
|
|
DWORD len = RtlUnicodeStringToOemSize( uni );
|
|
|
|
|
2002-04-02 04:43:53 +02:00
|
|
|
oem->Length = len - 1;
|
2000-08-26 00:12:42 +02:00
|
|
|
if (doalloc)
|
|
|
|
{
|
2002-04-02 04:43:53 +02:00
|
|
|
oem->MaximumLength = len;
|
|
|
|
if (!(oem->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, len ))) return STATUS_NO_MEMORY;
|
2000-08-26 00:12:42 +02:00
|
|
|
}
|
2002-04-02 04:43:53 +02:00
|
|
|
else if (oem->MaximumLength < len)
|
2000-08-26 00:12:42 +02:00
|
|
|
{
|
|
|
|
if (!oem->MaximumLength) return STATUS_BUFFER_OVERFLOW;
|
|
|
|
oem->Length = oem->MaximumLength - 1;
|
|
|
|
ret = STATUS_BUFFER_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
2001-12-05 23:14:57 +01:00
|
|
|
RtlUnicodeToOemN( oem->Buffer, oem->Length, NULL, uni->Buffer, uni->Length );
|
2000-08-26 00:12:42 +02:00
|
|
|
oem->Buffer[oem->Length] = 0;
|
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlMultiByteToUnicodeN (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
2000-08-26 00:12:42 +02:00
|
|
|
* if unistr is too small a part is copied
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS WINAPI RtlMultiByteToUnicodeN( LPWSTR dst, DWORD dstlen, LPDWORD reslen,
|
|
|
|
LPCSTR src, DWORD srclen )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
|
|
|
|
int ret = cp_mbstowcs( get_ansi_table(), 0, src, srclen, dst, dstlen/sizeof(WCHAR) );
|
2000-08-26 00:12:42 +02:00
|
|
|
if (reslen)
|
2001-12-05 23:14:57 +01:00
|
|
|
*reslen = (ret >= 0) ? ret*sizeof(WCHAR) : dstlen; /* overflow -> we filled up to dstlen */
|
2000-08-26 00:12:42 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlOemToUnicodeN (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlOemToUnicodeN( LPWSTR dst, DWORD dstlen, LPDWORD reslen,
|
|
|
|
LPCSTR src, DWORD srclen )
|
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
int ret = cp_mbstowcs( get_oem_table(), 0, src, srclen, dst, dstlen/sizeof(WCHAR) );
|
2000-08-26 00:12:42 +02:00
|
|
|
if (reslen)
|
2001-12-05 23:14:57 +01:00
|
|
|
*reslen = (ret >= 0) ? ret*sizeof(WCHAR) : dstlen; /* overflow -> we filled up to dstlen */
|
2000-08-26 00:12:42 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlUnicodeToMultiByteN (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlUnicodeToMultiByteN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
|
|
|
|
LPCWSTR src, DWORD srclen )
|
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
int ret = cp_wcstombs( get_ansi_table(), 0, src, srclen / sizeof(WCHAR),
|
|
|
|
dst, dstlen, NULL, NULL );
|
2000-08-26 00:12:42 +02:00
|
|
|
if (reslen)
|
2001-12-05 23:14:57 +01:00
|
|
|
*reslen = (ret >= 0) ? ret : dstlen; /* overflow -> we filled up to dstlen */
|
2000-08-26 00:12:42 +02:00
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlUnicodeToOemN (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlUnicodeToOemN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
|
|
|
|
LPCWSTR src, DWORD srclen )
|
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
int ret = cp_wcstombs( get_oem_table(), 0, src, srclen / sizeof(WCHAR),
|
|
|
|
dst, dstlen, NULL, NULL );
|
2000-08-26 00:12:42 +02:00
|
|
|
if (reslen)
|
2001-12-05 23:14:57 +01:00
|
|
|
*reslen = (ret >= 0) ? ret : dstlen; /* overflow -> we filled up to dstlen */
|
2000-08-26 00:12:42 +02:00
|
|
|
return STATUS_SUCCESS;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/*
|
2000-08-26 00:12:42 +02:00
|
|
|
CASE CONVERSIONS
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlUpperString (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-09-04 22:21:06 +02:00
|
|
|
void WINAPI RtlUpperString( STRING *dst, const STRING *src )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
unsigned int i, len = min(src->Length, dst->MaximumLength);
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
for (i = 0; i < len; i++) dst->Buffer[i] = toupper(src->Buffer[i]);
|
|
|
|
dst->Length = len;
|
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlUpcaseUnicodeString (NTDLL.@)
|
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
* destination string is never 0-terminated because dest can be equal to src
|
|
|
|
* and src might be not 0-terminated
|
|
|
|
* dest.Length only set when success
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlUpcaseUnicodeString( UNICODE_STRING *dest,
|
|
|
|
const UNICODE_STRING *src,
|
|
|
|
BOOLEAN doalloc )
|
|
|
|
{
|
|
|
|
DWORD i, len = src->Length;
|
|
|
|
|
|
|
|
if (doalloc)
|
|
|
|
{
|
|
|
|
dest->MaximumLength = len;
|
2001-12-05 23:14:57 +01:00
|
|
|
if (!(dest->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, len ))) return STATUS_NO_MEMORY;
|
2000-08-26 00:12:42 +02:00
|
|
|
}
|
|
|
|
else if (len > dest->MaximumLength) return STATUS_BUFFER_OVERFLOW;
|
|
|
|
|
|
|
|
for (i = 0; i < len/sizeof(WCHAR); i++) dest->Buffer[i] = toupperW(src->Buffer[i]);
|
|
|
|
dest->Length = len;
|
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlUpcaseUnicodeStringToAnsiString (NTDLL.@)
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* writes terminating 0
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS WINAPI RtlUpcaseUnicodeStringToAnsiString( STRING *dst,
|
|
|
|
const UNICODE_STRING *src,
|
|
|
|
BOOLEAN doalloc )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS ret;
|
|
|
|
UNICODE_STRING upcase;
|
|
|
|
|
|
|
|
if (!(ret = RtlUpcaseUnicodeString( &upcase, src, TRUE )))
|
|
|
|
{
|
|
|
|
ret = RtlUnicodeStringToAnsiString( dst, &upcase, doalloc );
|
|
|
|
RtlFreeUnicodeString( &upcase );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlUpcaseUnicodeStringToOemString (NTDLL.@)
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* writes terminating 0
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlUpcaseUnicodeStringToOemString( STRING *dst,
|
|
|
|
const UNICODE_STRING *src,
|
|
|
|
BOOLEAN doalloc )
|
|
|
|
{
|
|
|
|
NTSTATUS ret;
|
|
|
|
UNICODE_STRING upcase;
|
|
|
|
|
|
|
|
if (!(ret = RtlUpcaseUnicodeString( &upcase, src, TRUE )))
|
|
|
|
{
|
|
|
|
ret = RtlUnicodeStringToOemString( dst, &upcase, doalloc );
|
|
|
|
RtlFreeUnicodeString( &upcase );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlUpcaseUnicodeToMultiByteN (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlUpcaseUnicodeToMultiByteN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
|
|
|
|
LPCWSTR src, DWORD srclen )
|
|
|
|
{
|
|
|
|
NTSTATUS ret;
|
|
|
|
LPWSTR upcase;
|
|
|
|
DWORD i;
|
|
|
|
|
2001-12-05 23:14:57 +01:00
|
|
|
if (!(upcase = RtlAllocateHeap( GetProcessHeap(), 0, srclen ))) return STATUS_NO_MEMORY;
|
2000-08-26 00:12:42 +02:00
|
|
|
for (i = 0; i < srclen/sizeof(WCHAR); i++) upcase[i] = toupperW(src[i]);
|
|
|
|
ret = RtlUnicodeToMultiByteN( dst, dstlen, reslen, upcase, srclen );
|
2001-12-05 23:14:57 +01:00
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, upcase );
|
2000-08-26 00:12:42 +02:00
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlUpcaseUnicodeToOemN (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS WINAPI RtlUpcaseUnicodeToOemN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
|
|
|
|
LPCWSTR src, DWORD srclen )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS ret;
|
|
|
|
LPWSTR upcase;
|
|
|
|
DWORD i;
|
|
|
|
|
2001-12-05 23:14:57 +01:00
|
|
|
if (!(upcase = RtlAllocateHeap( GetProcessHeap(), 0, srclen ))) return STATUS_NO_MEMORY;
|
2000-08-26 00:12:42 +02:00
|
|
|
for (i = 0; i < srclen/sizeof(WCHAR); i++) upcase[i] = toupperW(src[i]);
|
|
|
|
ret = RtlUnicodeToOemN( dst, dstlen, reslen, upcase, srclen );
|
2001-12-05 23:14:57 +01:00
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, upcase );
|
2000-08-26 00:12:42 +02:00
|
|
|
return ret;
|
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/*
|
|
|
|
STRING SIZE
|
|
|
|
*/
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlOemStringToUnicodeSize (NTDLL.@)
|
2001-07-11 20:56:41 +02:00
|
|
|
* RtlxOemStringToUnicodeSize (NTDLL.@)
|
2000-08-26 00:12:42 +02:00
|
|
|
*
|
|
|
|
* Return the size in bytes necessary for the Unicode conversion of 'str',
|
|
|
|
* including the terminating NULL.
|
|
|
|
*/
|
2001-12-05 23:14:57 +01:00
|
|
|
UINT WINAPI RtlOemStringToUnicodeSize( const STRING *str )
|
2000-08-26 00:12:42 +02:00
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
int ret = cp_mbstowcs( get_oem_table(), 0, str->Buffer, str->Length, NULL, 0 );
|
2000-08-26 00:12:42 +02:00
|
|
|
return (ret + 1) * sizeof(WCHAR);
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlAnsiStringToUnicodeSize (NTDLL.@)
|
2001-07-11 20:56:41 +02:00
|
|
|
* RtlxAnsiStringToUnicodeSize (NTDLL.@)
|
2000-08-26 00:12:42 +02:00
|
|
|
*
|
|
|
|
* Return the size in bytes necessary for the Unicode conversion of 'str',
|
|
|
|
* including the terminating NULL.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2001-12-05 23:14:57 +01:00
|
|
|
DWORD WINAPI RtlAnsiStringToUnicodeSize( const STRING *str )
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
DWORD ret;
|
|
|
|
RtlMultiByteToUnicodeSize( &ret, str->Buffer, str->Length );
|
|
|
|
return ret + sizeof(WCHAR);
|
2000-08-26 00:12:42 +02:00
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlMultiByteToUnicodeSize (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Compute the size in bytes necessary for the Unicode conversion of 'str',
|
|
|
|
* without the terminating NULL.
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlMultiByteToUnicodeSize( DWORD *size, LPCSTR str, UINT len )
|
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
*size = cp_mbstowcs( get_ansi_table(), 0, str, len, NULL, 0 ) * sizeof(WCHAR);
|
|
|
|
return STATUS_SUCCESS;
|
2000-08-26 00:12:42 +02:00
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlUnicodeToMultiByteSize (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Compute the size necessary for the multibyte conversion of 'str',
|
|
|
|
* without the terminating NULL.
|
|
|
|
*/
|
2002-09-13 00:07:02 +02:00
|
|
|
NTSTATUS WINAPI RtlUnicodeToMultiByteSize( PULONG size, LPCWSTR str, ULONG len )
|
2000-08-26 00:12:42 +02:00
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
*size = cp_wcstombs( get_ansi_table(), 0, str, len / sizeof(WCHAR), NULL, 0, NULL, NULL );
|
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlUnicodeStringToAnsiSize (NTDLL.@)
|
2001-07-11 20:56:41 +02:00
|
|
|
* RtlxUnicodeStringToAnsiSize (NTDLL.@)
|
2000-08-26 00:12:42 +02:00
|
|
|
*
|
|
|
|
* Return the size in bytes necessary for the Ansi conversion of 'str',
|
|
|
|
* including the terminating NULL.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
DWORD WINAPI RtlUnicodeStringToAnsiSize( const UNICODE_STRING *str )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
DWORD ret;
|
|
|
|
RtlUnicodeToMultiByteSize( &ret, str->Buffer, str->Length );
|
|
|
|
return ret + 1;
|
2000-08-26 00:12:42 +02:00
|
|
|
}
|
1999-03-09 18:47:51 +01:00
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlUnicodeStringToOemSize (NTDLL.@)
|
2001-07-11 20:56:41 +02:00
|
|
|
* RtlxUnicodeStringToOemSize (NTDLL.@)
|
2000-08-26 00:12:42 +02:00
|
|
|
*
|
|
|
|
* Return the size in bytes necessary for the OEM conversion of 'str',
|
|
|
|
* including the terminating NULL.
|
|
|
|
*/
|
|
|
|
DWORD WINAPI RtlUnicodeStringToOemSize( const UNICODE_STRING *str )
|
|
|
|
{
|
2001-12-05 23:14:57 +01:00
|
|
|
return cp_wcstombs( get_oem_table(), 0, str->Buffer, str->Length / sizeof(WCHAR),
|
|
|
|
NULL, 0, NULL, NULL ) + 1;
|
2000-08-26 00:12:42 +02:00
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* RtlAppendStringToString (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlAppendStringToString( STRING *dst, const STRING *src )
|
|
|
|
{
|
|
|
|
unsigned int len = src->Length + dst->Length;
|
|
|
|
if (len > dst->MaximumLength) return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
memcpy( dst->Buffer + dst->Length, src->Buffer, src->Length );
|
|
|
|
dst->Length = len;
|
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlAppendAsciizToString (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS WINAPI RtlAppendAsciizToString( STRING *dst, LPCSTR src )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
if (src)
|
|
|
|
{
|
|
|
|
unsigned int srclen = strlen(src);
|
|
|
|
unsigned int total = srclen + dst->Length;
|
|
|
|
if (total > dst->MaximumLength) return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
memcpy( dst->Buffer + dst->Length, src, srclen );
|
|
|
|
dst->Length = total;
|
|
|
|
}
|
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlAppendUnicodeToString (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS WINAPI RtlAppendUnicodeToString( UNICODE_STRING *dst, LPCWSTR src )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
if (src)
|
|
|
|
{
|
|
|
|
unsigned int srclen = strlenW(src) * sizeof(WCHAR);
|
|
|
|
unsigned int total = srclen + dst->Length;
|
|
|
|
if (total > dst->MaximumLength) return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
memcpy( dst->Buffer + dst->Length/sizeof(WCHAR), src, srclen );
|
|
|
|
dst->Length = total;
|
|
|
|
/* append terminating NULL if enough space */
|
|
|
|
if (total < dst->MaximumLength) dst->Buffer[total / sizeof(WCHAR)] = 0;
|
|
|
|
}
|
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2000-08-26 00:12:42 +02:00
|
|
|
* RtlAppendUnicodeStringToString (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
2000-08-26 00:12:42 +02:00
|
|
|
NTSTATUS WINAPI RtlAppendUnicodeStringToString( UNICODE_STRING *dst, const UNICODE_STRING *src )
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2000-08-26 00:12:42 +02:00
|
|
|
unsigned int len = src->Length + dst->Length;
|
|
|
|
if (len > dst->MaximumLength) return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
memcpy( dst->Buffer + dst->Length/sizeof(WCHAR), src->Buffer, src->Length );
|
|
|
|
dst->Length = len;
|
|
|
|
/* append terminating NULL if enough space */
|
|
|
|
if (len < dst->MaximumLength) dst->Buffer[len / sizeof(WCHAR)] = 0;
|
|
|
|
return STATUS_SUCCESS;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
2000-08-26 00:12:42 +02:00
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/*
|
|
|
|
MISC
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlIsTextUnicode (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*
|
|
|
|
* Apply various feeble heuristics to guess whether
|
|
|
|
* the text buffer contains Unicode.
|
|
|
|
* FIXME: should implement more tests.
|
|
|
|
*/
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
DWORD WINAPI RtlIsTextUnicode(
|
|
|
|
LPVOID buf,
|
|
|
|
DWORD len,
|
|
|
|
DWORD *pf)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
|
|
|
LPWSTR s = buf;
|
|
|
|
DWORD flags = -1, out_flags = 0;
|
|
|
|
|
|
|
|
if (!len)
|
|
|
|
goto out;
|
|
|
|
if (pf)
|
|
|
|
flags = *pf;
|
|
|
|
/*
|
|
|
|
* Apply various tests to the text string. According to the
|
|
|
|
* docs, each test "passed" sets the corresponding flag in
|
|
|
|
* the output flags. But some of the tests are mutually
|
|
|
|
* exclusive, so I don't see how you could pass all tests ...
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Check for an odd length ... pass if even. */
|
|
|
|
if (!(len & 1))
|
|
|
|
out_flags |= IS_TEXT_UNICODE_ODD_LENGTH;
|
|
|
|
|
|
|
|
/* Check for the special unicode marker byte. */
|
|
|
|
if (*s == 0xFEFF)
|
|
|
|
out_flags |= IS_TEXT_UNICODE_SIGNATURE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check whether the string passed all of the tests.
|
|
|
|
*/
|
|
|
|
flags &= ITU_IMPLEMENTED_TESTS;
|
|
|
|
if ((out_flags & flags) != flags)
|
|
|
|
len = 0;
|
|
|
|
out:
|
|
|
|
if (pf)
|
|
|
|
*pf = out_flags;
|
|
|
|
return len;
|
|
|
|
}
|
2002-11-12 03:17:34 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* RtlUnicodeStringToInteger (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Convert a text buffer into its integer form
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlUnicodeStringToInteger(
|
|
|
|
const UNICODE_STRING *str,
|
|
|
|
int base,
|
|
|
|
int * pdest)
|
|
|
|
{
|
|
|
|
LPWSTR lpwstr = str->Buffer;
|
|
|
|
WCHAR wchCurrent = 0;
|
|
|
|
int CharsParsed = 0;
|
|
|
|
int RunningTotal = 0;
|
|
|
|
char bMinus = 0;
|
|
|
|
|
|
|
|
/* no checking done on UNICODE_STRING and int* in native DLL either */
|
|
|
|
TRACE("(%p, %d, %p)", str, base, pdest);
|
|
|
|
|
|
|
|
switch (base)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
base = 10;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 8:
|
|
|
|
case 10:
|
|
|
|
case 16:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((str->Length) >= 4 && (base == 10) && (*lpwstr == '0') && (*(lpwstr+1) == 'x'))
|
|
|
|
{
|
|
|
|
lpwstr+=2;
|
|
|
|
base = 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pdest = 0;
|
|
|
|
for (; (CharsParsed*sizeof(WCHAR) < str->Length) && (*lpwstr <= ' '); lpwstr++)
|
|
|
|
CharsParsed++;
|
|
|
|
|
|
|
|
if (*lpwstr == '+')
|
|
|
|
lpwstr++;
|
|
|
|
else if (*lpwstr == '-')
|
|
|
|
{
|
|
|
|
bMinus = 1;
|
|
|
|
lpwstr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; (CharsParsed*sizeof(WCHAR) < str->Length) && (*lpwstr != '\0'); lpwstr++)
|
|
|
|
{
|
|
|
|
CharsParsed++;
|
|
|
|
wchCurrent = *lpwstr;
|
|
|
|
if (wchCurrent >= 'A')
|
|
|
|
wchCurrent = '0' + 10 + wchCurrent - 'A';
|
|
|
|
if ((wchCurrent - '0') >= base || wchCurrent < '0')
|
|
|
|
{
|
|
|
|
*pdest = bMinus ? -RunningTotal: RunningTotal;
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* increase significance of previous digits each time
|
|
|
|
* we find another valid one and add on this valid one
|
|
|
|
*/
|
|
|
|
RunningTotal = wchCurrent - '0' + RunningTotal * base;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pdest = bMinus ? -RunningTotal : RunningTotal;
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|