Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Kuhne <jeremy.kuhne@microsoft.com>2017-05-16 18:40:15 +0300
committerJan Kotas <jkotas@microsoft.com>2017-05-16 19:54:35 +0300
commit2a42a6a9a0dcb8d7ea8e9a61d1db899bb08b46e2 (patch)
tree68386b25396ec924acc9382f2c9328451c63035e /src/System.Private.CoreLib
parent62cdd75b06c7124f2bd553b672c934caaef86f9e (diff)
Update Corelib to use SetThreadErrorMode (dotnet/coreclr#11625)
See #19738. Note that the enumerable is only used on Unix- but updated it anyway. Conditioned the set/unset for ! Unix. SetErrorMode in the PAL is a no-op, want to use the shared interop. Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Diffstat (limited to 'src/System.Private.CoreLib')
-rw-r--r--src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs (renamed from src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.SetErrorMode.cs)4
-rw-r--r--src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems2
-rw-r--r--src/System.Private.CoreLib/shared/System/IO/FileStream.Win32.cs13
3 files changed, 8 insertions, 11 deletions
diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.SetErrorMode.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs
index 276f49c51..123eb75d7 100644
--- a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.SetErrorMode.cs
+++ b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs
@@ -8,8 +8,8 @@ internal partial class Interop
{
internal partial class Kernel32
{
- [DllImport(Libraries.Kernel32, SetLastError = false, EntryPoint = "SetErrorMode", ExactSpelling = true)]
- internal static extern uint SetErrorMode(uint newMode);
+ [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)]
+ internal static extern bool SetThreadErrorMode(uint dwNewMode, out uint lpOldMode);
internal const uint SEM_FAILCRITICALERRORS = 1;
}
diff --git a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
index 716ed69e7..981d35811 100644
--- a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
+++ b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
@@ -491,7 +491,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.SECURITY_ATTRIBUTES.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.SecurityOptions.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.SetEndOfFile.cs"/>
- <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.SetErrorMode.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.SetThreadErrorMode.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.SetFilePointerEx.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.WideCharToMultiByte.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs"/>
diff --git a/src/System.Private.CoreLib/shared/System/IO/FileStream.Win32.cs b/src/System.Private.CoreLib/shared/System/IO/FileStream.Win32.cs
index 0045ebeaf..61cd00789 100644
--- a/src/System.Private.CoreLib/shared/System/IO/FileStream.Win32.cs
+++ b/src/System.Private.CoreLib/shared/System/IO/FileStream.Win32.cs
@@ -2,13 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Buffers;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Threading;
-using System.Threading.Tasks;
using Microsoft.Win32.SafeHandles;
-using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
namespace System.IO
{
@@ -38,7 +33,8 @@ namespace System.IO
flagsAndAttributes |= (Interop.Kernel32.SecurityOptions.SECURITY_SQOS_PRESENT | Interop.Kernel32.SecurityOptions.SECURITY_ANONYMOUS);
// Don't pop up a dialog for reading from an empty floppy drive
- uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS);
+ uint oldMode;
+ bool success = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out oldMode);
try
{
SafeFileHandle fileHandle = Interop.Kernel32.CreateFile(_path, fAccess, share, ref secAttrs, mode, flagsAndAttributes, IntPtr.Zero);
@@ -70,7 +66,8 @@ namespace System.IO
}
finally
{
- Interop.Kernel32.SetErrorMode(oldMode);
+ if (success)
+ Interop.Kernel32.SetThreadErrorMode(oldMode, out oldMode);
}
}
}