From dd76e08c862f51746ce93bd68d65bdcc912de460 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Thu, 25 May 2000 15:55:35 +0000 Subject: [PATCH] Implemented: - dbg functions - RtlFreeUserThreadStack() - rtl nls functions - rtl process heaps functions Improved .def and .edf files svn path=/trunk/; revision=1159 --- reactos/include/ddk/dbgfuncs.h | 4 +- reactos/include/internal/teb.h | 2 +- reactos/include/ntdll/dbg.h | 22 ++++- reactos/include/ntdll/rtl.h | 10 +- reactos/include/security.h | 8 +- reactos/lib/ntdll/dbg/debug.c | 168 +++++++++++++++++++++++++++++++- reactos/lib/ntdll/dbg/print.c | 27 ++++- reactos/lib/ntdll/def/ntdll.def | 55 ++++++++--- reactos/lib/ntdll/def/ntdll.edf | 50 ++++++++-- reactos/lib/ntdll/ldr/startup.c | 25 ++++- reactos/lib/ntdll/rtl/heap.c | 85 ++++++++++++++++ reactos/lib/ntdll/rtl/nls.c | 4 +- reactos/lib/ntdll/rtl/thread.c | 46 ++++++++- reactos/lib/ntdll/stubs/stubs.c | 7 +- reactos/ntoskrnl/dbg/print.c | 27 ++++- reactos/ntoskrnl/se/token.c | 6 +- 16 files changed, 499 insertions(+), 47 deletions(-) diff --git a/reactos/include/ddk/dbgfuncs.h b/reactos/include/ddk/dbgfuncs.h index fcd125d7f29..7c9278a5ae5 100644 --- a/reactos/include/ddk/dbgfuncs.h +++ b/reactos/include/ddk/dbgfuncs.h @@ -1,6 +1,6 @@ #ifndef __INCLUDE_DDK_DBGFUNCS_H #define __INCLUDE_DDK_DBGFUNCS_H -/* $Id: dbgfuncs.h,v 1.4 2000/03/04 21:58:49 ekohl Exp $ */ +/* $Id: dbgfuncs.h,v 1.5 2000/05/25 15:49:50 ekohl Exp $ */ #define DBG_STATUS_CONTROL_C 1 #define DBG_STATUS_SYSRQ 2 @@ -10,6 +10,8 @@ VOID STDCALL DbgBreakPointWithStatus (ULONG Status); VOID STDCALL DbgBreakPoint(VOID); ULONG DbgPrint(PCH Format,...); +VOID STDCALL DbgPrompt (PCH OutputString, PCH InputString, USHORT InputSize); + #define DBG_GET_SHOW_FACILITY 0x0001 #define DBG_GET_SHOW_SEVERITY 0x0002 diff --git a/reactos/include/internal/teb.h b/reactos/include/internal/teb.h index 15ec46f5a23..f09e7970f62 100644 --- a/reactos/include/internal/teb.h +++ b/reactos/include/internal/teb.h @@ -87,7 +87,7 @@ typedef struct _PEB PRTL_USER_PROCESS_PARAMETERS ProcessParameters; // 10h PVOID SubSystemData; // 14h PVOID ProcessHeap; // 18h - PVOID LastPebLock; // 1Ch + PVOID FastPebLock; // 1Ch PVOID FastPebLockRoutine; // 20h PVOID FastPebUnlockRoutine; // 24h ULONG EnvironmentUpdateCount; // 28h diff --git a/reactos/include/ntdll/dbg.h b/reactos/include/ntdll/dbg.h index 0a0db933541..c9f14833ec3 100644 --- a/reactos/include/ntdll/dbg.h +++ b/reactos/include/ntdll/dbg.h @@ -1,10 +1,24 @@ -/* $Id: dbg.h,v 1.1 2000/04/14 01:41:38 ekohl Exp $ +/* $Id: dbg.h,v 1.2 2000/05/25 15:50:21 ekohl Exp $ * */ #ifndef __INCLUDE_NTDLL_DBG_H #define __INCLUDE_NTDLL_DBG_H +NTSTATUS +STDCALL +DbgSsInitialize ( + HANDLE ReplyPort, + ULONG Unknown1, + ULONG Unknown2, + ULONG Unknown3 + ); + +NTSTATUS +STDCALL +DbgUiConnectToDbg ( + VOID + ); NTSTATUS STDCALL @@ -13,6 +27,12 @@ DbgUiContinue ( ULONG ContinueStatus ); +NTSTATUS +STDCALL +DbgUiWaitStateChange ( + ULONG Unknown1, + ULONG Unknown2 + ); #endif /* __INCLUDE_NTDLL_DBG_H */ diff --git a/reactos/include/ntdll/rtl.h b/reactos/include/ntdll/rtl.h index 274daa44abe..59b4065d7c5 100644 --- a/reactos/include/ntdll/rtl.h +++ b/reactos/include/ntdll/rtl.h @@ -1,4 +1,4 @@ -/* $Id: rtl.h,v 1.15 2000/04/15 23:11:42 ekohl Exp $ +/* $Id: rtl.h,v 1.16 2000/05/25 15:50:22 ekohl Exp $ * */ @@ -94,6 +94,7 @@ RtlLargeIntegerToChar ( IN OUT PCHAR String ); + /* Path functions */ ULONG @@ -235,6 +236,13 @@ RtlCreateUserThread ( IN OUT PCLIENT_ID ClientId ); +NTSTATUS +STDCALL +RtlFreeUserThreadStack ( + IN HANDLE ProcessHandle, + IN HANDLE ThreadHandle + ); + /* * Preliminary prototype!! * diff --git a/reactos/include/security.h b/reactos/include/security.h index 3601c9ea7f5..3d41f6c84e9 100644 --- a/reactos/include/security.h +++ b/reactos/include/security.h @@ -28,14 +28,18 @@ typedef ULONG TOKEN_TYPE, *PTOKEN_TYPE; #define TokenPrimary ((TOKEN_TYPE)1) #define TokenImpersonation ((TOKEN_TYPE)2) +//typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE; + +//#define SECURITY_DYNAMIC_TRACKING (TRUE) +//#define SECURITY_STATIC_TRACKING (FALSE) + typedef ULONG ACCESS_MASK, *PACCESS_MASK; typedef ULONG ACCESS_MODE, *PACCESS_MODE; typedef struct _SECURITY_QUALITY_OF_SERVICE { DWORD Length; SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; - /* SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; */ - WINBOOL ContextTrackingMode; + SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; BOOLEAN EffectiveOnly; } SECURITY_QUALITY_OF_SERVICE; diff --git a/reactos/lib/ntdll/dbg/debug.c b/reactos/lib/ntdll/dbg/debug.c index 823f598b03e..e9ffc065002 100644 --- a/reactos/lib/ntdll/dbg/debug.c +++ b/reactos/lib/ntdll/dbg/debug.c @@ -1,4 +1,4 @@ -/* $Id: debug.c,v 1.1 2000/04/14 01:43:05 ekohl Exp $ +/* $Id: debug.c,v 1.2 2000/05/25 15:50:44 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -12,11 +12,167 @@ /* INCLUDES *****************************************************************/ #include +#include #include +#include + +/* FUNCTIONS *****************************************************************/ + +static HANDLE DbgSsApiPort = NULL; +static HANDLE DbgSsReplyPort = NULL; + + +typedef struct _LPC_DBGSS_MESSAGE +{ + LPC_MESSAGE_HEADER Header; + ULONG Unknown1; + ULONG Unknown2; + ULONG Unknown3; + ULONG Unknown4; +} LPC_DBGSS_MESSAGE, *PLPC_DBGSS_MESSAGE; /* FUNCTIONS *****************************************************************/ +VOID +STDCALL +DbgSsServerThread ( + PVOID Unused + ) +{ + LPC_DBGSS_MESSAGE Message; + NTSTATUS Status; + + for (;;) + { + Status = NtReplyWaitReceivePort (DbgSsApiPort, + NULL, + NULL, + (PLPC_MESSAGE)&Message); + if (!NT_SUCCESS(Status)) + { + DbgPrint ("DbgSs: NtReplyWaitReceivePort failed - Status == %lx\n", + Status); + + DbgBreakPoint (); + } + else + { + /* FIXME: missing code!! */ + + } + } +} + + +NTSTATUS +STDCALL +DbgSsHandleKmApiMsg ( + ULONG Unknown1, + HANDLE EventHandle + ) +{ + + return STATUS_NOT_IMPLEMENTED; +} + + +NTSTATUS +STDCALL +DbgSsInitialize ( + HANDLE ReplyPort, + ULONG Unknown1, + ULONG Unknown2, + ULONG Unknown3 + ) +{ + SECURITY_QUALITY_OF_SERVICE Qos; + UNICODE_STRING PortName; + NTSTATUS Status; + + RtlInitUnicodeString (&PortName, + L"\\DbgSsApiPort"); + + Qos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE); + Qos.ImpersonationLevel = SecurityIdentification; + Qos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING; + Qos.EffectiveOnly = TRUE; + + Status = NtConnectPort (&DbgSsApiPort, + &PortName, + &Qos, + NULL, + NULL, + NULL, + NULL, + NULL); + if (!NT_SUCCESS(Status)) + return Status; + + DbgSsReplyPort = ReplyPort; +// UnknownData1 = Unknown1; +// UnknownData2 = Unknown2; +// UnknownData3 = Unknown3; + + Status = RtlCreateUserThread (NtCurrentProcess (), + NULL, + FALSE, + 0, + NULL, + NULL, + (PTHREAD_START_ROUTINE)DbgSsServerThread, + NULL, + NULL, + NULL); + + return Status; +} + + +NTSTATUS +STDCALL +DbgUiConnectToDbg ( + VOID + ) +{ + SECURITY_QUALITY_OF_SERVICE Qos; + UNICODE_STRING PortName; + NTSTATUS Status; + PNT_TEB Teb; + ULONG InfoSize; + + Teb = NtCurrentTeb (); + + RtlInitUnicodeString (&PortName, + L"\\DbgUiApiPort"); + + Qos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE); + Qos.ImpersonationLevel = SecurityIdentification; + Qos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING; + Qos.EffectiveOnly = TRUE; + + InfoSize = sizeof(ULONG); + + Status = NtConnectPort (&Teb->DbgSsReserved[1], + &PortName, + &Qos, + NULL, + NULL, + NULL, + &Teb->DbgSsReserved[0], + &InfoSize); + if (!NT_SUCCESS(Status)) + { + Teb->DbgSsReserved[1] = NULL; + return Status; + } + + NtRegisterThreadTerminatePort(Teb->DbgSsReserved[1]); + + return Status; +} + + NTSTATUS STDCALL DbgUiContinue ( @@ -27,4 +183,14 @@ DbgUiContinue ( return STATUS_NOT_IMPLEMENTED; } +NTSTATUS +STDCALL +DbgUiWaitStateChange ( + ULONG Unknown1, + ULONG Unknown2 + ) +{ + return STATUS_NOT_IMPLEMENTED; +} + /* EOF */ diff --git a/reactos/lib/ntdll/dbg/print.c b/reactos/lib/ntdll/dbg/print.c index 4d43b20549c..8d4e37bb032 100644 --- a/reactos/lib/ntdll/dbg/print.c +++ b/reactos/lib/ntdll/dbg/print.c @@ -1,4 +1,4 @@ -/* $Id: print.c,v 1.2 2000/01/18 12:04:16 ekohl Exp $ +/* $Id: print.c,v 1.3 2000/05/25 15:50:44 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -46,4 +46,29 @@ DbgPrint(PCH Format, ...) return (ULONG)DebugString.Length; } + +VOID +STDCALL +DbgPrompt ( + PCH OutputString, + PCH InputString, + USHORT InputSize + ) +{ + ANSI_STRING Output; + ANSI_STRING Input; + + Input.Length = 0; + Input.MaximumLength = InputSize; + Input.Buffer = InputString; + + Output.Length = strlen (OutputString); + Output.MaximumLength = Output.Length + 1; + Output.Buffer = OutputString; + + DbgService (2, + &Output, + &Input); +} + /* EOF */ diff --git a/reactos/lib/ntdll/def/ntdll.def b/reactos/lib/ntdll/def/ntdll.def index c6723eed56b..5601a9b4bad 100644 --- a/reactos/lib/ntdll/def/ntdll.def +++ b/reactos/lib/ntdll/def/ntdll.def @@ -1,22 +1,53 @@ -; $Id: ntdll.def,v 1.54 2000/05/13 01:48:01 ekohl Exp $ +; $Id: ntdll.def,v 1.55 2000/05/25 15:51:05 ekohl Exp $ ; ; ReactOS Operating System ; LIBRARY ntdll.dll EXPORTS +;CsrAllocateCaptureBuffer +;CsrAllocateCapturePointer +;CsrAllocateMessagePointer +;CsrCaptureMessageBuffer +;CsrCaptureMessageString +;CsrCaptureTimeout CsrClientCallServer@16 ;CsrClientConnectToServer@24 +;CsrFreeCaptureBuffer +;CsrIdentifyAlertableThread +;CrsNewThread +;CsrProbeForRead +;CsrProbeForWrite CsrSetPriorityClass@8 DbgBreakPoint@0 DbgPrint -;DbgPrompt -;DbgSsHandleKmApiMsg -;DbgSsInitialize -;DbgUiConnectToDbg +DbgPrompt@12 +DbgSsHandleKmApiMsg@8 +DbgSsInitialize@16 +DbgUiConnectToDbg@0 DbgUiContinue@8 -;DbgUiWaitStateChange +DbgUiWaitStateChange@8 DbgUserBreakPoint@0 +;KiRaiseUserExceptionDispatcher +;KiUserApcDispatcher +;KiUserCallbackDispatcher +;KiUserExceptionDispatcher +LdrAccessResource +;LdrDisableThreadCalloutsForDll +;LdrEnumResources +;LdrFindResourceDirectory_U +LdrFindResource_U +;LdrGetDllHandle +;LdrGetProcedureAddress +;LdrInitializeThunk +LdrLoadDll +;LdrProcessRelocationBlock +;LdrQueryImageFileExecutionOptions +;LdrQueryProcessModuleInformation +;LdrShutdownProcess +;LdrShutdownThread +LdrUnloadDll +;LdrVerifyImageMatchesChecksum NlsAnsiCodePage DATA NlsMbCodePageTag DATA NlsMbOemCodePageTag DATA @@ -338,7 +369,7 @@ RtlEnlargedIntegerMultiply@8 RtlEnlargedUnsignedDivide@16 RtlEnlargedUnsignedMultiply@8 RtlEnterCriticalSection@4 -;RtlEnumProcessHeaps +RtlEnumProcessHeaps@8 ;RtlEnumerateGenericTable ;RtlEnumerateGenericTableWithoutSplaying ;RtlEnumerateProperties @@ -374,7 +405,7 @@ RtlFreeHeap@12 RtlFreeOemString@4 RtlFreeSid@4 RtlFreeUnicodeString@4 -;RtlFreeUserThreadStack +RtlFreeUserThreadStack@8 ;RtlGenerate8dot3Name RtlGetAce@12 ;RtlGetCallersAddress @@ -389,7 +420,7 @@ RtlGetLongestNtPathLength@0 ;RtlGetNtGlobalFlags ;RtlGetNtProductType RtlGetOwnerSecurityDescriptor@12 -;RtlGetProcessHeaps +RtlGetProcessHeaps@8 RtlGetProcessHeap@0 RtlGetSaclSecurityDescriptor@16 ;RtlGetUserInfoHeap @@ -553,7 +584,7 @@ RtlValidAcl@4 RtlValidSecurityDescriptor@4 RtlValidSid@4 RtlValidateHeap@12 -;RtlValidateProcessHeaps +RtlValidateProcessHeaps@0 ;RtlWalkHeap ;RtlWriteRegistryValue ;RtlZeroHeap @@ -900,7 +931,3 @@ wcstombs wcstoul LdrGetExportByName LdrGetExportByOrdinal -LdrLoadDll -LdrUnloadDll -LdrFindResource_U -LdrAccessResource diff --git a/reactos/lib/ntdll/def/ntdll.edf b/reactos/lib/ntdll/def/ntdll.edf index 8be8bf6c927..7f76667efad 100644 --- a/reactos/lib/ntdll/def/ntdll.edf +++ b/reactos/lib/ntdll/def/ntdll.edf @@ -1,22 +1,52 @@ -; $Id: ntdll.edf,v 1.43 2000/05/13 01:48:01 ekohl Exp $ +; $Id: ntdll.edf,v 1.44 2000/05/25 15:51:05 ekohl Exp $ ; ; ReactOS Operating System ; LIBRARY ntdll.dll EXPORTS +;CsrAllocateCaptureBuffer +;CsrAllocateCapturePointer +;CsrAllocateMessagePointer +;CsrCaptureMessageBuffer +;CsrCaptureMessageString +;CsrCaptureTimeout CsrClientCallServer=CsrClientCallServer@16 ;CsrClientConnectToServer=CsrClientConnectToServer@24 +;CsrFreeCaptureBuffer +;CsrIdentifyAlertableThread +;CrsNewThread +;CsrProbeForRead +;CsrProbeForWrite CsrSetPriorityClass=CsrSetPriorityClass@8 DbgBreakPoint=DbgBreakPoint@0 DbgPrint -;DbgPrompt -;DbgSsHandleKmApiMsg -;DbgSsInitialize -;DbgUiConnectToDbg +DbgPrompt=DbgPrompt@12 +DbgSsHandleKmApiMsg=DbgSsHandleKmApiMsg@8 +DbgSsInitialize=DbgSsInitialize@16 +DbgUiConnectToDbg=DbgUiConnectToDbg@0 DbgUiContinue=DbgUiContinue@8 -;DbgUiWaitStateChange +DbgUiWaitStateChange=DbgUiWaitStateChange@8 DbgUserBreakPoint=DbgUserBreakPoint@0 +;KiRaiseUserExceptionDispatcher +;KiUserApcDispatcher +;KiUserCallbackDispatcher +;KiUserExceptionDispatcher +LdrAccessResource +;LdrDisableThreadCalloutsForDll +;LdrEnumResources +;LdrFindResourceDirectory_U +LdrFindResource_U +;LdrGetDllHandle +;LdrGetProcedureAddress +;LdrInitializeThunk +LdrLoadDll +;LdrProcessRelocationBlock +;LdrQueryImageFileExecutionOptions +;LdrQueryProcessModuleInformation +;LdrShutdownProcess +;LdrShutdownThread +LdrUnloadDll NlsAnsiCodePage DATA NlsMbCodePageTag DATA NlsMbOemCodePageTag DATA @@ -288,6 +318,7 @@ RtlEnlargedIntegerMultiply=RtlEnlargedIntegerMultiply@8 RtlEnlargedUnsignedDivide=RtlEnlargedUnsignedDivide@16 RtlEnlargedUnsignedMultiply=RtlEnlargedUnsignedMultiply@8 RtlEnterCriticalSection=RtlEnterCriticalSection@4 +RtlEnumProcessHeaps=RtlEnumProcessHeaps@8 RtlEqualComputerName=RtlEqualComputerName@8 RtlEqualDomainName=RtlEqualDomainName@8 RtlEqualLuid=RtlEqualLuid@8 @@ -313,6 +344,7 @@ RtlFreeAnsiString=RtlFreeAnsiString@4 RtlFreeHeap=RtlFreeHeap@12 RtlFreeSid=RtlFreeSid@4 RtlFreeUnicodeString=RtlFreeUnicodeString@4 +RtlFreeUserThreadStack=RtlFreeUserThreadStack@8 RtlGetAce=RtlGetAce@12 RtlGetControlSecurityDescriptor=RtlGetControlSecurityDescriptor@12 RtlGetCurrentDirectory_U=RtlGetCurrentDirectory_U@8 @@ -321,6 +353,7 @@ RtlGetFullPathName_U=RtlGetFullPathName_U@16 RtlGetGroupSecurityDescriptor=RtlGetGroupSecurityDescriptor@12 RtlGetLongestNtPathLength=RtlGetLongestNtPathLength@0 RtlGetOwnerSecurityDescriptor=RtlGetOwnerSecurityDescriptor@12 +RtlGetProcessHeaps=RtlGetProcessHeaps@8 RtlGetProcessHeap=RtlGetProcessHeap@0 RtlGetSaclSecurityDescriptor=RtlGetSaclSecurityDescriptor@16 RtlIdentifierAuthoritySid=RtlIdentifierAuthoritySid@4 @@ -420,6 +453,7 @@ RtlValidAcl=RtlValidAcl@4 RtlValidSecurityDescriptor=RtlValidSecurityDescriptor@4 RtlValidSid=RtlValidSid@4 RtlValidateHeap=RtlValidateHeap@12 +RtlValidateProcessHeaps=RtlValidateProcessHeaps@0 RtlZeroMemory=RtlZeroMemory@8 RtlxAnsiStringToUnicodeSize=RtlxAnsiStringToUnicodeSize@4 RtlxOemStringToUnicodeSize=RtlxOemStringToUnicodeSize@4 @@ -743,7 +777,3 @@ wcstombs wcstoul LdrGetExportByName LdrGetExportByOrdinal -LdrLoadDll -LdrUnloadDll -LdrAccessResource -LdrFindResource_U diff --git a/reactos/lib/ntdll/ldr/startup.c b/reactos/lib/ntdll/ldr/startup.c index 117496f3853..5a90cbd35f4 100644 --- a/reactos/lib/ntdll/ldr/startup.c +++ b/reactos/lib/ntdll/ldr/startup.c @@ -1,4 +1,4 @@ -/* $Id: startup.c,v 1.23 2000/05/24 22:29:35 dwelch Exp $ +/* $Id: startup.c,v 1.24 2000/05/25 15:51:16 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -21,11 +21,16 @@ //#define NDEBUG #include + +VOID RtlpInitProcessHeaps (PPEB Peb); + /* GLOBALS *******************************************************************/ DLL LdrDllListHead; extern unsigned int _image_base__; +CRITICAL_SECTION PebLock; + ULONG NtGlobalFlag = 0; @@ -76,6 +81,15 @@ VOID LdrStartup(VOID) /* normalize process parameters */ RtlNormalizeProcessParams (Peb->ProcessParameters); +#if 0 + /* initialize NLS data */ + RtlInitNlsTables (Peb->AnsiCodePageData, + Peb->OemCodePageData, + Peb->UnicodeCaseTableData, + &TranslationTable); + RtlResetRtlTranslations (&TranslationTable); +#endif + NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + PEDosHeader->e_lfanew); /* create process heap */ @@ -91,6 +105,15 @@ VOID LdrStartup(VOID) ZwTerminateProcess(NtCurrentProcess(),STATUS_UNSUCCESSFUL); } + /* initialize process heaps support */ + RtlpInitProcessHeaps (Peb); + + /* initalize peb lock support */ + RtlInitializeCriticalSection (&PebLock); + Peb->FastPebLock = &PebLock; + Peb->FastPebLockRoutine = RtlEnterCriticalSection; + Peb->FastPebUnlockRoutine = RtlLeaveCriticalSection; + EntryPoint = LdrPEStartup((PVOID)ImageBase, NULL); if (EntryPoint == NULL) { diff --git a/reactos/lib/ntdll/rtl/heap.c b/reactos/lib/ntdll/rtl/heap.c index 665094ab6b5..65766ff9fe2 100644 --- a/reactos/lib/ntdll/rtl/heap.c +++ b/reactos/lib/ntdll/rtl/heap.c @@ -12,6 +12,8 @@ #define NDEBUG #include +CRITICAL_SECTION ProcessHeapsLock; + /* Note: the heap data structures are based on what Pietrek describes in his * book 'Windows 95 System Programming Secrets'. The layout is not exactly * the same, but could be easily adapted if it turns out some programs @@ -1270,3 +1272,86 @@ HANDLE WINAPI RtlGetProcessHeap(VOID) return (HANDLE)NtCurrentPeb()->ProcessHeap; } +VOID +RtlpInitProcessHeaps (PPEB Peb) +{ + Peb->NumberOfHeaps = 0; + Peb->MaximumNumberOfHeaps = (PAGESIZE - sizeof(PPEB)) / sizeof(HANDLE); + Peb->ProcessHeaps = (PVOID)Peb + sizeof(PEB); + + RtlInitializeCriticalSection (&ProcessHeapsLock); +} + + +NTSTATUS +STDCALL +RtlEnumProcessHeaps ( + DWORD WINAPI(*func)(void*,LONG), + LONG lParam + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + ULONG i; + + RtlEnterCriticalSection (&ProcessHeapsLock); + + for (i = 0; i < NtCurrentPeb ()->NumberOfHeaps; i++) + { + Status = func (NtCurrentPeb ()->ProcessHeaps[i],lParam); + if(!NT_SUCCESS(Status)) + break; + } + + RtlLeaveCriticalSection (&ProcessHeapsLock); + + return Status; +} + + +ULONG +STDCALL +RtlGetProcessHeaps ( + ULONG HeapCount, + HANDLE *HeapArray + ) +{ + ULONG Result = 0; + + RtlEnterCriticalSection (&ProcessHeapsLock); + + if (NtCurrentPeb ()->NumberOfHeaps <= HeapCount) + { + Result = NtCurrentPeb ()->NumberOfHeaps; + memmove (HeapArray, + NtCurrentPeb ()->ProcessHeaps, + Result * sizeof(HANDLE)); + } + + RtlLeaveCriticalSection (&ProcessHeapsLock); + + return Result; +} + + +BOOLEAN +STDCALL +RtlValidateProcessHeaps ( + VOID + ) +{ + HANDLE Heaps[128]; + BOOLEAN Result = TRUE; + ULONG HeapCount; + ULONG i; + + HeapCount = RtlGetProcessHeaps (128, Heaps); + for (i = 0; i < HeapCount; i++) + { + if (!RtlValidateHeap (Heaps[i], 0, NULL)) + Result = FALSE; + } + + return Result; +} + +/* EOF */ diff --git a/reactos/lib/ntdll/rtl/nls.c b/reactos/lib/ntdll/rtl/nls.c index c7eaed0753d..e9e4afd5259 100644 --- a/reactos/lib/ntdll/rtl/nls.c +++ b/reactos/lib/ntdll/rtl/nls.c @@ -1,4 +1,4 @@ -/* $Id: nls.c,v 1.3 2000/05/13 01:47:33 ekohl Exp $ +/* $Id: nls.c,v 1.4 2000/05/25 15:52:53 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -94,7 +94,7 @@ RtlCustomCPToUnicodeN ( for (i = 0; i < Size; i++) { - *UnicodeString = NlsData->MultiByteToUnicode[*CustomString]; + *UnicodeString = NlsData->MultiByteToUnicode[(int)*CustomString]; UnicodeString++; CustomString++; } diff --git a/reactos/lib/ntdll/rtl/thread.c b/reactos/lib/ntdll/rtl/thread.c index 482eb9ace64..8895c024166 100644 --- a/reactos/lib/ntdll/rtl/thread.c +++ b/reactos/lib/ntdll/rtl/thread.c @@ -13,7 +13,8 @@ #include #include -#include +#include +//#include #include #define NDEBUG @@ -239,9 +240,50 @@ RtlInitializeContext(HANDLE ProcessHandle, } -NTSTATUS STDCALL RtlDestroyUserThreadStack(param1, param2) +NTSTATUS +STDCALL +RtlFreeUserThreadStack ( + HANDLE ProcessHandle, + HANDLE ThreadHandle + ) { + THREAD_BASIC_INFORMATION ThreadInfo; + NTSTATUS Status; + ULONG BytesRead; + ULONG RegionSize; + PVOID StackBase; + PNT_TEB Teb; + Status = NtQueryInformationThread (ThreadHandle, + ThreadBasicInformation, + &ThreadInfo, + sizeof(THREAD_BASIC_INFORMATION), + NULL); + if (!NT_SUCCESS(Status)) + return Status; + + if (ThreadInfo.TebBaseAddress == NULL) + return Status; + + Teb = (PNT_TEB)ThreadInfo.TebBaseAddress; + Status = NtReadVirtualMemory (ProcessHandle, + &Teb->DeallocationStack, + &StackBase, + sizeof(PVOID), + &BytesRead); + if (!NT_SUCCESS(Status)) + return Status; + + if (StackBase == NULL) + return Status; + + RegionSize = 0; + Status = NtFreeVirtualMemory (ProcessHandle, + StackBase, + &RegionSize, + MEM_RELEASE); + + return Status; } /* EOF */ diff --git a/reactos/lib/ntdll/stubs/stubs.c b/reactos/lib/ntdll/stubs/stubs.c index f141153c31a..95c51a9f94c 100644 --- a/reactos/lib/ntdll/stubs/stubs.c +++ b/reactos/lib/ntdll/stubs/stubs.c @@ -24,11 +24,7 @@ STUB(CsrNewThread) STUB(CsrProbeForRead) STUB(CsrProbeForWrite) STUB(CsrSetPriorityClass) -STUB(DbgPrompt) -STUB(DbgSsHandleKmApiMsg) -STUB(DbgSsInitialize) -STUB(DbgUiConnectToDbg) -STUB(DbgUiWaitStateChange) + STUB(KiRaiseUserExceptionDispatcher) STUB(KiUserExceptionDispatcher) @@ -52,7 +48,6 @@ STUB(PfxInitialize) STUB(PfxInsertPrefix) STUB(PfxRemovePrefix) STUB(RestoreEm87Context) -STUB(RtlValidateProcessHeaps) STUB(RtlWalkHeap) STUB(RtlZeroHeap) STUB(RtlpNtCreateKey) diff --git a/reactos/ntoskrnl/dbg/print.c b/reactos/ntoskrnl/dbg/print.c index 77020af4d37..3c2be93e63a 100644 --- a/reactos/ntoskrnl/dbg/print.c +++ b/reactos/ntoskrnl/dbg/print.c @@ -1,4 +1,4 @@ -/* $Id: print.c,v 1.8 2000/02/27 02:08:33 ekohl Exp $ +/* $Id: print.c,v 1.9 2000/05/25 15:55:08 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -54,4 +54,29 @@ ULONG DbgPrint(PCH Format, ...) return (ULONG)DebugString.Length; } + +VOID +STDCALL +DbgPrompt ( + PCH OutputString, + PCH InputString, + USHORT InputSize + ) +{ + ANSI_STRING Output; + ANSI_STRING Input; + + Input.Length = 0; + Input.MaximumLength = InputSize; + Input.Buffer = InputString; + + Output.Length = strlen (OutputString); + Output.MaximumLength = Output.Length + 1; + Output.Buffer = OutputString; + + /* FIXME: Not implemented yet! */ +// KdpPromptString (&Output, +// &Input); +} + /* EOF */ diff --git a/reactos/ntoskrnl/se/token.c b/reactos/ntoskrnl/se/token.c index 53eb3d4dcf5..afaa5dbba0f 100644 --- a/reactos/ntoskrnl/se/token.c +++ b/reactos/ntoskrnl/se/token.c @@ -1,4 +1,4 @@ -/* $Id: token.c,v 1.5 2000/05/09 21:30:39 ekohl Exp $ +/* $Id: token.c,v 1.6 2000/05/25 15:55:35 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -17,7 +17,7 @@ /* GLOBALS *******************************************************************/ -POBJECT_TYPE SeTokenType = NULL; +POBJECT_TYPE EXPORTED SeTokenType = NULL; /* FUNCTIONS *****************************************************************/ @@ -451,7 +451,7 @@ VOID SepAdjustGroups(PACCESS_TOKEN Token, { UNIMPLEMENTED; } - + NTSTATUS STDCALL NtAdjustGroupsToken(IN HANDLE TokenHandle, IN BOOLEAN ResetToDefault, IN PTOKEN_GROUPS NewState,