Commit f4757bb6 authored by Thomas Mertes's avatar Thomas Mertes Committed by Alexandre Julliard

- Implement RtlCharToInteger, RtlExtendedMagicDivide, RtlUpperChar,

RtlInt64ToUnicodeString, RtlIntegerToChar, RtlIntegerToUnicodeString, RtlLargeIntegerToChar, RtlUnicodeStringToInteger and RtlUpcaseUnicodeChar. - Use toupperW instead of toupper in RtlCompareUnicodeString.
parent 8cded56d
......@@ -2,6 +2,7 @@
* Large integer functions
*
* Copyright 2000 Alexandre Julliard
* Copyright 2003 Thomas Mertes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -191,13 +192,174 @@ LONGLONG WINAPI RtlExtendedIntegerMultiply( LONGLONG a, INT b )
* must be chosen such that b = 2^(64+shift) / c.
* Then we have RtlExtendedMagicDivide(a,b,shift) == a * b / 2^(64+shift) == a / c.
*
* I'm too lazy to implement it right now...
* Parameter b although defined as LONGLONG is used as ULONGLONG.
*/
/* LONGLONG WINAPI RtlExtendedMagicDivide( LONGLONG a, LONGLONG b, INT shift )
* {
* return 0;
* }
#define LOWER_32(A) ((A) & 0xffffffff)
#define UPPER_32(A) ((A) >> 32)
LONGLONG WINAPI RtlExtendedMagicDivide(
LONGLONG a,
LONGLONG b,
INT shift)
{
ULONGLONG a_high;
ULONGLONG a_low;
ULONGLONG b_high;
ULONGLONG b_low;
ULONGLONG ah_bl;
ULONGLONG al_bh;
LONGLONG result;
int positive;
if (a < 0) {
a_high = UPPER_32((ULONGLONG) -a);
a_low = LOWER_32((ULONGLONG) -a);
positive = 0;
} else {
a_high = UPPER_32((ULONGLONG) a);
a_low = LOWER_32((ULONGLONG) a);
positive = 1;
} /* if */
b_high = UPPER_32((ULONGLONG) b);
b_low = LOWER_32((ULONGLONG) b);
ah_bl = a_high * b_low;
al_bh = a_low * b_high;
result = (LONGLONG) ((a_high * b_high +
UPPER_32(ah_bl) +
UPPER_32(al_bh) +
UPPER_32(LOWER_32(ah_bl) + LOWER_32(al_bh) + UPPER_32(a_low * b_low))) >> shift);
if (positive) {
return result;
} else {
return -result;
} /* if */
}
/******************************************************************************
* RtlLargeIntegerToChar [NTDLL.@]
*
* Convert an unsigned large integer to a character string.
*
* On success assign a string and return STATUS_SUCCESS.
* If base is not 0 (=10), 2, 8, 10 or 16 return STATUS_INVALID_PARAMETER
* Writes at most length characters to the string str.
* Str is '\0' terminated when length allowes it.
* When str fits exactly in length characters the '\0' is ommitted.
* When str would be larger than length: return STATUS_BUFFER_OVERFLOW
* For str == NULL return STATUS_ACCESS_VIOLATION.
* Do not check for value_ptr != NULL (as native DLL).
*
* Difference:
* - Accept base 0 as 10 instead of crashing as native DLL does.
* - The native DLL does produce garbage or STATUS_BUFFER_OVERFLOW for
* base 2, 8 and 16 when the value is larger than 0xFFFFFFFF.
*/
NTSTATUS WINAPI RtlLargeIntegerToChar(
const ULONGLONG *value_ptr,
ULONG base,
ULONG length,
PCHAR str)
{
ULONGLONG value = *value_ptr;
CHAR buffer[65];
PCHAR pos;
CHAR digit;
ULONG len;
if (base == 0) {
base = 10;
} else if (base != 2 && base != 8 && base != 10 && base != 16) {
return STATUS_INVALID_PARAMETER;
} /* if */
pos = &buffer[64];
*pos = '\0';
do {
pos--;
digit = value % base;
value = value / base;
if (digit < 10) {
*pos = '0' + digit;
} else {
*pos = 'A' + digit - 10;
} /* if */
} while (value != 0L);
len = &buffer[64] - pos;
if (len > length) {
return STATUS_BUFFER_OVERFLOW;
} else if (str == NULL) {
return STATUS_ACCESS_VIOLATION;
} else if (len == length) {
memcpy(str, pos, len);
} else {
memcpy(str, pos, len + 1);
} /* if */
return STATUS_SUCCESS;
}
/**************************************************************************
* RtlInt64ToUnicodeString (NTDLL.@)
*
* Convert a large unsigned integer to a NULL terminated unicode string.
*
* On success assign a NULL terminated string and return STATUS_SUCCESS.
* If base is not 0 (=10), 2, 8, 10 or 16 return STATUS_INVALID_PARAMETER.
* If str is too small to hold the string (with the NULL termination):
* Set str->Length to the length the string would have (which can be
* larger than the MaximumLength) and return STATUS_BUFFER_OVERFLOW.
* Do not check for str != NULL (as native DLL).
*
* Difference:
* - Accept base 0 as 10 instead of crashing as native DLL does.
* - Do not return STATUS_BUFFER_OVERFLOW when the string is long enough.
* The native DLL does this when the string would be longer than 31
* characters even when the string parameter is long enough.
* - The native DLL does produce garbage or STATUS_BUFFER_OVERFLOW for
* base 2, 8 and 16 when the value is larger than 0xFFFFFFFF.
*/
NTSTATUS WINAPI RtlInt64ToUnicodeString(
ULONGLONG value,
ULONG base,
UNICODE_STRING *str)
{
WCHAR buffer[65];
PWCHAR pos;
WCHAR digit;
if (base == 0) {
base = 10;
} else if (base != 2 && base != 8 && base != 10 && base != 16) {
return STATUS_INVALID_PARAMETER;
} /* if */
pos = &buffer[64];
*pos = '\0';
do {
pos--;
digit = value % base;
value = value / base;
if (digit < 10) {
*pos = '0' + digit;
} else {
*pos = 'A' + digit - 10;
} /* if */
} while (value != 0L);
str->Length = (&buffer[64] - pos) * sizeof(WCHAR);
if (str->Length >= str->MaximumLength) {
return STATUS_BUFFER_OVERFLOW;
} else {
memcpy(str->Buffer, pos, str->Length + 1);
} /* if */
return STATUS_SUCCESS;
}
/******************************************************************************
......
......@@ -289,7 +289,7 @@
@ stdcall RtlAreBitsSet(ptr long long) RtlAreBitsSet
@ stdcall RtlAssert(ptr ptr long long) RtlAssert
@ stub RtlCaptureStackBackTrace
@ stub RtlCharToInteger
@ stdcall RtlCharToInteger(ptr long ptr) RtlCharToInteger
@ stub RtlCheckRegistryKey
@ stdcall RtlClearAllBits(ptr) RtlClearAllBits
@ stdcall RtlClearBits(ptr long long) RtlClearBits
......@@ -367,7 +367,7 @@
@ stub RtlExtendHeap
@ stdcall -ret64 RtlExtendedIntegerMultiply(long long long) RtlExtendedIntegerMultiply
@ stdcall -ret64 RtlExtendedLargeIntegerDivide(long long long ptr) RtlExtendedLargeIntegerDivide
@ stub RtlExtendedMagicDivide
@ stdcall -ret64 RtlExtendedMagicDivide(long long long long long) RtlExtendedMagicDivide
@ stdcall RtlFillMemory(ptr long long) RtlFillMemory
@ stdcall RtlFillMemoryUlong(ptr long long) RtlFillMemoryUlong
@ stdcall RtlFindClearBits(ptr long long) RtlFindClearBits
......@@ -432,8 +432,9 @@
@ stdcall RtlInitializeResource(ptr) RtlInitializeResource
@ stdcall RtlInitializeSid(ptr ptr long) RtlInitializeSid
@ stub RtlInsertElementGenericTable
@ stdcall RtlIntegerToChar(long long long long) RtlIntegerToChar
@ stub RtlIntegerToUnicodeString
@ stdcall RtlInt64ToUnicodeString(long long long ptr) RtlInt64ToUnicodeString
@ stdcall RtlIntegerToChar(long long long ptr) RtlIntegerToChar
@ stdcall RtlIntegerToUnicodeString(long long ptr) RtlIntegerToUnicodeString
@ stub RtlIsDosDeviceName_U
@ stub RtlIsGenericTableEmpty
@ stub RtlIsNameLegalDOS8Dot3
......@@ -445,7 +446,7 @@
@ stdcall -ret64 RtlLargeIntegerShiftLeft(long long long) RtlLargeIntegerShiftLeft
@ stdcall -ret64 RtlLargeIntegerShiftRight(long long long) RtlLargeIntegerShiftRight
@ stdcall -ret64 RtlLargeIntegerSubtract(long long long long) RtlLargeIntegerSubtract
@ stub RtlLargeIntegerToChar
@ stdcall RtlLargeIntegerToChar(ptr long long ptr) RtlLargeIntegerToChar
@ stdcall RtlLeaveCriticalSection(ptr) RtlLeaveCriticalSection
@ stdcall RtlLengthRequiredSid(long) RtlLengthRequiredSid
@ stdcall RtlLengthSecurityDescriptor(ptr) RtlLengthSecurityDescriptor
......@@ -540,7 +541,7 @@
@ stub RtlUniform
@ stdcall RtlUnlockHeap(long) RtlUnlockHeap
@ stdcall RtlUnwind(ptr ptr ptr long) RtlUnwind
@ stub RtlUpcaseUnicodeChar
@ stdcall RtlUpcaseUnicodeChar(long) RtlUpcaseUnicodeChar
@ stdcall RtlUpcaseUnicodeString(ptr ptr long) RtlUpcaseUnicodeString
@ stdcall RtlUpcaseUnicodeStringToAnsiString(ptr ptr long) RtlUpcaseUnicodeStringToAnsiString
@ stub RtlUpcaseUnicodeStringToCountedOemString
......@@ -548,7 +549,7 @@
@ stub RtlUpcaseUnicodeToCustomCPN
@ stdcall RtlUpcaseUnicodeToMultiByteN(ptr long ptr ptr long) RtlUpcaseUnicodeToMultiByteN
@ stdcall RtlUpcaseUnicodeToOemN(ptr long ptr ptr long) RtlUpcaseUnicodeToOemN
@ stub RtlUpperChar
@ stdcall RtlUpperChar(long) RtlUpperChar
@ stdcall RtlUpperString(ptr ptr) RtlUpperString
@ stub RtlUsageHeap
@ stub RtlValidAcl
......
......@@ -262,13 +262,6 @@ VOID WINAPI RtlReleasePebLock(void)
}
/******************************************************************************
* RtlIntegerToChar [NTDLL.@]
*/
DWORD WINAPI RtlIntegerToChar(DWORD x1,DWORD x2,DWORD x3,DWORD x4) {
FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4);
return 0;
}
/******************************************************************************
* RtlSetEnvironmentVariable [NTDLL.@]
*/
DWORD WINAPI RtlSetEnvironmentVariable(DWORD x1,PUNICODE_STRING key,PUNICODE_STRING val) {
......
......@@ -977,7 +977,9 @@ void WINAPI RtlInitializeBitMap(PRTL_BITMAP,LPBYTE,ULONG);
void WINAPI RtlInitializeResource(LPRTL_RWLOCK);
BOOL WINAPI RtlInitializeSid(PSID,PSID_IDENTIFIER_AUTHORITY,BYTE);
DWORD WINAPI RtlIntegerToChar(DWORD,DWORD,DWORD,DWORD);
NTSTATUS WINAPI RtlInt64ToUnicodeString(ULONGLONG,ULONG,UNICODE_STRING *);
NTSTATUS WINAPI RtlIntegerToChar(ULONG,ULONG,ULONG,PCHAR);
NTSTATUS WINAPI RtlIntegerToUnicodeString(ULONG,ULONG,UNICODE_STRING *);
BOOLEAN WINAPI RtlIsNameLegalDOS8Dot3(PUNICODE_STRING,POEM_STRING,PBOOLEAN);
DWORD WINAPI RtlIsTextUnicode(LPVOID,DWORD,DWORD *);
......@@ -988,6 +990,7 @@ LONGLONG WINAPI RtlLargeIntegerNegate(LONGLONG);
LONGLONG WINAPI RtlLargeIntegerShiftLeft(LONGLONG,INT);
LONGLONG WINAPI RtlLargeIntegerShiftRight(LONGLONG,INT);
LONGLONG WINAPI RtlLargeIntegerSubtract(LONGLONG,LONGLONG);
NTSTATUS WINAPI RtlLargeIntegerToChar(const ULONGLONG *,ULONG,ULONG,PCHAR);
NTSTATUS WINAPI RtlLeaveCriticalSection(RTL_CRITICAL_SECTION *);
DWORD WINAPI RtlLengthRequiredSid(DWORD);
ULONG WINAPI RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR);
......@@ -1045,6 +1048,7 @@ BOOL WINAPI RtlTryEnterCriticalSection(RTL_CRITICAL_SECTION *);
DWORD WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING*);
NTSTATUS WINAPI RtlUnicodeStringToAnsiString(PANSI_STRING,PCUNICODE_STRING,BOOLEAN);
NTSTATUS WINAPI RtlUnicodeStringToInteger(const UNICODE_STRING *,ULONG,ULONG *);
DWORD WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING*);
NTSTATUS WINAPI RtlUnicodeStringToOemString(POEM_STRING,PCUNICODE_STRING,BOOLEAN);
NTSTATUS WINAPI RtlUnicodeToMultiByteN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
......@@ -1057,11 +1061,14 @@ void WINAPI RtlUnwind(PVOID,PVOID,PEXCEPTION_RECORD,PVOID);
void WINAPI RtlUnwind2(FRAME_POINTERS,PVOID,PEXCEPTION_RECORD,PVOID,PCONTEXT);
void WINAPI RtlUnwindEx(FRAME_POINTERS,PVOID,PEXCEPTION_RECORD,PVOID,PCONTEXT,PUNWIND_HISTORY_TABLE);
#endif
WCHAR WINAPI RtlUpcaseUnicodeChar(WCHAR);
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);
CHAR WINAPI RtlUpperChar(CHAR);
void WINAPI RtlUpperString(STRING *,const STRING *);
NTSTATUS WINAPI RtlValidSecurityDescriptor(PSECURITY_DESCRIPTOR);
BOOL WINAPI RtlValidSid(PSID);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment