From 92857818cbfda65116d12026b8565c1e869ff873 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Fri, 3 Mar 2000 00:48:50 +0000 Subject: [PATCH] Added bitmaps Added some Rtl string functions Various changes svn path=/trunk/; revision=1026 --- reactos/include/ddk/dbgfuncs.h | 5 +- reactos/include/ddk/exfuncs.h | 11 ++ reactos/include/ddk/kefuncs.h | 11 +- reactos/include/ddk/rtl.h | 24 +++- reactos/lib/ntdll/dbg/brkpoint.c | 6 +- reactos/lib/ntdll/def/ntdll.def | 12 +- reactos/lib/ntdll/def/ntdll.edf | 12 +- reactos/ntoskrnl/dbg/brkpoint.c | 8 +- reactos/ntoskrnl/hal/x86/misc.c | 46 +++++++ reactos/ntoskrnl/hal/x86/sources | 6 +- reactos/ntoskrnl/kd/kdebug.c | 13 +- reactos/ntoskrnl/ke/catch.c | 45 +++++-- reactos/ntoskrnl/ke/spinlock.c | 118 ++++++++++++++++++ reactos/ntoskrnl/makefile_rex | 14 ++- reactos/ntoskrnl/ntoskrnl.def | 62 ++++++---- reactos/ntoskrnl/ntoskrnl.edf | 41 +++++-- reactos/ntoskrnl/rtl/bitmap.c | 125 +++++++++++++++++++ reactos/ntoskrnl/rtl/nls.c | 58 ++++++--- reactos/ntoskrnl/rtl/unicode.c | 205 +++++++++++++++++++++++++++---- 19 files changed, 704 insertions(+), 118 deletions(-) create mode 100644 reactos/ntoskrnl/hal/x86/misc.c create mode 100644 reactos/ntoskrnl/ke/spinlock.c create mode 100644 reactos/ntoskrnl/rtl/bitmap.c diff --git a/reactos/include/ddk/dbgfuncs.h b/reactos/include/ddk/dbgfuncs.h index 4830c335abd..0a7f15c2e13 100644 --- a/reactos/include/ddk/dbgfuncs.h +++ b/reactos/include/ddk/dbgfuncs.h @@ -1,6 +1,7 @@ -VOID DbgBreakPoint(VOID); -ULONG DbgPrint(PCH Format,...); +VOID STDCALL DbgBreakPoint(VOID); +VOID STDCALL DbgBreakPointWithStatus (ULONG Status); +ULONG DbgPrint(PCH Format,...); #define DBG_GET_SHOW_FACILITY 0x0001 #define DBG_GET_SHOW_SEVERITY 0x0002 diff --git a/reactos/include/ddk/exfuncs.h b/reactos/include/ddk/exfuncs.h index af12a353ddf..fa395a4a01c 100644 --- a/reactos/include/ddk/exfuncs.h +++ b/reactos/include/ddk/exfuncs.h @@ -247,6 +247,17 @@ ExQueueWorkItem ( WORK_QUEUE_TYPE QueueType ); VOID +STDCALL +ExRaiseAccessViolation ( + VOID + ); +VOID +STDCALL +ExRaiseDatatypeMisalignment ( + VOID + ); +VOID +STDCALL ExRaiseStatus ( NTSTATUS Status ); diff --git a/reactos/include/ddk/kefuncs.h b/reactos/include/ddk/kefuncs.h index 7a0bbf1cc55..529e9fbb118 100644 --- a/reactos/include/ddk/kefuncs.h +++ b/reactos/include/ddk/kefuncs.h @@ -228,9 +228,18 @@ NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray, /* * FUNCTION: Raises a user mode exception * ARGUMENTS: - * ExceptionCode = Status code of the exception + * ExceptionCode = Status code of the exception */ VOID KeRaiseUserException(NTSTATUS ExceptionCode); +/* + * FUNCTION: Enters the kernel debugger + * ARGUMENTS: + * None + */ +VOID +STDCALL +KeEnterKernelDebugger (VOID); + #endif /* __INCLUDE_DDK_KEFUNCS_H */ diff --git a/reactos/include/ddk/rtl.h b/reactos/include/ddk/rtl.h index 02c2df3c3f5..667efadf532 100644 --- a/reactos/include/ddk/rtl.h +++ b/reactos/include/ddk/rtl.h @@ -1,4 +1,4 @@ -/* $Id: rtl.h,v 1.27 2000/02/21 22:36:00 ekohl Exp $ +/* $Id: rtl.h,v 1.28 2000/03/03 00:38:15 ekohl Exp $ * */ @@ -277,6 +277,12 @@ RtlCheckRegistryKey ( PWSTR Path ); +VOID +STDCALL +RtlClearAllBits ( + IN PRTL_BITMAP BitMapHeader + ); + UINT STDCALL RtlCompactHeap ( @@ -558,6 +564,14 @@ RtlInitUnicodeString ( PCWSTR SourceString ); +VOID +STDCALL +RtlInitializeBitMap ( + IN OUT PRTL_BITMAP BitMapHeader, + IN PULONG BitMapBuffer, + IN ULONG SizeOfBitMap + ); + NTSTATUS STDCALL RtlInitializeContext ( @@ -894,6 +908,12 @@ RtlSecondsSince1980ToTime ( PLARGE_INTEGER Time ); +VOID +STDCALL +RtlSetAllBits ( + IN PRTL_BITMAP BitMapHeader + ); + NTSTATUS STDCALL RtlSetDaclSecurityDescriptor ( @@ -911,12 +931,14 @@ RtlSizeHeap ( PVOID pmem ); +#if 0 PWSTR RtlStrtok ( PUNICODE_STRING _string, PWSTR _sep, PWSTR * temp ); +#endif VOID RtlStoreLong ( diff --git a/reactos/lib/ntdll/dbg/brkpoint.c b/reactos/lib/ntdll/dbg/brkpoint.c index eb3507ae672..3b5a036cf0b 100644 --- a/reactos/lib/ntdll/dbg/brkpoint.c +++ b/reactos/lib/ntdll/dbg/brkpoint.c @@ -1,4 +1,4 @@ -/* $Id: brkpoint.c,v 1.1 1999/12/29 17:12:28 ekohl Exp $ +/* $Id: brkpoint.c,v 1.2 2000/03/03 00:39:38 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -16,12 +16,12 @@ /* FUNCTIONS *****************************************************************/ -VOID DbgBreakPoint(VOID) +VOID STDCALL DbgBreakPoint(VOID) { __asm__("int $3\n\t"); } -VOID DbgUserBreakPoint(VOID) +VOID STDCALL DbgUserBreakPoint(VOID) { __asm__("int $3\n\t"); } diff --git a/reactos/lib/ntdll/def/ntdll.def b/reactos/lib/ntdll/def/ntdll.def index 45013858e09..c35c84f1c76 100644 --- a/reactos/lib/ntdll/def/ntdll.def +++ b/reactos/lib/ntdll/def/ntdll.def @@ -1,4 +1,4 @@ -; $Id: ntdll.def,v 1.42 2000/02/27 02:05:40 ekohl Exp $ +; $Id: ntdll.def,v 1.43 2000/03/03 00:40:29 ekohl Exp $ ; ; ReactOS Operating System ; @@ -7,12 +7,12 @@ LIBRARY ntdll.dll EXPORTS CsrClientCallServer@16 CsrClientConnectToServer@24 -DbgBreakPoint +DbgBreakPoint@0 DbgPrint -DbgUserBreakPoint -NlsAnsiCodePage -NlsMbCodePageTag -NlsMbOemCodePageTag +DbgUserBreakPoint@0 +NlsAnsiCodePage DATA +NlsMbCodePageTag DATA +NlsMbOemCodePageTag DATA NtAcceptConnectPort@24 NtAccessCheck@32 NtAccessCheckAndAuditAlarm@44 diff --git a/reactos/lib/ntdll/def/ntdll.edf b/reactos/lib/ntdll/def/ntdll.edf index 46ecf011ba4..90172c3f107 100644 --- a/reactos/lib/ntdll/def/ntdll.edf +++ b/reactos/lib/ntdll/def/ntdll.edf @@ -1,4 +1,4 @@ -; $Id: ntdll.edf,v 1.31 2000/02/27 02:05:40 ekohl Exp $ +; $Id: ntdll.edf,v 1.32 2000/03/03 00:40:29 ekohl Exp $ ; ; ReactOS Operating System ; @@ -7,12 +7,12 @@ LIBRARY ntdll.dll EXPORTS CsrClientCallServer=CsrClientCallServer@16 CsrClientConnectToServer=CsrClientConnectToServer@24 -DbgBreakPoint +DbgBreakPoint=DbgBreakPoint@0 DbgPrint -DbgUserBreakPoint -NlsAnsiCodePage -NlsMbCodePageTag -NlsMbOemCodePageTag +DbgUserBreakPoint=DbgUserBreakPoint@0 +NlsAnsiCodePage DATA +NlsMbCodePageTag DATA +NlsMbOemCodePageTag DATA NtAcceptConnectPort=NtAcceptConnectPort@24 NtAccessCheck=NtAccessCheck@32 NtAccessCheckAndAuditAlarm=NtAccessCheckAndAuditAlarm@44 diff --git a/reactos/ntoskrnl/dbg/brkpoint.c b/reactos/ntoskrnl/dbg/brkpoint.c index 0c577b1f221..17e5cc44b1e 100644 --- a/reactos/ntoskrnl/dbg/brkpoint.c +++ b/reactos/ntoskrnl/dbg/brkpoint.c @@ -21,8 +21,14 @@ NTSTATUS STDCALL NtSystemDebugControl(VOID) UNIMPLEMENTED; } -VOID DbgBreakPoint(VOID) +VOID STDCALL DbgBreakPoint(VOID) { __asm__("int $3\n\t"); } +VOID STDCALL DbgBreakPointWithStatus(ULONG Status) +{ + __asm__("mov %0, %%eax\n\t" + "int $3\n\t" + ::"m"(Status)); +} diff --git a/reactos/ntoskrnl/hal/x86/misc.c b/reactos/ntoskrnl/hal/x86/misc.c new file mode 100644 index 00000000000..7cdf7177972 --- /dev/null +++ b/reactos/ntoskrnl/hal/x86/misc.c @@ -0,0 +1,46 @@ +/* $Id: misc.c,v 1.1 2000/03/03 00:45:53 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: ntoskrnl/hal/x86/misc.c + * PURPOSE: Miscellaneous hardware functions + * PROGRAMMER: Eric Kohl (ekohl@rz-online.de) + */ + +/* INCLUDES *****************************************************************/ + +#include + + +/* FUNCTIONS ****************************************************************/ + +VOID +STDCALL +HalHandleNMI (ULONG Unused) +{ + UCHAR ucStatus; + + ucStatus = READ_PORT_UCHAR((PUCHAR) 0x61); + + HalDisplayString ("\n*** Hardware Malfunction\n\n"); + HalDisplayString ("Call your hardware vendor for support\n\n"); + + if (ucStatus & 0x80) + HalDisplayString ("NMI: Parity Check / Memory Parity Error\n"); + + if (ucStatus & 0x40) + HalDisplayString ("NMI: Channel Check / IOCHK\n"); + + HalDisplayString ("\n*** The system has halted ***\n"); + KeEnterKernelDebugger (); +} + +VOID +STDCALL +HalProcessorIdle (VOID) +{ + __asm__("sti\n\t" \ + "hlt\n\t"); +} + +/* EOF */ \ No newline at end of file diff --git a/reactos/ntoskrnl/hal/x86/sources b/reactos/ntoskrnl/hal/x86/sources index 035c976918b..6d43da75caf 100644 --- a/reactos/ntoskrnl/hal/x86/sources +++ b/reactos/ntoskrnl/hal/x86/sources @@ -1,7 +1,7 @@ HAL_OBJECTS = hal/x86/head.o hal/x86/irq.o hal/x86/isa.o \ hal/x86/pci.o hal/x86/irqhand.o hal/x86/halinit.o \ - hal/x86/irql.o hal/x86/bios32.o hal/x86/spinlock.o \ + hal/x86/irql.o hal/x86/bios32.o \ hal/x86/mp.o hal/x86/dma.o hal/x86/bus.o hal/x86/mbr.o \ hal/x86/sysinfo.o hal/x86/time.o hal/x86/beep.o \ - hal/x86/display.o hal/x86/reboot.o hal/x86/kdbg.o hal/x86/portio.o - + hal/x86/display.o hal/x86/reboot.o hal/x86/kdbg.o \ + hal/x86/portio.o hal/x86/misc.o diff --git a/reactos/ntoskrnl/kd/kdebug.c b/reactos/ntoskrnl/kd/kdebug.c index d50cd1c6b12..97878dd28d6 100644 --- a/reactos/ntoskrnl/kd/kdebug.c +++ b/reactos/ntoskrnl/kd/kdebug.c @@ -1,4 +1,4 @@ -/* $Id: kdebug.c,v 1.6 2000/02/27 02:09:40 ekohl Exp $ +/* $Id: kdebug.c,v 1.7 2000/03/03 00:46:37 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -129,5 +129,16 @@ KdPollBreakIn ( return KdPortPollByte(); } +VOID +STDCALL +KeEnterKernelDebugger ( + VOID + ) +{ + HalDisplayString ("\n\n *** Entered kernel debugger ***\n"); + + for (;;) + __asm__("hlt\n\t"); +} /* EOF */ diff --git a/reactos/ntoskrnl/ke/catch.c b/reactos/ntoskrnl/ke/catch.c index 77d27296b68..9b79cb43ff0 100644 --- a/reactos/ntoskrnl/ke/catch.c +++ b/reactos/ntoskrnl/ke/catch.c @@ -1,4 +1,5 @@ -/* +/* $Id: catch.c,v 1.7 2000/03/03 00:47:06 ekohl Exp $ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/catch.c @@ -14,16 +15,44 @@ /* FUNCTIONS ****************************************************************/ -VOID ExRaiseStatus(NTSTATUS Status) +VOID +STDCALL +ExRaiseAccessViolation ( + VOID + ) { - DbgPrint("ExRaiseStatus(%x)\n",Status); - for(;;); + ExRaiseStatus (STATUS_ACCESS_VIOLATION); +} + +VOID +STDCALL +ExRaiseDatatypeMisalignment ( + VOID + ) +{ + ExRaiseStatus (STATUS_DATATYPE_MISALIGNMENT); +} + +VOID +STDCALL +ExRaiseStatus ( + IN NTSTATUS Status + ) +{ + DbgPrint("ExRaiseStatus(%x)\n",Status); + for(;;); } -NTSTATUS STDCALL NtRaiseException(IN PEXCEPTION_RECORD ExceptionRecord, - IN PCONTEXT Context, - IN BOOL IsDebugger OPTIONAL) +NTSTATUS +STDCALL +NtRaiseException ( + IN PEXCEPTION_RECORD ExceptionRecord, + IN PCONTEXT Context, + IN BOOL IsDebugger OPTIONAL + ) { - UNIMPLEMENTED; + UNIMPLEMENTED; } + +/* EOF */ diff --git a/reactos/ntoskrnl/ke/spinlock.c b/reactos/ntoskrnl/ke/spinlock.c new file mode 100644 index 00000000000..05d1c094e32 --- /dev/null +++ b/reactos/ntoskrnl/ke/spinlock.c @@ -0,0 +1,118 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: ntoskrnl/hal/x86/spinlock.c + * PURPOSE: Implements spinlocks + * PROGRAMMER: David Welch (welch@cwcom.net) + * UPDATE HISTORY: + * 3/6/98: Created + */ + +/* + * NOTE: On a uniprocessor machine spinlocks are implemented by raising + * the irq level + */ + +/* INCLUDES ****************************************************************/ + +#include + +#include + +/* FUNCTIONS ***************************************************************/ + +BOOLEAN KeSynchronizeExecution(PKINTERRUPT Interrupt, + PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, + PVOID SynchronizeContext) +/* + * FUNCTION: Synchronizes the execution of a given routine with the ISR + * of a given interrupt object + * ARGUMENTS: + * Interrupt = Interrupt object to synchronize with + * SynchronizeRoutine = Routine to call whose execution is + * synchronized with the ISR + * SynchronizeContext = Parameter to pass to the synchronized routine + * RETURNS: TRUE if the operation succeeded + */ +{ + KIRQL oldlvl; + BOOLEAN ret; + + KeRaiseIrql(Interrupt->SynchLevel,&oldlvl); + KeAcquireSpinLockAtDpcLevel(Interrupt->IrqLock); + + ret = SynchronizeRoutine(SynchronizeContext); + + KeReleaseSpinLockFromDpcLevel(Interrupt->IrqLock); + KeLowerIrql(oldlvl); + + return(ret); +} + +VOID KeInitializeSpinLock(PKSPIN_LOCK SpinLock) +/* + * FUNCTION: Initalizes a spinlock + * ARGUMENTS: + * SpinLock = Caller supplied storage for the spinlock + */ +{ + SpinLock->Lock = 0; +} + +VOID KeAcquireSpinLockAtDpcLevel(PKSPIN_LOCK SpinLock) +/* + * FUNCTION: Acquires a spinlock when the caller is already running at + * dispatch level + * ARGUMENTS: + * SpinLock = Spinlock to acquire + */ +{ + ULONG i; + + while ((i = InterlockedExchange(&SpinLock->Lock, 1)) == 1) + { + DbgPrint("Spinning on spinlock %x current value %x\n", SpinLock, i); + KeBugCheck(0); + } +} + +VOID KeReleaseSpinLockFromDpcLevel(PKSPIN_LOCK SpinLock) +/* + * FUNCTION: Releases a spinlock when the caller was running at dispatch + * level before acquiring it + * ARGUMENTS: + * SpinLock = Spinlock to release + */ +{ + if (SpinLock->Lock != 1) + { + DbgPrint("Releasing unacquired spinlock %x\n", SpinLock); + KeBugCheck(0); + } + (void)InterlockedExchange(&SpinLock->Lock, 0); +} + +VOID KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql) +/* + * FUNCTION: Acquires a spinlock + * ARGUMENTS: + * SpinLock = Spinlock to acquire + * OldIrql (OUT) = Caller supplied storage for the previous irql + */ +{ + KeRaiseIrql(DISPATCH_LEVEL,OldIrql); + KeAcquireSpinLockAtDpcLevel(SpinLock); +} + +VOID KeReleaseSpinLock(PKSPIN_LOCK SpinLock, KIRQL NewIrql) +/* + * FUNCTION: Releases a spinlock + * ARGUMENTS: + * SpinLock = Spinlock to release + * NewIrql = Irql level before acquiring the spinlock + */ +{ + KeReleaseSpinLockFromDpcLevel(SpinLock); + KeLowerIrql(NewIrql); +} + diff --git a/reactos/ntoskrnl/makefile_rex b/reactos/ntoskrnl/makefile_rex index 98828385739..6e36a83b6af 100644 --- a/reactos/ntoskrnl/makefile_rex +++ b/reactos/ntoskrnl/makefile_rex @@ -1,4 +1,4 @@ -# $Id: makefile_rex,v 1.55 2000/03/01 22:52:27 ea Exp $ +# $Id: makefile_rex,v 1.56 2000/03/03 00:43:28 ekohl Exp $ # # ReactOS Operating System # @@ -6,6 +6,7 @@ TARGET=ntoskrnl BASE_CFLAGS = -I../include -D__NTOSKRNL__ + all: objects $(TARGET).exe # @@ -22,12 +23,12 @@ RTL_OBJECTS = rtl/ctype.o rtl/interlck.o rtl/largeint.o rtl/list.o \ rtl/memmove.o rtl/memset.o rtl/nls.o rtl/regio.o \ rtl/return.o rtl/slist.o rtl/sprintf.o rtl/swprintf.o \ rtl/stdlib.o rtl/string.o rtl/time.o rtl/unalign.o \ - rtl/unicode.o rtl/wstring.o + rtl/unicode.o rtl/wstring.o rtl/bitmap.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 \ ke/sem.o ke/critical.o ke/event.o ke/apc.o ke/bug.o \ - ke/mutex.o ke/kernel.o ke/ldt.o \ + ke/mutex.o ke/kernel.o ke/ldt.o ke/spinlock.o\ ke/process.o ke/gdt.o ke/idt.o ke/udelay.o KE_I386_OBJECTS = ke/i386/thread.o ke/i386/usercall.o ke/i386/exp.o @@ -143,23 +144,24 @@ OBJECTS = objects/hal.o objects/ke.o objects/rtl.o objects/mm.o \ objects/io.o objects/ob.o objects/ps.o objects/ex.o \ objects/se.o objects/cm.o objects/dbg.o objects/nt.o \ objects/cc.o objects/kd.o objects/ldr.o objects/fs.o \ - objects/po.o objects/nls.o \ + objects/po.o objects/nls.o \ $(TARGET).coff ifeq ($(DOSCLI),yes) CLEAN_FILES = objects\*.o cc\*.o cm\*.o dbg\*.o ex\*.o hal\x86\*.o io\*.o \ ke\*.o ldr\*.o mm\*.o nt\*.o ob\*.o ps\*.o rtl\*.o se\*.o \ - ke\i386\*.o mm\i386\*.o fs\*.o po\*.o nls\*.o \ + ke\i386\*.o mm\i386\*.o fs\*.o po\*.o nls\*.o \ kd\*.o utils\export\export.exe $(TARGET).o $(TARGET).a junk.tmp \ base.tmp temp.exp $(TARGET).exe $(TARGET).sym $(TARGET).coff else CLEAN_FILES = objects/*.o cc/*.o cm/*.o dbg/*.o ex/*.o hal/x86/*.o io/*.o \ ke/*.o ldr/*.o mm/*.o nt/*.o ob/*.o ps/*.o rtl/*.o se/*.o \ - ke/i386/*.o mm/i386/*.o fs/*.o po/*.o nls/*.o \ + ke/i386/*.o mm/i386/*.o fs/*.o po/*.o nls/*.o \ kd/*.o utils/export/export $(TARGET).o $(TARGET).a junk.tmp \ base.tmp temp.exp $(TARGET).exe $(TARGET).sym $(TARGET).coff endif + $(TARGET).exe: $(OBJECTS) $(TARGET).def $(LD) \ -r $(OBJECTS) \ diff --git a/reactos/ntoskrnl/ntoskrnl.def b/reactos/ntoskrnl/ntoskrnl.def index c6ec1bddc69..4d943124eb6 100644 --- a/reactos/ntoskrnl/ntoskrnl.def +++ b/reactos/ntoskrnl/ntoskrnl.def @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.def,v 1.48 2000/03/01 22:52:27 ea Exp $ +; $Id: ntoskrnl.def,v 1.49 2000/03/03 00:43:28 ekohl Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -10,6 +10,8 @@ CcInitializeFileCache@8 CcRequestCachePage@20 CcReleaseCachePage@12 CcReleaseFileCache@8 +DbgBreakPoint@0 +DbgBreakPointWithStatus@4 DbgPrint ExAcquireResourceExclusive ExAcquireResourceExclusiveLite @@ -66,7 +68,9 @@ ExIsResourceAcquiredSharedLite ExLocalTimeToSystemTime ExQueryDepthSListHead ExQueueWorkItem -ExRaiseStatus +ExRaiseAccessViolation@0 +ExRaiseDatatypeMisalignment@0 +ExRaiseStatus@4 ExReinitializeResourceLite ExReleaseFastMutexUnsafe ExReleaseResource @@ -167,6 +171,7 @@ KeBugCheck KeBugCheckEx KeClearEvent KeDelayExecutionThread@12 +KeEnterKernelDebugger@0 KeFlushIoBuffers KeGetPreviousMode KeInitializeDpc @@ -183,8 +188,11 @@ KeSynchronizeExecution KeWaitForSingleObject MmGetSystemAddressForMdl MmMapIoSpace -NlsMbCodePageTag -NlsMbOemCodePageTag +NlsAnsiCodePage DATA +NlsLeadByteInfo DATA +NlsMbCodePageTag DATA +NlsMbOemCodePageTag DATA +NlsOemLeadByteInfo DATA NtAddAtom@8 NtAdjustPrivilegesToken@24 NtAllocateLocallyUniqueId@4 @@ -243,7 +251,7 @@ READ_REGISTER_USHORT READ_REGISTER_BUFFER_UCHAR READ_REGISTER_BUFFER_ULONG READ_REGISTER_BUFFER_USHORT -;RtlAbsoluteToSelfRelativeSD +RtlAbsoluteToSelfRelativeSD@12 ;RtlAddAccessAllowedAce ;RtlAddAce ;RtlAddAtomToAtomTable @@ -264,8 +272,8 @@ RtlAppendUnicodeToString@8 ;RtlCaptureStackBackTrace RtlCharToInteger@12 ;RtlCheckRegistryKey -;RtlClearAllBits -;RtlClearBits +RtlClearAllBits@4 +RtlClearBits@12 RtlCompareMemory@12 RtlCompareMemoryUlong@12 RtlCompareString@12 @@ -283,7 +291,7 @@ RtlCopyUnicodeString@8 ;RtlCreateAtomTable ;RtlCreateHeap ;RtlCreateRegistryKey -;RtlCreateSecurityDescriptor +RtlCreateSecurityDescriptor@8 RtlCreateUnicodeString@8 ;RtlCustomCPToUnicodeN ;RtlDecompressBuffer @@ -331,17 +339,17 @@ RtlFreeUnicodeString@4 ;RtlGenerate8dot3Name ;RtlGetCallersAddress ;RtlGetCompressionWorkSpaceSize -;RtlGetDaclSecurityDescriptor +RtlGetDaclSecurityDescriptor@16 RtlGetDefaultCodePage@8 ;RtlGetElementGenericTable -;RtlGetGroupSecurityDescriptor -;RtlGetOwnerSecurityDescriptor -;RtlImageNtHeader@4 +RtlGetGroupSecurityDescriptor@12 +RtlGetOwnerSecurityDescriptor@12 +;RtlImageNtHeader RtlInitAnsiString@8 ;RtlInitCodePageTable RtlInitString@8 RtlInitUnicodeString@8 -;RtlInitializeBitmap +RtlInitializeBitMap@12 ;RtlInitializeGenericTable RtlInitializeSid@12 ;RtlInitializeUnicodePrefix @@ -358,7 +366,7 @@ RtlLargeIntegerShiftLeft@12 RtlLargeIntegerShiftRight@12 RtlLargeIntegerSubtract@16 RtlLengthRequiredSid@4 -;RtlLengthRequiredSecurityDescriptor +RtlLengthSecurityDescriptor@4 RtlLengthSid@4 ;RtlLookupAtomInAtomTable ;RtlLookupElementGenericTable @@ -372,14 +380,14 @@ RtlMultiByteToUnicodeSize@12 ;RtlNumberGenericTableElements ;RtlNumberOfClearBits ;RtlNumberOfSetBits -;RtlOemStringToCountedUnicodeString +RtlOemStringToCountedUnicodeString@12 RtlOemStringToUnicodeSize@4 RtlOemStringToUnicodeString@12 RtlOemToUnicodeN@20 ;RtlPinAtomInAtomTable ;RtlPrefixString ;RtlPrefixUnicodeString -;RtlQueryAtominAtomTable +;RtlQueryAtomInAtomTable ;RtlQueryRegistryValues ;RtlQueryTimeZoneInformation ;RtlRaiseException @@ -388,11 +396,11 @@ RtlOemToUnicodeN@20 ;RtlReserveChunk RtlSecondsSince1970ToTime@8 RtlSecondsSince1980ToTime@8 -;RtlSetAllBits -;RtlSetBits -;RtlSetDaclSecurityDescriptor -;RtlSetGroupSecurityDescriptor -;RtlSetOwnerSecurityDescriptor +RtlSetAllBits@4 +RtlSetBits@12 +RtlSetDaclSecurityDescriptor@16 +RtlSetGroupSecurityDescriptor@12 +RtlSetOwnerSecurityDescriptor@12 ;RtlSetSaclSecurityDescriptor ;RtlSetTimeZoneInformation ;RtlSplay @@ -404,7 +412,7 @@ RtlTimeToSecondsSince1980@8 RtlTimeToTimeFields@8 RtlUnicodeStringToAnsiSize@4 RtlUnicodeStringToAnsiString@12 -;RtlUnicodeStringToCountedOemString +RtlUnicodeStringToCountedOemString@12 RtlUnicodeStringToInteger@12 RtlUnicodeStringToOemSize@4 RtlUnicodeStringToOemString@12 @@ -416,14 +424,14 @@ RtlUnicodeToOemN@20 RtlUpcaseUnicodeChar@4 RtlUpcaseUnicodeString@12 RtlUpcaseUnicodeStringToAnsiString@12 -;RtlUpcaseUnicodeStringToCountedOemString +RtlUpcaseUnicodeStringToCountedOemString@12 RtlUpcaseUnicodeStringToOemString@12 ;RtlUpcaseUnicodeToCustomCPN RtlUpcaseUnicodeToMultiByteN@20 RtlUpcaseUnicodeToOemN@20 RtlUpperChar@4 RtlUpperString@8 -;RtlValidSecurityDescriptor +RtlValidSecurityDescriptor@4 RtlValidSid@4 ;RtlWriteRegistryValue ;RtlZeroHeap @@ -600,7 +608,7 @@ wctomb ; exports from hal.dll ; ; -;ExAcquireFastMutex +ExAcquireFastMutex ExReleaseFastMutex ExTryToAcquireFastMutex HalAcquireDisplayOwnership @@ -624,11 +632,11 @@ HalDisplayString HalGetBusDataByOffset ;HalGetEnvironmentVariable HalGetInterruptVector -;HalHandleNMI +HalHandleNMI@4 HalInitSystem ;HalInitializeProcessor HalMakeBeep -;HalProcessorIdle +HalProcessorIdle@0 HalQueryDisplayParameters HalQueryRealTimeClock ;HalReadDmaCounter diff --git a/reactos/ntoskrnl/ntoskrnl.edf b/reactos/ntoskrnl/ntoskrnl.edf index f1764b4b396..6b9cc3b5a81 100644 --- a/reactos/ntoskrnl/ntoskrnl.edf +++ b/reactos/ntoskrnl/ntoskrnl.edf @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.edf,v 1.35 2000/03/01 22:52:27 ea Exp $ +; $Id: ntoskrnl.edf,v 1.36 2000/03/03 00:43:29 ekohl Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -10,6 +10,8 @@ CcInitializeFileCache=CcInitializeFileCache@8 CcRequestCachePage=CcRequestCachePage@20 CcReleaseCachePage=CcReleaseCachePage@12 CcReleaseFileCache=CcReleaseFileCache@8 +DbgBreakPoint=DbgBreakPoint@0 +DbgBreakPointWithStatus=DbgBreakPointWithStatus@4 DbgPrint ExAcquireResourceExclusive ExAcquireResourceExclusiveLite @@ -66,7 +68,9 @@ ExIsResourceAcquiredSharedLite ExLocalTimeToSystemTime ExQueryDepthSListHead ExQueueWorkItem -ExRaiseStatus +ExRaiseAccessViolation=ExRaiseAccessViolation@0 +ExRaiseDatatypeMisalignment=ExRaiseDatatypeMisalignment@0 +ExRaiseStatus=ExRaiseStatus@4 ExReinitializeResourceLite ExReleaseFastMutexUnsafe ExReleaseResource @@ -167,6 +171,7 @@ KeBugCheck KeBugCheckEx KeClearEvent KeDelayExecutionThread=KeDelayExecutionThread@12 +KeEnterKernelDebugger=KeEnterKernelDebugger@0 KeFlushIoBuffers KeGetPreviousMode KeInitializeDpc @@ -183,8 +188,11 @@ KeSynchronizeExecution KeWaitForSingleObject MmGetSystemAddressForMdl MmMapIoSpace -NlsMbCodePageTag -NlsMbOemCodePageTag +NlsAnsiCodePage DATA +NlsLeadByteInfo DATA +NlsMbCodePageTag DATA +NlsMbOemCodePageTag DATA +NlsOemLeadByteInfo DATA NtAddAtom=NtAddAtom@8 NtAdjustPrivilegesToken=NtAdjustPrivilegesToken@24 NtAllocateLocallyUniqueId=NtAllocateLocallyUniqueId@4 @@ -243,6 +251,7 @@ READ_REGISTER_USHORT READ_REGISTER_BUFFER_UCHAR READ_REGISTER_BUFFER_ULONG READ_REGISTER_BUFFER_USHORT +RtlAbsoluteToSelfRelativeSD=RtlAbsoluteToSelfRelativeSD@12 RtlAnsiCharToUnicodeChar=RtlAnsiCharToUnicodeChar@4 RtlAnsiStringToUnicodeSize=RtlAnsiStringToUnicodeSize@4 RtlAnsiStringToUnicodeString=RtlAnsiStringToUnicodeString@12 @@ -251,6 +260,8 @@ RtlAppendStringToString=RtlAppendStringToString@8 RtlAppendUnicodeStringToString=RtlAppendUnicodeStringToString@8 RtlAppendUnicodeToString=RtlAppendUnicodeToString@8 RtlCharToInteger=RtlCharToInteger@12 +RtlClearAllBits=RtlClearAllBits@4 +RtlClearBits=RtlClearBits@12 RtlCompareMemory=RtlCompareMemory@12 RtlCompareMemoryUlong=RtlCompareMemoryUlong@12 RtlCompareString=RtlCompareString@12 @@ -261,6 +272,7 @@ RtlCopyLuid=RtlCopyLuid@8 RtlCopySid=RtlCopySid@12 RtlCopyString=RtlCopyString@8 RtlCopyUnicodeString=RtlCopyUnicodeString@8 +RtlCreateSecurityDescriptor=RtlCreateSecurityDescriptor@8 RtlCreateUnicodeString=RtlCreateUnicodeString@8 RtlDowncaseUnicodeString=RtlDowncaseUnicodeString@12 RtlEnlargedIntegerMultiply=RtlEnlargedIntegerMultiply@8 @@ -278,11 +290,14 @@ RtlFillMemoryUlong=RtlFillMemoryUlong@12 RtlFreeAnsiString=RtlFreeAnsiString@4 RtlFreeOemString=RtlFreeOemString@4 RtlFreeUnicodeString=RtlFreeUnicodeString@4 +RtlGetDaclSecurityDescriptor=RtlGetDaclSecurityDescriptor@16 RtlGetDefaultCodePage=RtlGetDefaultCodePage@8 -;RtlImageNtHeader=RtlImageNtHeader@4 +RtlGetGroupSecurityDescriptor=RtlGetGroupSecurityDescriptor@12 +RtlGetOwnerSecurityDescriptor=RtlGetOwnerSecurityDescriptor@12 RtlInitAnsiString=RtlInitAnsiString@8 RtlInitString=RtlInitString@8 RtlInitUnicodeString=RtlInitUnicodeString@8 +RtlInitializeBitMap=RtlInitializeBitMap@12 RtlInitializeSid=RtlInitializeSid@12 RtlIntegerToChar=RtlIntegerToChar@16 RtlIntegerToUnicodeString=RtlIntegerToUnicodeString@12 @@ -294,14 +309,21 @@ RtlLargeIntegerShiftLeft=RtlLargeIntegerShiftLeft@12 RtlLargeIntegerShiftRight=RtlLargeIntegerShiftRight@12 RtlLargeIntegerSubtract=RtlLargeIntegerSubtract@16 RtlLengthRequiredSid=RtlLengthRequiredSid@4 +RtlLengthSecurityDescriptor=RtlLengthSecurityDescriptor@4 RtlLengthSid=RtlLengthSid@4 RtlMoveMemory=RtlMoveMemory@12 RtlMultiByteToUnicodeN=RtlMultiByteToUnicodeN@20 RtlMultiByteToUnicodeSize=RtlMultiByteToUnicodeSize@12 +RtlOemStringToCountedUnicodeString=RtlOemStringToCountedUnicodeString@12 RtlOemStringToUnicodeSize=RtlOemStringToUnicodeSize@4 RtlOemStringToUnicodeString=RtlOemStringToUnicodeString@12 RtlSecondsSince1970ToTime=RtlSecondsSince1970ToTime@8 RtlSecondsSince1980ToTime=RtlSecondsSince1980ToTime@8 +RtlSetAllBits=RtlSetAllBits@4 +RtlSetBits=RtlSetBits@12 +RtlSetDaclSecurityDescriptor=RtlSetDaclSecurityDescriptor@16 +RtlSetGroupSecurityDescriptor=RtlSetGroupSecurityDescriptor@12 +RtlSetOwnerSecurityDescriptor=RtlSetOwnerSecurityDescriptor@12 RtlSubAuthorityCountSid=RtlSubAuthorityCountSid@4 RtlSubAuthoritySid=RtlSubAuthoritySid@8 RtlTimeFieldsToTime=RtlTimeFieldsToTime@8 @@ -310,6 +332,7 @@ RtlTimeToSecondsSince1980=RtlTimeToSecondsSince1980@8 RtlTimeToTimeFields=RtlTimeToTimeFields@8 RtlUnicodeStringToAnsiSize=RtlUnicodeStringToAnsiSize@4 RtlUnicodeStringToAnsiString=RtlUnicodeStringToAnsiString@12 +RtlUnicodeStringToCountedOemString=RtlUnicodeStringToCountedOemString@12 RtlUnicodeStringToInteger=RtlUnicodeStringToInteger@12 RtlUnicodeStringToOemSize=RtlUnicodeStringToOemSize@4 RtlUnicodeStringToOemString=RtlUnicodeStringToOemString@12 @@ -318,11 +341,13 @@ RtlUnicodeToMultiByteSize=RtlUnicodeToMultiByteSize@12 RtlUpcaseUnicodeChar=RtlUpcaseUnicodeChar@4 RtlUpcaseUnicodeString=RtlUpcaseUnicodeString@12 RtlUpcaseUnicodeStringToAnsiString=RtlUpcaseUnicodeStringToAnsiString@12 +RtlUpcaseUnicodeStringToCountedOemString=RtlUpcaseUnicodeStringToCountedOemString@12 RtlUpcaseUnicodeStringToOemString=RtlUpcaseUnicodeStringToOemString@12 RtlUpcaseUnicodeToMultiByteN=RtlUpcaseUnicodeToMultiByteN@20 RtlUpcaseUnicodeToOemN=RtlUpcaseUnicodeToOemN@20 RtlUpperChar=RtlUpperChar@4 RtlUpperString=RtlUpperString@8 +RtlValidSecurityDescriptor=RtlValidSecurityDescriptor@4 RtlValidSid=RtlValidSid@4 RtlZeroMemory=RtlZeroMemory@8 RtlxAnsiStringToUnicodeSize=RtlxAnsiStringToUnicodeSize@4 @@ -497,7 +522,7 @@ wctomb ; exports from hal.dll ; ; -;ExAcquireFastMutex +ExAcquireFastMutex ExReleaseFastMutex ExTryToAcquireFastMutex HalAcquireDisplayOwnership @@ -521,11 +546,11 @@ HalDisplayString HalGetBusDataByOffset ;HalGetEnvironmentVariable HalGetInterruptVector -;HalHandleNMI +HalHandleNMI=HalHandleNMI@4 HalInitSystem ;HalInitializeProcessor HalMakeBeep -;HalProcessorIdle +HalProcessorIdle=HalProcessorIdle@0 HalQueryDisplayParameters HalQueryRealTimeClock ;HalReadDmaCounter diff --git a/reactos/ntoskrnl/rtl/bitmap.c b/reactos/ntoskrnl/rtl/bitmap.c new file mode 100644 index 00000000000..f832aa400d0 --- /dev/null +++ b/reactos/ntoskrnl/rtl/bitmap.c @@ -0,0 +1,125 @@ +/* $Id: bitmap.c,v 1.1 2000/03/03 00:48:50 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: ntoskrnl/rtl/bitmap.c + * PURPOSE: Bitmap functions + * UPDATE HISTORY: + * 20/08/99 Created by Eric Kohl + */ + +#include + + +#define ALIGN(x,align) (((x)+(align)-1) / (align)) + + +VOID +STDCALL +RtlInitializeBitMap ( + PRTL_BITMAP BitMapHeader, + PULONG BitMapBuffer, + ULONG SizeOfBitMap + ) +{ + BitMapHeader->SizeOfBitMap = SizeOfBitMap; + BitMapHeader->Buffer = BitMapBuffer; +} + + +VOID +STDCALL +RtlClearAllBits ( + IN OUT PRTL_BITMAP BitMapHeader + ) +{ + memset (BitMapHeader->Buffer, + 0x00, + ALIGN(BitMapHeader->SizeOfBitMap, 8)); +} + + +VOID +STDCALL +RtlClearBits ( + PRTL_BITMAP BitMapHeader, + ULONG StartingIndex, + ULONG NumberToClear + ) +{ + ULONG Size = BitMapHeader->SizeOfBitMap; + ULONG n; + ULONG shift; + PCHAR p; + + if (StartingIndex >= Size || NumberToClear == 0) + return; + + if (StartingIndex + NumberToClear > Size) + NumberToClear = Size - StartingIndex; + + p = (PCHAR)(BitMapHeader->Buffer + (StartingIndex / 8)); + while (NumberToClear) + { + /* bit shift in current byte */ + shift = StartingIndex & 7; + + /* number of bits to change in current byte */ + n = (NumberToClear > 8 - shift ) ? 8 - shift : NumberToClear; + + /* adjust byte */ + *p++ &= ~(~(0xFF << n) << shift); + NumberToClear -= n; + StartingIndex += n; + } +} + + +VOID +STDCALL +RtlSetAllBits ( + IN OUT PRTL_BITMAP BitMapHeader + ) +{ + memset (BitMapHeader->Buffer, + 0xFF, + ALIGN(BitMapHeader->SizeOfBitMap, 8)); +} + +VOID +STDCALL +RtlSetBits ( + PRTL_BITMAP BitMapHeader, + ULONG StartingIndex, + ULONG NumberToSet + ) +{ + ULONG Size = BitMapHeader->SizeOfBitMap; + ULONG n; + ULONG shift; + PCHAR p; + + if (StartingIndex >= Size || NumberToSet == 0) + return; + + if (StartingIndex + NumberToSet > Size) + NumberToSet = Size - StartingIndex; + + p = (PCHAR)BitMapHeader->Buffer + (StartingIndex / 8); + while (NumberToSet) + { + /* bit shift in current byte */ + shift = StartingIndex & 7; + + /* number of bits to change in current byte */ + n = (NumberToSet > 8 - shift) ? 8 - shift : NumberToSet; + + /* adjust byte */ + *p++ |= ~( 0xFF << n ) << shift; + NumberToSet -= n; + StartingIndex += n; + } +} + + +/* EOF */ diff --git a/reactos/ntoskrnl/rtl/nls.c b/reactos/ntoskrnl/rtl/nls.c index 64d96b27a7e..778ca261ec0 100644 --- a/reactos/ntoskrnl/rtl/nls.c +++ b/reactos/ntoskrnl/rtl/nls.c @@ -1,4 +1,4 @@ -/* $Id: nls.c,v 1.2 1999/11/20 21:45:20 ekohl Exp $ +/* $Id: nls.c,v 1.3 2000/03/03 00:48:50 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -54,6 +54,11 @@ CHAR UnicodeToOemTable [65536]; /* FUNCTIONS *****************************************************************/ +/* + * RtlCustomCPToUnicodeN + */ + + VOID STDCALL RtlGetDefaultCodePage ( @@ -138,11 +143,12 @@ RtlMultiByteToUnicodeSize ( NTSTATUS STDCALL -RtlOemToUnicodeN(PWCHAR UnicodeString, - ULONG UnicodeSize, - PULONG ResultSize, - PCHAR OemString, - ULONG OemSize) +RtlOemToUnicodeN ( + PWCHAR UnicodeString, + ULONG UnicodeSize, + PULONG ResultSize, + PCHAR OemString, + ULONG OemSize) { ULONG Size = 0; ULONG i; @@ -180,13 +186,19 @@ RtlOemToUnicodeN(PWCHAR UnicodeString, } +/* + * RtlUnicodeToCustomCPN + */ + + NTSTATUS STDCALL -RtlUnicodeToMultiByteN(PCHAR MbString, - ULONG MbSize, - PULONG ResultSize, - PWCHAR UnicodeString, - ULONG UnicodeSize) +RtlUnicodeToMultiByteN ( + PCHAR MbString, + ULONG MbSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize) { ULONG Size = 0; ULONG i; @@ -226,9 +238,10 @@ RtlUnicodeToMultiByteN(PCHAR MbString, NTSTATUS STDCALL -RtlUnicodeToMultiByteSize(PULONG MbSize, - PWCHAR UnicodeString, - ULONG UnicodeSize) +RtlUnicodeToMultiByteSize ( + PULONG MbSize, + PWCHAR UnicodeString, + ULONG UnicodeSize) { if (NlsMbCodePageTag == FALSE) { @@ -248,11 +261,12 @@ RtlUnicodeToMultiByteSize(PULONG MbSize, NTSTATUS STDCALL -RtlUnicodeToOemN(PCHAR OemString, - ULONG OemSize, - PULONG ResultSize, - PWCHAR UnicodeString, - ULONG UnicodeSize) +RtlUnicodeToOemN ( + PCHAR OemString, + ULONG OemSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize) { ULONG Size = 0; ULONG i; @@ -290,6 +304,11 @@ RtlUnicodeToOemN(PCHAR OemString, } +/* + * RtlUpcaseUnicodeToCustomCPN + */ + + NTSTATUS STDCALL RtlUpcaseUnicodeToMultiByteN ( @@ -383,5 +402,4 @@ RtlUpcaseUnicodeToOemN ( return STATUS_SUCCESS; } - /* EOF */ diff --git a/reactos/ntoskrnl/rtl/unicode.c b/reactos/ntoskrnl/rtl/unicode.c index a4d13a92aee..47d2ab3b301 100644 --- a/reactos/ntoskrnl/rtl/unicode.c +++ b/reactos/ntoskrnl/rtl/unicode.c @@ -1,4 +1,4 @@ -/* $Id: unicode.c,v 1.13 2000/02/19 19:31:18 ekohl Exp $ +/* $Id: unicode.c,v 1.14 2000/03/03 00:48:50 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -480,11 +480,6 @@ RtlCreateUnicodeStringFromAsciiz ( } -/* -RtlCustomCPToUnicodeN -*/ - - NTSTATUS STDCALL RtlDowncaseUnicodeString ( @@ -627,11 +622,6 @@ RtlEqualUnicodeString ( } -/* -RtlEraseUnicodeString -*/ - - VOID STDCALL RtlFreeAnsiString ( @@ -838,9 +828,61 @@ RtlIntegerToUnicodeString ( } -/* -RtlOemStringToCountedUnicodeString -*/ +NTSTATUS +STDCALL +RtlOemStringToCountedUnicodeString ( + IN OUT PUNICODE_STRING DestinationString, + IN POEM_STRING SourceString, + IN 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; + + 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->MaximumLength) + return STATUS_BUFFER_TOO_SMALL; + } + DestinationString->Length = Length; + + RtlZeroMemory (DestinationString->Buffer, + 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; +} ULONG @@ -982,9 +1024,68 @@ RtlUnicodeStringToAnsiString ( } -/* -RtlUnicodeStringToCountedOemString -*/ +NTSTATUS +STDCALL +RtlUnicodeStringToCountedOemString ( + IN OUT POEM_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) +{ + NTSTATUS Status; + ULONG Length; + ULONG Size; + + if (NlsMbOemCodePageTag == TRUE) + Length = RtlUnicodeStringToAnsiSize (SourceString) + 1; + else + Length = SourceString->Length / sizeof(WCHAR) + 1; + + if (Length > 0x0000FFFF) + return STATUS_INVALID_PARAMETER_2; + + DestinationString->Length = (WORD)(Length - 1); + + if (AllocateDestinationString) + { + DestinationString->Buffer = ExAllocatePool (NonPagedPool, + Length); + + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + + RtlZeroMemory (DestinationString->Buffer, + Length); + DestinationString->MaximumLength = (WORD)Length; + } + else + { + if (Length > DestinationString->MaximumLength) + { + if (DestinationString->MaximumLength == 0) + return STATUS_BUFFER_OVERFLOW; + DestinationString->Length = + DestinationString->MaximumLength - 1; + } + } + + Status = RtlUnicodeToOemN (DestinationString->Buffer, + DestinationString->Length, + &Size, + SourceString->Buffer, + SourceString->Length); + if (!NT_SUCCESS(Status)) + { + if (AllocateDestinationString) + ExFreePool (DestinationString->Buffer); + + return Status; + } + + DestinationString->Buffer[Size] = 0; + + return STATUS_SUCCESS; +} NTSTATUS @@ -1258,9 +1359,68 @@ RtlUpcaseUnicodeStringToAnsiString ( } -/* -RtlUpcaseUnicodeStringToCountedOemString -*/ +NTSTATUS +STDCALL +RtlUpcaseUnicodeStringToCountedOemString ( + IN OUT POEM_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) +{ + NTSTATUS Status; + ULONG Length; + ULONG Size; + + if (NlsMbCodePageTag == TRUE) + Length = RtlUnicodeStringToAnsiSize (SourceString) + 1; + else + Length = SourceString->Length / sizeof(WCHAR) + 1; + + if (Length > 0x0000FFFF) + return STATUS_INVALID_PARAMETER_2; + + DestinationString->Length = (WORD)(Length - 1); + + if (AllocateDestinationString == TRUE) + { + DestinationString->Buffer = ExAllocatePool (NonPagedPool, + Length); + + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + + RtlZeroMemory (DestinationString->Buffer, + Length); + DestinationString->MaximumLength = (WORD)Length; + } + else + { + if (Length > DestinationString->MaximumLength) + { + if (DestinationString->MaximumLength == 0) + return STATUS_BUFFER_OVERFLOW; + DestinationString->Length = + DestinationString->MaximumLength - 1; + } + } + + Status = RtlUpcaseUnicodeToOemN (DestinationString->Buffer, + DestinationString->Length, + &Size, + SourceString->Buffer, + SourceString->Length); + if (!NT_SUCCESS(Status)) + { + if (AllocateDestinationString) + ExFreePool (DestinationString->Buffer); + + return Status; + } + + DestinationString->Buffer[Size] = 0; + + return STATUS_SUCCESS; +} NTSTATUS @@ -1315,11 +1475,6 @@ RtlUpcaseUnicodeStringToOemString ( } -/* -RtlUpcaseUnicodeToCustomCP -*/ - - CHAR STDCALL RtlUpperChar (