Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
d2f8bf6f
Commit
d2f8bf6f
authored
Aug 25, 2000
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Rtl* string functions for proper MBCS/codepage support. Added a
few more functions.
parent
973ce4a0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
627 additions
and
490 deletions
+627
-490
ntdll.spec
dlls/ntdll/ntdll.spec
+27
-27
rtlstr.c
dlls/ntdll/rtlstr.c
+560
-384
ntddk.h
include/ntddk.h
+40
-79
No files found.
dlls/ntdll/ntdll.spec
View file @
d2f8bf6f
...
...
@@ -272,12 +272,12 @@ type win32
@ stdcall RtlAllocateAndInitializeSid (ptr long long long long long long long long long ptr) RtlAllocateAndInitializeSid
@ stdcall RtlAllocateHeap(long long long) RtlAllocateHeap
@ stub RtlAnsiCharToUnicodeChar
@ st
ub
RtlAnsiStringToUnicodeSize
@ st
dcall RtlAnsiStringToUnicodeSize(ptr)
RtlAnsiStringToUnicodeSize
@ stdcall RtlAnsiStringToUnicodeString(ptr ptr long) RtlAnsiStringToUnicodeString
@ st
ub
RtlAppendAsciizToString
@ st
ub
RtlAppendStringToString
@ st
ub
RtlAppendUnicodeStringToString
@ st
ub
RtlAppendUnicodeToString
@ st
dcall RtlAppendAsciizToString(ptr str)
RtlAppendAsciizToString
@ st
dcall RtlAppendStringToString(ptr ptr)
RtlAppendStringToString
@ st
dcall RtlAppendUnicodeStringToString(ptr ptr)
RtlAppendUnicodeStringToString
@ st
dcall RtlAppendUnicodeToString(ptr wstr)
RtlAppendUnicodeToString
@ stub RtlApplyRXact
@ stub RtlApplyRXactNoFlush
@ stub RtlAreAllAccessesGranted
...
...
@@ -293,7 +293,7 @@ type win32
@ stub RtlCompactHeap
@ stdcall RtlCompareMemory(ptr ptr long) RtlCompareMemory
@ stub RtlCompareMemoryUlong
@ st
ub
RtlCompareString
@ st
dcall RtlCompareString(ptr ptr long)
RtlCompareString
@ stdcall RtlCompareUnicodeString (ptr ptr long) RtlCompareUnicodeString
@ stub RtlCompressBuffer
@ stub RtlConsoleMultiByteToUnicodeN
...
...
@@ -308,8 +308,8 @@ type win32
@ stub RtlCopySecurityDescriptor
@ stdcall RtlCopySid(long ptr ptr) RtlCopySid
@ stub RtlCopySidAndAttributesArray
@ st
ub
RtlCopyString
@ st
ub
RtlCopyUnicodeString
@ st
dcall RtlCopyString(ptr ptr)
RtlCopyString
@ st
dcall RtlCopyUnicodeString(ptr ptr)
RtlCopyUnicodeString
@ stdcall RtlCreateAcl(ptr long long) RtlCreateAcl
@ stub RtlCreateAndSetSD
@ stdcall RtlCreateEnvironment(long long) RtlCreateEnvironment
...
...
@@ -319,8 +319,8 @@ type win32
@ stub RtlCreateRegistryKey
@ stdcall RtlCreateSecurityDescriptor(ptr long) RtlCreateSecurityDescriptor
@ stub RtlCreateTagHeap
@ st
ub
RtlCreateUnicodeString
@ st
ub
RtlCreateUnicodeStringFromAsciiz
@ st
dcall RtlCreateUnicodeString(ptr wstr)
RtlCreateUnicodeString
@ st
dcall RtlCreateUnicodeStringFromAsciiz(ptr str)
RtlCreateUnicodeStringFromAsciiz
@ stub RtlCreateUserProcess
@ stub RtlCreateUserSecurityObject
@ stub RtlCreateUserThread
...
...
@@ -357,9 +357,9 @@ type win32
@ stub RtlEqualLuid
@ stdcall RtlEqualPrefixSid(ptr ptr) RtlEqualPrefixSid
@ stdcall RtlEqualSid (long long) RtlEqualSid
@ st
ub
RtlEqualString
@ stdcall RtlEqualUnicodeString(
long long
long) RtlEqualUnicodeString
@ st
ub
RtlEraseUnicodeString
@ st
dcall RtlEqualString(ptr ptr long)
RtlEqualString
@ stdcall RtlEqualUnicodeString(
ptr ptr
long) RtlEqualUnicodeString
@ st
dcall RtlEraseUnicodeString(ptr)
RtlEraseUnicodeString
@ stub RtlExpandEnvironmentStrings_U
@ stub RtlExtendHeap
@ stdcall RtlExtendedIntegerMultiply(long long long) RtlExtendedIntegerMultiply
...
...
@@ -379,7 +379,7 @@ type win32
@ stub RtlFormatMessage
@ stdcall RtlFreeAnsiString(long) RtlFreeAnsiString
@ stdcall RtlFreeHeap(long long long) RtlFreeHeap
@ st
ub
RtlFreeOemString
@ st
dcall RtlFreeOemString(ptr)
RtlFreeOemString
@ stdcall RtlFreeSid (long) RtlFreeSid
@ stdcall RtlFreeUnicodeString(ptr) RtlFreeUnicodeString
@ stub RtlGenerate8dot3Name
...
...
@@ -441,7 +441,7 @@ type win32
@ stub RtlMapGenericMask
@ stdcall RtlMoveMemory(ptr ptr long) RtlMoveMemory
@ stdcall RtlMultiByteToUnicodeN(ptr long ptr ptr long) RtlMultiByteToUnicodeN
@ st
ub
RtlMultiByteToUnicodeSize
@ st
dcall RtlMultiByteToUnicodeSize(ptr str long)
RtlMultiByteToUnicodeSize
@ stub RtlNewInstanceSecurityObject
@ stub RtlNewSecurityGrantedAccess
@ stdcall RtlNewSecurityObject(long long long long long long) RtlNewSecurityObject
...
...
@@ -450,12 +450,12 @@ type win32
@ stub RtlNumberGenericTableElements
@ stub RtlNumberOfClearBits
@ stub RtlNumberOfSetBits
@ st
ub
RtlOemStringToUnicodeSize
@ st
dcall RtlOemStringToUnicodeSize(ptr)
RtlOemStringToUnicodeSize
@ stdcall RtlOemStringToUnicodeString(ptr ptr long) RtlOemStringToUnicodeString
@ stdcall RtlOemToUnicodeN(ptr long ptr ptr long) RtlOemToUnicodeN
@ stdcall RtlOpenCurrentUser(long ptr) RtlOpenCurrentUser
@ stub RtlPcToFileHeader
@ st
ub
RtlPrefixString
@ st
dcall RtlPrefixString(ptr ptr long)
RtlPrefixString
@ stdcall RtlPrefixUnicodeString(ptr ptr long) RtlPrefixUnicodeString
@ stub RtlProtectHeap
@ stdcall RtlQueryEnvironmentVariable_U(long long long) RtlQueryEnvironmentVariable_U
...
...
@@ -510,29 +510,29 @@ type win32
@ stdcall RtlTimeToSecondsSince1970(ptr ptr) RtlTimeToSecondsSince1970
@ stdcall RtlTimeToSecondsSince1980(ptr ptr) RtlTimeToSecondsSince1980
@ stdcall RtlTimeToTimeFields (long long) RtlTimeToTimeFields
@ st
ub
RtlUnicodeStringToAnsiSize
@ st
dcall RtlUnicodeStringToAnsiSize(ptr)
RtlUnicodeStringToAnsiSize
@ stdcall RtlUnicodeStringToAnsiString(ptr ptr long) RtlUnicodeStringToAnsiString
@ stub RtlUnicodeStringToCountedOemString
@ stub RtlUnicodeStringToInteger
@ st
ub
RtlUnicodeStringToOemSize
@ st
dcall RtlUnicodeStringToOemSize(ptr)
RtlUnicodeStringToOemSize
@ stdcall RtlUnicodeStringToOemString(ptr ptr long) RtlUnicodeStringToOemString
@ stub RtlUnicodeToCustomCPN
@ stdcall RtlUnicodeToMultiByteN(ptr long ptr ptr long) RtlUnicodeToMultiByteN
@ st
ub
RtlUnicodeToMultiByteSize
@ st
dcall RtlUnicodeToMultiByteSize(ptr wstr long)
RtlUnicodeToMultiByteSize
@ stdcall RtlUnicodeToOemN(ptr long ptr ptr long) RtlUnicodeToOemN
@ stub RtlUniform
@ stub RtlUnlockHeap
@ stdcall RtlUnwind(ptr ptr ptr long) RtlUnwind
@ stub RtlUpcaseUnicodeChar
@ stdcall RtlUpcaseUnicodeString(ptr ptr long) RtlUpcaseUnicodeString
@ st
ub
RtlUpcaseUnicodeStringToAnsiString
@ st
dcall RtlUpcaseUnicodeStringToAnsiString(ptr ptr long)
RtlUpcaseUnicodeStringToAnsiString
@ stub RtlUpcaseUnicodeStringToCountedOemString
@ stdcall RtlUpcaseUnicodeStringToOemString(ptr ptr long) RtlUpcaseUnicodeStringToOemString
@ stub RtlUpcaseUnicodeToCustomCPN
@ st
ub
RtlUpcaseUnicodeToMultiByteN
@ st
dcall RtlUpcaseUnicodeToMultiByteN(ptr long ptr ptr long)
RtlUpcaseUnicodeToMultiByteN
@ stdcall RtlUpcaseUnicodeToOemN(ptr long ptr ptr long) RtlUpcaseUnicodeToOemN
@ stub RtlUpperChar
@ st
ub
RtlUpperString
@ st
dcall RtlUpperString(ptr ptr)
RtlUpperString
@ stub RtlUsageHeap
@ stub RtlValidAcl
@ stdcall RtlValidSecurityDescriptor(ptr) RtlValidSecurityDescriptor
...
...
@@ -552,10 +552,10 @@ type win32
@ stub RtlpNtSetValueKey
@ stub RtlpUnWaitCriticalSection
@ stub RtlpWaitForCriticalSection
@ stdcall RtlxAnsiStringToUnicodeSize(ptr) Rtl
x
AnsiStringToUnicodeSize
@ stdcall RtlxOemStringToUnicodeSize(ptr) Rtl
x
OemStringToUnicodeSize
@ st
ub Rtlx
UnicodeStringToAnsiSize
@ stdcall RtlxUnicodeStringToOemSize(ptr) Rtl
x
UnicodeStringToOemSize
@ stdcall RtlxAnsiStringToUnicodeSize(ptr) RtlAnsiStringToUnicodeSize
@ stdcall RtlxOemStringToUnicodeSize(ptr) RtlOemStringToUnicodeSize
@ st
dcall RtlxUnicodeStringToAnsiSize(ptr) Rtl
UnicodeStringToAnsiSize
@ stdcall RtlxUnicodeStringToOemSize(ptr) RtlUnicodeStringToOemSize
@ stub SaveEm87Context
@ stdcall ZwAcceptConnectPort(long long long long long long) NtAcceptConnectPort
@ stub ZwAccessCheck
...
...
dlls/ntdll/rtlstr.c
View file @
d2f8bf6f
/*
*
Rtl string functions
*
Rtl string functions
*
* Copyright 1996-1998 Marcus Meissner
* Copyright (C) 1996-1998 Marcus Meissner
* Copyright (C) 2000 Alexandre Julliard
*/
#include "config.h"
...
...
@@ -19,538 +20,726 @@
DEFAULT_DEBUG_CHANNEL
(
ntdll
);
/*
STRING FUNCTIONS
*/
/*
STRING CREATION FUNCTIONS
*/
/**************************************************************************
* RtlInit
String
* RtlInit
AnsiString (NTDLL.@)
*/
VOID
WINAPI
RtlInitString
(
PSTRING
target
,
LPCSTR
source
)
void
WINAPI
RtlInitAnsiString
(
PSTRING
target
,
LPCSTR
source
)
{
TRACE
(
"%p %p(%s)
\n
"
,
target
,
source
,
debugstr_a
(
source
));
if
((
target
->
Buffer
=
(
LPSTR
)
source
))
{
target
->
Length
=
strlen
(
source
);
target
->
MaximumLength
=
target
->
Length
+
1
;
}
else
target
->
Length
=
target
->
MaximumLength
=
0
;
}
target
->
Buffer
=
(
LPSTR
)
source
;
if
(
source
)
{
target
->
Length
=
strlen
(
source
);
target
->
MaximumLength
=
target
->
Length
+
1
;
}
else
{
target
->
Length
=
target
->
MaximumLength
=
0
;
}
/**************************************************************************
* RtlInitString (NTDLL.@)
*/
void
WINAPI
RtlInitString
(
PSTRING
target
,
LPCSTR
source
)
{
return
RtlInitAnsiString
(
target
,
source
);
}
/**************************************************************************
* RtlFreeAnsiString (NTDLL.@)
*/
void
WINAPI
RtlFreeAnsiString
(
PSTRING
str
)
{
if
(
str
->
Buffer
)
HeapFree
(
GetProcessHeap
(),
0
,
str
->
Buffer
);
}
/* ANSI FUNCTIONS */
/**************************************************************************
* Rtl
InitAnsiString
* Rtl
FreeOemString (NTDLL.@)
*/
VOID
WINAPI
RtlInitAnsiString
(
PANSI_STRING
target
,
LPCSTR
source
)
void
WINAPI
RtlFreeOemString
(
PSTRING
str
)
{
TRACE
(
"%p %p(%s)
\n
"
,
target
,
source
,
debugstr_a
(
source
));
RtlFreeAnsiString
(
str
);
}
target
->
Buffer
=
(
LPSTR
)
source
;
if
(
source
)
{
target
->
Length
=
strlen
(
source
);
target
->
MaximumLength
=
target
->
Length
+
1
;
}
else
{
target
->
Length
=
target
->
MaximumLength
=
0
;
}
/**************************************************************************
* 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
;
}
/**************************************************************************
* Rtl
FreeAnsiString
* Rtl
InitUnicodeString (NTDLL.@)
*/
VOID
WINAPI
RtlFreeAnsiString
(
PANSI_STRING
AnsiString
)
void
WINAPI
RtlInitUnicodeString
(
PUNICODE_STRING
target
,
LPCWSTR
source
)
{
TRACE
(
"%p
\n
"
,
AnsiString
);
dump_AnsiString
(
AnsiString
,
TRUE
);
if
((
target
->
Buffer
=
(
LPWSTR
)
source
))
{
target
->
Length
=
strlenW
(
source
)
*
sizeof
(
WCHAR
);
target
->
MaximumLength
=
target
->
Length
+
sizeof
(
WCHAR
);
}
else
target
->
Length
=
target
->
MaximumLength
=
0
;
}
if
(
AnsiString
->
Buffer
)
HeapFree
(
GetProcessHeap
(),
0
,
AnsiString
->
Buffer
);
/**************************************************************************
* RtlCreateUnicodeString (NTDLL.@)
*/
BOOLEAN
WINAPI
RtlCreateUnicodeString
(
PUNICODE_STRING
target
,
LPCWSTR
src
)
{
int
len
=
(
strlenW
(
src
)
+
1
)
*
sizeof
(
WCHAR
);
if
(
!
(
target
->
Buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
)))
return
FALSE
;
memcpy
(
target
->
Buffer
,
src
,
len
);
target
->
MaximumLength
=
len
;
target
->
Length
=
len
-
2
;
return
TRUE
;
}
/**************************************************************************
* RtlCreateUnicodeStringFromAsciiz (NTDLL.@)
*/
BOOLEAN
WINAPI
RtlCreateUnicodeStringFromAsciiz
(
PUNICODE_STRING
target
,
LPCSTR
src
)
{
STRING
ansi
;
RtlInitAnsiString
(
&
ansi
,
src
);
return
!
RtlAnsiStringToUnicodeString
(
target
,
&
ansi
,
TRUE
);
}
/* UNICODE FUNCTIONS */
/**************************************************************************
* Rtl
InitUnicodeString [NTDLL.403]
* Rtl
FreeUnicodeString (NTDLL.@)
*/
VOID
WINAPI
RtlInitUnicodeString
(
PUNICODE_STRING
target
,
LPCWSTR
source
)
void
WINAPI
RtlFreeUnicodeString
(
PUNICODE_STRING
str
)
{
TRACE
(
"%p %p(%s)
\n
"
,
target
,
source
,
debugstr_w
(
source
));
target
->
Buffer
=
(
LPWSTR
)
source
;
if
(
source
)
{
target
->
Length
=
strlenW
(
source
)
*
2
;
target
->
MaximumLength
=
target
->
Length
+
2
;
}
else
{
target
->
Length
=
target
->
MaximumLength
=
0
;
}
if
(
str
->
Buffer
)
HeapFree
(
GetProcessHeap
(),
0
,
str
->
Buffer
);
}
/**************************************************************************
* Rtl
FreeUnicodeString [NTDLL.377]
* Rtl
CopyUnicodeString (NTDLL.@)
*/
VOID
WINAPI
RtlFreeUnicodeString
(
PUNICODE_STRING
UnicodeString
)
void
WINAPI
RtlCopyUnicodeString
(
UNICODE_STRING
*
dst
,
const
UNICODE_STRING
*
src
)
{
TRACE
(
"%p
\n
"
,
UnicodeString
);
dump_UnicodeString
(
UnicodeString
,
TRUE
);
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
;
}
if
(
UnicodeString
->
Buffer
)
HeapFree
(
GetProcessHeap
(),
0
,
UnicodeString
->
Buffer
);
/**************************************************************************
* RtlEraseUnicodeString (NTDLL.@)
*/
void
WINAPI
RtlEraseUnicodeString
(
UNICODE_STRING
*
str
)
{
if
(
str
->
Buffer
)
{
memset
(
str
->
Buffer
,
0
,
str
->
MaximumLength
);
str
->
Length
=
0
;
}
}
/*
COMPARE
FUNCTIONS
COMPARISON
FUNCTIONS
*/
/**************************************************************************
* Rtl
EqualUnicodeString
/**************************************************************************
****
* Rtl
CompareString (NTDLL.@)
*/
BOOLEAN
WINAPI
RtlEqualUnicodeString
(
IN
PUNICODE_STRING
s1
,
IN
PUNICODE_STRING
s2
,
IN
BOOLEAN
CaseInsensitive
)
LONG
WINAPI
RtlCompareString
(
const
STRING
*
s1
,
const
STRING
*
s2
,
BOOLEAN
CaseInsensitive
)
{
BOOLEAN
ret
;
TRACE
(
"(%p,%p,%x)
\n
"
,
s1
,
s2
,
CaseInsensitive
);
dump_UnicodeString
(
s1
,
TRUE
);
dump_UnicodeString
(
s2
,
TRUE
);
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
;
}
if
(
!
s1
||
!
s2
||
!
s1
->
Buffer
||
!
s2
->
Buffer
)
return
FALSE
;
if
(
s1
->
Length
!=
s2
->
Length
)
return
FALSE
;
if
(
CaseInsensitive
)
ret
=
!
strncmpiW
(
s1
->
Buffer
,
s2
->
Buffer
,
s1
->
Length
/
sizeof
(
WCHAR
));
else
ret
=
!
strncmpW
(
s1
->
Buffer
,
s2
->
Buffer
,
s1
->
Length
/
sizeof
(
WCHAR
));
return
ret
;
/******************************************************************************
* 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
;
}
/******************************************************************************
* RtlCompareUnicodeString
/**************************************************************************
* RtlEqualString (NTDLL.@)
*/
LONG
WINAPI
RtlCompareUnicodeString
(
PUNICODE_STRING
s1
,
PUNICODE_STRING
s2
,
BOOLEAN
CaseInsensitive
)
BOOLEAN
WINAPI
RtlEqualString
(
const
STRING
*
s1
,
const
STRING
*
s2
,
BOOLEAN
CaseInsensitive
)
{
LONG
ret
;
if
(
s1
->
Length
!=
s2
->
Length
)
return
FALSE
;
return
!
RtlCompareString
(
s1
,
s2
,
CaseInsensitive
);
}
TRACE
(
"(%p,%p,%x)
\n
"
,
s1
,
s2
,
CaseInsensitive
);
dump_UnicodeString
(
s1
,
TRUE
);
dump_UnicodeString
(
s2
,
TRUE
);
if
(
!
s1
||
!
s2
||
!
s1
->
Buffer
||
!
s2
->
Buffer
)
return
FALSE
;
if
(
s1
->
Length
!=
s2
->
Length
)
return
(
s1
->
Length
-
s2
->
Length
);
/**************************************************************************
* 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
);
}
if
(
CaseInsensitive
)
ret
=
strncmpiW
(
s1
->
Buffer
,
s2
->
Buffer
,
s1
->
Length
/
sizeof
(
WCHAR
));
else
ret
=
strncmpW
(
s1
->
Buffer
,
s2
->
Buffer
,
s1
->
Length
/
sizeof
(
WCHAR
));
return
ret
;
/**************************************************************************
* 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
;
}
/**************************************************************************
* 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
;
}
/*
COPY BETWEEN ANSI_STRING or UNICODE_STRING
there is no parameter checking, it just crashes
*/
/**************************************************************************
* RtlAnsiStringToUnicodeString
* RtlAnsiStringToUnicodeString
(NTDLL.@)
*
* NOTES:
* writes terminating 0
*/
NTSTATUS
WINAPI
RtlAnsiStringToUnicodeString
(
PUNICODE_STRING
uni
,
PANSI_STRING
ansi
,
BOOLEAN
doalloc
)
NTSTATUS
WINAPI
RtlAnsiStringToUnicodeString
(
UNICODE_STRING
*
uni
,
const
STRING
*
ansi
,
BOOLEAN
doalloc
)
{
int
len
=
ansi
->
Length
*
sizeof
(
WCHAR
);
TRACE
(
"%p %p %u
\n
"
,
uni
,
ansi
,
doalloc
);
dump_AnsiString
(
ansi
,
TRUE
);
dump_UnicodeString
(
uni
,
FALSE
);
if
(
len
>
0xfffe
)
return
STATUS_INVALID_PARAMETER_2
;
uni
->
Length
=
len
;
if
(
doalloc
)
{
uni
->
MaximumLength
=
len
+
sizeof
(
WCHAR
);
uni
->
Buffer
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
uni
->
MaximumLength
);
if
(
!
uni
->
Buffer
)
return
STATUS_NO_MEMORY
;
}
else
if
(
len
+
sizeof
(
WCHAR
)
>
uni
->
MaximumLength
)
{
return
STATUS_BUFFER_OVERFLOW
;
}
lstrcpynAtoW
(
uni
->
Buffer
,
ansi
->
Buffer
,
ansi
->
Length
+
1
);
return
STATUS_SUCCESS
;
DWORD
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
ansi
->
Buffer
,
ansi
->
Length
,
NULL
,
0
);
DWORD
total
=
(
len
+
1
)
*
sizeof
(
WCHAR
);
if
(
total
>
0xffff
)
return
STATUS_INVALID_PARAMETER_2
;
uni
->
Length
=
len
*
sizeof
(
WCHAR
);
if
(
doalloc
)
{
uni
->
MaximumLength
=
total
;
if
(
!
(
uni
->
Buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
total
)))
return
STATUS_NO_MEMORY
;
}
else
if
(
total
>
uni
->
MaximumLength
)
return
STATUS_BUFFER_OVERFLOW
;
MultiByteToWideChar
(
CP_ACP
,
0
,
ansi
->
Buffer
,
ansi
->
Length
,
uni
->
Buffer
,
len
);
uni
->
Buffer
[
len
]
=
0
;
return
STATUS_SUCCESS
;
}
/**************************************************************************
* Rtl
UpcaseUnicodeString
* Rtl
OemStringToUnicodeString (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
* NOTES
* writes terminating 0
* if resulting length > 0xffff it returns STATUS_INVALID_PARAMETER_2
*/
DWORD
WINAPI
RtlUpcaseUnicodeString
(
PUNICODE_STRING
dest
,
PUNICODE_STRING
src
,
BOOLEAN
doalloc
)
NTSTATUS
WINAPI
RtlOemStringToUnicodeString
(
UNICODE_STRING
*
uni
,
const
STRING
*
oem
,
BOOLEAN
doalloc
)
{
int
i
,
len
=
src
->
Length
;
TRACE
(
"(%p,%p,%x)
\n
"
,
dest
,
src
,
doalloc
);
dump_UnicodeString
(
dest
,
FALSE
);
dump_UnicodeString
(
src
,
TRUE
);
if
(
doalloc
)
{
dest
->
Buffer
=
(
LPWSTR
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
len
);
if
(
!
dest
->
Buffer
)
return
STATUS_NO_MEMORY
;
dest
->
MaximumLength
=
len
;
}
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
;
DWORD
len
=
MultiByteToWideChar
(
CP_OEMCP
,
0
,
oem
->
Buffer
,
oem
->
Length
,
NULL
,
0
);
DWORD
total
=
(
len
+
1
)
*
sizeof
(
WCHAR
);
if
(
total
>
0xffff
)
return
STATUS_INVALID_PARAMETER_2
;
uni
->
Length
=
len
*
sizeof
(
WCHAR
);
if
(
doalloc
)
{
uni
->
MaximumLength
=
total
;
if
(
!
(
uni
->
Buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
total
)))
return
STATUS_NO_MEMORY
;
}
else
if
(
total
>
uni
->
MaximumLength
)
return
STATUS_BUFFER_OVERFLOW
;
MultiByteToWideChar
(
CP_OEMCP
,
0
,
oem
->
Buffer
,
oem
->
Length
,
uni
->
Buffer
,
len
);
uni
->
Buffer
[
len
]
=
0
;
return
STATUS_SUCCESS
;
}
/**************************************************************************
* Rtl
OemStringToUnicodeString
* Rtl
UnicodeStringToAnsiString (NTDLL.@)
*
* NOTES
* writes terminating 0
* buffer must be bigger than (ansi->Length+1)*2
* if astr.Length > 0x7ffe it returns STATUS_INVALID_PARAMETER_2
*
* FIXME
* OEM to unicode
* copies a part if the buffer is too small
*/
NTSTATUS
WINAPI
RtlOemStringToUnicodeString
(
PUNICODE_STRING
uni
,
PSTRING
ansi
,
BOOLEAN
doalloc
)
NTSTATUS
WINAPI
RtlUnicodeStringToAnsiString
(
STRING
*
ansi
,
const
UNICODE_STRING
*
uni
,
BOOLEAN
doalloc
)
{
int
len
=
ansi
->
Length
*
sizeof
(
WCHAR
);
if
(
len
>
0xfffe
)
return
STATUS_INVALID_PARAMETER_2
;
uni
->
Length
=
len
;
if
(
doalloc
)
{
uni
->
Buffer
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
len
+
sizeof
(
WCHAR
));
if
(
!
uni
->
Buffer
)
return
STATUS_NO_MEMORY
;
uni
->
MaximumLength
=
len
+
sizeof
(
WCHAR
);
}
else
if
(
len
+
1
>
uni
->
MaximumLength
)
{
return
STATUS_BUFFER_OVERFLOW
;
}
lstrcpynAtoW
(
uni
->
Buffer
,
ansi
->
Buffer
,
ansi
->
Length
+
1
);
return
STATUS_SUCCESS
;
NTSTATUS
ret
=
STATUS_SUCCESS
;
DWORD
len
=
RtlUnicodeStringToAnsiSize
(
uni
);
ansi
->
Length
=
len
;
if
(
doalloc
)
{
ansi
->
MaximumLength
=
len
+
1
;
if
(
!
(
ansi
->
Buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
+
1
)))
return
STATUS_NO_MEMORY
;
}
else
if
(
ansi
->
MaximumLength
<=
len
)
{
if
(
!
ansi
->
MaximumLength
)
return
STATUS_BUFFER_OVERFLOW
;
ansi
->
Length
=
ansi
->
MaximumLength
-
1
;
ret
=
STATUS_BUFFER_OVERFLOW
;
}
WideCharToMultiByte
(
CP_ACP
,
0
,
uni
->
Buffer
,
uni
->
Length
/
sizeof
(
WCHAR
),
ansi
->
Buffer
,
ansi
->
Length
,
NULL
,
NULL
);
ansi
->
Buffer
[
ansi
->
Length
]
=
0
;
return
ret
;
}
/**************************************************************************
* RtlUnicodeStringToOemString
* RtlUnicodeStringToOemString
(NTDLL.@)
*
* NOTES
* allocates uni->Length+1
* writes terminating 0
*/
NTSTATUS
WINAPI
RtlUnicodeStringToOemString
(
PANSI_STRING
oem
,
PUNICODE_STRING
uni
,
BOOLEAN
doalloc
)
NTSTATUS
WINAPI
RtlUnicodeStringToOemString
(
STRING
*
oem
,
const
UNICODE_STRING
*
uni
,
BOOLEAN
doalloc
)
{
int
len
=
uni
->
Length
/
sizeof
(
WCHAR
);
TRACE
(
"%p %s %i
\n
"
,
oem
,
debugstr_us
(
uni
),
doalloc
);
oem
->
Length
=
len
;
if
(
doalloc
)
{
oem
->
Buffer
=
(
LPSTR
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
len
+
1
);
if
(
!
oem
->
Buffer
)
return
STATUS_NO_MEMORY
;
oem
->
MaximumLength
=
len
+
1
;
}
else
if
(
oem
->
MaximumLength
<=
len
)
{
return
STATUS_BUFFER_OVERFLOW
;
}
lstrcpynWtoA
(
oem
->
Buffer
,
uni
->
Buffer
,
len
+
1
);
return
STATUS_SUCCESS
;
NTSTATUS
ret
=
STATUS_SUCCESS
;
DWORD
len
=
RtlUnicodeStringToOemSize
(
uni
);
oem
->
Length
=
len
;
if
(
doalloc
)
{
oem
->
MaximumLength
=
len
+
1
;
if
(
!
(
oem
->
Buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
+
1
)))
return
STATUS_NO_MEMORY
;
}
else
if
(
oem
->
MaximumLength
<=
len
)
{
if
(
!
oem
->
MaximumLength
)
return
STATUS_BUFFER_OVERFLOW
;
oem
->
Length
=
oem
->
MaximumLength
-
1
;
ret
=
STATUS_BUFFER_OVERFLOW
;
}
WideCharToMultiByte
(
CP_OEMCP
,
0
,
uni
->
Buffer
,
uni
->
Length
/
sizeof
(
WCHAR
),
oem
->
Buffer
,
oem
->
Length
,
NULL
,
NULL
);
oem
->
Buffer
[
oem
->
Length
]
=
0
;
return
ret
;
}
/**************************************************************************
* Rtl
UpcaseUnicodeStringToOemString
* Rtl
MultiByteToUnicodeN (NTDLL.@)
*
* NOTES
*
writes terminating 0
*
if unistr is too small a part is copied
*/
NTSTATUS
WINAPI
RtlUpcaseUnicodeStringToOemString
(
PANSI_STRING
oem
,
PUNICODE_STRING
uni
,
BOOLEAN
doalloc
)
NTSTATUS
WINAPI
RtlMultiByteToUnicodeN
(
LPWSTR
dst
,
DWORD
dstlen
,
LPDWORD
reslen
,
LPCSTR
src
,
DWORD
srclen
)
{
int
i
,
len
=
uni
->
Length
/
sizeof
(
WCHAR
);
DWORD
res
=
MultiByteToWideChar
(
CP_ACP
,
0
,
src
,
srclen
,
dst
,
dstlen
/
sizeof
(
WCHAR
)
);
if
(
reslen
)
*
reslen
=
res
?
res
*
sizeof
(
WCHAR
)
:
dstlen
;
/* overflow -> we filled up to dstlen */
return
STATUS_SUCCESS
;
}
TRACE
(
"%p %s %i
\n
"
,
oem
,
debugstr_us
(
uni
),
doalloc
);
oem
->
Length
=
len
;
if
(
doalloc
)
{
oem
->
Buffer
=
(
LPSTR
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
len
+
1
);
if
(
!
oem
->
Buffer
)
return
STATUS_NO_MEMORY
;
oem
->
MaximumLength
=
len
+
1
;
}
else
if
(
oem
->
MaximumLength
<=
len
)
{
return
STATUS_BUFFER_OVERFLOW
;
}
/**************************************************************************
* RtlOemToUnicodeN (NTDLL.@)
*/
NTSTATUS
WINAPI
RtlOemToUnicodeN
(
LPWSTR
dst
,
DWORD
dstlen
,
LPDWORD
reslen
,
LPCSTR
src
,
DWORD
srclen
)
{
DWORD
res
=
MultiByteToWideChar
(
CP_OEMCP
,
0
,
src
,
srclen
,
dst
,
dstlen
/
sizeof
(
WCHAR
)
);
if
(
reslen
)
*
reslen
=
res
?
res
*
sizeof
(
WCHAR
)
:
dstlen
;
/* overflow -> we filled up to dstlen */
return
STATUS_SUCCESS
;
}
for
(
i
=
0
;
i
<
len
;
i
++
)
{
oem
->
Buffer
[
i
]
=
toupperW
((
char
)(
uni
->
Buffer
[
i
]));
}
oem
->
Buffer
[
i
]
=
0
;
return
STATUS_SUCCESS
;
/**************************************************************************
* RtlUnicodeToMultiByteN (NTDLL.@)
*/
NTSTATUS
WINAPI
RtlUnicodeToMultiByteN
(
LPSTR
dst
,
DWORD
dstlen
,
LPDWORD
reslen
,
LPCWSTR
src
,
DWORD
srclen
)
{
DWORD
res
=
WideCharToMultiByte
(
CP_ACP
,
0
,
src
,
srclen
/
sizeof
(
WCHAR
),
dst
,
dstlen
,
NULL
,
NULL
);
if
(
reslen
)
*
reslen
=
res
?
res
*
sizeof
(
WCHAR
)
:
dstlen
;
/* overflow -> we filled up to dstlen */
return
STATUS_SUCCESS
;
}
/**************************************************************************
* RtlUnicodeStringToAnsiString
*
* NOTES
* writes terminating 0
* copys a part if the buffer is to small
*/
NTSTATUS
WINAPI
RtlUnicodeStringToAnsiString
(
PANSI_STRING
ansi
,
PUNICODE_STRING
uni
,
BOOLEAN
doalloc
)
{
int
len
=
uni
->
Length
/
sizeof
(
WCHAR
);
NTSTATUS
ret
=
STATUS_SUCCESS
;
TRACE
(
"%p %s %i
\n
"
,
ansi
,
debugstr_us
(
uni
),
doalloc
);
ansi
->
Length
=
len
;
if
(
doalloc
)
{
ansi
->
Buffer
=
(
LPSTR
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
len
+
1
);
if
(
!
ansi
->
Buffer
)
return
STATUS_NO_MEMORY
;
ansi
->
MaximumLength
=
len
+
1
;
}
else
if
(
ansi
->
MaximumLength
<=
len
)
{
ansi
->
Length
=
ansi
->
MaximumLength
-
1
;
ret
=
STATUS_BUFFER_OVERFLOW
;
}
lstrcpynWtoA
(
ansi
->
Buffer
,
uni
->
Buffer
,
ansi
->
Length
+
1
);
return
ret
;
* RtlUnicodeToOemN (NTDLL.@)
*/
NTSTATUS
WINAPI
RtlUnicodeToOemN
(
LPSTR
dst
,
DWORD
dstlen
,
LPDWORD
reslen
,
LPCWSTR
src
,
DWORD
srclen
)
{
DWORD
res
=
WideCharToMultiByte
(
CP_OEMCP
,
0
,
src
,
srclen
/
sizeof
(
WCHAR
),
dst
,
dstlen
,
NULL
,
NULL
);
if
(
reslen
)
*
reslen
=
res
?
res
*
sizeof
(
WCHAR
)
:
dstlen
;
/* overflow -> we filled up to dstlen */
return
STATUS_SUCCESS
;
}
/*
COPY BETWEEN ANSI/UNICODE_STRING AND MULTIBYTE STRING
S
CASE CONVERSION
S
*/
/**************************************************************************
* RtlMultiByteToUnicodeN
*
* NOTES
* dest can be equal to src
* if unistr is to small a part is copyed
*
* FIXME
* multibyte support
* RtlUpperString (NTDLL.@)
*/
NTSTATUS
WINAPI
RtlMultiByteToUnicodeN
(
LPWSTR
unistr
,
DWORD
unilen
,
LPDWORD
reslen
,
LPSTR
oemstr
,
DWORD
oemlen
)
void
WINAPI
RtlUpperString
(
STRING
*
dst
,
const
STRING
*
src
,
BOOLEAN
doalloc
)
{
UINT
len
;
int
i
;
unsigned
int
i
,
len
=
min
(
src
->
Length
,
dst
->
MaximumLength
);
TRACE
(
"%p %lu, %p, %s, %lu
\n
"
,
oemstr
,
oemlen
,
reslen
,
debugstr_w
(
unistr
),
unilen
);
len
=
(
unilen
/
sizeof
(
WCHAR
)
<
oemlen
)
?
unilen
/
sizeof
(
WCHAR
)
:
oemlen
;
for
(
i
=
0
;
i
<
len
;
i
++
)
dst
->
Buffer
[
i
]
=
toupper
(
src
->
Buffer
[
i
]
);
dst
->
Length
=
len
;
}
for
(
i
=
len
-
1
;
i
>=
0
;
i
--
)
unistr
[
i
]
=
(
WCHAR
)
oemstr
[
i
];
if
(
reslen
)
*
reslen
=
len
*
2
;
return
0
;
/**************************************************************************
* 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
;
if
(
!
(
dest
->
Buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
)))
return
STATUS_NO_MEMORY
;
}
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
;
}
/**************************************************************************
* RtlOemToUnicodeN
* RtlUpcaseUnicodeStringToAnsiString (NTDLL.@)
*
* NOTES
* writes terminating 0
*/
NTSTATUS
WINAPI
RtlOemToUnicodeN
(
LPWSTR
unistr
,
DWORD
unilen
,
LPDWORD
reslen
,
LPSTR
oemstr
,
DWORD
oemlen
)
NTSTATUS
WINAPI
RtlUpcaseUnicodeStringToAnsiString
(
STRING
*
dst
,
const
UNICODE_STRING
*
src
,
BOOLEAN
doalloc
)
{
UINT
len
;
int
i
;
NTSTATUS
ret
;
UNICODE_STRING
upcase
;
if
(
!
(
ret
=
RtlUpcaseUnicodeString
(
&
upcase
,
src
,
TRUE
)))
{
ret
=
RtlUnicodeStringToAnsiString
(
dst
,
&
upcase
,
doalloc
);
RtlFreeUnicodeString
(
&
upcase
);
}
return
ret
;
}
TRACE
(
"%p %lu, %p, %s, %lu
\n
"
,
oemstr
,
oemlen
,
reslen
,
debugstr_w
(
unistr
),
unilen
);
len
=
(
unilen
/
sizeof
(
WCHAR
)
<
oemlen
)
?
unilen
/
sizeof
(
WCHAR
)
:
oemlen
;
/**************************************************************************
* 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
;
}
for
(
i
=
len
-
1
;
i
>=
0
;
i
--
)
unistr
[
i
]
=
(
WCHAR
)
oemstr
[
i
];
if
(
reslen
)
*
reslen
=
len
*
2
;
return
0
;
/**************************************************************************
* RtlUpcaseUnicodeToMultiByteN (NTDLL.@)
*/
NTSTATUS
WINAPI
RtlUpcaseUnicodeToMultiByteN
(
LPSTR
dst
,
DWORD
dstlen
,
LPDWORD
reslen
,
LPCWSTR
src
,
DWORD
srclen
)
{
NTSTATUS
ret
;
LPWSTR
upcase
;
DWORD
i
;
if
(
!
(
upcase
=
HeapAlloc
(
GetProcessHeap
(),
0
,
srclen
)))
return
STATUS_NO_MEMORY
;
for
(
i
=
0
;
i
<
srclen
/
sizeof
(
WCHAR
);
i
++
)
upcase
[
i
]
=
toupperW
(
src
[
i
]);
ret
=
RtlUnicodeToMultiByteN
(
dst
,
dstlen
,
reslen
,
upcase
,
srclen
);
HeapFree
(
GetProcessHeap
(),
0
,
upcase
);
return
ret
;
}
/**************************************************************************
* RtlU
nicodeToOemN
* RtlU
pcaseUnicodeToOemN (NTDLL.@)
*/
NTSTATUS
WINAPI
RtlUnicodeToOemN
(
LPSTR
oemstr
,
DWORD
oemlen
,
LPDWORD
reslen
,
LPWSTR
unistr
,
DWORD
unilen
)
NTSTATUS
WINAPI
RtlUpcaseUnicodeToOemN
(
LPSTR
dst
,
DWORD
dstlen
,
LPDWORD
reslen
,
LPCWSTR
src
,
DWORD
srclen
)
{
UINT
len
;
int
i
;
TRACE
(
"%p %lu, %p, %s, %lu
\n
"
,
oemstr
,
oemlen
,
reslen
,
debugstr_w
(
unistr
),
unilen
);
NTSTATUS
ret
;
LPWSTR
upcase
;
DWORD
i
;
if
(
!
(
upcase
=
HeapAlloc
(
GetProcessHeap
(),
0
,
srclen
)))
return
STATUS_NO_MEMORY
;
for
(
i
=
0
;
i
<
srclen
/
sizeof
(
WCHAR
);
i
++
)
upcase
[
i
]
=
toupperW
(
src
[
i
]);
ret
=
RtlUnicodeToOemN
(
dst
,
dstlen
,
reslen
,
upcase
,
srclen
);
HeapFree
(
GetProcessHeap
(),
0
,
upcase
);
return
ret
;
}
len
=
(
oemlen
<
unilen
/
sizeof
(
WCHAR
))
?
unilen
/
sizeof
(
WCHAR
)
:
oemlen
;
for
(
i
=
len
-
1
;
i
>=
0
;
i
--
)
oemstr
[
i
]
=
(
CHAR
)
unistr
[
i
];
/*
STRING SIZE
*/
if
(
reslen
)
*
reslen
=
len
*
2
;
return
0
;
/**************************************************************************
* RtlOemStringToUnicodeSize (NTDLL.@)
*
* Return the size in bytes necessary for the Unicode conversion of 'str',
* including the terminating NULL.
*/
UINT
WINAPI
RtlOemStringToUnicodeSize
(
PSTRING
str
)
{
DWORD
ret
=
MultiByteToWideChar
(
CP_OEMCP
,
0
,
str
->
Buffer
,
str
->
Length
,
NULL
,
0
);
return
(
ret
+
1
)
*
sizeof
(
WCHAR
);
}
/**************************************************************************
* RtlUpcaseUnicodeToOemN
* RtlAnsiStringToUnicodeSize (NTDLL.@)
*
* Return the size in bytes necessary for the Unicode conversion of 'str',
* including the terminating NULL.
*/
NTSTATUS
WINAPI
RtlUpcaseUnicodeToOemN
(
LPSTR
oemstr
,
DWORD
oemlen
,
LPDWORD
reslen
,
LPWSTR
unistr
,
DWORD
unilen
)
DWORD
WINAPI
RtlAnsiStringToUnicodeSize
(
PSTRING
str
)
{
UINT
len
;
int
i
;
DWORD
ret
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
->
Buffer
,
str
->
Length
,
NULL
,
0
);
return
(
ret
+
1
)
*
sizeof
(
WCHAR
);
}
TRACE
(
"%p %lu, %p, %s, %lu
\n
"
,
oemstr
,
oemlen
,
reslen
,
debugstr_w
(
unistr
),
unilen
);
len
=
(
oemlen
<
unilen
/
sizeof
(
WCHAR
))
?
unilen
/
sizeof
(
WCHAR
)
:
oemlen
;
/**************************************************************************
* 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
)
{
*
size
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
len
,
NULL
,
0
)
*
sizeof
(
WCHAR
);
return
0
;
}
for
(
i
=
len
-
1
;
i
>=
0
;
i
--
)
oemstr
[
i
]
=
toupper
((
CHAR
)
unistr
[
i
]);
if
(
reslen
)
*
reslen
=
len
*
2
;
return
0
;
/**************************************************************************
* RtlUnicodeToMultiByteSize (NTDLL.@)
*
* Compute the size necessary for the multibyte conversion of 'str',
* without the terminating NULL.
*/
NTSTATUS
WINAPI
RtlUnicodeToMultiByteSize
(
DWORD
*
size
,
LPCWSTR
str
,
UINT
len
)
{
*
size
=
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
len
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
);
return
0
;
}
/**************************************************************************
* RtlUnicodeToMultiByteN
* RtlUnicodeStringToAnsiSize (NTDLL.@)
*
* Return the size in bytes necessary for the Ansi conversion of 'str',
* including the terminating NULL.
*/
NTSTATUS
WINAPI
RtlUnicodeToMultiByteN
(
PCHAR
MbString
,
ULONG
MbSize
,
PULONG
ResultSize
,
PWCHAR
UnicodeString
,
ULONG
UnicodeSize
)
DWORD
WINAPI
RtlUnicodeStringToAnsiSize
(
const
UNICODE_STRING
*
str
)
{
int
Size
=
0
,
i
;
return
WideCharToMultiByte
(
CP_ACP
,
0
,
str
->
Buffer
,
str
->
Length
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
)
+
1
;
}
TRACE
(
"(%p,%lu,%p,%p(%s),%lu)
\n
"
,
MbString
,
MbSize
,
ResultSize
,
UnicodeString
,
debugstr_w
(
UnicodeString
),
UnicodeSize
);
Size
=
(
UnicodeSize
>
(
MbSize
*
sizeof
(
WCHAR
)))
?
MbSize
:
UnicodeSize
/
sizeof
(
WCHAR
);
/**************************************************************************
* RtlUnicodeStringToOemSize (NTDLL.@)
*
* Return the size in bytes necessary for the OEM conversion of 'str',
* including the terminating NULL.
*/
DWORD
WINAPI
RtlUnicodeStringToOemSize
(
const
UNICODE_STRING
*
str
)
{
return
WideCharToMultiByte
(
CP_OEMCP
,
0
,
str
->
Buffer
,
str
->
Length
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
)
+
1
;
}
if
(
ResultSize
!=
NULL
)
*
ResultSize
=
Size
;
for
(
i
=
0
;
i
<
Size
;
i
++
)
{
*
(
MbString
++
)
=
*
(
UnicodeString
++
);
}
return
STATUS_SUCCESS
;
/**************************************************************************
* 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
;
}
/*
STRING SIZE
Rtlx* supports multibyte
*/
/**************************************************************************
*
RtlxOemStringToUnicodeSize
*
RtlAppendAsciizToString (NTDLL.@)
*/
UINT
WINAPI
RtlxOemStringToUnicodeSize
(
PSTRING
str
)
NTSTATUS
WINAPI
RtlAppendAsciizToString
(
STRING
*
dst
,
LPCSTR
src
)
{
return
str
->
Length
*
2
+
2
;
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
;
}
/**************************************************************************
*
RtlxAnsiStringToUnicodeSize
*
RtlAppendUnicodeToString (NTDLL.@)
*/
UINT
WINAPI
RtlxAnsiStringToUnicodeSize
(
PANSI_STRING
str
)
NTSTATUS
WINAPI
RtlAppendUnicodeToString
(
UNICODE_STRING
*
dst
,
LPCWSTR
src
)
{
return
str
->
Length
*
2
+
2
;
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
;
}
/**************************************************************************
* RtlxUnicodeStringToOemSize
*
* RtlAppendUnicodeStringToString (NTDLL.@)
*/
UINT
WINAPI
RtlxUnicodeStringToOemSize
(
PUNICODE_STRING
str
)
NTSTATUS
WINAPI
RtlAppendUnicodeStringToString
(
UNICODE_STRING
*
dst
,
const
UNICODE_STRING
*
src
)
{
return
str
->
Length
+
1
;
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
;
}
/*
MISC
*/
...
...
@@ -600,16 +789,3 @@ out:
*
pf
=
out_flags
;
return
len
;
}
/**************************************************************************
* RtlPrefixUnicodeString
*/
NTSTATUS
WINAPI
RtlPrefixUnicodeString
(
PUNICODE_STRING
a
,
PUNICODE_STRING
b
,
DWORD
x
)
{
TRACE
(
"(%s,%s,%lx)
\n
"
,
debugstr_us
(
a
),
debugstr_us
(
b
),
x
);
return
STATUS_SUCCESS
;
}
include/ntddk.h
View file @
d2f8bf6f
...
...
@@ -585,91 +585,52 @@ DWORD WINAPI RtlGetAce(
/* string functions */
VOID
WINAPI
RtlInitAnsiString
(
PANSI_STRING
target
,
LPCSTR
source
);
VOID
WINAPI
RtlInitString
(
PSTRING
target
,
LPCSTR
source
);
VOID
WINAPI
RtlInitUnicodeString
(
PUNICODE_STRING
target
,
LPCWSTR
source
);
VOID
WINAPI
RtlFreeUnicodeString
(
PUNICODE_STRING
str
);
VOID
WINAPI
RtlFreeAnsiString
(
PANSI_STRING
AnsiString
);
NTSTATUS
WINAPI
RtlAnsiStringToUnicodeString
(
PUNICODE_STRING
uni
,
PANSI_STRING
ansi
,
BOOLEAN
doalloc
);
NTSTATUS
WINAPI
RtlOemStringToUnicodeString
(
PUNICODE_STRING
uni
,
PSTRING
ansi
,
BOOLEAN
doalloc
);
NTSTATUS
WINAPI
RtlMultiByteToUnicodeN
(
LPWSTR
unistr
,
DWORD
unilen
,
LPDWORD
reslen
,
LPSTR
oemstr
,
DWORD
oemlen
);
NTSTATUS
WINAPI
RtlOemToUnicodeN
(
LPWSTR
unistr
,
DWORD
unilen
,
LPDWORD
reslen
,
LPSTR
oemstr
,
DWORD
oemlen
);
NTSTATUS
WINAPI
RtlUnicodeToOemN
(
LPSTR
oemstr
,
DWORD
oemlen
,
LPDWORD
reslen
,
LPWSTR
unistr
,
DWORD
unilen
);
NTSTATUS
WINAPI
RtlUnicodeStringToOemString
(
PANSI_STRING
oem
,
PUNICODE_STRING
uni
,
BOOLEAN
alloc
);
NTSTATUS
WINAPI
RtlUnicodeStringToAnsiString
(
PANSI_STRING
oem
,
PUNICODE_STRING
uni
,
BOOLEAN
alloc
);
BOOLEAN
WINAPI
RtlEqualUnicodeString
(
PUNICODE_STRING
s1
,
PUNICODE_STRING
s2
,
BOOLEAN
x
);
DWORD
WINAPI
RtlUpcaseUnicodeString
(
PUNICODE_STRING
dest
,
PUNICODE_STRING
src
,
BOOLEAN
doalloc
);
UINT
WINAPI
RtlxOemStringToUnicodeSize
(
PSTRING
str
);
UINT
WINAPI
RtlxAnsiStringToUnicodeSize
(
PANSI_STRING
str
);
DWORD
WINAPI
RtlAnsiStringToUnicodeSize
(
PSTRING
);
NTSTATUS
WINAPI
RtlAnsiStringToUnicodeString
(
UNICODE_STRING
*
,
const
STRING
*
,
BOOLEAN
);
NTSTATUS
WINAPI
RtlAppendAsciizToString
(
STRING
*
,
LPCSTR
);
NTSTATUS
WINAPI
RtlAppendStringToString
(
STRING
*
,
const
STRING
*
);
NTSTATUS
WINAPI
RtlAppendUnicodeStringToString
(
UNICODE_STRING
*
,
const
UNICODE_STRING
*
);
NTSTATUS
WINAPI
RtlAppendUnicodeToString
(
UNICODE_STRING
*
,
LPCWSTR
);
LONG
WINAPI
RtlCompareString
(
const
STRING
*
,
const
STRING
*
,
BOOLEAN
);
LONG
WINAPI
RtlCompareUnicodeString
(
const
UNICODE_STRING
*
,
const
UNICODE_STRING
*
,
BOOLEAN
);
void
WINAPI
RtlCopyString
(
STRING
*
,
const
STRING
*
);
void
WINAPI
RtlCopyUnicodeString
(
UNICODE_STRING
*
,
const
UNICODE_STRING
*
);
BOOLEAN
WINAPI
RtlCreateUnicodeString
(
PUNICODE_STRING
,
LPCWSTR
);
BOOLEAN
WINAPI
RtlCreateUnicodeStringFromAsciiz
(
PUNICODE_STRING
,
LPCSTR
);
void
WINAPI
RtlEraseUnicodeString
(
UNICODE_STRING
*
);
BOOLEAN
WINAPI
RtlEqualString
(
const
STRING
*
,
const
STRING
*
,
BOOLEAN
);
BOOLEAN
WINAPI
RtlEqualUnicodeString
(
const
UNICODE_STRING
*
,
const
UNICODE_STRING
*
,
BOOLEAN
);
void
WINAPI
RtlFreeAnsiString
(
PSTRING
);
void
WINAPI
RtlFreeOemString
(
PSTRING
);
void
WINAPI
RtlFreeUnicodeString
(
PUNICODE_STRING
);
void
WINAPI
RtlInitAnsiString
(
PSTRING
,
LPCSTR
);
void
WINAPI
RtlInitString
(
PSTRING
,
LPCSTR
);
void
WINAPI
RtlInitUnicodeString
(
PUNICODE_STRING
,
LPCWSTR
);
NTSTATUS
WINAPI
RtlMultiByteToUnicodeN
(
LPWSTR
,
DWORD
,
LPDWORD
,
LPCSTR
,
DWORD
);
NTSTATUS
WINAPI
RtlMultiByteToUnicodeSize
(
DWORD
*
,
LPCSTR
,
UINT
);
UINT
WINAPI
RtlOemStringToUnicodeSize
(
PSTRING
);
NTSTATUS
WINAPI
RtlOemStringToUnicodeString
(
UNICODE_STRING
*
,
const
STRING
*
,
BOOLEAN
);
NTSTATUS
WINAPI
RtlOemToUnicodeN
(
LPWSTR
,
DWORD
,
LPDWORD
,
LPCSTR
,
DWORD
);
BOOLEAN
WINAPI
RtlPrefixString
(
const
STRING
*
,
const
STRING
*
,
BOOLEAN
);
BOOLEAN
WINAPI
RtlPrefixUnicodeString
(
const
UNICODE_STRING
*
,
const
UNICODE_STRING
*
,
BOOLEAN
);
DWORD
WINAPI
RtlUnicodeStringToAnsiSize
(
const
UNICODE_STRING
*
);
NTSTATUS
WINAPI
RtlUnicodeStringToAnsiString
(
STRING
*
,
const
UNICODE_STRING
*
,
BOOLEAN
);
DWORD
WINAPI
RtlUnicodeStringToOemSize
(
const
UNICODE_STRING
*
);
NTSTATUS
WINAPI
RtlUnicodeStringToOemString
(
STRING
*
,
const
UNICODE_STRING
*
,
BOOLEAN
);
NTSTATUS
WINAPI
RtlUnicodeToMultiByteN
(
LPSTR
,
DWORD
,
LPDWORD
,
LPCWSTR
,
DWORD
);
NTSTATUS
WINAPI
RtlUnicodeToMultiByteSize
(
DWORD
*
,
LPCWSTR
,
UINT
);
NTSTATUS
WINAPI
RtlUnicodeToOemN
(
LPSTR
,
DWORD
,
LPDWORD
,
LPCWSTR
,
DWORD
);
NTSTATUS
WINAPI
RtlUpcaseUnicodeString
(
UNICODE_STRING
*
,
const
UNICODE_STRING
*
,
BOOLEAN
);
NTSTATUS
WINAPI
RtlUpcaseUnicodeStringToAnsiString
(
STRING
*
,
const
UNICODE_STRING
*
,
BOOLEAN
);
NTSTATUS
WINAPI
RtlUpcaseUnicodeStringToOemString
(
STRING
*
,
const
UNICODE_STRING
*
,
BOOLEAN
);
NTSTATUS
WINAPI
RtlUpcaseUnicodeToMultiByteN
(
LPSTR
,
DWORD
,
LPDWORD
,
LPCWSTR
,
DWORD
);
NTSTATUS
WINAPI
RtlUpcaseUnicodeToOemN
(
LPSTR
,
DWORD
,
LPDWORD
,
LPCWSTR
,
DWORD
);
DWORD
WINAPI
RtlIsTextUnicode
(
LPVOID
buf
,
DWORD
len
,
DWORD
*
pf
);
NTSTATUS
WINAPI
RtlCompareUnicodeString
(
PUNICODE_STRING
String1
,
PUNICODE_STRING
String2
,
BOOLEAN
CaseInSensitive
);
/* resource functions */
typedef
struct
_RTL_RWLOCK
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment