Started NLS support and improved Rtl string functions.
authorEric Kohl <eric.kohl@reactos.org>
Mon, 15 Nov 1999 16:02:50 +0000 (16:02 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Mon, 15 Nov 1999 16:02:50 +0000 (16:02 +0000)
svn path=/trunk/; revision=771

17 files changed:
reactos/include/ddk/rtl.h
reactos/include/ddk/status.h
reactos/lib/ntdll/def/ntdll.def
reactos/lib/ntdll/def/ntdll.edf
reactos/lib/ntdll/makefile
reactos/lib/ntdll/rtl/nls.c [new file with mode: 0644]
reactos/lib/ntdll/rtl/unicode.c
reactos/lib/psxdll/misc/rtl.c
reactos/lib/psxdll/psxdll.def
reactos/lib/psxdll/psxdll.edf
reactos/ntoskrnl/makefile_rex
reactos/ntoskrnl/ntoskrnl.def
reactos/ntoskrnl/ntoskrnl.edf
reactos/ntoskrnl/rtl/nls.c [new file with mode: 0644]
reactos/ntoskrnl/rtl/unicode.c
reactos/subsys/win32k/stubs/stubs.c
reactos/subsys/win32k/win32k.def

index 405e704..cf596dd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rtl.h,v 1.16 1999/10/31 22:44:39 ea Exp $
+/* $Id: rtl.h,v 1.17 1999/11/15 15:55:00 ekohl Exp $
  * 
  */
 
@@ -16,7 +16,7 @@ typedef struct _CONTROLLER_OBJECT
    ULONG Spare1;
    LARGE_INTEGER Spare2;
 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
-   
+
 typedef struct _STRING
 {
    USHORT Length;
@@ -54,6 +54,12 @@ typedef struct _TIME_FIELDS
    CSHORT Weekday;
 } TIME_FIELDS, *PTIME_FIELDS;
 
+typedef struct _RTL_BITMAP
+{
+   ULONG  SizeOfBitMap;
+   PULONG Buffer;
+} RTL_BITMAP, *PRTL_BITMAP;
+
 /*
  * PURPOSE: Flags for RtlQueryRegistryValues
  */
@@ -102,6 +108,19 @@ enum
    RTL_REGISTRY_VALUE,
 };
 
+
+#if defined(__NTOSKRNL__) || defined(__NTDLL__)
+#define NLS_MB_CODE_PAGE_TAG     NlsMbCodePageTag
+#define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
+#else
+#define NLS_MB_CODE_PAGE_TAG     (*NlsMbCodePageTag)
+#define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag)
+#endif /* __NTOSKRNL__ || __NTDLL__ */
+
+extern BOOLEAN NLS_MB_CODE_PAGE_TAG;
+extern BOOLEAN NLS_MB_OEM_CODE_PAGE_TAG;
+
+
 /*
  * FUNCTION: Sets up a parameter of type OBJECT_ATTRIBUTES for a 
  * subsequent call to ZwCreateXXX or ZwOpenXXX
@@ -170,12 +189,20 @@ RemoveTailList (
        PLIST_ENTRY     ListHead
        );
 
+WCHAR
+STDCALL
+RtlAnsiCharToUnicodeChar (
+       PCHAR   AnsiChar
+       );
+
 ULONG
+STDCALL
 RtlAnsiStringToUnicodeSize (
        PANSI_STRING    AnsiString
        );
 
 NTSTATUS
+STDCALL
 RtlAnsiStringToUnicodeString (
        PUNICODE_STRING DestinationString,
        PANSI_STRING    SourceString,
@@ -183,18 +210,35 @@ RtlAnsiStringToUnicodeString (
        );
 
 NTSTATUS
+STDCALL
+RtlAppendAsciizToString(
+       PSTRING Destination,
+       PCSZ    Source
+       );
+
+NTSTATUS
+STDCALL
+RtlAppendStringToString(
+       PSTRING Destination,
+       PSTRING Source
+       );
+
+NTSTATUS
+STDCALL
 RtlAppendUnicodeStringToString (
        PUNICODE_STRING Destination,
        PUNICODE_STRING Source
        );
 
 NTSTATUS
+STDCALL
 RtlAppendUnicodeToString (
        PUNICODE_STRING Destination,
        PWSTR           Source
        );
 
 NTSTATUS
+STDCALL
 RtlCharToInteger (
        PCSZ    String,
        ULONG   Base,
@@ -209,6 +253,7 @@ RtlCheckRegistryKey (
        );
 
 ULONG
+STDCALL
 RtlCompareMemory (
        PVOID   Source1,
        PVOID   Source2,
@@ -216,13 +261,15 @@ RtlCompareMemory (
        );
 
 LONG
+STDCALL
 RtlCompareString (
        PSTRING String1,
-       PSTRING String2, 
+       PSTRING String2,
        BOOLEAN CaseInsensitive
        );
 
 LONG
+STDCALL
 RtlCompareUnicodeString (
        PUNICODE_STRING String1,
        PUNICODE_STRING String2,
@@ -254,12 +301,14 @@ RtlCopyMemory (
        );
 
 VOID
+STDCALL
 RtlCopyString (
        PSTRING DestinationString,
        PSTRING SourceString
        );
 
 VOID
+STDCALL
 RtlCopyUnicodeString (
        PUNICODE_STRING DestinationString,
        PUNICODE_STRING SourceString
@@ -278,6 +327,13 @@ RtlCreateSecurityDescriptor (
        ULONG                   Revision
        );
 
+BOOLEAN
+STDCALL
+RtlCreateUnicodeString (
+       PUNICODE_STRING Destination,
+       PWSTR           Source
+       );
+
 NTSTATUS
 STDCALL
 RtlDeleteRegistryValue (
@@ -306,6 +362,7 @@ RtlEnlargedUnsignedMultiply (
        );
 
 BOOLEAN
+STDCALL
 RtlEqualString (
        PSTRING String1,
        PSTRING String2,
@@ -313,6 +370,7 @@ RtlEqualString (
        );
 
 BOOLEAN
+STDCALL
 RtlEqualUnicodeString (
        PUNICODE_STRING String1,
        PUNICODE_STRING String2,
@@ -348,34 +406,61 @@ RtlFillMemory (
        );
 
 VOID
+STDCALL
+RtlFillMemoryUlong (
+       PVOID   Destination,
+       ULONG   Length,
+       ULONG   Fill
+       );
+
+VOID
+STDCALL
 RtlFreeAnsiString (
        PANSI_STRING    AnsiString
        );
 
 VOID
+STDCALL
+RtlFreeOemString (
+       PSTRING OemString
+       );
+
+VOID
+STDCALL
 RtlFreeUnicodeString (
        PUNICODE_STRING UnicodeString
        );
 
 VOID
+STDCALL
+RtlGetDefaultCodePage (
+       PUSHORT AnsiCodePage,
+       PUSHORT OemCodePage
+       );
+
+VOID
+STDCALL
 RtlInitAnsiString (
        PANSI_STRING    DestinationString,
        PCSZ            SourceString
        );
 
 VOID
+STDCALL
 RtlInitString (
        PSTRING DestinationString,
        PCSZ    SourceString
        );
 
 VOID
+STDCALL
 RtlInitUnicodeString (
        PUNICODE_STRING DestinationString,
        PCWSTR          SourceString
        );
 
 NTSTATUS
+STDCALL
 RtlIntegerToUnicodeString (
        ULONG           Value,
        ULONG           Base,
@@ -397,16 +482,6 @@ RtlLargeIntegerAnd (
 
 /* MISSING FUNCTIONS GO HERE */
 
-LARGE_INTEGER
-RtlConvertLongToLargeInteger (
-       LONG    SignedInteger
-       );
-
-LARGE_INTEGER
-RtlConvertUlongToLargeInteger (
-       ULONG   UnsignedInteger
-       );
-
 LARGE_INTEGER
 RtlEnlargedIntegerMultiply (
        LONG    Multiplicand,
@@ -581,11 +656,53 @@ RtlMoveMemory (
        ULONG           Length
        );
 
+NTSTATUS
+STDCALL
+RtlMultiByteToUnicodeN (
+       PWCHAR UnicodeString,
+       ULONG  UnicodeSize,
+       PULONG ResultSize,
+       PCHAR  MbString,
+       ULONG  MbSize
+       );
+
+NTSTATUS
+STDCALL
+RtlMultiByteToUnicodeSize (
+       PULONG UnicodeSize,
+       PCHAR  MbString,
+       ULONG  MbSize
+       );
+
+ULONG
+STDCALL
+RtlOemStringToUnicodeSize (
+       PANSI_STRING    AnsiString
+       );
+
+NTSTATUS
+STDCALL
+RtlOemStringToUnicodeString (
+       PUNICODE_STRING DestinationString,
+       PANSI_STRING    SourceString,
+       BOOLEAN         AllocateDestinationString
+       );
+
+NTSTATUS
+STDCALL
+RtlOemToUnicodeN (
+       PWCHAR UnicodeString,
+       ULONG  UnicodeSize,
+       PULONG ResultSize,
+       PCHAR  OemString,
+       ULONG  OemSize
+       );
+
 NTSTATUS
 STDCALL
 RtlQueryRegistryValues (
        ULONG                           RelativeTo,
-       PWSTR                           Path, 
+       PWSTR                           Path,
        PRTL_QUERY_REGISTRY_TABLE       QueryTable,
        PVOID                           Context,
        PVOID                           Environment
@@ -664,10 +781,10 @@ typedef struct {
 HANDLE
 STDCALL
 RtlCreateHeap (
-       ULONG                   Flags, 
-       PVOID                   BaseAddress, 
-       ULONG                   SizeToReserve, 
-       ULONG                   SizeToCommit, 
+       ULONG                   Flags,
+       PVOID                   BaseAddress,
+       ULONG                   SizeToReserve,
+       ULONG                   SizeToCommit,
        PVOID                   Unknown,
        PRTL_HEAP_DEFINITION    Definition
        );
@@ -675,8 +792,8 @@ RtlCreateHeap (
 PVOID
 STDCALL
 RtlAllocateHeap (
-       HANDLE  Heap, 
-       ULONG   Flags, 
+       HANDLE  Heap,
+       ULONG   Flags,
        ULONG   Size
        );
 
@@ -684,12 +801,19 @@ RtlAllocateHeap (
 BOOLEAN
 STDCALL
 RtlFreeHeap (
-       HANDLE  Heap, 
-       ULONG   Flags, 
+       HANDLE  Heap,
+       ULONG   Flags,
        PVOID   Address
        );
 
+ULONG
+STDCALL
+RtlUnicodeStringToAnsiSize (
+       IN      PUNICODE_STRING UnicodeString
+       );
+
 NTSTATUS
+STDCALL
 RtlUnicodeStringToAnsiString (
        IN OUT  PANSI_STRING    DestinationString,
        IN      PUNICODE_STRING SourceString,
@@ -697,20 +821,65 @@ RtlUnicodeStringToAnsiString (
        );
 
 NTSTATUS
+STDCALL
 RtlUnicodeStringToInteger (
        IN      PUNICODE_STRING String,
        IN      ULONG           Base,
        OUT     PULONG          Value
        );
 
+ULONG
+STDCALL
+RtlUnicodeStringToOemSize (
+       IN      PUNICODE_STRING UnicodeString
+       );
+
 NTSTATUS
-RtlUpcaseUnicodeString (
-       IN OUT  PUNICODE_STRING DestinationString,
+STDCALL
+RtlUnicodeStringToOemString (
+       IN OUT  PANSI_STRING    DestinationString,
        IN      PUNICODE_STRING SourceString,
        IN      BOOLEAN         AllocateDestinationString
        );
 
+NTSTATUS
+STDCALL
+RtlUnicodeToMultiByteN (
+       PCHAR  MbString,
+       ULONG  MbSize,
+       PULONG ResultSize,
+       PWCHAR UnicodeString,
+       ULONG  UnicodeSize
+       );
+
+NTSTATUS
+STDCALL
+RtlUnicodeToMultiByteSize (
+       PULONG MbSize,
+       PWCHAR UnicodeString,
+       ULONG UnicodeSize
+       );
+
+NTSTATUS
+STDCALL
+RtlUnicodeToOemN (
+       PCHAR  OemString,
+       ULONG  OemSize,
+       PULONG ResultSize,
+       PWCHAR UnicodeString,
+       ULONG  UnicodeSize
+       );
+
+NTSTATUS
+STDCALL
+RtlUpcaseUnicodeString (
+       PUNICODE_STRING DestinationString,
+       PUNICODE_STRING SourceString,
+       BOOLEAN         AllocateDestinationString
+       );
+
 VOID
+STDCALL
 RtlUpperString (
        PSTRING DestinationString,
        PSTRING SourceString
@@ -846,9 +1015,6 @@ RtlCreateUserProcess(PUNICODE_STRING ApplicationName,
                      PSECURITY_DESCRIPTOR ThreadSd,
                      WINBOOL bInheritHandles,
                      DWORD dwCreationFlags,
-//                     LPVOID lpEnvironment,
-//                     LPCWSTR lpCurrentDirectory,
-//                     LPSTARTUPINFO lpStartupInfo,
                      PCLIENT_ID ClientId,
                      PHANDLE ProcessHandle,
                      PHANDLE ThreadHandle);
index 52ef619..62689f2 100644 (file)
 #endif
 #define STATUS_REPARSE                         (0x00000104)
 #define STATUS_MORE_ENTRIES                    (0x00000105)
-#define STATUS_NOTIFY_ENUM_DIR                 (0x10C)
+#define STATUS_NOT_ALL_ASSIGNED                (0x00000106)
+#define STATUS_SOME_NOT_MAPPED                 (0x00000107)
+#define STATUS_OPLOCK_BREAK_IN_PROCESS         (0x00000108)
+#define STATUS_VOLUME_MOUNTED                  (0x00000109)
+#define STATUS_RXACT_COMMITTED                 (0x0000010A)
+#define STATUS_NOTIFY_CLEANUP                  (0x0000010B)
+#define STATUS_NOTIFY_ENUM_DIR                 (0x0000010C)
+#define STATUS_NO_QUOTAS_NO_ACCOUNT            (0x0000010D)
+#define STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED (0x0000010E)
 
 #define STATUS_OBJECT_EXISTS                   (0x40000000)
 #define STATUS_THREAD_WAS_SUSPENDED            (0x40000001)
 #define STATUS_WORKING_SET_LIMIT_RANGE         (0x40000002)
-
-#define STATUS_UNSUCCESSFUL                    (0xC0000001)
-#define STATUS_NOT_IMPLEMENTED                 (0xC0000002)
-#define STATUS_INVALID_INFO_CLASS              (0xC0000003)
-#define STATUS_INFO_LENGTH_MISMATCH            (0xC0000004)
-#define STATUS_ACCESS_VIOLATION                (0xC0000005)
-#define STATUS_IN_PAGE_ERROR                   (0xC0000006)
-#define STATUS_PAGEFILE_QUOTA                  (0xC0000007)
-#define STATUS_INVALID_HANDLE                  (0xC0000008)
-#define STATUS_BAD_INITIAL_STACK               (0xC0000009)
-#define STATUS_BAD_INITIAL_PC                  (0xC000000A)
-#define STATUS_INVALID_CID                     (0xC000000B)
-#define STATUS_TIMER_NOT_CANCELED              (0xC000000C)
-#define STATUS_INVALID_PARAMETER               (0xC000000D)
-#define STATUS_NO_SUCH_DEVICE                  (0xC000000E)
-#define STATUS_NO_SUCH_FILE                    (0xC000000F)
-
-#define STATUS_GUARD_PAGE_VIOLATION            (0x80000001)
-#define STATUS_DATATYPE_MISALIGNMENT           (0x80000002)
-#define STATUS_BREAKPOINT                      (0x80000003)
-#define STATUS_SINGLE_STEP                     (0x80000004)
-#define STATUS_BUFFER_OVERFLOW                 (0x80000005)
-#define STATUS_NO_MORE_FILES                   (0x80000006)
-#define STATUS_WAKE_SYSTEM_DEBUGGER            (0x80000007)
-
 #define STATUS_IMAGE_NOT_AT_BASE               (0x40000003)
 #define STATUS_RXACT_STATE_CREATED             (0x40000004)
 #define STATUS_SEGMENT_NOTIFICATION            (0x40000005)
 #define STATUS_CARDBUS_NOT_SUPPORTED           (0x40000027)
 #define STATUS_WX86_CREATEWX86TIB              (0x40000028)
 
+#define STATUS_GUARD_PAGE_VIOLATION            (0x80000001)
+#define STATUS_DATATYPE_MISALIGNMENT           (0x80000002)
+#define STATUS_BREAKPOINT                      (0x80000003)
+#define STATUS_SINGLE_STEP                     (0x80000004)
+#define STATUS_BUFFER_OVERFLOW                 (0x80000005)
+#define STATUS_NO_MORE_FILES                   (0x80000006)
+#define STATUS_WAKE_SYSTEM_DEBUGGER            (0x80000007)
+
 #define STATUS_HANDLES_CLOSED                  (0x8000000A)
 #define STATUS_NO_INHERITANCE                  (0x8000000B)
 #define STATUS_GUID_SUBSTITUTION_MADE          (0x8000000C)
 #define STATUS_ALREADY_DISCONNECTED            (0x80000025)
 #define STATUS_LONGJUMP                        (0x80000026)
 
+#define STATUS_UNSUCCESSFUL                    (0xC0000001)
+#define STATUS_NOT_IMPLEMENTED                 (0xC0000002)
+#define STATUS_INVALID_INFO_CLASS              (0xC0000003)
+#define STATUS_INFO_LENGTH_MISMATCH            (0xC0000004)
+#define STATUS_ACCESS_VIOLATION                (0xC0000005)
+#define STATUS_IN_PAGE_ERROR                   (0xC0000006)
+#define STATUS_PAGEFILE_QUOTA                  (0xC0000007)
+#define STATUS_INVALID_HANDLE                  (0xC0000008)
+#define STATUS_BAD_INITIAL_STACK               (0xC0000009)
+#define STATUS_BAD_INITIAL_PC                  (0xC000000A)
+#define STATUS_INVALID_CID                     (0xC000000B)
+#define STATUS_TIMER_NOT_CANCELED              (0xC000000C)
+#define STATUS_INVALID_PARAMETER               (0xC000000D)
+#define STATUS_NO_SUCH_DEVICE                  (0xC000000E)
+#define STATUS_NO_SUCH_FILE                    (0xC000000F)
 #define STATUS_INVALID_DEVICE_REQUEST          (0xc0000010)
 #define STATUS_END_OF_FILE                     (0xc0000011)
 #define STATUS_WRONG_VOLUME                    (0xc0000012)
 #define STATUS_ILLEGAL_INSTRUCTION             (0xc000001D)
 #define STATUS_INVALID_LOCK_SEQUENCE           (0xc000001E)
 #define STATUS_INVALID_VIEW_SIZE               (0xc000001F)
-
 #define STATUS_INVALID_FILE_FOR_SECTION        (0xc0000020)
 #define STATUS_ALREADY_COMMITTED               (0xc0000021)
 #define STATUS_ACCESS_DENIED                   (0xc0000022)
index 5fe1312..76937af 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: ntdll.def,v 1.21 1999/11/14 13:04:01 ariadne Exp $
+; $Id: ntdll.def,v 1.22 1999/11/15 15:57:55 ekohl Exp $
 ;
 ; ReactOS Operating System
 ;
@@ -6,6 +6,9 @@ LIBRARY ntdll.dll
 
 EXPORTS
 InitializeObjectAttributes
+NlsAnsiCodePage
+NlsMbCodePageTag
+NlsMbOemCodePageTag
 NtAcceptConnectPort@24
 NtAccessCheck@32
 NtAccessCheckAndAuditAlarm@44
@@ -428,38 +431,42 @@ ZwW32Call@20
 ZwYieldExecution@0
 RtlAllocateHeap@12
 RtlAnsiCharToUnicodeChar@4
-RtlAnsiStringToUnicodeSize
-RtlAnsiStringToUnicodeString
-RtlAppendUnicodeStringToString
-RtlAppendUnicodeToString
-RtlCharToInteger
+RtlAnsiStringToUnicodeSize@4
+RtlAnsiStringToUnicodeString@12
+RtlAppendUnicodeStringToString@12
+RtlAppendUnicodeToString@12
+RtlCharToInteger@12
 RtlCreateHeap@24
 RtlCreateUserProcess@32
 RtlCreateUserThread@40
 RtlCompactHeap@8
-RtlCompareString
-RtlCompareUnicodeString
+RtlCompareString@12
+RtlCompareUnicodeString@12
 RtlConvertLongToLargeInteger
 RtlConvertUlongToLargeInteger
-RtlCopyString
-RtlCopyUnicodeString
+RtlCopyString@8
+RtlCopyUnicodeString@8
 RtlDestroyHeap@4
 RtlEnlargedIntegerMultiply
+RtlEnlargedUnsignedDivide
 RtlEnlargedUnsignedMultiply
-RtlEqualString
-RtlEqualUnicodeString
+RtlEqualString@12
+RtlEqualUnicodeString@12
 RtlExtendedIntegerMultiply
+RtlExtendedLargeIntegerDivide
+RtlExtendedMagicDivide
 RtlFillMemory@12
-RtlFreeAnsiString
+RtlFreeAnsiString@4
 RtlFreeHeap@12
-RtlFreeUnicodeString
+RtlFreeUnicodeString@4
 RtlGetProcessHeap@0
-RtlInitAnsiString
+RtlInitAnsiString@8
 RtlInitializeContext@20
-RtlInitString
-RtlInitUnicodeString
-RtlIntegerToUnicodeString
+RtlInitString@8
+RtlInitUnicodeString@8
+RtlIntegerToUnicodeString@12
 RtlLargeIntegerAdd
+RtlLargeIntegerArithmeticShift
 RtlLargeIntegerDivide
 RtlLargeIntegerNegate
 RtlLargeIntegerShiftLeft
@@ -468,20 +475,20 @@ RtlLargeIntegerSubtract
 RtlLengthSecurityDescriptor
 RtlLockHeap@4
 RtlMoveMemory@12
-RtlMultiByteToUnicodeN@0
+RtlMultiByteToUnicodeN@20
 RtlNtStatusToDosError
 RtlReAllocateHeap@16
 RtlSizeHeap@12
 RtlUnlockHeap@4
-RtlUnicodeStringToAnsiSize
-RtlUnicodeStringToAnsiString
-RtlUnicodeStringToInteger
-RtlUnicodeToMultiByteN@0
-RtlUnicodeToMultiByteSize@0
+RtlUnicodeStringToAnsiSize@4
+RtlUnicodeStringToAnsiString@12
+RtlUnicodeStringToInteger@12
+RtlUnicodeToMultiByteN@20
+RtlUnicodeToMultiByteSize@12
 RtlUnwind@0
-RtlUpcaseString
-RtlUpcaseUnicodeChar@0
-RtlUpcaseUnicodeString
+RtlUpcaseString@8
+RtlUpcaseUnicodeChar
+RtlUpcaseUnicodeString@12
 RtlUpcaseUnicodeToMultiByteN@0
 RtlValidateHeap@12
 RtlZeroMemory@8
index f352c4d..45eae27 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: ntdll.edf,v 1.10 1999/11/12 12:01:10 dwelch Exp $
+; $Id: ntdll.edf,v 1.11 1999/11/15 15:57:55 ekohl Exp $
 ;
 ; ReactOS Operating System
 ;
@@ -6,6 +6,9 @@ LIBRARY ntdll.dll
 
 EXPORTS
 InitializeObjectAttributes
+NlsAnsiCodePage
+NlsMbCodePageTag
+NlsMbOemCodePageTag
 NtAcceptConnectPort=NtAcceptConnectPort@24
 NtAccessCheck=NtAccessCheck@32
 NtAccessCheckAndAuditAlarm=NtAccessCheckAndAuditAlarm@44
@@ -428,38 +431,42 @@ ZwW32Call=ZwW32Call@20
 ZwYieldExecution=ZwYieldExecution@0
 RtlAllocateHeap=RtlAllocateHeap@12
 RtlAnsiCharToUnicodeChar=RtlAnsiCharToUnicodeChar@4
-RtlAnsiStringToUnicodeSize
-RtlAnsiStringToUnicodeString
-RtlAppendUnicodeStringToString
-RtlAppendUnicodeToString
-RtlCharToInteger
+RtlAnsiStringToUnicodeSize=RtlAnsiStringToUnicodeSize@4
+RtlAnsiStringToUnicodeString=RtlAnsiStringToUnicodeString@12
+RtlAppendUnicodeStringToString=RtlAppendUnicodeStringToString@8
+RtlAppendUnicodeToString=RtlAppendUnicodeToString@8
+RtlCharToInteger=RtlCharToInteger@12
 RtlCreateHeap=RtlCreateHeap@24
 RtlCreateUserProcess=RtlCreateUserProcess@32
 RtlCreateUserThread=RtlCreateUserThread@40
 RtlCompactHeap=RtlCompactHeap@8
-RtlCompareString
-RtlCompareUnicodeString
+RtlCompareString=RtlCompareString@12
+RtlCompareUnicodeString=RtlCompareUnicodeString@12
 RtlConvertLongToLargeInteger
 RtlConvertUlongToLargeInteger
-RtlCopyString
-RtlCopyUnicodeString
+RtlCopyString=RtlCopyString@8
+RtlCopyUnicodeString=RtlCopyUnicodeString@8
 RtlDestroyHeap=RtlDestroyHeap@4
 RtlEnlargedIntegerMultiply
+RtlEnlargedUnsignedDivide
 RtlEnlargedUnsignedMultiply
-RtlEqualString
-RtlEqualUnicodeString
+RtlEqualString=RtlEqualString@12
+RtlEqualUnicodeString=RtlEqualUnicodeString@12
 RtlExtendedIntegerMultiply
+RtlExtendedLargeIntegerDivide
+RtlExtendedMagicDivide
 RtlFillMemory=RtlFillMemory@12
-RtlFreeAnsiString
+RtlFreeAnsiString=RtlFreeAnsiString@4
 RtlFreeHeap=RtlFreeHeap@12
-RtlFreeUnicodeString
+RtlFreeUnicodeString=RtlFreeUnicodeString@4
 RtlGetProcessHeap=RtlGetProcessHeap@0
-RtlInitAnsiString
+RtlInitAnsiString=RtlInitAnsiString@8
 RtlInitializeContext=RtlInitializeContext@20
-RtlInitString
-RtlInitUnicodeString
-RtlIntegerToUnicodeString
+RtlInitString=RtlInitString@8
+RtlInitUnicodeString=RtlInitUnicodeString@8
+RtlIntegerToUnicodeString=RtlIntegerToUnicodeString@12
 RtlLargeIntegerAdd
+RtlLargeIntegerArithmeticShift
 RtlLargeIntegerDivide
 RtlLargeIntegerNegate
 RtlLargeIntegerShiftLeft
@@ -468,20 +475,20 @@ RtlLargeIntegerSubtract
 RtlLengthSecurityDescriptor
 RtlLockHeap=RtlLockHeap@4
 RtlMoveMemory=RtlMoveMemory@12
-RtlMultiByteToUnicodeN=RtlMultiByteToUnicodeN@0
+RtlMultiByteToUnicodeN=RtlMultiByteToUnicodeN@20
 RtlNtStatusToDosError
 RtlReAllocateHeap=RtlReAllocateHeap@16
 RtlSizeHeap=RtlSizeHeap@12
 RtlUnlockHeap=RtlUnlockHeap@4
-RtlUnicodeStringToAnsiSize
-RtlUnicodeStringToAnsiString
-RtlUnicodeStringToInteger
-RtlUnicodeToMultiByteN=RtlUnicodeToMultiByteN@0
-RtlUnicodeToMultiByteSize=RtlUnicodeToMultiByteSize@0
+RtlUnicodeStringToAnsiSize=RtlUnicodeStringToAnsiSize@4
+RtlUnicodeStringToAnsiString=RtlUnicodeStringToAnsiString@12
+RtlUnicodeStringToInteger=RtlUnicodeStringToInteger@12
+RtlUnicodeToMultiByteN=RtlUnicodeToMultiByteN@20
+RtlUnicodeToMultiByteSize=RtlUnicodeToMultiByteSize@12
 RtlUnwind=RtlUnwind@0
-RtlUpcaseString
+RtlUpcaseString=RtlUpcaseString@8
 RtlUpcaseUnicodeChar=RtlUpcaseUnicodeChar@0
-RtlUpcaseUnicodeString
+RtlUpcaseUnicodeString=RtlUpcaseUnicodeString@12
 RtlUpcaseUnicodeToMultiByteN=RtlUpcaseUnicodeToMultiByteN@0
 RtlValidateHeap=RtlValidateHeap@12
 RtlZeroMemory=RtlZeroMemory@8
index 478e1fe..8a354e5 100644 (file)
@@ -1,10 +1,10 @@
-# $Id: makefile,v 1.25 1999/10/26 19:47:05 ea Exp $
+# $Id: makefile,v 1.26 1999/11/15 15:57:27 ekohl Exp $
 #
 # ReactOS Operating System
 #
 TARGET=ntdll
 
-BASE_CFLAGS = -I../../include
+BASE_CFLAGS = -I../../include -D__NTDLL__
 
 IMAGE_BASE = 0x77f60000
 
@@ -25,7 +25,7 @@ all: $(DLLTARGET)
 
 RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \
               rtl/mem.o rtl/namespc.o rtl/security.o rtl/unicode.o \
-              rtl/thread.o rtl/process.o
+              rtl/thread.o rtl/process.o rtl/nls.o
 
 STDLIB_OBJECTS = stdlib/atoi.o stdlib/atol.o stdlib/splitp.o \
                  stdlib/strtol.o stdlib/strtoul.o
diff --git a/reactos/lib/ntdll/rtl/nls.c b/reactos/lib/ntdll/rtl/nls.c
new file mode 100644 (file)
index 0000000..d72d02d
--- /dev/null
@@ -0,0 +1,198 @@
+/* $Id: nls.c,v 1.1 1999/11/15 15:59:29 ekohl Exp $
+ *
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS kernel
+ * FILE:            ntoskrnl/rtl/nls.c
+ * PURPOSE:         National Language Support (NLS) functions
+ * UPDATE HISTORY:
+ *                  20/08/99 Created by Emanuele Aliberti
+ *                  10/11/99 Added translation functions.
+ *
+ * NOTE:
+ *   Multi-byte code pages are not supported yet. Even single-byte code
+ *   pages are not supported properly. Only stupid CHAR->WCHAR and
+ *   WCHAR->CHAR (Attention: data loss!!!) translation is done.
+ *
+ * TODO:
+ *   1) Implement code to initialize the translation tables.
+ *   2) Use fixed translation table for translation.
+ *   3) Add loading of translation tables (NLS files).
+ *   4) Add multi-byte translation code.
+ */
+
+#include <ddk/ntddk.h>
+//#include <internal/nls.h>
+
+
+BOOLEAN
+NlsMbCodePageTag = FALSE;
+
+BOOLEAN
+NlsMbOemCodePageTag = FALSE;
+
+BYTE
+NlsLeadByteInfo = 0; /* ? */
+
+USHORT
+NlsOemLeadByteInfo = 0;
+
+USHORT
+NlsAnsiCodePage = 0;
+
+USHORT
+NlsOemCodePage = 0; /* not exported */
+
+
+#if 0
+WCHAR AnsiToUnicodeTable[256];
+WCHAR OemToUnicodeTable[256];
+
+CHAR UnicodeToAnsiTable [65536];
+CHAR UnicodeToOemTable [65536];
+#endif
+
+
+/* FUNCTIONS *****************************************************************/
+
+VOID
+STDCALL
+RtlGetDefaultCodePage (PUSHORT AnsiCodePage,
+                       PUSHORT OemCodePage)
+{
+        *AnsiCodePage = NlsAnsiCodePage;
+        *OemCodePage = NlsOemCodePage;
+}
+
+
+NTSTATUS
+STDCALL
+RtlMultiByteToUnicodeN(PWCHAR UnicodeString,
+                       ULONG  UnicodeSize,
+                       PULONG ResultSize,
+                       PCHAR  MbString,
+                       ULONG  MbSize)
+{
+        ULONG Size = 0;
+        ULONG i;
+
+        if (NlsMbCodePageTag == FALSE)
+        {
+                /* single-byte code page */
+                if (MbSize > (UnicodeSize / sizeof(WCHAR)))
+                        Size = UnicodeSize / sizeof(WCHAR);
+                else
+                        Size = MbSize;
+
+                if (ResultSize != NULL)
+                        *ResultSize = Size * sizeof(WCHAR);
+
+                for (i = 0; i < Size; i++)
+                {
+                        *UnicodeString = *MbString;
+#if 0
+                        *UnicodeString = AnsiToUnicodeTable[*MbString];
+#endif
+
+                        UnicodeString++;
+                        MbString++;
+                };
+        }
+        else
+        {
+                /* multi-byte code page */
+                /* FIXME */
+
+        }
+
+        return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+STDCALL
+RtlMultiByteToUnicodeSize(PULONG UnicodeSize,
+                          PCHAR MbString,
+                          ULONG MbSize)
+{
+        if (NlsMbCodePageTag == FALSE)
+        {
+                /* single-byte code page */
+                *UnicodeSize = MbSize * sizeof (WCHAR);
+        }
+        else
+        {
+                /* multi-byte code page */
+                /* FIXME */
+
+        }
+
+        return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+STDCALL
+RtlUnicodeToMultiByteN(PCHAR  MbString,
+                       ULONG  MbSize,
+                       PULONG ResultSize,
+                       PWCHAR UnicodeString,
+                       ULONG  UnicodeSize)
+{
+        ULONG Size = 0;
+        ULONG i;
+
+        if (NlsMbCodePageTag == FALSE)
+        {
+                /* single-byte code page */
+                if (UnicodeSize > (MbSize * sizeof(WCHAR)))
+                        Size = MbSize;
+                else
+                        Size = UnicodeSize / sizeof(WCHAR);
+
+                if (ResultSize != NULL)
+                        *ResultSize = Size;
+
+                for (i = 0; i < Size; i++)
+                {
+                        *MbString = *UnicodeString;
+#if 0
+                        *MbString = UnicodeToAnsiTable[*UnicodeString];
+#endif
+
+                        MbString++;
+                        UnicodeString++;
+                };
+        }
+        else
+        {
+                /* multi-byte code page */
+                /* FIXME */
+
+        }
+
+        return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+STDCALL
+RtlUnicodeToMultiByteSize(PULONG MbSize,
+                          PWCHAR UnicodeString,
+                          ULONG UnicodeSize)
+{
+        if (NlsMbCodePageTag == FALSE)
+        {
+                /* single-byte code page */
+                *MbSize = UnicodeSize / sizeof (WCHAR);
+        }
+        else
+        {
+                /* multi-byte code page */
+                /* FIXME */
+
+        }
+
+        return STATUS_SUCCESS;
+}
+
+/* EOF */
index cdd9847..368f531 100644 (file)
@@ -1,8 +1,8 @@
-/* $Id: unicode.c,v 1.7 1999/09/12 21:58:32 ea Exp $
+/* $Id: unicode.c,v 1.8 1999/11/15 15:58:24 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/rtl/unicode.c
+ * FILE:            lib/ntdll/rtl/unicode.c
  * PURPOSE:         String functions
  * PROGRAMMER:      Jason Filby (jasonfilby@yahoo.com)
  * UPDATE HISTORY:
  */
 
 #include <ddk/ntddk.h>
-#include <stdio.h>
-#include <string.h>
 #include <ctype.h>
 
+//#include <internal/nls.h>
+
+
 #define NDEBUG
 #include <internal/debug.h>
 
-#define Aa_Difference ('A'-'a')
 
-extern unsigned long simple_strtoul(const char *cp,
-                                   char **endp,
+extern unsigned long simple_strtoul(const char *cp, char **endp,
                                    unsigned int base);
 
-WCHAR wtoupper(WCHAR c)
-{
-        if((c>='a') && (c<='z')) return c+Aa_Difference;
-        return c;
-}
 
-WCHAR wtolower(WCHAR c)
+/* FUNCTIONS *****************************************************************/
+
+WCHAR
+STDCALL
+RtlAnsiCharToUnicodeChar(PCHAR AnsiChar)
 {
-//   DPRINT("c %c (c-Aa_Difference) %c\n",(char)c,(char)(c-Aa_Difference));
-        if((c>='A') && (c<='Z')) return c-Aa_Difference;
-        return c;
+        ULONG Size;
+        WCHAR UnicodeChar;
+
+        Size = 1;
+#if 0
+        Size = (NlsLeadByteInfo[*AnsiChar] == 0) ? 1 : 2;
+#endif
+
+        RtlMultiByteToUnicodeN (&UnicodeChar,
+                                sizeof(WCHAR),
+                                NULL,
+                                AnsiChar,
+                                Size);
+
+        return UnicodeChar;
 }
 
-ULONG RtlAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString)
+
+ULONG
+STDCALL
+RtlAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString)
 {
-        return AnsiString->Length*2;
+        ULONG Size;
+
+        RtlMultiByteToUnicodeSize (&Size,
+                                   AnsiString->Buffer,
+                                   AnsiString->Length);
+
+        return Size;
 }
 
-NTSTATUS RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
-                                     IN PANSI_STRING SourceString, 
-                                     IN BOOLEAN AllocateDestinationString)
+
+NTSTATUS
+STDCALL
+RtlAnsiStringToUnicodeString(
+        IN OUT PUNICODE_STRING DestinationString,
+        IN PANSI_STRING SourceString,
+        IN BOOLEAN AllocateDestinationString)
 {
-   unsigned long i;
-
-   if (AllocateDestinationString == TRUE)
-     {
-       DestinationString->Buffer=RtlAllocateHeap(RtlGetProcessHeap(), 
-                                                 0, 
-                                                 (SourceString->Length+1)*2);
-       DestinationString->MaximumLength=SourceString->Length;
-     }
-
-   DestinationString->Length=SourceString->Length;
-   memset(DestinationString->Buffer, 0, SourceString->Length*2);
-   
-   for (i=0; i<SourceString->Length; i++)
-     {
-       *DestinationString->Buffer=*SourceString->Buffer;
-       
-       SourceString->Buffer++;
-       DestinationString->Buffer++;
-     }
-   *DestinationString->Buffer=0;
-   
-   SourceString->Buffer-=SourceString->Length;
-   DestinationString->Buffer-=SourceString->Length;
-   
-   return STATUS_SUCCESS;
+        NTSTATUS Status;
+        ULONG Length;
+
+        if (NlsMbCodePageTag == TRUE)
+                Length = RtlAnsiStringToUnicodeSize (SourceString);
+        else
+                Length = SourceString->Length * sizeof(WCHAR);
+
+        if (Length > 65535)
+                return STATUS_INVALID_PARAMETER_2;
+
+        DestinationString->Length = Length;
+
+        if (AllocateDestinationString == TRUE)
+        {
+                DestinationString->MaximumLength = Length + sizeof(WCHAR);
+                DestinationString->Buffer =
+                        RtlAllocateHeap (RtlGetProcessHeap (),
+                                         0,
+                                         DestinationString->MaximumLength);
+                if (DestinationString->Buffer == NULL)
+                        return STATUS_NO_MEMORY;
+        }
+        else
+        {
+                if (Length > DestinationString->Length)
+                        return STATUS_BUFFER_OVERFLOW;
+        }
+
+        RtlZeroMemory (DestinationString->Buffer,
+                       DestinationString->Length);
+
+        Status = RtlMultiByteToUnicodeN (DestinationString->Buffer,
+                                         DestinationString->Length,
+                                         NULL,
+                                         SourceString->Buffer,
+                                         SourceString->Length);
+        if (!NT_SUCCESS(Status))
+        {
+                if (AllocateDestinationString)
+                        RtlFreeHeap (RtlGetProcessHeap (),
+                                     0,
+                                     DestinationString->Buffer);
+                return Status;
+        }
+
+        DestinationString->Buffer[Length / sizeof(WCHAR)] = 0;
+
+        return STATUS_SUCCESS;
 }
 
-NTSTATUS RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination,
+
+NTSTATUS
+STDCALL
+RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination,
         IN PUNICODE_STRING Source)
 {
-        unsigned long i;
+        PWCHAR Src;
+        PWCHAR Dest;
+        ULONG  i;
 
-        if(Destination->MaximumLength-Destination->Length-Source->Length<0)
+        if ((Source->Length + Destination->Length) >= Destination->MaximumLength)
                 return STATUS_BUFFER_TOO_SMALL;
 
-        Destination->Buffer+=Destination->Length;
-        for(i=0; i<Source->Length; i++) {
-                *Destination->Buffer=*Source->Buffer;
-                Destination->Buffer++;
-                Source->Buffer++;
-        };
-        *Destination->Buffer=0;
-        Destination->Buffer-=(Destination->Length+Source->Length);
-        Source->Buffer-=Source->Length;
+        Src  = Source->Buffer;
+        Dest = Destination->Buffer + (Destination->Length / sizeof (WCHAR));
+        for (i = 0; i < (Source->Length / sizeof(WCHAR)); i++)
+        {
+                *Dest = *Src;
+                Dest++;
+                Src++;
+        }
+        *Dest = 0;
+
+        Destination->Length += Source->Length;
 
-        Destination->Length+=Source->Length;
         return STATUS_SUCCESS;
-};
+}
 
-NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
+NTSTATUS
+STDCALL
+RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
         IN PWSTR Source)
 {
-        unsigned long i, slen=wcslen(Source);
+        PWCHAR Src;
+        PWCHAR Dest;
+        ULONG  i;
+        ULONG  slen;
 
-        if(Destination->MaximumLength-Destination->Length-slen<0)
+        slen = wcslen (Source);
+
+        if (Destination->Length + slen >= Destination->MaximumLength)
                 return STATUS_BUFFER_TOO_SMALL;
 
-        Destination->Buffer+=Destination->Length;
-        for(i=0; i<slen; i++) {
-                *Destination->Buffer=*Source;
-                Destination->Buffer++;
-                Source++;
+        Src = Source;
+        Dest = Destination->Buffer + (Destination->Length / sizeof (WCHAR));
+
+        for (i = 0; i < slen; i++)
+        {
+                *Dest = *Src;
+                Dest++;
+                Src++;
         };
-        *Destination->Buffer=0;
-        Destination->Buffer-=(Destination->Length+slen);
-        Source-=slen;
+        *Dest = 0;
+
+        Destination->Length += (slen * sizeof(WCHAR));
 
-        Destination->Length+=slen;
         return STATUS_SUCCESS;
-};
+}
 
-NTSTATUS RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value)
+NTSTATUS
+STDCALL
+RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value)
 {
-   *Value = simple_strtoul((const char *)String, NULL, Base);
+   *Value=simple_strtoul((const char *)String, NULL, Base);
    return(STATUS_SUCCESS);
 }
 
-LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
+LONG
+STDCALL
+RtlCompareString(PSTRING String1,
+                 PSTRING String2,
+                 BOOLEAN CaseInsensitive)
 {
         unsigned long i;
         char c1, c2;
 
-        if(String1->Length!=String2->Length) return String1->Length-String2->Length;
+        if (String1->Length!=String2->Length)
+                return String1->Length-String2->Length;
 
-        for(i=0; i<String1->Length; i++) {
-                if(CaseInsensitive==TRUE) {
+        for (i=0; i<String1->Length; i++)
+        {
+                if(CaseInsensitive==TRUE)
+                {
                         c1=toupper(*String1->Buffer);
                         c2=toupper(*String2->Buffer);
-                } else {
+                }
+                else
+                {
                         c1=*String1->Buffer;
                         c2=*String2->Buffer;
-                };
-                if(c1!=c2) {
+                }
+
+                if(c1!=c2)
+                {
                         String1->Buffer-=i;
                         String2->Buffer-=i;
                         return c1-c2;
-                };
+                }
                 String1->Buffer++;
                 String2->Buffer++;
-        };
+        }
         String1->Buffer-=i;
         String2->Buffer-=i;
 
         return 0;
-};
+}
 
-LONG RtlCompareUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2,
-                             BOOLEAN CaseInsensitive)
+LONG
+STDCALL
+RtlCompareUnicodeString(PUNICODE_STRING String1,
+        PUNICODE_STRING String2,
+        BOOLEAN CaseInsensitive)
 {
         unsigned long i;
         WCHAR wc1, wc2;
-
-        if(String1->Length!=String2->Length) return
-                String1->Length-String2->Length;
-
-        for(i=0; i<String1->Length; i++) {
-                if(CaseInsensitive==TRUE) {
-                        wc1=wtoupper(*String1->Buffer);
-                        wc2=wtoupper(*String2->Buffer);
-                } else {
-                        wc1=*String1->Buffer;
-                        wc2=*String2->Buffer;
-                };
-
-                if(wc1!=wc2) {
-                        String1->Buffer-=i;
-                        String2->Buffer-=i;
-                        return wc1-wc2;
-                };
-
-                String1->Buffer++;
-                String2->Buffer++;
-        };
-
-        String1->Buffer-=i;
-        String2->Buffer-=i;
+        PWCHAR pw1, pw2;
+
+        if (String1->Length != String2->Length)
+                return String1->Length-String2->Length;
+
+        pw1 = String1->Buffer;
+        pw2 = String2->Buffer;
+
+        for(i = 0; i < (String1->Length / sizeof(WCHAR)); i++)
+        {
+                if(CaseInsensitive == TRUE)
+                {
+                        wc1 = towupper (*pw1);
+                        wc2 = towupper (*pw2);
+                }
+                else
+                {
+                        wc1 = *pw1;
+                        wc2 = *pw2;
+                }
+
+                if (wc1 != wc2)
+                {
+                        return wc1 - wc2;
+                }
+
+                pw1++;
+                pw2++;
+        }
 
         return 0;
-};
+}
 
-VOID RtlCopyString(IN OUT PSTRING DestinationString, IN PSTRING SourceString)
+VOID
+STDCALL
+RtlCopyString(IN OUT PSTRING DestinationString, IN PSTRING SourceString)
 {
         unsigned long copylen, i;
 
-        if(SourceString==NULL) {
+        if(SourceString==NULL)
+        {
                  DestinationString->Length=0;
-        } else {
-                 if(SourceString->Length<DestinationString->MaximumLength) {
+        }
+        else
+        {
+                 if(SourceString->Length<DestinationString->MaximumLength)
+                 {
                          copylen=SourceString->Length;
-                 } else {
+                 }
+                 else
+                 {
                          copylen=DestinationString->MaximumLength;
-                 };
+                 }
+
                  for(i=0; i<copylen; i++)
                  {
                          *DestinationString->Buffer=*SourceString->Buffer;
                          DestinationString->Buffer++;
                          SourceString->Buffer++;
-                 };
+                 }
+
                  *DestinationString->Buffer=0;
                  DestinationString->Buffer-=copylen;
                  SourceString->Buffer-=copylen;
-        };
-};
+        }
+}
 
-VOID RtlCopyUnicodeString(IN OUT PUNICODE_STRING DestinationString,
-                          IN PUNICODE_STRING SourceString)
+VOID
+STDCALL
+RtlCopyUnicodeString(IN OUT PUNICODE_STRING DestinationString,
+                     IN PUNICODE_STRING SourceString)
 {
         unsigned long copylen, i;
+        PWCHAR Src, Dest;
+   
+        if(SourceString==NULL) 
+        {
+                DestinationString->Length=0;
+        } 
+        else 
+        {
+                copylen = min(DestinationString->MaximumLength - sizeof(WCHAR),
+                              SourceString->Length);
+                Src = SourceString->Buffer;
+                Dest = DestinationString->Buffer;
+
+                for (i = 0; i < (copylen / sizeof (WCHAR)); i++)
+                {
+                        *Dest = *Src;
+                        Dest++;
+                        Src++;
+                }
+                *Dest = 0;
+
+                DestinationString->Length = copylen;
+        }
+}
 
-        if(SourceString==NULL) {
-                 DestinationString->Length=0;
-        } else {
-                 if(SourceString->Length<DestinationString->MaximumLength) {
-                         copylen=SourceString->Length;
-                 } else {
-                         copylen=DestinationString->MaximumLength;
-                 };
-                 for(i=0; i<copylen; i++)
-                 {
-                         *DestinationString->Buffer=*SourceString->Buffer;
-                         DestinationString->Buffer++;
-                         SourceString->Buffer++;
-                 };
-                 *DestinationString->Buffer=0;
-                 DestinationString->Buffer-=copylen;
-                 SourceString->Buffer-=copylen;
-        };
-};
-
-BOOLEAN RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
+BOOLEAN
+STDCALL
+RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
 {
         unsigned long s1l=String1->Length;
         unsigned long s2l=String2->Length;
@@ -267,123 +366,151 @@ BOOLEAN RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive
         String2->Buffer-=i;
 
         return TRUE;
-};
+}
 
-BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2,
-                              BOOLEAN CaseInsensitive)
+BOOLEAN
+STDCALL
+RtlEqualUnicodeString(PUNICODE_STRING String1,
+                      PUNICODE_STRING String2,
+                      BOOLEAN CaseInsensitive)
 {
-        unsigned long s1l=String1->Length;
-        unsigned long s2l=String2->Length;
+        unsigned long s1l = String1->Length / sizeof(WCHAR);
+        unsigned long s2l = String2->Length / sizeof(WCHAR);
         unsigned long i;
-        char wc1, wc2;
-
-        if(s1l!=s2l) return FALSE;
-
-        for(i=0; i<s1l; i++) {
-                if(CaseInsensitive==TRUE) {
-                        wc1=wtoupper(*String1->Buffer);
-                        wc2=wtoupper(*String2->Buffer);
-                } else {
-                        wc1=*String1->Buffer;
-                        wc2=*String2->Buffer;
-                };
-
-                if(wc1!=wc2) {
-                        String1->Buffer-=i;
-                        String2->Buffer-=i;
+        WCHAR wc1, wc2;
+        PWCHAR pw1, pw2;
+
+        if (s1l != s2l)
+                return FALSE;
+
+        pw1 = String1->Buffer;
+        pw2 = String2->Buffer;
+
+        for (i = 0; i < s1l; i++)
+        {
+                if(CaseInsensitive == TRUE)
+                {
+                        wc1 = towupper (*pw1);
+                        wc2 = towupper (*pw2);
+                }
+                else
+                {
+                        wc1 = *pw1;
+                        wc2 = *pw2;
+                }
+
+                if (wc1 != wc2)
                         return FALSE;
-                };
 
-                String1->Buffer++;
-                String2->Buffer++;
-        };
-
-        String1->Buffer-=i;
-        String2->Buffer-=i;
+                pw1++;
+                pw2++;
+        }
 
         return TRUE;
-};
-
+}
 
 VOID
+STDCALL
 RtlFreeAnsiString(IN PANSI_STRING AnsiString)
 {
-       if (NULL == AnsiString) return;
-//        ExFreePool(AnsiString->Buffer);
-};
+        RtlFreeHeap (RtlGetProcessHeap (),
+                     0,
+                     AnsiString->Buffer);
+}
 
+VOID
+STDCALL
+RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
+{
+        RtlFreeHeap (RtlGetProcessHeap (),
+                     0,
+                     UnicodeString->Buffer);
+}
 
 VOID
-RtlFreeUnicodeString (
-       IN      PUNICODE_STRING UnicodeString
-       )
+STDCALL
+RtlInitAnsiString(IN OUT PANSI_STRING DestinationString,
+                  IN PCSZ SourceString)
 {
-       if (NULL == UnicodeString) return;
-//        ExFreePool(UnicodeString->Buffer);
+        unsigned long DestSize;
+
+        if(SourceString==NULL) {
+                DestinationString->Length=0;
+                DestinationString->MaximumLength=0;
+        } else {
+                DestSize=strlen((const char *)SourceString);
+                DestinationString->Length=DestSize;
+                DestinationString->MaximumLength=DestSize+1;
+        };
+        DestinationString->Buffer=(PCHAR)SourceString;
 };
 
-VOID RtlInitAnsiString(IN OUT PANSI_STRING DestinationString,
-                       IN PCSZ SourceString)
+VOID
+STDCALL
+RtlInitString(IN OUT PSTRING DestinationString,
+              IN PCSZ SourceString)
 {
-   unsigned long DestSize;
-   
-   if(SourceString==NULL) 
-     {
-       DestinationString->Length=0;
-       DestinationString->MaximumLength=0;
-     } 
-   else 
-     {
-       DestSize=strlen((const char *)SourceString);
-       DestinationString->Length=DestSize;
-       DestinationString->MaximumLength=DestSize+1;
-     }
-   DestinationString->Buffer=(PCHAR)SourceString;
+        ULONG DestSize;
+
+        if (SourceString == NULL)
+        {
+                DestinationString->Length = 0;
+                DestinationString->MaximumLength = 0;
+                DestinationString->Buffer = NULL;
+        }
+        else
+        {
+                DestSize = strlen((const char *)SourceString);
+                DestinationString->Length = DestSize;
+                DestinationString->MaximumLength = DestSize + sizeof(CHAR);
+                DestinationString->Buffer = (PCHAR)SourceString;
+        }
 }
 
-VOID RtlInitString(IN OUT PSTRING DestinationString,
-                   IN PCSZ SourceString)
+VOID
+STDCALL
+RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
+                     IN PCWSTR SourceString)
 {
-        DestinationString->Length=strlen((char *)SourceString);
-        DestinationString->MaximumLength=strlen((char *)SourceString)+1;
-        DestinationString->Buffer=SourceString;
+        ULONG DestSize;
+
+        if (SourceString==NULL)
+        {
+                DestinationString->Length=0;
+                DestinationString->MaximumLength=0;
+                DestinationString->Buffer = NULL;
+        }
+        else
+        {
+                DestSize = wcslen((PWSTR)SourceString) * sizeof(WCHAR);
+                DestinationString->Length = DestSize;
+                DestinationString->MaximumLength = DestSize + sizeof(WCHAR);
+                DestinationString->Buffer = (PWSTR)SourceString;
+        }
 }
 
-VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
-                          IN PCWSTR SourceString)
+NTSTATUS
+STDCALL
+RtlIntegerToUnicodeString(IN ULONG Value,
+                          IN ULONG Base,                    /* optional */
+                          IN OUT PUNICODE_STRING String)
 {
-   unsigned long DestSize;
-   
-   if (SourceString == NULL)
-     {
-       DestinationString->Length = 0;
-       DestinationString->MaximumLength = 0;
-       DestinationString->Buffer = NULL;
-     } 
-   else 
-     {
-       DestSize = wcslen((PWSTR)SourceString);
-       DestinationString->Length = DestSize;
-       DestinationString->MaximumLength = DestSize+1;
-       DestinationString->Buffer = (PWSTR)SourceString;
-     }
-}
+//        UNIMPLEMENTED;
 
-NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,                    /* optional */
-                                   IN OUT PUNICODE_STRING String)
-{
+        return STATUS_NOT_IMPLEMENTED;
+#if 0
         char *str;
         unsigned long len, i;
 
-        str = RtlAllocateHeap(RtlGetProcessHeap, 0, 1024);
+        str=ExAllocatePool(NonPagedPool, 1024);
         if(Base==16) {
-                sprintf(str, "%x", (unsigned int)Value);
+                sprintf(str, "%x", Value);
         } else
         if(Base==8) {
-                sprintf(str, "%o", (unsigned int)Value);
+                sprintf(str, "%o", Value);
         } else
         if(Base==2) {
-//                sprintf(str, "%b", Value);
+                sprintf(str, "%b", Value);
         } else {
                 sprintf(str, "%u", (unsigned int)Value);
         };
@@ -400,135 +527,206 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
         String->Buffer-=len;
         String->Length=len;
         str-=len;
-//        ExFreePool(str);
+        ExFreePool(str);
 
         return STATUS_SUCCESS;
+#endif
 }
 
 
-ULONG RtlUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString)
+ULONG
+STDCALL
+RtlOemStringToUnicodeSize(IN PANSI_STRING OemString)
 {
-        return UnicodeString->Length/2;
-}
+        ULONG Size;
 
+        RtlMultiByteToUnicodeSize (&Size,
+                                   OemString->Buffer,
+                                   OemString->Length);
 
-NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
-                                      IN PUNICODE_STRING SourceString,
-                                      IN BOOLEAN AllocateDestinationString)
-{
-        unsigned long i;
-
-        if(AllocateDestinationString==TRUE) {
+        return Size;
+}
 
-                // Causes excetion 14(0) in _Validate_Free_List
-//                DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length+1);
-                DestinationString->MaximumLength=SourceString->Length+1;
-        };
+ULONG
+STDCALL
+RtlUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString)
+{
+        ULONG Size;
 
-        DestinationString->Length=SourceString->Length;
+        RtlUnicodeToMultiByteSize (&Size,
+                                   UnicodeString->Buffer,
+                                   UnicodeString->Length);
 
-        for(i=0; i<SourceString->Length; i++) {
-                *DestinationString->Buffer=*SourceString->Buffer;
-                DestinationString->Buffer++;
-                SourceString->Buffer++;
-        };
-        *DestinationString->Buffer=0;
+        return Size;
+}
 
-        DestinationString->Buffer-=SourceString->Length;
-        SourceString->Buffer-=SourceString->Length;
+NTSTATUS
+STDCALL
+RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
+                             IN PUNICODE_STRING SourceString,
+                             IN BOOLEAN AllocateDestinationString)
+{
+        NTSTATUS Status;
+        ULONG Length;
+
+        if (NlsMbCodePageTag == TRUE)
+                Length = RtlUnicodeStringToAnsiSize (SourceString);
+        else
+                Length = SourceString->Length / sizeof(WCHAR);
+
+        /* this doesn't make sense */
+//        if (Length > 65535)
+//                return STATUS_INVALID_PARAMETER_2;
+
+        DestinationString->Length = Length;
+
+        if (AllocateDestinationString == TRUE)
+        {
+                DestinationString->MaximumLength = Length + sizeof(CHAR);
+                DestinationString->Buffer =
+                        RtlAllocateHeap (RtlGetProcessHeap (),
+                                         0,
+                                         DestinationString->MaximumLength);
+                if (DestinationString->Buffer == NULL)
+                        return STATUS_NO_MEMORY;
+        }
+        else
+        {
+                if (Length >= DestinationString->Length)
+                        return STATUS_BUFFER_OVERFLOW;
+        }
+
+        RtlZeroMemory (DestinationString->Buffer,
+                       DestinationString->Length);
+
+        Status = RtlUnicodeToMultiByteN (DestinationString->Buffer,
+                                         DestinationString->Length,
+                                         NULL,
+                                         SourceString->Buffer,
+                                         SourceString->Length);
+        if (!NT_SUCCESS(Status))
+        {
+                if (AllocateDestinationString)
+                        RtlFreeHeap (RtlGetProcessHeap (),
+                                     0,
+                                     DestinationString->Buffer);
+                return Status;
+        }
+
+        DestinationString->Buffer[Length] = 0;
 
         return STATUS_SUCCESS;
 }
 
-
-NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
-                                   OUT PULONG Value)
+NTSTATUS
+STDCALL
+RtlUnicodeStringToInteger(IN PUNICODE_STRING String,
+                          IN ULONG Base,
+                          OUT PULONG Value)
 {
-   char *str;
-   unsigned long i, lenmin=0;
-   BOOLEAN addneg=FALSE;
-   
-   str=RtlAllocateHeap(RtlGetProcessHeap(), 0, String->Length+1);
-   
-   for(i=0; i<String->Length; i++) 
-     {
-       *str=*String->Buffer;
-       
-       if(*str=='b') { Base=2;  lenmin++; } else
-         if(*str=='o') { Base=8;  lenmin++; } else
-         if(*str=='d') { Base=10; lenmin++; } else
-         if(*str=='x') { Base=16; lenmin++; } else
-         if(*str=='+') { lenmin++; } else
-         if(*str=='-') { addneg=TRUE; lenmin++; } else
-         if((*str>'1') && (Base==2)) {
-            String->Buffer-=i;
-            *Value=0;
-            return STATUS_INVALID_PARAMETER;
-         } else
-         if(((*str>'7') || (*str<'0')) && (Base==8)) {
-            String->Buffer-=i;
-            *Value=0;
-            return STATUS_INVALID_PARAMETER;
-         } else
-         if(((*str>'9') || (*str<'0')) && (Base==10)) {
-            String->Buffer-=i;
-            *Value=0;
-            return STATUS_INVALID_PARAMETER;
-         } else
-         if((((*str>'9') || (*str<'0')) ||
-             ((toupper(*str)>'F') || (toupper(*str)<'A'))) && (Base==16))
-         {
-            String->Buffer-=i;
-            *Value=0;
-            return STATUS_INVALID_PARAMETER;
-         } else
-         str++;
-       
-       String->Buffer++;
+        return STATUS_NOT_IMPLEMENTED;
+#if 0
+        char *str;
+        unsigned long i, lenmin=0;
+        BOOLEAN addneg=FALSE;
+
+        str = RtlAllocateHeap (RtlGetProcessHeap (),
+                               0,
+                               String->Length+1);
+
+        for(i=0; i<String->Length; i++)
+        {
+                *str=*String->Buffer;
+
+                if(*str=='b') { Base=2;  lenmin++; } else
+                if(*str=='o') { Base=8;  lenmin++; } else
+                if(*str=='d') { Base=10; lenmin++; } else
+                if(*str=='x') { Base=16; lenmin++; } else
+                if(*str=='+') { lenmin++; } else
+                if(*str=='-') { addneg=TRUE; lenmin++; } else
+                if((*str>'1') && (Base==2)) {
+                        String->Buffer-=i;
+                        *Value=0;
+                        return STATUS_INVALID_PARAMETER;
+                } else
+                if(((*str>'7') || (*str<'0')) && (Base==8)) {
+                        String->Buffer-=i;
+                        *Value=0;
+                        return STATUS_INVALID_PARAMETER;
+                } else
+                if(((*str>'9') || (*str<'0')) && (Base==10)) {
+                        String->Buffer-=i;
+                        *Value=0;
+                        return STATUS_INVALID_PARAMETER;
+                } else
+                if((((*str>'9') || (*str<'0')) ||
+                    ((toupper(*str)>'F') || (toupper(*str)<'A'))) && (Base==16))
+                {
+                        String->Buffer-=i;
+                        *Value=0;
+                        return STATUS_INVALID_PARAMETER;
+                } else
+                        str++;
+
+                String->Buffer++;
         };
-   
-   *str=0;
-   String->Buffer-=String->Length;
-   str-=(String->Length-lenmin);
-   
-   if(addneg==TRUE) {
-      *Value=simple_strtoul(str, NULL, Base)*-1;
+
+        *str=0;
+        String->Buffer-=String->Length;
+        str-=(String->Length-lenmin);
+
+        if(addneg==TRUE) {
+          *Value=simple_strtoul(str, NULL, Base)*-1;
         } else
-     *Value=simple_strtoul(str, NULL, Base);
-   
-   //        ExFreePool(str);
-   return(STATUS_SUCCESS);
+          *Value=simple_strtoul(str, NULL, Base);
+
+        RtlFreeHeap (RtlGetProcessHeap (),
+                     0,
+                     str);
+
+        return(STATUS_SUCCESS);
+#endif
 }
 
-NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
-                                IN PUNICODE_STRING SourceString,
-                                IN BOOLEAN AllocateDestinationString)
+NTSTATUS
+STDCALL
+RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
+                       IN PUNICODE_STRING SourceString,
+                       IN BOOLEAN AllocateDestinationString)
 {
-        unsigned long i;
-
-        if(AllocateDestinationString==TRUE) {
-//                DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length*2+1);
+        ULONG i;
+        PWCHAR Src, Dest;
+
+        if(AllocateDestinationString==TRUE)
+        {
+                DestinationString->Buffer =
+                        RtlAllocateHeap (RtlGetProcessHeap (),
+                                         0,
+                                         SourceString->Length + sizeof(WCHAR));
                 DestinationString->Length=SourceString->Length;
-                DestinationString->MaximumLength=SourceString->Length+1;
-        };
-
-        for(i=0; i<SourceString->Length; i++) {
-                *DestinationString->Buffer=wtoupper(*SourceString->Buffer);
-                DestinationString->Buffer++;
-                SourceString->Buffer++;
-        };
-        *DestinationString->Buffer=0;
-
-        DestinationString->Buffer-=SourceString->Length;
-        SourceString->Buffer-=SourceString->Length;
+                DestinationString->MaximumLength=SourceString->Length+sizeof(WCHAR);
+        }
+
+        Src = SourceString->Buffer;
+        Dest = DestinationString->Buffer;
+        for (i=0; i < SourceString->Length / sizeof(WCHAR); i++)
+        {
+                *Dest = towupper (*Src);
+                Dest++;
+                Src++;
+        }
+        *Dest = 0;
 
         return STATUS_SUCCESS;
-};
+}
 
-VOID RtlUpcaseString(IN OUT PSTRING DestinationString,
-                     IN PSTRING SourceString)
+VOID
+STDCALL
+RtlUpcaseString(IN OUT PSTRING DestinationString,
+                IN PSTRING SourceString)
 {
         unsigned long i, len;
+        PCHAR Src, Dest;
 
         if(SourceString->Length>DestinationString->MaximumLength) {
                 len=DestinationString->MaximumLength;
@@ -547,52 +745,13 @@ VOID RtlUpcaseString(IN OUT PSTRING DestinationString,
         SourceString->Buffer-=len;
 }
 
-/*---*/
-
-#include <wchar.h>
-
-WCHAR
-STDCALL
-RtlAnsiCharToUnicodeChar (
-       CHAR    AnsiChar
-       )
-{
-       /* FIXME: it should probably call RtlMultiByteToUnicodeN
-        * with length==1.
-        */
-       return (WCHAR) AnsiChar;
-}
-
-
-
 VOID
 STDCALL
-RtlMultiByteToUnicodeN (
-       VOID
-       )
+RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
 {
+//   UNIMPLEMENTED;
 }
 
-
-VOID
-STDCALL
-RtlUnicodeToMultiByteN (
-       VOID
-       )
-{
-}
-
-
-ULONG
-STDCALL
-RtlUnicodeToMultiByteSize (
-       VOID
-       )
-{
-       return 0;
-}
-
-
 VOID
 STDCALL
 RtlUnwind (
@@ -620,4 +779,5 @@ RtlUpcaseUnicodeToMultiByteN (
 }
 
 
+
 /* EOF */
index 9336648..fe6ef8d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rtl.c,v 1.1 1999/09/12 21:54:16 ea Exp $
+/* $Id: rtl.c,v 1.2 1999/11/15 16:02:50 ekohl Exp $
  *
  * reactos/lib/psxdll/misc/rtl.c
  *
 WCHAR
 STDCALL
 RtlAnsiCharToUnicodeChar (
-       CHAR    AnsiChar
+       PCHAR   AnsiChar
        )
 {
        /* FIXME: it should probably call RtlMultiByteToUnicodeN
         * with length==1.
         */
-       return (WCHAR) AnsiChar;
+       return (WCHAR) *AnsiChar;
 }
 
 
@@ -57,31 +57,43 @@ RtlMoveMemory (
 }
 
 
-VOID
+NTSTATUS
 STDCALL
 RtlMultiByteToUnicodeN (
-       VOID
+       PWCHAR UnicodeString,
+       ULONG  UnicodeSize,
+       PULONG ResultSize,
+       PCHAR  MbString,
+       ULONG  MbSize
        )
 {
+       return STATUS_NOT_IMPLEMENTED;
 }
 
 
-VOID
+NTSTATUS
 STDCALL
 RtlUnicodeToMultiByteN (
-       VOID
+       PCHAR  MbString,
+       ULONG  MbSize,
+       PULONG ResultSize,
+       PWCHAR UnicodeString,
+       ULONG  UnicodeSize
        )
 {
+       return STATUS_NOT_IMPLEMENTED;
 }
 
 
-ULONG
+NTSTATUS
 STDCALL
 RtlUnicodeToMultiByteSize (
-       VOID
+       PULONG MbSize,
+       PWCHAR UnicodeString,
+       ULONG  UnicodeSize
        )
 {
-       return 0;
+       return STATUS_NOT_IMPLEMENTED;
 }
 
 
index ee8d311..5aedf9e 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: psxdll.def,v 1.4 1999/10/26 19:47:06 ea Exp $
+; $Id: psxdll.def,v 1.5 1999/11/15 16:02:36 ekohl Exp $
 ;
 ; psxdll.def
 ;
@@ -14,9 +14,9 @@ ntdll.RtlSizeHeap@12
 ntdll.RtlAnsiCharToUnicodeChar@4
 ntdll.RtlFillMemory@12
 ntdll.RtlMoveMemory@12
-ntdll.RtlMultiByteToUnicodeN@0
-ntdll.RtlUnicodeToMultiByteN@0
-ntdll.RtlUnicodeToMultiByteSize@0
+ntdll.RtlMultiByteToUnicodeN@20
+ntdll.RtlUnicodeToMultiByteN@20
+ntdll.RtlUnicodeToMultiByteSize@12
 ntdll.RtlUnwind@0
 ntdll.RtlUpcaseUnicodeChar@0
 ntdll.RtlUpcaseUnicodeToMultiByteN@0
@@ -31,9 +31,9 @@ HeapSize@12
 RtlAnsiCharToUnicodeChar@4
 RtlFillMemory@12
 RtlMoveMemory@12
-RtlMultiByteToUnicodeN@0
-RtlUnicodeToMultiByteN@0
-RtlUnicodeToMultiByteSize@0
+RtlMultiByteToUnicodeN@20
+RtlUnicodeToMultiByteN@20
+RtlUnicodeToMultiByteSize@12
 RtlUnwind@0
 RtlUpcaseUnicodeChar@0
 RtlUpcaseUnicodeToMultiByteN@0
index 6de9ee7..e1c1493 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: psxdll.edf,v 1.3 1999/10/26 19:47:06 ea Exp $
+; $Id: psxdll.edf,v 1.4 1999/11/15 16:02:36 ekohl Exp $
 ;
 ; psxdll.edf
 ;
@@ -14,9 +14,9 @@ ntdll.RtlSizeHeap@12
 ntdll.RtlAnsiCharToUnicodeChar@4
 ntdll.RtlFillMemory@12
 ntdll.RtlMoveMemory@12
-ntdll.RtlMultiByteToUnicodeN@0
-ntdll.RtlUnicodeToMultiByteN@0
-ntdll.RtlUnicodeToMultiByteSize@0
+ntdll.RtlMultiByteToUnicodeN@20
+ntdll.RtlUnicodeToMultiByteN@20
+ntdll.RtlUnicodeToMultiByteSize@12
 ntdll.RtlUnwind@0
 ntdll.RtlUpcaseUnicodeChar@0
 ntdll.RtlUpcaseUnicodeToMultiByteN@0
@@ -31,9 +31,9 @@ HeapSize=HeapSize@12
 RtlAnsiCharToUnicodeChar=RtlAnsiCharToUnicodeChar@4
 RtlFillMemory=RtlFillMemory@12
 RtlMoveMemory=RtlMoveMemory@12
-RtlMultiByteToUnicodeN=RtlMultiByteToUnicodeN@0
-RtlUnicodeToMultiByteN=RtlUnicodeToMultiByteN@0
-RtlUnicodeToMultiByteSize=RtlUnicodeToMultiByteSize@0
+RtlMultiByteToUnicodeN=RtlMultiByteToUnicodeN@20
+RtlUnicodeToMultiByteN=RtlUnicodeToMultiByteN@20
+RtlUnicodeToMultiByteSize=RtlUnicodeToMultiByteSize@12
 RtlUnwind=RtlUnwind@0
 RtlUpcaseUnicodeChar=RtlUpcaseUnicodeChar@0
 RtlUpcaseUnicodeToMultiByteN=RtlUpcaseUnicodeToMultiByteN@0
index 996f258..4ace4a5 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: makefile_rex,v 1.36 1999/11/12 12:01:11 dwelch Exp $
+# $Id: makefile_rex,v 1.37 1999/11/15 15:56:16 ekohl Exp $
 #
 # ReactOS Operating System
 #
@@ -15,13 +15,13 @@ include hal/x86/sources
 
 NT_OBJECTS = nt/port.o nt/channel.o nt/ntevent.o nt/nttimer.o nt/atom.o \
              nt/evtpair.o nt/ntsem.o nt/mutant.o nt/misc.o nt/plugplay.o \
-            nt/profile.o nt/nt.o nt/zw.o
+             nt/profile.o nt/nt.o nt/zw.o
 
 RTL_OBJECTS = rtl/vsprintf.o rtl/lookas.o rtl/unicode.o rtl/time.o \
               rtl/unalign.o rtl/mem.o rtl/largeint.o rtl/ctype.o \
               rtl/list.o rtl/slist.o rtl/interlck.o rtl/return.o \
               rtl/wstring.o rtl/memcpy.o rtl/memmove.o rtl/memset.o \
-              rtl/memchr.o rtl/string.o rtl/stdlib.o
+              rtl/memchr.o rtl/nls.o rtl/string.o rtl/stdlib.o
 
 KE_OBJECTS = ke/main.o ke/timer.o ke/error.o ke/catch.o \
              ke/dpc.o ke/wait.o ke/kqueue.o ke/dispatch.o \
index 48cae22..24870e0 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: ntoskrnl.def,v 1.24 1999/11/09 18:04:26 ekohl Exp $
+; $Id: ntoskrnl.def,v 1.25 1999/11/15 15:56:16 ekohl Exp $
 ;
 ; reactos/ntoskrnl/ntoskrnl.def
 ;
@@ -120,6 +120,8 @@ KeSynchronizeExecution
 KeWaitForSingleObject
 MmGetSystemAddressForMdl
 MmMapIoSpace
+NlsMbCodePageTag
+NlsMbOemCodePageTag
 NtAddAtom@8
 NtAdjustPrivilegesToken@24
 NtAllocateLocallyUniqueId@4
@@ -172,22 +174,41 @@ NtUnlockFile@20
 ;NtVdmControl@8 <--- ?
 NtWaitForSingleObject@12
 NtWriteFile@36
-RtlAnsiStringToUnicodeString
+RtlAnsiCharToUnicodeChar@4
+RtlAnsiStringToUnicodeSize@4
+RtlAnsiStringToUnicodeString@12
+RtlAppendAsciizToString@8
+RtlAppendStringToString@8
+RtlAppendUnicodeStringToString@8
+RtlAppendUnicodeToString@8
+RtlCharToInteger@12
 RtlCompareMemory@12
+RtlCompareString@12
+RtlCompareUnicodeString@12
 RtlConvertLongToLargeInteger
 RtlConvertUlongToLargeInteger
 RtlCopyMemory
+RtlCopyString@8
+RtlCopyUnicodeString@8
+RtlCreateUnicodeString@8
 RtlEnlargedIntegerMultiply
 RtlEnlargedUnsignedDivide
 RtlEnlargedUnsignedMultiply
+RtlEqualString@12
+RtlEqualUnicodeString@12
 RtlExtendedIntegerMultiply
 RtlExtendedLargeIntegerDivide
 RtlExtendedMagicDivide
 RtlFillMemory@12
 RtlFillMemoryUlong@12
-RtlFreeUnicodeString
-RtlInitAnsiString
-RtlInitUnicodeString
+RtlFreeAnsiString@4
+RtlFreeOemString@4
+RtlFreeUnicodeString@4
+RtlGetDefaultCodePage@8
+RtlInitAnsiString@8
+RtlInitString@8
+RtlInitUnicodeString@8
+RtlIntegerToUnicodeString@12
 RtlLargeIntegerAdd
 RtlLargeIntegerArithmeticShift
 RtlLargeIntegerDivide
@@ -196,12 +217,28 @@ RtlLargeIntegerShiftLeft
 RtlLargeIntegerShiftRight
 RtlLargeIntegerSubtract
 RtlMoveMemory@12
+RtlMultiByteToUnicodeN@20
+RtlMultiByteToUnicodeSize@12
+RtlOemStringToUnicodeSize@4
+RtlOemStringToUnicodeString@12
+RtlOemToUnicodeN@20
 RtlSecondsSince1970ToTime
 RtlSecondsSince1980ToTime
 RtlTimeFieldsToTime
 RtlTimeToSecondsSince1970
 RtlTimeToSecondsSince1980
 RtlTimeToTimeFields
+RtlUnicodeStringToAnsiSize@4
+RtlUnicodeStringToAnsiString@12
+RtlUnicodeStringToInteger@12
+RtlUnicodeStringToOemSize@4
+RtlUnicodeStringToOemString@12
+RtlUnicodeToMultiByteN@20
+RtlUnicodeToMultiByteSize@12
+RtlUnicodeToOemN@20
+RtlUpcaseUnicodeString@12
+RtlUpcaseString@8
+RtlUpperString@8
 RtlZeroMemory@8
 ZwAccessCheckAndAuditAlarm@44
 ZwAlertThread@4
index 242bd8c..5156056 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: ntoskrnl.edf,v 1.11 1999/11/09 18:04:26 ekohl Exp $
+; $Id: ntoskrnl.edf,v 1.12 1999/11/15 15:56:16 ekohl Exp $
 ;
 ; reactos/ntoskrnl/ntoskrnl.def
 ;
@@ -120,12 +120,14 @@ KeSynchronizeExecution
 KeWaitForSingleObject
 MmGetSystemAddressForMdl
 MmMapIoSpace
+NlsMbCodePageTag
+NlsMbOemCodePageTag
 NtAddAtom=NtAddAtom@8
 NtAdjustPrivilegesToken=NtAdjustPrivilegesToken@24
 NtAllocateLocallyUniqueId=NtAllocateLocallyUniqueId@4
 NtAllocateUuids=NtAllocateUuids@12
 NtAllocateVirtualMemory=NtAllocateVirtualMemory@24
-;NtBuildNumber <--- variable?
+;NtBuildNumber <--- variable
 NtClose=NtClose@4
 ;NtConnectPort@32
 NtConnectPort=NtConnectPort@8
@@ -140,7 +142,7 @@ NtDuplicateToken=NtDuplicateToken@24
 NtFindAtom=NtFindAtom@8
 NtFreeVirtualMemory=NtFreeVirtualMemory@16
 NtFsControlFile=NtFsControlFile@40
-;NtGlobalFlag <--- variable?
+;NtGlobalFlag <--- variable
 NtLockFile=NtLockFile@40
 NtMapViewOfSection=NtMapViewOfSection@40
 NtNotifyChangeDirectoryFile=NtNotifyChangeDirectoryFile@36
@@ -172,22 +174,41 @@ NtUnlockFile=NtUnlockFile@20
 ;NtVdmControl@8 <--- ?
 NtWaitForSingleObject=NtWaitForSingleObject@12
 NtWriteFile=NtWriteFile@36
-RtlAnsiStringToUnicodeString
+RtlAnsiCharToUnicodeChar=RtlAnsiCharToUnicodeChar@4
+RtlAnsiStringToUnicodeSize=RtlAnsiStringToUnicodeSize@4
+RtlAnsiStringToUnicodeString=RtlAnsiStringToUnicodeString@12
+RtlAppendAsciizToString=RtlAppendAsciizToString@8
+RtlAppendStringToString=RtlAppendStringToString@8
+RtlAppendUnicodeStringToString=RtlAppendUnicodeStringToString@8
+RtlAppendUnicodeToString=RtlAppendUnicodeToString@8
+RtlCharToInteger=RtlCharToInteger@12
 RtlCompareMemory=RtlCompareMemory@12
+RtlCompareString=RtlCompareString@12
+RtlCompareUnicodeString=RtlCompareUnicodeString@12
 RtlConvertLongToLargeInteger
 RtlConvertUlongToLargeInteger
 RtlCopyMemory
+RtlCopyString=RtlCopyString@8
+RtlCopyUnicodeString=RtlCopyUnicodeString@8
+RtlCreateUnicodeString=RtlCreateUnicodeString@8
 RtlEnlargedIntegerMultiply
 RtlEnlargedUnsignedDivide
 RtlEnlargedUnsignedMultiply
+RtlEqualString=RtlEqualString@12
+RtlEqualUnicodeString=RtlEqualUnicodeString@12
 RtlExtendedIntegerMultiply
 RtlExtendedLargeIntegerDivide
 RtlExtendedMagicDivide
 RtlFillMemory=RtlFillMemory@12
 RtlFillMemoryUlong=RtlFillMemoryUlong@12
-RtlFreeUnicodeString
-RtlInitAnsiString
-RtlInitUnicodeString
+RtlFreeAnsiString=RtlFreeAnsiString@4
+RtlFreeOemString=RtlFreeOemString@4
+RtlFreeUnicodeString=RtlFreeUnicodeString@4
+RtlGetDefaultCodePage=RtlGetDefaultCodePage@8
+RtlInitAnsiString=RtlInitAnsiString@8
+RtlInitString=RtlInitString@8
+RtlInitUnicodeString=RtlInitUnicodeString@8
+RtlIntegerToUnicodeString=RtlIntegerToUnicodeString@12
 RtlLargeIntegerAdd
 RtlLargeIntegerArithmeticShift
 RtlLargeIntegerDivide
@@ -196,12 +217,26 @@ RtlLargeIntegerShiftLeft
 RtlLargeIntegerShiftRight
 RtlLargeIntegerSubtract
 RtlMoveMemory=RtlMoveMemory@12
+RtlMultiByteToUnicodeN=RtlMultiByteToUnicodeN@20
+RtlMultiByteToUnicodeSize=RtlMultiByteToUnicodeSize@12
+RtlOemStringToUnicodeSize=RtlOemStringToUnicodeSize@4
+RtlOemStringToUnicodeString=RtlOemStringToUnicodeString@12
 RtlSecondsSince1970ToTime
 RtlSecondsSince1980ToTime
 RtlTimeFieldsToTime
 RtlTimeToSecondsSince1970
 RtlTimeToSecondsSince1980
 RtlTimeToTimeFields
+RtlUnicodeStringToAnsiSize=RtlUnicodeStringToAnsiSize@4
+RtlUnicodeStringToAnsiString=RtlUnicodeStringToAnsiString@12
+RtlUnicodeStringToInteger=RtlUnicodeStringToInteger@12
+RtlUnicodeStringToOemSize=RtlUnicodeStringToOemSize@4
+RtlUnicodeStringToOemString=RtlUnicodeStringToOemString@12
+RtlUnicodeToMultiByteN=RtlUnicodeToMultiByteN@20
+RtlUnicodeToMultiByteSize=RtlUnicodeToMultiByteSize@12
+RtlUpcaseUnicodeString=RtlUpcaseUnicodeString@12
+RtlUpcaseString=RtlUpcaseString@8
+RtlUpperString=RtlUpperString@8
 RtlZeroMemory=RtlZeroMemory@8
 ZwAccessCheckAndAuditAlarm=ZwAccessCheckAndAuditAlarm@44
 ZwAlertThread=ZwAlertThread@4
diff --git a/reactos/ntoskrnl/rtl/nls.c b/reactos/ntoskrnl/rtl/nls.c
new file mode 100644 (file)
index 0000000..37344c8
--- /dev/null
@@ -0,0 +1,287 @@
+/* $Id: nls.c,v 1.1 1999/11/15 15:57:01 ekohl Exp $
+ *
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS kernel
+ * FILE:            ntoskrnl/rtl/nls.c
+ * PURPOSE:         National Language Support (NLS) functions
+ * UPDATE HISTORY:
+ *                  20/08/99 Created by Emanuele Aliberti
+ *                  10/11/99 Added translation functions.
+ *
+ * NOTE:
+ *   Multi-byte code pages are not supported yet. Even single-byte code
+ *   pages are not supported properly. Only stupid CHAR->WCHAR and
+ *   WCHAR->CHAR (Attention: data loss!!!) translation is done.
+ *
+ * TODO:
+ *   1) Implement code to initialize the translation tables.
+ *   2) Use fixed translation table for translation.
+ *   3) Add loading of translation tables (NLS files).
+ *   4) Add multi-byte translation code.
+ */
+
+#include <ddk/ntddk.h>
+//#include <internal/nls.h>
+
+
+BOOLEAN
+NlsMbCodePageTag = FALSE;
+
+BOOLEAN
+NlsMbOemCodePageTag = FALSE;
+
+BYTE
+NlsLeadByteInfo = 0; /* ? */
+
+USHORT
+NlsOemLeadByteInfo = 0;
+
+USHORT
+NlsAnsiCodePage = 0;
+
+USHORT
+NlsOemCodePage = 0; /* not exported */
+
+
+#if 0
+WCHAR AnsiToUnicodeTable[256];
+WCHAR OemToUnicodeTable[256];
+
+CHAR UnicodeToAnsiTable [65536];
+CHAR UnicodeToOemTable [65536];
+#endif
+
+
+/* FUNCTIONS *****************************************************************/
+
+VOID
+STDCALL
+RtlGetDefaultCodePage (PUSHORT AnsiCodePage,
+                       PUSHORT OemCodePage)
+{
+       *AnsiCodePage = NlsAnsiCodePage;
+       *OemCodePage = NlsOemCodePage;
+}
+
+
+NTSTATUS
+STDCALL
+RtlMultiByteToUnicodeN(PWCHAR UnicodeString,
+                       ULONG  UnicodeSize,
+                       PULONG ResultSize,
+                       PCHAR  MbString,
+                       ULONG  MbSize)
+{
+       ULONG Size = 0;
+       ULONG i;
+
+       if (NlsMbCodePageTag == FALSE)
+       {
+               /* single-byte code page */
+               if (MbSize > (UnicodeSize / sizeof(WCHAR)))
+                       Size = UnicodeSize / sizeof(WCHAR);
+               else
+                       Size = MbSize;
+
+               if (ResultSize != NULL)
+                       *ResultSize = Size * sizeof(WCHAR);
+
+               for (i = 0; i < Size; i++)
+               {
+                       *UnicodeString = *MbString;
+#if 0
+                       *UnicodeString = AnsiToUnicodeTable[*MbString];
+#endif
+
+                       UnicodeString++;
+                       MbString++;
+               };
+       }
+       else
+       {
+               /* multi-byte code page */
+               /* FIXME */
+
+       }
+
+       return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+STDCALL
+RtlMultiByteToUnicodeSize(PULONG UnicodeSize,
+                          PCHAR MbString,
+                          ULONG MbSize)
+{
+       if (NlsMbCodePageTag == FALSE)
+       {
+               /* single-byte code page */
+               *UnicodeSize = MbSize * sizeof (WCHAR);
+       }
+       else
+       {
+               /* multi-byte code page */
+               /* FIXME */
+
+       }
+
+       return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+STDCALL
+RtlOemToUnicodeN(PWCHAR UnicodeString,
+                 ULONG  UnicodeSize,
+                 PULONG ResultSize,
+                 PCHAR  OemString,
+                 ULONG  OemSize)
+{
+       ULONG Size = 0;
+       ULONG i;
+
+       if (NlsMbOemCodePageTag == FALSE)
+       {
+               /* single-byte code page */
+               if (OemSize > (UnicodeSize / sizeof(WCHAR)))
+                       Size = UnicodeSize / sizeof(WCHAR);
+               else
+                       Size = OemSize;
+
+               if (ResultSize != NULL)
+                       *ResultSize = Size * sizeof(WCHAR);
+
+               for (i = 0; i < Size; i++)
+               {
+                       *UnicodeString = *OemString;
+#if 0
+                       *UnicodeString = OemToUnicodeTable[*OemString];
+#endif
+
+                       UnicodeString++;
+                       OemString++;
+               };
+       }
+       else
+       {
+               /* multi-byte code page */
+               /* FIXME */
+
+       }
+
+       return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+STDCALL
+RtlUnicodeToMultiByteN(PCHAR  MbString,
+                       ULONG  MbSize,
+                       PULONG ResultSize,
+                       PWCHAR UnicodeString,
+                       ULONG  UnicodeSize)
+{
+       ULONG Size = 0;
+       ULONG i;
+
+       if (NlsMbCodePageTag == FALSE)
+       {
+               /* single-byte code page */
+               if (UnicodeSize > (MbSize * sizeof(WCHAR)))
+                       Size = MbSize;
+               else
+                       Size = UnicodeSize / sizeof(WCHAR);
+
+               if (ResultSize != NULL)
+                       *ResultSize = Size;
+
+               for (i = 0; i < Size; i++)
+               {
+                       *MbString = *UnicodeString;
+#if 0
+                       *MbString = UnicodeToAnsiTable[*UnicodeString];
+#endif
+
+                       MbString++;
+                       UnicodeString++;
+               };
+       }
+       else
+       {
+               /* multi-byte code page */
+               /* FIXME */
+
+       }
+
+       return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+STDCALL
+RtlUnicodeToMultiByteSize(PULONG MbSize,
+                          PWCHAR UnicodeString,
+                          ULONG UnicodeSize)
+{
+       if (NlsMbCodePageTag == FALSE)
+       {
+               /* single-byte code page */
+               *MbSize = UnicodeSize / sizeof (WCHAR);
+       }
+       else
+       {
+               /* multi-byte code page */
+               /* FIXME */
+
+       }
+
+       return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+STDCALL
+RtlUnicodeToOemN(PCHAR  OemString,
+                 ULONG  OemSize,
+                 PULONG ResultSize,
+                 PWCHAR UnicodeString,
+                 ULONG  UnicodeSize)
+{
+       ULONG Size = 0;
+       ULONG i;
+
+       if (NlsMbOemCodePageTag == FALSE)
+       {
+               /* single-byte code page */
+               if (UnicodeSize > (OemSize * sizeof(WCHAR)))
+                       Size = OemSize;
+               else
+                       Size = UnicodeSize / sizeof(WCHAR);
+
+               if (ResultSize != NULL)
+                       *ResultSize = Size;
+
+               for (i = 0; i < Size; i++)
+               {
+                       *OemString = *UnicodeString;
+#if 0
+                       *OemString = UnicodeToOemTable[*UnicodeString];
+#endif
+
+                       OemString++;
+                       UnicodeString++;
+               };
+       }
+       else
+       {
+               /* multi-byte code page */
+               /* FIXME */
+
+       }
+
+       return STATUS_SUCCESS;
+}
+
+
+/* EOF */
index e09944e..4bf32cd 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: unicode.c,v 1.8 1999/11/15 15:57:01 ekohl Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/rtl/unicode.c
  *                  Created 10/08/98
  */
 
-#include <wchar.h>
-
 #include <ddk/ntddk.h>
-
-#include <internal/string.h>
-#include <internal/ke.h>
 #include <ctype.h>
 
+//#include <internal/nls.h>
+
+
 #define NDEBUG
 #include <internal/debug.h>
 
-#define Aa_Difference ('A'-'a')
+#define STR_FIX
 
 extern unsigned long simple_strtoul(const char *cp, char **endp,
                                    unsigned int base);
 
-VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
+
+/* FUNCTIONS *****************************************************************/
+
+WCHAR
+STDCALL
+RtlAnsiCharToUnicodeChar(PCHAR AnsiChar)
 {
-   UNIMPLEMENTED;
+       ULONG Size;
+       WCHAR UnicodeChar;
+
+       Size = 1;
+#if 0
+       Size = (NlsLeadByteInfo[*AnsiChar] == 0) ? 1 : 2;
+#endif
+
+       RtlMultiByteToUnicodeN (&UnicodeChar,
+                               sizeof(WCHAR),
+                               NULL,
+                               AnsiChar,
+                               Size);
+
+       return UnicodeChar;
 }
 
-ULONG RtlAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString)
+
+ULONG
+STDCALL
+RtlAnsiStringToUnicodeSize(PANSI_STRING AnsiString)
 {
-        return AnsiString->Length*2;
+       ULONG Size;
+
+       RtlMultiByteToUnicodeSize (&Size,
+                                  AnsiString->Buffer,
+                                  AnsiString->Length);
+
+       return Size;
 }
 
-NTSTATUS RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
-        IN PANSI_STRING SourceString, IN BOOLEAN AllocateDestinationString)
+
+NTSTATUS
+STDCALL
+RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString,
+                             PANSI_STRING SourceString,
+                             BOOLEAN AllocateDestinationString)
 {
-        unsigned long i;
+       NTSTATUS Status;
+       ULONG Length;
+
+       if (NlsMbCodePageTag == TRUE)
+               Length = RtlAnsiStringToUnicodeSize (SourceString);
+       else
+               Length = SourceString->Length * sizeof(WCHAR);
+
+       if (Length > 65535)
+               return STATUS_INVALID_PARAMETER_2;
+
+       DestinationString->Length = Length;
+
+       if (AllocateDestinationString == TRUE)
+       {
+               DestinationString->MaximumLength = Length + sizeof(WCHAR);
+               DestinationString->Buffer =
+                       ExAllocatePool (NonPagedPool,
+                                       DestinationString->MaximumLength);
+               if (DestinationString->Buffer == NULL)
+                       return STATUS_NO_MEMORY;
+       }
+       else
+       {
+               if (Length > DestinationString->Length)
+                       return STATUS_BUFFER_OVERFLOW;
+       }
+
+       memset (DestinationString->Buffer,
+               0,
+               DestinationString->Length);
+
+       Status = RtlMultiByteToUnicodeN (DestinationString->Buffer,
+                                        DestinationString->Length,
+                                        NULL,
+                                        SourceString->Buffer,
+                                        SourceString->Length);
+       if (!NT_SUCCESS(Status))
+       {
+               if (AllocateDestinationString)
+                       ExFreePool (DestinationString->Buffer);
+               return Status;
+       }
+
+       DestinationString->Buffer[Length / sizeof(WCHAR)] = 0;
+
+       return STATUS_SUCCESS;
+}
 
-        if(AllocateDestinationString==TRUE) {
-          DestinationString->Buffer=ExAllocatePool(NonPagedPool, (SourceString->Length+1)*2);
-          DestinationString->MaximumLength=SourceString->Length;
-        };
 
-        DestinationString->Length=SourceString->Length;
-        memset(DestinationString->Buffer, 0, SourceString->Length*2);
+NTSTATUS
+STDCALL
+RtlAppendAsciizToString(IN OUT PSTRING Destination,
+                        IN PCSZ Source)
+{
+       ULONG Length;
+       PCHAR Ptr;
 
-        for (i=0; i<SourceString->Length; i++)
-        {
-                *DestinationString->Buffer=*SourceString->Buffer;
+       if (Source == NULL)
+               return STATUS_SUCCESS;
 
-                SourceString->Buffer++;
-                DestinationString->Buffer++;
-        };
-        *DestinationString->Buffer=0;
+       Length = strlen (Source);
+       if (Destination->Length + Length >= Destination->MaximumLength)
+               return STATUS_BUFFER_TOO_SMALL;
 
-        SourceString->Buffer-=SourceString->Length;
-        DestinationString->Buffer-=SourceString->Length;
+       Ptr = Destination->Buffer + Destination->Length;
+       memmove (Ptr,
+                Source,
+                Length);
+       Ptr += Length;
+       *Ptr = 0;
+
+       Destination->Length += Length;
+
+       return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+STDCALL
+RtlAppendStringToString(PSTRING Destination,
+                        PSTRING Source)
+{
+       PCHAR Ptr;
+
+       if (Source->Length == 0)
+               return STATUS_SUCCESS;
+
+       if (Destination->Length + Source->Length >= Destination->MaximumLength)
+               return STATUS_BUFFER_TOO_SMALL;
+
+       Ptr = Destination->Buffer + Destination->Length;
+       memmove (Ptr,
+                Source->Buffer,
+                Source->Length);
+       Ptr += Source->Length;
+       *Ptr = 0;
+
+       Destination->Length += Source->Length;
+
+       return STATUS_SUCCESS;
+}
 
-        return STATUS_SUCCESS;
-};
 
-NTSTATUS RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination,
+NTSTATUS
+STDCALL
+RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination,
         IN PUNICODE_STRING Source)
 {
-        unsigned long i;
+       PWCHAR Src, Dest;
+       ULONG i;
 
-        if(Destination->MaximumLength-Destination->Length-Source->Length<0)
-                return STATUS_BUFFER_TOO_SMALL;
+       if ((Source->Length + Destination->Length) >= Destination->MaximumLength)
+               return STATUS_BUFFER_TOO_SMALL;
 
-        Destination->Buffer+=Destination->Length;
-        for(i=0; i<Source->Length; i++) {
-                *Destination->Buffer=*Source->Buffer;
-                Destination->Buffer++;
-                Source->Buffer++;
-        };
-        *Destination->Buffer=0;
-        Destination->Buffer-=(Destination->Length+Source->Length);
-        Source->Buffer-=Source->Length;
+       Src  = Source->Buffer;
+       Dest = Destination->Buffer + (Destination->Length / sizeof (WCHAR));
+       for (i = 0; i < (Source->Length / sizeof(WCHAR)); i++)
+       {
+               *Dest = *Src;
+               Dest++;
+               Src++;
+       }
+       *Dest = 0;
+
+       Destination->Length += Source->Length;
+
+       return STATUS_SUCCESS;
+}
 
-        Destination->Length+=Source->Length;
-        return STATUS_SUCCESS;
-};
 
-NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
+NTSTATUS
+STDCALL
+RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
         IN PWSTR Source)
 {
-        unsigned long i, slen=wcslen(Source);
+       PWCHAR Src;
+       PWCHAR Dest;
+       ULONG  i;
+       ULONG  slen;
 
-        if(Destination->MaximumLength-Destination->Length-slen<0)
-                return STATUS_BUFFER_TOO_SMALL;
+       slen = wcslen (Source);
 
-        Destination->Buffer+=Destination->Length;
-        for(i=0; i<slen; i++) {
-                *Destination->Buffer=*Source;
-                Destination->Buffer++;
-                Source++;
-        };
-        *Destination->Buffer=0;
-        Destination->Buffer-=(Destination->Length+slen);
-        Source-=slen;
+       if (Destination->Length + slen >= Destination->MaximumLength)
+               return STATUS_BUFFER_TOO_SMALL;
 
-        Destination->Length+=slen;
-        return STATUS_SUCCESS;
-};
+       Src = Source;
+       Dest = Destination->Buffer + (Destination->Length / sizeof (WCHAR));
+
+       for (i = 0; i < slen; i++)
+       {
+               *Dest = *Src;
+               Dest++;
+               Src++;
+       }
+       *Dest = 0;
+
+       Destination->Length += (slen * sizeof(WCHAR));
 
-NTSTATUS RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value)
+       return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+STDCALL
+RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value)
 {
-   *Value=simple_strtoul((const char *)String, NULL, Base);
-   return(STATUS_SUCCESS);
+       *Value=simple_strtoul((const char *)String, NULL, Base);
+       return STATUS_SUCCESS;
 }
 
-LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
-{
-        unsigned long i;
-        char c1, c2;
-
-        if(String1->Length!=String2->Length) return String1->Length-String2->Length;
-
-        for(i=0; i<String1->Length; i++) {
-                if(CaseInsensitive==TRUE) {
-                        c1=toupper(*String1->Buffer);
-                        c2=toupper(*String2->Buffer);
-                } else {
-                        c1=*String1->Buffer;
-                        c2=*String2->Buffer;
-                };
-                if(c1!=c2) {
-                        String1->Buffer-=i;
-                        String2->Buffer-=i;
-                        return c1-c2;
-                };
-                String1->Buffer++;
-                String2->Buffer++;
-        };
-        String1->Buffer-=i;
-        String2->Buffer-=i;
-
-        return 0;
-};
-
-LONG RtlCompareUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2,
-                             BOOLEAN CaseInsensitive)
-{
-        unsigned long i;
-        WCHAR wc1, wc2;
-
-        if(String1->Length!=String2->Length) return
-                String1->Length-String2->Length;
-
-        for(i=0; i<String1->Length; i++) {
-                if(CaseInsensitive==TRUE) {
-                        wc1=towupper(*String1->Buffer);
-                        wc2=towupper(*String2->Buffer);
-                } else {
-                        wc1=*String1->Buffer;
-                        wc2=*String2->Buffer;
-                };
-
-                if(wc1!=wc2) {
-                        String1->Buffer-=i;
-                        String2->Buffer-=i;
-                        return wc1-wc2;
-                };
-
-                String1->Buffer++;
-                String2->Buffer++;
-        };
 
-        String1->Buffer-=i;
-        String2->Buffer-=i;
+LONG
+STDCALL
+RtlCompareString(PSTRING String1,
+                 PSTRING String2,
+                 BOOLEAN CaseInsensitive)
+{
+       unsigned long i;
+       char c1, c2;
+
+       if (String1->Length != String2->Length)
+               return String1->Length - String2->Length;
+
+       for (i=0; i<String1->Length; i++)
+       {
+               if (CaseInsensitive == TRUE)
+               {
+                       c1 = toupper(*String1->Buffer);
+                       c2 = toupper(*String2->Buffer);
+               }
+               else
+               {
+                       c1 = *String1->Buffer;
+                       c2 = *String2->Buffer;
+               }
+
+               if (c1!=c2)
+               {
+                       String1->Buffer -= i;
+                       String2->Buffer -= i;
+                       return c1 - c2;
+               }
+
+               String1->Buffer++;
+               String2->Buffer++;
+       }
+
+       String1->Buffer-=i;
+       String2->Buffer-=i;
+
+       return 0;
+}
+
+
+LONG
+STDCALL
+RtlCompareUnicodeString(PUNICODE_STRING String1,
+        PUNICODE_STRING String2,
+        BOOLEAN CaseInsensitive)
+{
+       unsigned long i;
+       WCHAR wc1, wc2;
+       PWCHAR pw1, pw2;
+
+       if (String1->Length != String2->Length)
+               return String1->Length - String2->Length;
+
+       pw1 = String1->Buffer;
+       pw2 = String2->Buffer;
+
+       for(i = 0; i < (String1->Length / sizeof(WCHAR)); i++)
+       {
+               if(CaseInsensitive == TRUE)
+               {
+                       wc1 = towupper (*pw1);
+                       wc2 = towupper (*pw2);
+               }
+               else
+               {
+                       wc1 = *pw1;
+                       wc2 = *pw2;
+               }
+
+               if (wc1 != wc2)
+               {
+                       return wc1 - wc2;
+               }
+
+               pw1++;
+               pw2++;
+       }
+
+       return 0;
+}
 
-        return 0;
-};
 
-VOID RtlCopyString(IN OUT PSTRING DestinationString, IN PSTRING SourceString)
+VOID
+STDCALL
+RtlCopyString(IN OUT PSTRING DestinationString, IN PSTRING SourceString)
 {
-        unsigned long copylen, i;
+       unsigned long copylen, i;
+
+       if(SourceString == NULL)
+       {
+               DestinationString->Length = 0;
+       }
+       else
+       {
+               if(SourceString->Length < DestinationString->MaximumLength)
+               {
+                       copylen = SourceString->Length;
+               }
+               else
+               {
+                       copylen = DestinationString->MaximumLength;
+               }
+
+               for(i=0; i<copylen; i++)
+               {
+                       *DestinationString->Buffer = *SourceString->Buffer;
+                       DestinationString->Buffer++;
+                       SourceString->Buffer++;
+               }
+
+               *DestinationString->Buffer = 0;
+               DestinationString->Buffer -= copylen;
+               SourceString->Buffer -= copylen;
+       }
+}
 
-        if(SourceString==NULL) {
-                 DestinationString->Length=0;
-        } else {
-                 if(SourceString->Length<DestinationString->MaximumLength) {
-                         copylen=SourceString->Length;
-                 } else {
-                         copylen=DestinationString->MaximumLength;
-                 };
-                 for(i=0; i<copylen; i++)
-                 {
-                         *DestinationString->Buffer=*SourceString->Buffer;
-                         DestinationString->Buffer++;
-                         SourceString->Buffer++;
-                 };
-                 *DestinationString->Buffer=0;
-                 DestinationString->Buffer-=copylen;
-                 SourceString->Buffer-=copylen;
-        };
-};
-
-VOID RtlCopyUnicodeString(IN OUT PUNICODE_STRING DestinationString,
-                          IN PUNICODE_STRING SourceString)
-{
-   unsigned long copylen, i;
-   
-   if(SourceString==NULL) 
-     {
-       DestinationString->Length=0;
-     } 
-   else 
-     {
-       copylen = min(DestinationString->MaximumLength,
-                     SourceString->Length);
-       for(i=0; i<copylen; i++)
-         {
-            *DestinationString->Buffer=*SourceString->Buffer;
-            DestinationString->Buffer++;
-            SourceString->Buffer++;
-         }
-       *DestinationString->Buffer=0;
-       DestinationString->Buffer-=copylen;
-       SourceString->Buffer-=copylen;
-     }
-}
-
-BOOLEAN RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
-{
-        unsigned long s1l=String1->Length;
-        unsigned long s2l=String2->Length;
-        unsigned long i;
-        char c1, c2;
-
-        if(s1l!=s2l) return FALSE;
-
-        for(i=0; i<s1l; i++) {
-                c1=*String1->Buffer;
-                c2=*String2->Buffer;
-
-                if(CaseInsensitive==TRUE) {
-                        c1=toupper(c1);
-                        c2=toupper(c2);
-                };
-
-                if(c1!=c2) {
-                        String1->Buffer-=i;
-                        String2->Buffer-=i;
-                        return FALSE;
-                };
-
-                String1->Buffer++;
-                String2->Buffer++;
-        };
 
-        String1->Buffer-=i;
-        String2->Buffer-=i;
+VOID
+STDCALL
+RtlCopyUnicodeString(IN OUT PUNICODE_STRING DestinationString,
+                     IN PUNICODE_STRING SourceString)
+{
+       unsigned long copylen, i;
+       PWCHAR Src, Dest;
+
+       if(SourceString==NULL)
+       {
+               DestinationString->Length=0;
+       }
+       else
+       {
+               copylen = min(DestinationString->MaximumLength - sizeof(WCHAR),
+                             SourceString->Length);
+               Src = SourceString->Buffer;
+               Dest = DestinationString->Buffer;
+
+               for (i = 0; i < (copylen / sizeof (WCHAR)); i++)
+               {
+                       *Dest = *Src;
+                       Dest++;
+                       Src++;
+               }
+               *Dest = 0;
+
+               DestinationString->Length = copylen;
+       }
+}
 
-        return TRUE;
-};
 
-BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2,
-                              BOOLEAN CaseInsensitive)
+BOOLEAN
+STDCALL
+RtlCreateUnicodeString (PUNICODE_STRING Destination,
+                        PWSTR Source)
 {
-        unsigned long s1l=String1->Length;
-        unsigned long s2l=String2->Length;
-        unsigned long i;
-        char wc1, wc2;
+       ULONG Length;
 
-        if(s1l!=s2l) return FALSE;
+       Length = (wcslen (Source) + 1) * sizeof(WCHAR);
 
-        for(i=0; i<s1l; i++) {
-                if(CaseInsensitive==TRUE) {
-                        wc1=towupper(*String1->Buffer);
-                        wc2=towupper(*String2->Buffer);
-                } else {
-                        wc1=*String1->Buffer;
-                        wc2=*String2->Buffer;
-                };
+       Destination->Buffer = ExAllocatePool (NonPagedPool,
+                                             Length);
+       if (Destination->Buffer == NULL)
+               return FALSE;
 
-                if(wc1!=wc2) {
-                        String1->Buffer-=i;
-                        String2->Buffer-=i;
-                        return FALSE;
-                };
+       memmove (Destination->Buffer,
+                Source,
+                Length);
 
-                String1->Buffer++;
-                String2->Buffer++;
-        };
+       Destination->MaximumLength = Length;
+       Destination->Length = Length - sizeof (WCHAR);
 
-        String1->Buffer-=i;
-        String2->Buffer-=i;
+       return TRUE;
+}
 
-        return TRUE;
-};
 
-VOID RtlFreeAnsiString(IN PANSI_STRING AnsiString)
+BOOLEAN
+STDCALL
+RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
 {
-        ExFreePool(AnsiString->Buffer);
-};
+       unsigned long s1l=String1->Length;
+       unsigned long s2l=String2->Length;
+       unsigned long i;
+       char c1, c2;
+
+       if (s1l != s2l)
+               return FALSE;
+
+       for (i = 0; i < s1l; i++)
+       {
+               c1 = *String1->Buffer;
+               c2 = *String2->Buffer;
+
+               if (CaseInsensitive == TRUE)
+               {
+                       c1 = toupper(c1);
+                       c2 = toupper(c2);
+               }
+
+               if (c1 != c2)
+               {
+                       String1->Buffer -= i;
+                       String2->Buffer -= i;
+                       return FALSE;
+               }
+
+               String1->Buffer++;
+               String2->Buffer++;
+       }
+
+       String1->Buffer -= i;
+       String2->Buffer -= i;
+
+       return TRUE;
+}
 
-VOID RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
+
+BOOLEAN
+STDCALL
+RtlEqualUnicodeString(PUNICODE_STRING String1,
+                      PUNICODE_STRING String2,
+                      BOOLEAN CaseInsensitive)
 {
-        ExFreePool(UnicodeString->Buffer);
-};
+       unsigned long s1l = String1->Length / sizeof(WCHAR);
+       unsigned long s2l = String2->Length / sizeof(WCHAR);
+       unsigned long i;
+       WCHAR wc1, wc2;
+       PWCHAR pw1, pw2;
+
+       if (s1l != s2l)
+               return FALSE;
+
+       pw1 = String1->Buffer;
+       pw2 = String2->Buffer;
+
+       for (i = 0; i < s1l; i++)
+       {
+               if(CaseInsensitive == TRUE)
+               {
+                       wc1 = towupper (*pw1);
+                       wc2 = towupper (*pw2);
+               }
+               else
+               {
+                       wc1 = *pw1;
+                       wc2 = *pw2;
+               }
+
+               if (wc1 != wc2)
+                       return FALSE;
+
+               pw1++;
+               pw2++;
+       }
+
+       return TRUE;
+}
 
-VOID RtlInitAnsiString(IN OUT PANSI_STRING DestinationString,
-                       IN PCSZ SourceString)
+
+VOID
+STDCALL
+RtlFreeAnsiString(IN PANSI_STRING AnsiString)
 {
-        unsigned long DestSize;
+       if (AnsiString->Buffer == NULL)
+               return;
+
+       ExFreePool (AnsiString->Buffer);
+
+       AnsiString->Buffer = NULL;
+       AnsiString->Length = 0;
+       AnsiString->MaximumLength = 0;
+}
 
-        if(SourceString==NULL) {
-                DestinationString->Length=0;
-                DestinationString->MaximumLength=0;
-        } else {
-                DestSize=strlen((const char *)SourceString);
-                DestinationString->Length=DestSize;
-                DestinationString->MaximumLength=DestSize+1;
-        };
-        DestinationString->Buffer=(PCHAR)SourceString;
-};
 
-VOID RtlInitString(IN OUT PSTRING DestinationString,
-                   IN PCSZ SourceString)
+VOID
+STDCALL
+RtlFreeOemString(IN PSTRING OemString)
 {
-        DestinationString->Length=strlen((char *)SourceString);
-        DestinationString->MaximumLength=strlen((char *)SourceString)+1;
-        DestinationString->Buffer=SourceString;
-};
+       if (OemString->Buffer == NULL)
+               return;
+
+       ExFreePool (OemString->Buffer);
+
+       OemString->Buffer = NULL;
+       OemString->Length = 0;
+       OemString->MaximumLength = 0;
+}
 
-VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
-                          IN PCWSTR SourceString)
+
+VOID
+STDCALL
+RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
 {
-        unsigned long DestSize;
+       if (UnicodeString->Buffer == NULL)
+               return;
 
-        DPRINT("RtlInitUnicodeString(DestinationString %x, "
-                 "SourceString %x)\n",DestinationString,SourceString);
+       ExFreePool (UnicodeString->Buffer);
 
-        if (SourceString==NULL)
-        {
-                DestinationString->Length=0;
-                DestinationString->MaximumLength=0;
-                DestinationString->Buffer=NULL;
-        }
-        else
-        {
-                DestSize=wcslen((PWSTR)SourceString);
-                DestinationString->Length=DestSize;
-                DestinationString->MaximumLength=DestSize+1;
-                DestinationString->Buffer=(PWSTR)SourceString;
-        }
+       UnicodeString->Buffer = NULL;
+       UnicodeString->Length = 0;
+       UnicodeString->MaximumLength = 0;
 }
 
-#if 0
-NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,                    /* optional */
-                                   IN OUT PUNICODE_STRING String)
+
+VOID
+STDCALL
+RtlInitAnsiString(IN OUT PANSI_STRING DestinationString,
+                  IN PCSZ SourceString)
+{
+       ULONG DestSize;
+
+       if (SourceString == NULL)
+       {
+               DestinationString->Length = 0;
+               DestinationString->MaximumLength = 0;
+       }
+       else
+       {
+               DestSize = strlen ((const char *)SourceString);
+               DestinationString->Length = DestSize;
+               DestinationString->MaximumLength = DestSize + sizeof(CHAR);
+       }
+       DestinationString->Buffer = (PCHAR)SourceString;
+}
+
+
+VOID
+STDCALL
+RtlInitString(IN OUT PSTRING DestinationString,
+              IN PCSZ SourceString)
+{
+       ULONG DestSize;
+
+       if (SourceString == NULL)
+       {
+               DestinationString->Length = 0;
+               DestinationString->MaximumLength = 0;
+       }
+       else
+       {
+               DestSize = strlen((const char *)SourceString);
+               DestinationString->Length = DestSize;
+               DestinationString->MaximumLength = DestSize + sizeof(CHAR);
+       }
+       DestinationString->Buffer = (PCHAR)SourceString;
+}
+
+VOID
+STDCALL
+RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
+                     IN PCWSTR SourceString)
 {
+       ULONG DestSize;
+
+       DPRINT("RtlInitUnicodeString(DestinationString %x, "
+              "SourceString %x)\n",DestinationString,SourceString);
+
+       if (SourceString == NULL)
+       {
+               DestinationString->Length = 0;
+               DestinationString->MaximumLength = 0;
+       }
+       else
+       {
+               DestSize = wcslen((PWSTR)SourceString) * sizeof(WCHAR);
+               DestinationString->Length = DestSize;
+               DestinationString->MaximumLength = DestSize + sizeof(WCHAR);
+       }
+       DestinationString->Buffer = (PWSTR)SourceString;
+}
+
+
+NTSTATUS
+STDCALL
+RtlIntegerToUnicodeString(IN ULONG Value,
+                          IN ULONG Base,                    /* optional */
+                          IN OUT PUNICODE_STRING String)
+{
+        UNIMPLEMENTED;
+
+        return STATUS_NOT_IMPLEMENTED;
+#if 0
         char *str;
         unsigned long len, i;
 
@@ -385,39 +654,154 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
         ExFreePool(str);
 
         return STATUS_SUCCESS;
-}
 #endif
+}
+
 
-NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
-                                      IN PUNICODE_STRING SourceString,
-                                      IN BOOLEAN AllocateDestinationString)
+ULONG
+STDCALL
+RtlOemStringToUnicodeSize(IN PANSI_STRING OemString)
 {
-        unsigned long i;
+       ULONG Size;
 
-        if(AllocateDestinationString==TRUE) {
+       RtlMultiByteToUnicodeSize (&Size,
+                                  OemString->Buffer,
+                                  OemString->Length);
 
-                // Causes excetion 14(0) in _Validate_Free_List
-                DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length+1);
-                DestinationString->MaximumLength=SourceString->Length+1;
-        };
+       return Size;
+}
 
-        DestinationString->Length=SourceString->Length;
 
-        for(i=0; i<SourceString->Length; i++) {
-                *DestinationString->Buffer=*SourceString->Buffer;
-                DestinationString->Buffer++;
-                SourceString->Buffer++;
-        };
-        *DestinationString->Buffer=0;
+NTSTATUS
+STDCALL
+RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString,
+                            PANSI_STRING SourceString,
+                            BOOLEAN AllocateDestinationString)
+{
+       NTSTATUS Status;
+       ULONG Length;
+
+       if (NlsMbCodePageTag == TRUE)
+               Length = RtlAnsiStringToUnicodeSize (SourceString);
+       else
+               Length = SourceString->Length * sizeof(WCHAR);
+
+       if (Length > 65535)
+               return STATUS_INVALID_PARAMETER_2;
+
+       DestinationString->Length = Length;
+
+       if (AllocateDestinationString == TRUE)
+       {
+               DestinationString->MaximumLength = Length + sizeof(WCHAR);
+               DestinationString->Buffer =
+                       ExAllocatePool (NonPagedPool,
+                                       DestinationString->MaximumLength);
+               if (DestinationString->Buffer == NULL)
+                       return STATUS_NO_MEMORY;
+       }
+       else
+       {
+               if (Length > DestinationString->Length)
+                       return STATUS_BUFFER_OVERFLOW;
+       }
+
+       memset (DestinationString->Buffer,
+               0,
+               DestinationString->Length);
+
+       Status = RtlOemToUnicodeN (DestinationString->Buffer,
+                                  DestinationString->Length,
+                                  NULL,
+                                  SourceString->Buffer,
+                                  SourceString->Length);
+       if (!NT_SUCCESS(Status))
+       {
+               if (AllocateDestinationString)
+                       ExFreePool (DestinationString->Buffer);
+               return Status;
+       }
+
+       DestinationString->Buffer[Length / sizeof(WCHAR)] = 0;
+
+       return STATUS_SUCCESS;
+}
 
-        DestinationString->Buffer-=SourceString->Length;
-        SourceString->Buffer-=SourceString->Length;
 
-        return STATUS_SUCCESS;
-};
+ULONG
+STDCALL
+RtlUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString)
+{
+       ULONG Size;
+
+       RtlUnicodeToMultiByteSize (&Size,
+                                  UnicodeString->Buffer,
+                                  UnicodeString->Length);
+
+       return Size;
+}
+
+
+NTSTATUS
+STDCALL
+RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
+                             IN PUNICODE_STRING SourceString,
+                             IN BOOLEAN AllocateDestinationString)
+{
+       NTSTATUS Status;
+       ULONG Length;
+
+       if (NlsMbCodePageTag == TRUE)
+               Length = RtlUnicodeStringToAnsiSize (SourceString);
+       else
+               Length = SourceString->Length / sizeof(WCHAR);
+
+//     if (Length > 65535)
+//             return STATUS_INVALID_PARAMETER_2;
+
+       DestinationString->Length = Length;
+
+       if (AllocateDestinationString == TRUE)
+       {
+               DestinationString->MaximumLength = Length + sizeof(CHAR);
+               DestinationString->Buffer =
+                       ExAllocatePool (NonPagedPool,
+                                       DestinationString->MaximumLength);
+               if (DestinationString->Buffer == NULL)
+                       return STATUS_NO_MEMORY;
+       }
+       else
+       {
+               if (Length >= DestinationString->Length)
+                       return STATUS_BUFFER_OVERFLOW;
+       }
+
+       RtlZeroMemory (DestinationString->Buffer,
+                      DestinationString->Length);
+
+       Status = RtlUnicodeToMultiByteN (DestinationString->Buffer,
+                                        DestinationString->Length,
+                                        NULL,
+                                        SourceString->Buffer,
+                                        SourceString->Length);
+       if (!NT_SUCCESS(Status))
+       {
+               if (AllocateDestinationString)
+                       ExFreePool (DestinationString->Buffer);
+               return Status;
+       }
+
+       DestinationString->Buffer[Length] = 0;
+
+       return STATUS_SUCCESS;
+}
+
 
-NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
-                                   OUT PULONG Value)
+NTSTATUS
+STDCALL
+RtlUnicodeStringToInteger(IN PUNICODE_STRING String,
+                          IN ULONG Base,
+                          OUT PULONG Value)
 {
         char *str;
         unsigned long i, lenmin=0;
@@ -474,35 +858,112 @@ NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
    return(STATUS_SUCCESS);
 }
 
-NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
-                                IN PUNICODE_STRING SourceString,
-                                IN BOOLEAN AllocateDestinationString)
+
+ULONG
+STDCALL
+RtlUnicodeStringToOemSize(IN PUNICODE_STRING UnicodeString)
 {
-        unsigned long i;
+       ULONG Size;
 
-        if(AllocateDestinationString==TRUE) {
-                DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length*2+1);
-                DestinationString->Length=SourceString->Length;
-                DestinationString->MaximumLength=SourceString->Length+1;
-        };
+       RtlUnicodeToMultiByteSize (&Size,
+                                  UnicodeString->Buffer,
+                                  UnicodeString->Length);
+
+       return Size;
+}
 
-        for(i=0; i<SourceString->Length; i++) {
-                *DestinationString->Buffer=towupper(*SourceString->Buffer);
-                DestinationString->Buffer++;
-                SourceString->Buffer++;
-        };
-        *DestinationString->Buffer=0;
 
-        DestinationString->Buffer-=SourceString->Length;
-        SourceString->Buffer-=SourceString->Length;
+NTSTATUS
+STDCALL
+RtlUnicodeStringToOemString(IN OUT PANSI_STRING DestinationString,
+                            IN PUNICODE_STRING SourceString,
+                            IN BOOLEAN AllocateDestinationString)
+{
+       NTSTATUS Status;
+       ULONG Length;
+
+       if (NlsMbOemCodePageTag == TRUE)
+               Length = RtlUnicodeStringToAnsiSize (SourceString);
+       else
+               Length = SourceString->Length / sizeof(WCHAR);
+
+//     if (Length > 65535)
+//             return STATUS_INVALID_PARAMETER_2;
+
+       DestinationString->Length = Length;
+
+       if (AllocateDestinationString == TRUE)
+       {
+               DestinationString->MaximumLength = Length + sizeof(CHAR);
+               DestinationString->Buffer =
+                       ExAllocatePool (NonPagedPool,
+                                       DestinationString->MaximumLength);
+               if (DestinationString->Buffer == NULL)
+                       return STATUS_NO_MEMORY;
+       }
+       else
+       {
+               if (Length >= DestinationString->Length)
+                       return STATUS_BUFFER_OVERFLOW;
+       }
+
+       RtlZeroMemory (DestinationString->Buffer,
+                      DestinationString->Length);
+
+       Status = RtlUnicodeToOemN (DestinationString->Buffer,
+                                  DestinationString->Length,
+                                  NULL,
+                                  SourceString->Buffer,
+                                  SourceString->Length);
+       if (!NT_SUCCESS(Status))
+       {
+               if (AllocateDestinationString)
+                       ExFreePool (DestinationString->Buffer);
+               return Status;
+       }
+
+       DestinationString->Buffer[Length] = 0;
+
+       return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+STDCALL
+RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
+                       IN PUNICODE_STRING SourceString,
+                       IN BOOLEAN AllocateDestinationString)
+{
+        ULONG i;
+        PWCHAR Src, Dest;
+
+        if(AllocateDestinationString==TRUE)
+        {
+                DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length + sizeof(WCHAR));
+                DestinationString->Length=SourceString->Length;
+                DestinationString->MaximumLength=SourceString->Length+sizeof(WCHAR);
+        }
+
+        Src = SourceString->Buffer;
+        Dest = DestinationString->Buffer;
+        for (i=0; i < SourceString->Length / sizeof(WCHAR); i++)
+        {
+                *Dest = towupper (*Src);
+                Dest++;
+                Src++;
+        }
+        *Dest = 0;
 
         return STATUS_SUCCESS;
-};
+}
 
-VOID RtlUpcaseString(IN OUT PSTRING DestinationString,
-                     IN PSTRING SourceString)
+VOID
+STDCALL
+RtlUpcaseString(IN OUT PSTRING DestinationString,
+                IN PSTRING SourceString)
 {
         unsigned long i, len;
+        PCHAR Src, Dest;
 
         if(SourceString->Length>DestinationString->MaximumLength) {
                 len=DestinationString->MaximumLength;
@@ -520,3 +981,12 @@ VOID RtlUpcaseString(IN OUT PSTRING DestinationString,
         DestinationString->Buffer-=len;
         SourceString->Buffer-=len;
 }
+
+VOID
+STDCALL
+RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
+{
+   UNIMPLEMENTED;
+}
+
+/* EOF */
index 41a45e2..9321b1f 100644 (file)
@@ -151,11 +151,11 @@ STUB(PATHOBJ_bPolyLineTo)
 STUB(PATHOBJ_vEnumStart)
 STUB(PATHOBJ_vEnumStartClipLines)
 STUB(PATHOBJ_vGetBounds)
-STUB(RtlAnsiCharToUnicodeChar)
-STUB(RtlMultiByteToUnicodeN)
+//STUB(RtlAnsiCharToUnicodeChar)
+//STUB(RtlMultiByteToUnicodeN)
 STUB(RtlRaiseException)
-STUB(RtlUnicodeToMultiByteN)
-STUB(RtlUnicodeToMultiByteSize)
+//STUB(RtlUnicodeToMultiByteN)
+//STUB(RtlUnicodeToMultiByteSize)
 STUB(RtlUnwind)
 STUB(RtlUpcaseUnicodeChar)
 STUB(RtlUpcaseUnicodeToMultiByteN)
index 299c2f6..c022ce3 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: win32k.def,v 1.5 1999/10/23 22:40:49 rex Exp $
+; $Id: win32k.def,v 1.6 1999/11/15 16:02:00 ekohl Exp $
 ;
 ; win32k.def
 ;
@@ -155,15 +155,15 @@ PATHOBJ_vEnumStart
 PATHOBJ_vEnumStartClipLines
 PATHOBJ_vGetBounds
 ; RtlAnsiCharToUnicodeChar = NTOSKRNL.RtlAnsiCharToUnicodeChar
-RtlAnsiCharToUnicodeChar
+;RtlAnsiCharToUnicodeChar
 ; RtlMultiByteToUnicodeN = NTOSKRNL.RtlMultiByteToUnicodeN
-RtlMultiByteToUnicodeN
+;RtlMultiByteToUnicodeN
 ; RtlRaiseException = NTOSKRNL.RtlRaiseException
 RtlRaiseException
 ; RtlUnicodeToMultiByteN = NTOSKRNL.RtlUnicodeToMultiByteN
-RtlUnicodeToMultiByteN
+;RtlUnicodeToMultiByteN
 ; RtlUnicodeToMultiByteSize = NTOSKRNL.RtlUnicodeToMultiByteSize
-RtlUnicodeToMultiByteSize
+;RtlUnicodeToMultiByteSize
 ; RtlUnwind = NTOSKRNL.RtlUnwind
 RtlUnwind
 ; RtlUpcaseUnicodeChar = NTOSKRNL.RtlUpcaseUnicodeChar