[NTDLL/RTL]: Implement RtlGet/SetThreadErrorMode.

[NTDLL/RTL]: Fix RtlIpv4AddressToStringA and RtlIpv4AddressToStringW to work like in Windows (and crash with a NULL buffer).

svn path=/trunk/; revision=55729
This commit is contained in:
Alex Ionescu 2012-02-20 01:13:31 +00:00
parent 9d05ce3297
commit 19a5d85926
4 changed files with 51 additions and 21 deletions

View file

@ -683,7 +683,7 @@
@ stdcall RtlGetSaclSecurityDescriptor(ptr ptr ptr ptr)
@ stdcall RtlGetSecurityDescriptorRMControl(ptr ptr)
@ stdcall RtlGetSetBootStatusData(ptr long long ptr long long)
//@ stdcall RtlGetThreadErrorMode
@ stdcall RtlGetThreadErrorMode()
//@ stdcall RtlGetUnloadEventTrace
@ stdcall RtlGetUserInfoHeap(ptr long ptr ptr ptr)
@ stdcall RtlGetVersion(ptr)
@ -894,7 +894,7 @@
@ stdcall RtlSetSecurityDescriptorRMControl(ptr ptr)
@ stdcall RtlSetSecurityObject(long ptr ptr ptr ptr)
//@ stdcall RtlSetSecurityObjectEx
//@ stdcall RtlSetThreadErrorMode
@ stdcall RtlSetThreadErrorMode(long ptr)
@ stdcall RtlSetThreadIsCritical(long ptr long)
@ stdcall RtlSetThreadPoolStartFunc(ptr ptr)
@ stdcall RtlSetTimeZoneInformation(ptr)

View file

@ -681,7 +681,7 @@
@ stdcall RtlGetSaclSecurityDescriptor(ptr ptr ptr ptr)
@ stdcall RtlGetSecurityDescriptorRMControl(ptr ptr)
@ stdcall RtlGetSetBootStatusData(ptr long long ptr long long)
;@ stdcall RtlGetThreadErrorMode
@ stdcall RtlGetThreadErrorMode()
;@ stdcall RtlGetUnloadEventTrace
@ stdcall RtlGetUserInfoHeap(ptr long ptr ptr ptr)
@ stdcall RtlGetVersion(ptr)
@ -894,7 +894,7 @@
@ stdcall RtlSetSecurityDescriptorRMControl(ptr ptr)
@ stdcall RtlSetSecurityObject(long ptr ptr ptr ptr)
;@ stdcall RtlSetSecurityObjectEx
;@ stdcall RtlSetThreadErrorMode
@ stdcall RtlSetThreadErrorMode(long ptr)
@ stdcall RtlSetThreadIsCritical(long ptr long)
@ stdcall RtlSetThreadPoolStartFunc(ptr ptr)
@ stdcall RtlSetTimeZoneInformation(ptr)

View file

@ -24,6 +24,10 @@
#define NDEBUG
#include <debug.h>
#define RTL_SEM_FAILCRITICALERRORS (SEM_FAILCRITICALERRORS << 4)
#define RTL_SEM_NOGPFAULTERRORBOX (SEM_NOGPFAULTERRORBOX << 4)
#define RTL_SEM_NOALIGNMENTFAULTEXCEPT (SEM_NOALIGNMENTFAULTEXCEPT << 4)
struct error_table
{
DWORD start;
@ -171,6 +175,44 @@ RtlMapSecurityErrorToNtStatus(
return STATUS_NOT_IMPLEMENTED;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
RtlSetThreadErrorMode(IN ULONG NewMode,
OUT PULONG OldMode OPTIONAL)
{
PTEB Teb = NtCurrentTeb();
/* Ignore invalid error modes */
if (NewMode & ~(RTL_SEM_FAILCRITICALERRORS |
RTL_SEM_NOGPFAULTERRORBOX |
RTL_SEM_NOALIGNMENTFAULTEXCEPT))
{
DPRINT1("Invalid error mode\n");
return STATUS_INVALID_PARAMETER_1;
}
/* Return old mode */
if (OldMode) *OldMode = Teb->HardErrorMode;
/* Set new one and return success */
Teb->HardErrorMode = NewMode;
return STATUS_SUCCESS;
}
/*
* @implemented
*/
ULONG
NTAPI
RtlGetThreadErrorMode(VOID)
{
/* Return it from the TEB */
return NtCurrentTeb()->HardErrorMode;
}
/* conversion tables */
static const DWORD table_00000102[32] =

View file

@ -31,18 +31,13 @@ NTAPI
RtlIpv4AddressToStringA(IN struct in_addr *Addr,
OUT PCHAR S)
{
CHAR Buffer[IPV4_ADDR_STRING_MAX_LEN];
INT Length;
if(!S)
return NULL;
Length = sprintf(Buffer, "%u.%u.%u.%u", Addr->S_un.S_un_b.s_b1,
Length = sprintf(S, "%u.%u.%u.%u", Addr->S_un.S_un_b.s_b1,
Addr->S_un.S_un_b.s_b2,
Addr->S_un.S_un_b.s_b3,
Addr->S_un.S_un_b.s_b4);
strcpy(S, Buffer);
return S + Length;
}
@ -88,19 +83,12 @@ NTAPI
RtlIpv4AddressToStringW(IN struct in_addr *Addr,
OUT PWCHAR S)
{
WCHAR Buffer[IPV4_ADDR_STRING_MAX_LEN];
INT Length;
if (!S)
return NULL;
Length = swprintf(Buffer, L"%u.%u.%u.%u", Addr->S_un.S_un_b.s_b1,
Addr->S_un.S_un_b.s_b2,
Addr->S_un.S_un_b.s_b3,
Addr->S_un.S_un_b.s_b4);
wcscpy(S, Buffer);
Length = swprintf(S, L"%u.%u.%u.%u", Addr->S_un.S_un_b.s_b1,
Addr->S_un.S_un_b.s_b2,
Addr->S_un.S_un_b.s_b3,
Addr->S_un.S_un_b.s_b4);
return S + Length;
}