Author: ion
Date: Mon Feb 20 01:13:31 2012
New Revision: 55729
URL:
http://svn.reactos.org/svn/reactos?rev=55729&view=rev
Log:
[NTDLL/RTL]: Implement RtlGet/SetThreadErrorMode.
[NTDLL/RTL]: Fix RtlIpv4AddressToStringA and RtlIpv4AddressToStringW to work like in
Windows (and crash with a NULL buffer).
Modified:
trunk/reactos/dll/ntdll/def/ntdll.pspec
trunk/reactos/dll/ntdll/def/ntdll.spec
trunk/reactos/lib/rtl/error.c
trunk/reactos/lib/rtl/network.c
Modified: trunk/reactos/dll/ntdll/def/ntdll.pspec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/def/ntdll.pspec?…
==============================================================================
--- trunk/reactos/dll/ntdll/def/ntdll.pspec [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/def/ntdll.pspec [iso-8859-1] Mon Feb 20 01:13:31 2012
@@ -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)
Modified: trunk/reactos/dll/ntdll/def/ntdll.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/def/ntdll.spec?r…
==============================================================================
--- trunk/reactos/dll/ntdll/def/ntdll.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/def/ntdll.spec [iso-8859-1] Mon Feb 20 01:13:31 2012
@@ -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)
Modified: trunk/reactos/lib/rtl/error.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/error.c?rev=55729&…
==============================================================================
--- trunk/reactos/lib/rtl/error.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/error.c [iso-8859-1] Mon Feb 20 01:13:31 2012
@@ -23,6 +23,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
{
@@ -169,6 +173,44 @@
{
UNIMPLEMENTED;
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 */
Modified: trunk/reactos/lib/rtl/network.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/network.c?rev=5572…
==============================================================================
--- trunk/reactos/lib/rtl/network.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/network.c [iso-8859-1] Mon Feb 20 01:13:31 2012
@@ -31,18 +31,13 @@
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 @@
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;
}