From 12df37e35b35af97fbda0e5fe1b221f9a7e57737 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 2 Jul 2016 20:37:35 +0000 Subject: [PATCH] [NTDLL] Export RtlMapSecurityErrorToNtStatus since we have it available in our RTL library (however it is still only stubbed). [RTL][NDK] - NT-ify a bit error.c - Add the prototypes of the functions that manipulate the "last Win32 error" and "last NT status". - Add the prototypes of the functions that get & set the thread-error-mode (for hard-errors). - Define some prototypes for NTOS_MODE_USER only. [CONSRV] RtlGetLastNtStatus is now in the NDK, no need to keep its prototype there anymore. svn path=/trunk/; revision=71767 --- reactos/dll/ntdll/def/ntdll.spec | 2 +- reactos/sdk/include/ndk/rtlfuncs.h | 75 +++++++++++++++----- reactos/sdk/lib/rtl/error.c | 54 ++++++++------ reactos/win32ss/user/winsrv/consrv/console.c | 2 - 4 files changed, 92 insertions(+), 41 deletions(-) diff --git a/reactos/dll/ntdll/def/ntdll.spec b/reactos/dll/ntdll/def/ntdll.spec index c0d3d876468..4d637176f02 100644 --- a/reactos/dll/ntdll/def/ntdll.spec +++ b/reactos/dll/ntdll/def/ntdll.spec @@ -771,7 +771,7 @@ @ stdcall -arch=x86_64 RtlLookupFunctionEntry(long ptr ptr) 767 stdcall RtlMakeSelfRelativeSD(ptr ptr ptr) 768 stdcall RtlMapGenericMask(long ptr) -# stdcall RtlMapSecurityErrorToNtStatus +769 stdcall RtlMapSecurityErrorToNtStatus(long) 770 stdcall RtlMoveMemory(ptr ptr long) 771 stdcall RtlMultiAppendUnicodeStringBuffer(ptr long ptr) 772 stdcall RtlMultiByteToUnicodeN(ptr long ptr ptr long) diff --git a/reactos/sdk/include/ndk/rtlfuncs.h b/reactos/sdk/include/ndk/rtlfuncs.h index 3c6f75f8129..5a6734bd97e 100644 --- a/reactos/sdk/include/ndk/rtlfuncs.h +++ b/reactos/sdk/include/ndk/rtlfuncs.h @@ -609,7 +609,7 @@ RtlIsGenericTableEmptyAvl( #endif /* RTL_USE_AVL_TABLES */ // -// Error and Exception Functions +// Exception and Error Functions // NTSYSAPI PVOID @@ -637,13 +637,11 @@ RtlSetUnhandledExceptionFilter( _In_ PRTLP_UNHANDLED_EXCEPTION_FILTER TopLevelExceptionFilter ); -#endif /* NTOS_MODE_USER */ - NTSYSAPI -VOID +LONG NTAPI -RtlCaptureContext( - _Out_ PCONTEXT ContextRecord +RtlUnhandledExceptionFilter( + _In_ struct _EXCEPTION_POINTERS* ExceptionInfo ); NTSYSAPI @@ -674,6 +672,58 @@ RtlDecodeSystemPointer( _In_ PVOID Pointer ); +NTSYSAPI +NTSTATUS +NTAPI +RtlGetLastNtStatus( + VOID +); + +NTSYSAPI +ULONG +NTAPI +RtlGetLastWin32Error( + VOID +); + +NTSYSAPI +VOID +NTAPI +RtlSetLastWin32Error( + _In_ ULONG LastError +); + +NTSYSAPI +VOID +NTAPI +RtlSetLastWin32ErrorAndNtStatusFromNtStatus( + _In_ NTSTATUS Status +); + +NTSYSAPI +NTSTATUS +NTAPI +RtlSetThreadErrorMode( + _In_ ULONG NewMode, + _Out_opt_ PULONG OldMode +); + +NTSYSAPI +ULONG +NTAPI +RtlGetThreadErrorMode( + VOID +); + +#endif /* NTOS_MODE_USER */ + +NTSYSAPI +VOID +NTAPI +RtlCaptureContext( + _Out_ PCONTEXT ContextRecord +); + NTSYSAPI BOOLEAN NTAPI @@ -702,10 +752,10 @@ RtlNtStatusToDosErrorNoTeb( ); NTSYSAPI -VOID +NTSTATUS NTAPI -RtlSetLastWin32ErrorAndNtStatusFromNtStatus( - _In_ NTSTATUS Status +RtlMapSecurityErrorToNtStatus( + _In_ ULONG SecurityError ); NTSYSAPI @@ -723,13 +773,6 @@ RtlRaiseStatus( _In_ NTSTATUS Status ); -NTSYSAPI -LONG -NTAPI -RtlUnhandledExceptionFilter( - _In_ struct _EXCEPTION_POINTERS* ExceptionInfo -); - NTSYSAPI VOID NTAPI diff --git a/reactos/sdk/lib/rtl/error.c b/reactos/sdk/lib/rtl/error.c index c453551c6e0..dc3e53fc59e 100644 --- a/reactos/sdk/lib/rtl/error.c +++ b/reactos/sdk/lib/rtl/error.c @@ -46,21 +46,23 @@ static const struct error_table error_table[20]; * The mapped Win32 error code, or ERROR_MR_MID_NOT_FOUND if there is no * mapping defined. */ -ULONG WINAPI RtlNtStatusToDosErrorNoTeb( NTSTATUS status ) +ULONG +NTAPI +RtlNtStatusToDosErrorNoTeb(IN NTSTATUS Status) { const struct error_table *table = error_table; - if (!status || (status & 0x20000000)) return status; + if (!Status || (Status & 0x20000000)) return Status; /* 0xd... is equivalent to 0xc... */ - if ((status & 0xf0000000) == 0xd0000000) status &= ~0x10000000; + if ((Status & 0xf0000000) == 0xd0000000) Status &= ~0x10000000; while (table->start) { - if ((ULONG)status < table->start) break; - if ((ULONG)status < table->end) + if ((ULONG)Status < table->start) break; + if ((ULONG)Status < table->end) { - DWORD ret = table->table[status - table->start]; + DWORD ret = table->table[Status - table->start]; /* unknown entries are 0 */ if (!ret) goto no_mapping; return ret; @@ -69,11 +71,11 @@ ULONG WINAPI RtlNtStatusToDosErrorNoTeb( NTSTATUS status ) } /* now some special cases */ - if (HIWORD(status) == 0xc001) return LOWORD(status); - if (HIWORD(status) == 0x8007) return LOWORD(status); + if (HIWORD(Status) == 0xc001) return LOWORD(Status); + if (HIWORD(Status) == 0x8007) return LOWORD(Status); no_mapping: - DPRINT1( "no mapping for %08x\n", status ); + DPRINT1( "no mapping for %08x\n", Status ); return ERROR_MR_MID_NOT_FOUND; } @@ -89,15 +91,17 @@ no_mapping: * The mapped Win32 error code, or ERROR_MR_MID_NOT_FOUND if there is no * mapping defined. */ -ULONG WINAPI RtlNtStatusToDosError( NTSTATUS status ) +ULONG +NTAPI +RtlNtStatusToDosError(IN NTSTATUS Status) { - PTEB Teb = NtCurrentTeb (); + PTEB Teb = NtCurrentTeb(); if (NULL != Teb) { - Teb->LastStatusValue = status; + Teb->LastStatusValue = Status; } - return RtlNtStatusToDosErrorNoTeb( status ); + return RtlNtStatusToDosErrorNoTeb(Status); } /********************************************************************** @@ -105,7 +109,9 @@ ULONG WINAPI RtlNtStatusToDosError( NTSTATUS status ) * * Get the current per-thread status. */ -NTSTATUS WINAPI RtlGetLastNtStatus(void) +NTSTATUS +NTAPI +RtlGetLastNtStatus(VOID) { return NtCurrentTeb()->LastStatusValue; } @@ -121,7 +127,9 @@ NTSTATUS WINAPI RtlGetLastNtStatus(void) * RETURNS * The current error value for the thread, as set by SetLastWin32Error() or SetLastError(). */ -DWORD WINAPI RtlGetLastWin32Error(void) +ULONG +NTAPI +RtlGetLastWin32Error(VOID) { return NtCurrentTeb()->LastErrorValue; } @@ -138,9 +146,11 @@ DWORD WINAPI RtlGetLastWin32Error(void) * RETURNS * Nothing. */ -void WINAPI RtlSetLastWin32Error( DWORD err ) +VOID +NTAPI +RtlSetLastWin32Error(IN ULONG LastError) { - NtCurrentTeb()->LastErrorValue = err; + NtCurrentTeb()->LastErrorValue = LastError; } /*********************************************************************** @@ -154,9 +164,11 @@ void WINAPI RtlSetLastWin32Error( DWORD err ) * RETURNS * Nothing. */ -void WINAPI RtlSetLastWin32ErrorAndNtStatusFromNtStatus( NTSTATUS status ) +VOID +NTAPI +RtlSetLastWin32ErrorAndNtStatusFromNtStatus(IN NTSTATUS Status) { - NtCurrentTeb()->LastErrorValue = RtlNtStatusToDosError( status ); + NtCurrentTeb()->LastErrorValue = RtlNtStatusToDosError(Status); } /* @@ -164,9 +176,7 @@ void WINAPI RtlSetLastWin32ErrorAndNtStatusFromNtStatus( NTSTATUS status ) */ NTSTATUS NTAPI -RtlMapSecurityErrorToNtStatus( - IN ULONG SecurityError - ) +RtlMapSecurityErrorToNtStatus(IN ULONG SecurityError) { UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; diff --git a/reactos/win32ss/user/winsrv/consrv/console.c b/reactos/win32ss/user/winsrv/consrv/console.c index 843c24da387..b45828e223e 100644 --- a/reactos/win32ss/user/winsrv/consrv/console.c +++ b/reactos/win32ss/user/winsrv/consrv/console.c @@ -24,8 +24,6 @@ #define NDEBUG #include -// FIXME: Add this prototype to winternl.h / rtlfuncs.h / ... -NTSTATUS NTAPI RtlGetLastNtStatus(VOID); /* GLOBALS ********************************************************************/ -- 2.17.1