From 207c3c4a535e3acde00ecbf252dcf2f2f41bd5d3 Mon Sep 17 00:00:00 2001 From: Alex Perovich Date: Thu, 2 Mar 2017 20:11:47 -0600 Subject: [PATCH] Merge shared changes from corert and use C# shared project to enable VS editing (dotnet/coreclr#9922) Commit migrated from https://github.com/dotnet/coreclr/commit/684784fdb929f2c7d0173a317cb6e3ac6dc29d1a --- .../src/mscorlib/System.Private.CoreLib.csproj | 1560 ++++++++++---------- .../src/mscorlib/System.Private.CoreLib.sln | 31 +- .../shared/Interop/Unix/Interop.Libraries.cs | 4 +- .../Interop/Unix/System.Native/Interop.GetCwd.cs | 2 +- .../Interop/Unix/System.Native/Interop.MksTemps.cs | 0 .../Windows/BCrypt/Interop.BCryptGenRandom.cs | 22 +- .../Interop/Windows/BCrypt/Interop.NTSTATUS.cs | 19 - .../shared/Interop/Windows/Interop.Errors.cs | 35 +- .../shared/Interop/Windows/Interop.Libraries.cs | 2 +- .../Windows/Kernel32}/Interop.CreateFile.cs | 4 +- .../Kernel32/Interop.FILE_INFO_BY_HANDLE_CLASS.cs} | 0 .../Windows/Kernel32/Interop.FileOperations.cs | 11 - .../Interop.GetFileInformationByHandleEx.cs | 2 +- .../Windows/Kernel32/Interop.SafeCreateFile.cs | 45 - .../Windows/Kernel32/Interop.SetErrorMode.cs | 2 + .../Windows/Kernel32/Interop.UnsafeCreateFile.cs | 25 - .../shared/System.Private.CoreLib.Shared.projitems | 182 +++ .../shared/System.Private.CoreLib.Shared.shproj | 19 + .../shared/System.Private.CoreLib.Shared.sources | 178 --- .../mscorlib/shared/System/IO/FileStream.OSX.cs | 4 +- .../mscorlib/shared/System/IO/FileStream.Win32.cs | 15 +- .../src/mscorlib/shared/System/IO/Path.Unix.cs | 21 +- .../src/mscorlib/shared/System/IO/Path.Win32.cs | 36 - src/coreclr/src/mscorlib/shared/System/IO/Path.cs | 2 +- src/coreclr/src/mscorlib/{corefx => src}/Debug.cs | 0 .../Interop.Calendar.cs | 0 .../System.Globalization.Native/Interop.Casing.cs | 0 .../Interop.Collation.cs | 0 .../System.Globalization.Native/Interop.Idna.cs | 0 .../System.Globalization.Native/Interop.Locale.cs | 0 .../Interop.Normalization.cs | 0 .../Interop.ResultCode.cs | 0 .../Interop.TimeZoneInfo.cs | 0 .../System.Globalization.Native/Interop.Utils.cs | 0 .../Unix/System.Native/Interop.GetRandomBytes.cs | 19 + .../Windows/Crypt32/Interop.CryptProtectMemory.cs | 0 .../Interop/Windows/Normaliz/Interop.Idna.cs | 0 .../Interop/Windows/NtDll/Interop.ZeroMemory.cs | 0 .../Windows/kernel32/Interop.Globalization.cs | 0 .../kernel32/Interop.WideCharToMultiByte.cs | 0 .../Windows/oleaut32/Interop.SysAllocStringLen.cs | 0 .../Windows/oleaut32/Interop.SysStringLen.cs | 0 src/coreclr/src/mscorlib/{corefx => src}/SR.cs | 3 + .../System/Buffers/ArrayPoolEventSource.cs | 0 .../mscorlib/{corefx => src}/System/HResults.cs | 0 .../System/Security/SafeBSTRHandle.cs | 0 .../System/Security/SecureString.Unix.cs | 0 .../System/Security/SecureString.Windows.cs | 0 .../System/Security/SecureString.cs | 0 .../System/Threading/ClrThreadPoolBoundHandle.cs | 0 .../ClrThreadPoolBoundHandleOverlapped.cs | 0 .../ClrThreadPoolPreAllocatedOverlapped.cs | 0 52 files changed, 1077 insertions(+), 1166 deletions(-) rename src/coreclr/src/mscorlib/{corefx => shared}/Interop/Unix/System.Native/Interop.MksTemps.cs (100%) delete mode 100644 src/coreclr/src/mscorlib/shared/Interop/Windows/BCrypt/Interop.NTSTATUS.cs rename src/coreclr/src/mscorlib/{corefx/Interop/Windows/kernel32 => shared/Interop/Windows/Kernel32}/Interop.CreateFile.cs (93%) rename src/coreclr/src/mscorlib/{corefx/Interop/Windows/kernel32/Interop.SetFileInformationByHandle.cs => shared/Interop/Windows/Kernel32/Interop.FILE_INFO_BY_HANDLE_CLASS.cs} (100%) delete mode 100644 src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.FileOperations.cs delete mode 100644 src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SafeCreateFile.cs delete mode 100644 src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.UnsafeCreateFile.cs create mode 100644 src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems create mode 100644 src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.shproj delete mode 100644 src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.sources delete mode 100644 src/coreclr/src/mscorlib/shared/System/IO/Path.Win32.cs rename src/coreclr/src/mscorlib/{corefx => src}/Debug.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Unix/System.Globalization.Native/Interop.Calendar.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Unix/System.Globalization.Native/Interop.Casing.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Unix/System.Globalization.Native/Interop.Collation.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Unix/System.Globalization.Native/Interop.Idna.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Unix/System.Globalization.Native/Interop.Locale.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Unix/System.Globalization.Native/Interop.Normalization.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Unix/System.Globalization.Native/Interop.ResultCode.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Unix/System.Globalization.Native/Interop.TimeZoneInfo.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Unix/System.Globalization.Native/Interop.Utils.cs (100%) create mode 100644 src/coreclr/src/mscorlib/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Windows/Crypt32/Interop.CryptProtectMemory.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Windows/Normaliz/Interop.Idna.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Windows/NtDll/Interop.ZeroMemory.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Windows/kernel32/Interop.Globalization.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Windows/kernel32/Interop.WideCharToMultiByte.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Windows/oleaut32/Interop.SysAllocStringLen.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/Interop/Windows/oleaut32/Interop.SysStringLen.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/SR.cs (99%) rename src/coreclr/src/mscorlib/{shared => src}/System/Buffers/ArrayPoolEventSource.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/System/HResults.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/System/Security/SafeBSTRHandle.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/System/Security/SecureString.Unix.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/System/Security/SecureString.Windows.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/System/Security/SecureString.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/System/Threading/ClrThreadPoolBoundHandle.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/System/Threading/ClrThreadPoolBoundHandleOverlapped.cs (100%) rename src/coreclr/src/mscorlib/{corefx => src}/System/Threading/ClrThreadPoolPreAllocatedOverlapped.cs (100%) diff --git a/src/coreclr/src/mscorlib/System.Private.CoreLib.csproj b/src/coreclr/src/mscorlib/System.Private.CoreLib.csproj index 43056cd..216dcf3 100644 --- a/src/coreclr/src/mscorlib/System.Private.CoreLib.csproj +++ b/src/coreclr/src/mscorlib/System.Private.CoreLib.csproj @@ -1,4 +1,4 @@ - + @@ -82,6 +82,11 @@ false none + + + PLATFORM_OSX;$(DefineConstants) + + System.Private.CoreLib @@ -101,7 +106,6 @@ $(MSBuildThisFileDirectory)Common $(MSBuildThisFileDirectory)src - $(MSBuildThisFileDirectory)corefx $(MSBuildThisFileDirectory) $(BclSourcesRoot)\System\Globalization\Tables @@ -118,895 +122,888 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - + + + + + - - - - - - - - + + + + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - + + + + - - - + + + - + - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - + - - - - - + + + - + - - + + - - - - - + + + + + - + - - + + - + - + - + - + - + - - - - - - @@ -1017,6 +1014,7 @@ $(DefineConstants) + true diff --git a/src/coreclr/src/mscorlib/System.Private.CoreLib.sln b/src/coreclr/src/mscorlib/System.Private.CoreLib.sln index 297d938..d5cdd02 100644 --- a/src/coreclr/src/mscorlib/System.Private.CoreLib.sln +++ b/src/coreclr/src/mscorlib/System.Private.CoreLib.sln @@ -1,10 +1,17 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26208.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Private.CoreLib", "System.Private.CoreLib.csproj", "{3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}" EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "System.Private.CoreLib.Shared", "shared\System.Private.CoreLib.Shared.shproj", "{C5ED3C1D-B572-46F1-8F96-522A85CE1179}" +EndProject Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + shared\System.Private.CoreLib.Shared.projitems*{3da06c3a-2e7b-4cb7-80ed-9b12916013f9}*SharedItemsImports = 4 + shared\System.Private.CoreLib.Shared.projitems*{c5ed3c1d-b572-46f1-8f96-522a85ce1179}*SharedItemsImports = 13 + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Checked|amd64 = Checked|amd64 Checked|arm = Checked|arm @@ -20,14 +27,14 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|amd64.ActiveCfg = Checked|amd64 - {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|amd64.Build.0 = Checked|amd64 - {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|arm.ActiveCfg = Checked|arm - {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|arm.Build.0 = Checked|arm - {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|arm64.ActiveCfg = Checked|arm64 - {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|arm64.Build.0 = Checked|arm64 - {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|x86.ActiveCfg = Checked|x86 - {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|x86.Build.0 = Checked|x86 + {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|amd64.ActiveCfg = Release|amd64 + {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|amd64.Build.0 = Release|amd64 + {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|arm.ActiveCfg = Release|arm + {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|arm.Build.0 = Release|arm + {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|arm64.ActiveCfg = Release|arm64 + {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|arm64.Build.0 = Release|arm64 + {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|x86.ActiveCfg = Release|x86 + {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Checked|x86.Build.0 = Release|x86 {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Debug|amd64.ActiveCfg = Debug|amd64 {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Debug|amd64.Build.0 = Debug|amd64 {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}.Debug|arm.ActiveCfg = Debug|arm @@ -48,4 +55,4 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection -EndGlobal \ No newline at end of file +EndGlobal diff --git a/src/coreclr/src/mscorlib/shared/Interop/Unix/Interop.Libraries.cs b/src/coreclr/src/mscorlib/shared/Interop/Unix/Interop.Libraries.cs index 1b6d26e..7b3dea4 100644 --- a/src/coreclr/src/mscorlib/shared/Interop/Unix/Interop.Libraries.cs +++ b/src/coreclr/src/mscorlib/shared/Interop/Unix/Interop.Libraries.cs @@ -4,9 +4,9 @@ internal static partial class Interop { - private static partial class Libraries + internal static partial class Libraries { - internal const string GlobalizationInterop = "System.Globalization.Native"; // CoreFX wrappers for ICU + internal const string GlobalizationInterop = "System.Globalization.Native"; internal const string SystemNative = "System.Native"; } } diff --git a/src/coreclr/src/mscorlib/shared/Interop/Unix/System.Native/Interop.GetCwd.cs b/src/coreclr/src/mscorlib/shared/Interop/Unix/System.Native/Interop.GetCwd.cs index 724e342..a27a35c 100644 --- a/src/coreclr/src/mscorlib/shared/Interop/Unix/System.Native/Interop.GetCwd.cs +++ b/src/coreclr/src/mscorlib/shared/Interop/Unix/System.Native/Interop.GetCwd.cs @@ -34,7 +34,7 @@ internal static partial class Interop { checked { bufferSize *= 2; } var buf = new byte[Math.Min(bufferSize, maxPath)]; - fixed (byte* ptr = buf) + fixed (byte* ptr = &buf[0]) { result = GetCwdHelper(ptr, buf.Length); if (result != null) diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Native/Interop.MksTemps.cs b/src/coreclr/src/mscorlib/shared/Interop/Unix/System.Native/Interop.MksTemps.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Native/Interop.MksTemps.cs rename to src/coreclr/src/mscorlib/shared/Interop/Unix/System.Native/Interop.MksTemps.cs diff --git a/src/coreclr/src/mscorlib/shared/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs b/src/coreclr/src/mscorlib/shared/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs index d2ce413..bc35712 100644 --- a/src/coreclr/src/mscorlib/shared/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs +++ b/src/coreclr/src/mscorlib/shared/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs @@ -10,7 +10,7 @@ internal partial class Interop { internal partial class BCrypt { - internal static unsafe NTSTATUS BCryptGenRandom(byte* pbBuffer, int count) + internal static unsafe int BCryptGenRandom(byte* pbBuffer, int count) { Debug.Assert(pbBuffer != null); Debug.Assert(count >= 0); @@ -19,8 +19,26 @@ internal partial class Interop } private const int BCRYPT_USE_SYSTEM_PREFERRED_RNG = 0x00000002; + internal const int STATUS_SUCCESS = 0x0; + internal const int STATUS_NO_MEMORY = unchecked((int)0xC0000017); [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - private static unsafe extern NTSTATUS BCryptGenRandom(IntPtr hAlgorithm, byte* pbBuffer, int cbBuffer, int dwFlags); + private static unsafe extern int BCryptGenRandom(IntPtr hAlgorithm, byte* pbBuffer, int cbBuffer, int dwFlags); + } + + internal static unsafe void GetRandomBytes(byte* buffer, int length) + { + int status = BCrypt.BCryptGenRandom(buffer, length); + if (status != BCrypt.STATUS_SUCCESS) + { + if (status == BCrypt.STATUS_NO_MEMORY) + { + throw new OutOfMemoryException(); + } + else + { + throw new InvalidOperationException(); + } + } } } diff --git a/src/coreclr/src/mscorlib/shared/Interop/Windows/BCrypt/Interop.NTSTATUS.cs b/src/coreclr/src/mscorlib/shared/Interop/Windows/BCrypt/Interop.NTSTATUS.cs deleted file mode 100644 index 49d674f..0000000 --- a/src/coreclr/src/mscorlib/shared/Interop/Windows/BCrypt/Interop.NTSTATUS.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// 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; - -internal partial class Interop -{ - internal partial class BCrypt - { - internal enum NTSTATUS : uint - { - STATUS_SUCCESS = 0x0, - STATUS_NOT_FOUND = 0xc0000225, - STATUS_INVALID_PARAMETER = 0xc000000d, - STATUS_NO_MEMORY = 0xc0000017, - } - } -} diff --git a/src/coreclr/src/mscorlib/shared/Interop/Windows/Interop.Errors.cs b/src/coreclr/src/mscorlib/shared/Interop/Windows/Interop.Errors.cs index 7eeb18d..9280d8f 100644 --- a/src/coreclr/src/mscorlib/shared/Interop/Windows/Interop.Errors.cs +++ b/src/coreclr/src/mscorlib/shared/Interop/Windows/Interop.Errors.cs @@ -7,65 +7,36 @@ internal partial class Interop internal partial class Errors { internal const int ERROR_SUCCESS = 0x0; - internal const int ERROR_INVALID_FUNCTION = 0x1; internal const int ERROR_FILE_NOT_FOUND = 0x2; internal const int ERROR_PATH_NOT_FOUND = 0x3; internal const int ERROR_ACCESS_DENIED = 0x5; internal const int ERROR_INVALID_HANDLE = 0x6; internal const int ERROR_NOT_ENOUGH_MEMORY = 0x8; - internal const int ERROR_INVALID_DATA = 0xD; internal const int ERROR_INVALID_DRIVE = 0xF; internal const int ERROR_NO_MORE_FILES = 0x12; internal const int ERROR_NOT_READY = 0x15; - internal const int ERROR_BAD_LENGTH = 0x18; internal const int ERROR_SHARING_VIOLATION = 0x20; - internal const int ERROR_LOCK_VIOLATION = 0x21; internal const int ERROR_HANDLE_EOF = 0x26; internal const int ERROR_FILE_EXISTS = 0x50; internal const int ERROR_INVALID_PARAMETER = 0x57; internal const int ERROR_BROKEN_PIPE = 0x6D; internal const int ERROR_INSUFFICIENT_BUFFER = 0x7A; internal const int ERROR_INVALID_NAME = 0x7B; - internal const int ERROR_NEGATIVE_SEEK = 0x83; - internal const int ERROR_DIR_NOT_EMPTY = 0x91; internal const int ERROR_BAD_PATHNAME = 0xA1; - internal const int ERROR_LOCK_FAILED = 0xA7; - internal const int ERROR_BUSY = 0xAA; internal const int ERROR_ALREADY_EXISTS = 0xB7; - internal const int ERROR_BAD_EXE_FORMAT = 0xC1; internal const int ERROR_ENVVAR_NOT_FOUND = 0xCB; internal const int ERROR_FILENAME_EXCED_RANGE = 0xCE; - internal const int ERROR_EXE_MACHINE_TYPE_MISMATCH = 0xD8; - internal const int ERROR_PIPE_BUSY = 0xE7; internal const int ERROR_NO_DATA = 0xE8; - internal const int ERROR_PIPE_NOT_CONNECTED = 0xE9; internal const int ERROR_MORE_DATA = 0xEA; internal const int ERROR_NO_MORE_ITEMS = 0x103; - internal const int ERROR_PARTIAL_COPY = 0x12B; + internal const int ERROR_NOT_OWNER = 0x120; + internal const int ERROR_TOO_MANY_POSTS = 0x12A; internal const int ERROR_ARITHMETIC_OVERFLOW = 0x216; - internal const int ERROR_PIPE_CONNECTED = 0x217; - internal const int ERROR_PIPE_LISTENING = 0x218; + internal const int ERROR_MUTANT_LIMIT_EXCEEDED = 0x24B; internal const int ERROR_OPERATION_ABORTED = 0x3E3; internal const int ERROR_IO_PENDING = 0x3E5; - internal const int ERROR_NO_TOKEN = 0x3f0; - internal const int ERROR_DLL_INIT_FAILED = 0x45A; internal const int ERROR_NOT_FOUND = 0x490; - internal const int ERROR_NON_ACCOUNT_SID = 0x4E9; - internal const int ERROR_NOT_ALL_ASSIGNED = 0x514; - internal const int ERROR_UNKNOWN_REVISION = 0x519; - internal const int ERROR_INVALID_OWNER = 0x51B; - internal const int ERROR_INVALID_PRIMARY_GROUP = 0x51C; - internal const int ERROR_NO_SUCH_PRIVILEGE = 0x521; - internal const int ERROR_PRIVILEGE_NOT_HELD = 0x522; - internal const int ERROR_INVALID_ACL = 0x538; - internal const int ERROR_INVALID_SECURITY_DESCR = 0x53A; - internal const int ERROR_INVALID_SID = 0x539; internal const int ERROR_BAD_IMPERSONATION_LEVEL = 0x542; - internal const int ERROR_CANT_OPEN_ANONYMOUS = 0x543; - internal const int ERROR_NO_SECURITY_ON_OBJECT = 0x546; - internal const int ERROR_TRUSTED_RELATIONSHIP_FAILURE = 0x6FD; - internal const int ERROR_RESOURCE_LANG_NOT_FOUND = 0x717; - internal const int EFail = unchecked((int)0x80004005); internal const int E_FILENOTFOUND = unchecked((int)0x80070002); } } diff --git a/src/coreclr/src/mscorlib/shared/Interop/Windows/Interop.Libraries.cs b/src/coreclr/src/mscorlib/shared/Interop/Windows/Interop.Libraries.cs index f19f9dc..58bb12d 100644 --- a/src/coreclr/src/mscorlib/shared/Interop/Windows/Interop.Libraries.cs +++ b/src/coreclr/src/mscorlib/shared/Interop/Windows/Interop.Libraries.cs @@ -4,7 +4,7 @@ internal static partial class Interop { - internal static class Libraries + internal static partial class Libraries { internal const string BCrypt = "BCrypt.dll"; internal const string Crypt32 = "crypt32.dll"; diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Windows/kernel32/Interop.CreateFile.cs b/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.CreateFile.cs similarity index 93% rename from src/coreclr/src/mscorlib/corefx/Interop/Windows/kernel32/Interop.CreateFile.cs rename to src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.CreateFile.cs index 5f6f611..9ee1e16 100644 --- a/src/coreclr/src/mscorlib/corefx/Interop/Windows/kernel32/Interop.CreateFile.cs +++ b/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.CreateFile.cs @@ -19,7 +19,7 @@ internal partial class Interop string lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, - [In] ref SECURITY_ATTRIBUTES securityAttrs, + ref SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile); @@ -28,7 +28,7 @@ internal partial class Interop string lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, - [In] ref SECURITY_ATTRIBUTES securityAttrs, + ref SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile) diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Windows/kernel32/Interop.SetFileInformationByHandle.cs b/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.FILE_INFO_BY_HANDLE_CLASS.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Windows/kernel32/Interop.SetFileInformationByHandle.cs rename to src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.FILE_INFO_BY_HANDLE_CLASS.cs diff --git a/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.FileOperations.cs b/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.FileOperations.cs deleted file mode 100644 index 2bc5228..0000000 --- a/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.FileOperations.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -internal partial class Interop -{ - internal partial class Kernel32 - { - internal const uint SEM_FAILCRITICALERRORS = 1; - } -} diff --git a/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.GetFileInformationByHandleEx.cs b/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.GetFileInformationByHandleEx.cs index 40f9e911..1106cff 100644 --- a/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.GetFileInformationByHandleEx.cs +++ b/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.GetFileInformationByHandleEx.cs @@ -13,7 +13,7 @@ internal partial class Interop [DllImport(Libraries.Kernel32, SetLastError = true)] internal static extern bool GetFileInformationByHandleEx(SafeFileHandle hFile, FILE_INFO_BY_HANDLE_CLASS FileInformationClass, out FILE_STANDARD_INFO lpFileInformation, uint dwBufferSize); - internal partial struct FILE_STANDARD_INFO + internal struct FILE_STANDARD_INFO { internal long AllocationSize; internal long EndOfFile; diff --git a/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SafeCreateFile.cs b/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SafeCreateFile.cs deleted file mode 100644 index 4192f56..0000000 --- a/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SafeCreateFile.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// 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; -using System.IO; -using System.Runtime.InteropServices; -using Microsoft.Win32.SafeHandles; - -internal partial class Interop -{ - internal partial class Kernel32 - { - internal static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1); // WinBase.h - - /// - /// Does not allow access to non-file devices. This disallows DOS devices like "con:", "com1:", - /// "lpt1:", etc. Use this to avoid security problems, like allowing a web client asking a server - /// for "http://server/com1.aspx" and then causing a worker process to hang. - /// - internal static SafeFileHandle SafeCreateFile( - String lpFileName, - int dwDesiredAccess, - System.IO.FileShare dwShareMode, - ref Interop.Kernel32.SECURITY_ATTRIBUTES securityAttrs, - FileMode dwCreationDisposition, - int dwFlagsAndAttributes, - IntPtr hTemplateFile) - { - SafeFileHandle handle = UnsafeCreateFile(lpFileName, dwDesiredAccess, dwShareMode, ref securityAttrs, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); - - if (!handle.IsInvalid) - { - int fileType = Interop.Kernel32.GetFileType(handle); - if (fileType != Interop.Kernel32.FileTypes.FILE_TYPE_DISK) - { - handle.Dispose(); - throw new NotSupportedException(SR.NotSupported_FileStreamOnNonFiles); - } - } - - return handle; - } - } -} diff --git a/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SetErrorMode.cs b/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SetErrorMode.cs index caa2ce5..276f49c 100644 --- a/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SetErrorMode.cs +++ b/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SetErrorMode.cs @@ -10,5 +10,7 @@ internal partial class Interop { [DllImport(Libraries.Kernel32, SetLastError = false, EntryPoint = "SetErrorMode", ExactSpelling = true)] internal static extern uint SetErrorMode(uint newMode); + + internal const uint SEM_FAILCRITICALERRORS = 1; } } diff --git a/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.UnsafeCreateFile.cs b/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.UnsafeCreateFile.cs deleted file mode 100644 index 9a5cd28..0000000 --- a/src/coreclr/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.UnsafeCreateFile.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// 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; -using System.IO; -using Microsoft.Win32.SafeHandles; - -internal partial class Interop -{ - internal partial class Kernel32 - { - internal static SafeFileHandle UnsafeCreateFile( - string lpFileName, - int dwDesiredAccess, - FileShare dwShareMode, - ref Interop.Kernel32.SECURITY_ATTRIBUTES securityAttrs, - FileMode dwCreationDisposition, - int dwFlagsAndAttributes, - IntPtr hTemplateFile) - { - return CreateFile(lpFileName, dwDesiredAccess, dwShareMode, ref securityAttrs, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); - } - } -} diff --git a/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems b/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems new file mode 100644 index 0000000..2ca7c35 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems @@ -0,0 +1,182 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + c5ed3c1d-b572-46f1-8f96-522a85ce1179 + + + + + + false + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.shproj b/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.shproj new file mode 100644 index 0000000..af61b3b --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.shproj @@ -0,0 +1,19 @@ + + + + c5ed3c1d-b572-46f1-8f96-522a85ce1179 + 14.0 + + + + true + true + true + + + + + + + + diff --git a/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.sources b/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.sources deleted file mode 100644 index 50a97e5..0000000 --- a/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.sources +++ /dev/null @@ -1,178 +0,0 @@ - - - - false - false - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/coreclr/src/mscorlib/shared/System/IO/FileStream.OSX.cs b/src/coreclr/src/mscorlib/shared/System/IO/FileStream.OSX.cs index a1167bf..f29e922 100644 --- a/src/coreclr/src/mscorlib/shared/System/IO/FileStream.OSX.cs +++ b/src/coreclr/src/mscorlib/shared/System/IO/FileStream.OSX.cs @@ -8,12 +8,12 @@ namespace System.IO { private void LockInternal(long position, long length) { - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_OSXFileLocking")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_OSXFileLocking); } private void UnlockInternal(long position, long length) { - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_OSXFileLocking")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_OSXFileLocking); } } } diff --git a/src/coreclr/src/mscorlib/shared/System/IO/FileStream.Win32.cs b/src/coreclr/src/mscorlib/shared/System/IO/FileStream.Win32.cs index 82e7473..d787320 100644 --- a/src/coreclr/src/mscorlib/shared/System/IO/FileStream.Win32.cs +++ b/src/coreclr/src/mscorlib/shared/System/IO/FileStream.Win32.cs @@ -80,7 +80,7 @@ namespace System.IO uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS); try { - SafeFileHandle fileHandle = Interop.Kernel32.SafeCreateFile(_path, fAccess, share, ref secAttrs, mode, flagsAndAttributes, IntPtr.Zero); + SafeFileHandle fileHandle = Interop.Kernel32.CreateFile(_path, fAccess, share, ref secAttrs, mode, flagsAndAttributes, IntPtr.Zero); fileHandle.IsAsync = _useAsyncIO; if (fileHandle.IsInvalid) @@ -92,11 +92,18 @@ namespace System.IO // probably be consistent w/ every other directory. int errorCode = Marshal.GetLastWin32Error(); - if (errorCode == Interop.Errors.ERROR_PATH_NOT_FOUND && _path.Equals(Directory.InternalGetDirectoryRoot(_path))) + if (errorCode == Interop.Errors.ERROR_PATH_NOT_FOUND && _path.Length == PathInternal.GetRootLength(_path)) errorCode = Interop.Errors.ERROR_ACCESS_DENIED; throw Win32Marshal.GetExceptionForWin32Error(errorCode, _path); } + + int fileType = Interop.Kernel32.GetFileType(fileHandle); + if (fileType != Interop.Kernel32.FileTypes.FILE_TYPE_DISK) + { + fileHandle.Dispose(); + throw new NotSupportedException(SR.NotSupported_FileStreamOnNonFiles); + } return fileHandle; } @@ -271,11 +278,11 @@ namespace System.IO get { return _canSeek; } } - private long GetLengthInternal() + private unsafe long GetLengthInternal() { Interop.Kernel32.FILE_STANDARD_INFO info = new Interop.Kernel32.FILE_STANDARD_INFO(); - if (!Interop.Kernel32.GetFileInformationByHandleEx(_fileHandle, Interop.Kernel32.FILE_INFO_BY_HANDLE_CLASS.FileStandardInfo, out info, (uint)Marshal.SizeOf())) + if (!Interop.Kernel32.GetFileInformationByHandleEx(_fileHandle, Interop.Kernel32.FILE_INFO_BY_HANDLE_CLASS.FileStandardInfo, out info, (uint)sizeof(Interop.Kernel32.FILE_STANDARD_INFO))) throw Win32Marshal.GetExceptionForLastWin32Error(); long len = info.EndOfFile; // If we're writing near the end of the file, we must include our diff --git a/src/coreclr/src/mscorlib/shared/System/IO/Path.Unix.cs b/src/coreclr/src/mscorlib/shared/System/IO/Path.Unix.cs index c566fa0..500c60a 100644 --- a/src/coreclr/src/mscorlib/shared/System/IO/Path.Unix.cs +++ b/src/coreclr/src/mscorlib/shared/System/IO/Path.Unix.cs @@ -16,8 +16,6 @@ namespace System.IO internal static int MaxPath => Interop.Sys.MaxPath; - private static readonly bool s_isMac = Interop.Sys.GetUnixName() == "OSX"; - // Expands the given path to a fully qualified path. public static string GetFullPath(string path) { @@ -201,16 +199,17 @@ namespace System.IO return IsPathRooted(path) ? PathInternal.DirectorySeparatorCharAsString : String.Empty; } - private static unsafe void GetCryptoRandomBytes(byte* bytes, int byteCount) + /// Gets whether the system is case-sensitive. + internal static bool IsCaseSensitive { - // We want to avoid dependencies on the Crypto library when compiling in CoreCLR. This - // will use the existing PAL implementation. - byte[] buffer = new byte[KeyLength]; - Microsoft.Win32.Win32Native.Random(bStrong: true, buffer: buffer, length: KeyLength); - Runtime.InteropServices.Marshal.Copy(buffer, 0, (IntPtr)bytes, KeyLength); + get + { + #if PLATFORM_OSX + return false; + #else + return true; + #endif + } } - - /// Gets whether the system is case-sensitive. - internal static bool IsCaseSensitive { get { return !s_isMac; } } } } diff --git a/src/coreclr/src/mscorlib/shared/System/IO/Path.Win32.cs b/src/coreclr/src/mscorlib/shared/System/IO/Path.Win32.cs deleted file mode 100644 index 8a9e62e..0000000 --- a/src/coreclr/src/mscorlib/shared/System/IO/Path.Win32.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// 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.Diagnostics; - -namespace System.IO -{ - public static partial class Path - { - private static unsafe void GetCryptoRandomBytes(byte* bytes, int byteCount) - { - // We need to fill a byte array with cryptographically-strong random bytes, but we can't reference - // System.Security.Cryptography.RandomNumberGenerator.dll due to layering. Instead, we just - // call to BCryptGenRandom directly, which is all that RandomNumberGenerator does. - - Debug.Assert(bytes != null); - Debug.Assert(byteCount >= 0); - - Interop.BCrypt.NTSTATUS status = Interop.BCrypt.BCryptGenRandom(bytes, byteCount); - if (status == Interop.BCrypt.NTSTATUS.STATUS_SUCCESS) - { - return; - } - else if (status == Interop.BCrypt.NTSTATUS.STATUS_NO_MEMORY) - { - throw new OutOfMemoryException(); - } - else - { - Debug.Fail("BCryptGenRandom should only fail due to OOM or invalid args / handle inputs."); - throw new InvalidOperationException(); - } - } - } -} diff --git a/src/coreclr/src/mscorlib/shared/System/IO/Path.cs b/src/coreclr/src/mscorlib/shared/System/IO/Path.cs index ce80424..b3a8783 100644 --- a/src/coreclr/src/mscorlib/shared/System/IO/Path.cs +++ b/src/coreclr/src/mscorlib/shared/System/IO/Path.cs @@ -154,7 +154,7 @@ namespace System.IO public static unsafe string GetRandomFileName() { byte* pKey = stackalloc byte[KeyLength]; - GetCryptoRandomBytes(pKey, KeyLength); + Interop.GetRandomBytes(pKey, KeyLength); const int RandomFileNameLength = 12; char* pRandomFileName = stackalloc char[RandomFileNameLength]; diff --git a/src/coreclr/src/mscorlib/corefx/Debug.cs b/src/coreclr/src/mscorlib/src/Debug.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Debug.cs rename to src/coreclr/src/mscorlib/src/Debug.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Calendar.cs b/src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Calendar.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Calendar.cs rename to src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Calendar.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Casing.cs b/src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Casing.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Casing.cs rename to src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Casing.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Collation.cs b/src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Collation.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Collation.cs rename to src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Collation.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Idna.cs b/src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Idna.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Idna.cs rename to src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Idna.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Locale.cs b/src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Locale.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Locale.cs rename to src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Locale.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Normalization.cs b/src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Normalization.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Normalization.cs rename to src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Normalization.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.ResultCode.cs b/src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.ResultCode.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.ResultCode.cs rename to src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.ResultCode.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.TimeZoneInfo.cs b/src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.TimeZoneInfo.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.TimeZoneInfo.cs rename to src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.TimeZoneInfo.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Utils.cs b/src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Utils.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Utils.cs rename to src/coreclr/src/mscorlib/src/Interop/Unix/System.Globalization.Native/Interop.Utils.cs diff --git a/src/coreclr/src/mscorlib/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs b/src/coreclr/src/mscorlib/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs new file mode 100644 index 0000000..4e81568 --- /dev/null +++ b/src/coreclr/src/mscorlib/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// 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; +using System.Diagnostics; +using System.Runtime.InteropServices; + +internal partial class Interop +{ + internal static unsafe void GetRandomBytes(byte* bytes, int byteCount) + { + // We want to avoid dependencies on the Crypto library when compiling in CoreCLR. This + // will use the existing PAL implementation. + byte[] buffer = new byte[byteCount]; + Microsoft.Win32.Win32Native.Random(bStrong: true, buffer: buffer, length: byteCount); + System.Runtime.InteropServices.Marshal.Copy(buffer, 0, (IntPtr)bytes, byteCount); + } +} diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Windows/Crypt32/Interop.CryptProtectMemory.cs b/src/coreclr/src/mscorlib/src/Interop/Windows/Crypt32/Interop.CryptProtectMemory.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Windows/Crypt32/Interop.CryptProtectMemory.cs rename to src/coreclr/src/mscorlib/src/Interop/Windows/Crypt32/Interop.CryptProtectMemory.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Windows/Normaliz/Interop.Idna.cs b/src/coreclr/src/mscorlib/src/Interop/Windows/Normaliz/Interop.Idna.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Windows/Normaliz/Interop.Idna.cs rename to src/coreclr/src/mscorlib/src/Interop/Windows/Normaliz/Interop.Idna.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Windows/NtDll/Interop.ZeroMemory.cs b/src/coreclr/src/mscorlib/src/Interop/Windows/NtDll/Interop.ZeroMemory.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Windows/NtDll/Interop.ZeroMemory.cs rename to src/coreclr/src/mscorlib/src/Interop/Windows/NtDll/Interop.ZeroMemory.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Windows/kernel32/Interop.Globalization.cs b/src/coreclr/src/mscorlib/src/Interop/Windows/kernel32/Interop.Globalization.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Windows/kernel32/Interop.Globalization.cs rename to src/coreclr/src/mscorlib/src/Interop/Windows/kernel32/Interop.Globalization.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Windows/kernel32/Interop.WideCharToMultiByte.cs b/src/coreclr/src/mscorlib/src/Interop/Windows/kernel32/Interop.WideCharToMultiByte.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Windows/kernel32/Interop.WideCharToMultiByte.cs rename to src/coreclr/src/mscorlib/src/Interop/Windows/kernel32/Interop.WideCharToMultiByte.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Windows/oleaut32/Interop.SysAllocStringLen.cs b/src/coreclr/src/mscorlib/src/Interop/Windows/oleaut32/Interop.SysAllocStringLen.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Windows/oleaut32/Interop.SysAllocStringLen.cs rename to src/coreclr/src/mscorlib/src/Interop/Windows/oleaut32/Interop.SysAllocStringLen.cs diff --git a/src/coreclr/src/mscorlib/corefx/Interop/Windows/oleaut32/Interop.SysStringLen.cs b/src/coreclr/src/mscorlib/src/Interop/Windows/oleaut32/Interop.SysStringLen.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/Interop/Windows/oleaut32/Interop.SysStringLen.cs rename to src/coreclr/src/mscorlib/src/Interop/Windows/oleaut32/Interop.SysStringLen.cs diff --git a/src/coreclr/src/mscorlib/corefx/SR.cs b/src/coreclr/src/mscorlib/src/SR.cs similarity index 99% rename from src/coreclr/src/mscorlib/corefx/SR.cs rename to src/coreclr/src/mscorlib/src/SR.cs index 35fe39c..d760e44 100644 --- a/src/coreclr/src/mscorlib/corefx/SR.cs +++ b/src/coreclr/src/mscorlib/src/SR.cs @@ -835,4 +835,7 @@ internal static class SR { get { return Environment.GetResourceString("Arg_ArrayPlusOffTooSmall"); } } + + internal static string PlatformNotSupported_OSXFileLocking => + Environment.GetResourceString("PlatformNotSupported_OSXFileLocking"); } diff --git a/src/coreclr/src/mscorlib/shared/System/Buffers/ArrayPoolEventSource.cs b/src/coreclr/src/mscorlib/src/System/Buffers/ArrayPoolEventSource.cs similarity index 100% rename from src/coreclr/src/mscorlib/shared/System/Buffers/ArrayPoolEventSource.cs rename to src/coreclr/src/mscorlib/src/System/Buffers/ArrayPoolEventSource.cs diff --git a/src/coreclr/src/mscorlib/corefx/System/HResults.cs b/src/coreclr/src/mscorlib/src/System/HResults.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/System/HResults.cs rename to src/coreclr/src/mscorlib/src/System/HResults.cs diff --git a/src/coreclr/src/mscorlib/corefx/System/Security/SafeBSTRHandle.cs b/src/coreclr/src/mscorlib/src/System/Security/SafeBSTRHandle.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/System/Security/SafeBSTRHandle.cs rename to src/coreclr/src/mscorlib/src/System/Security/SafeBSTRHandle.cs diff --git a/src/coreclr/src/mscorlib/corefx/System/Security/SecureString.Unix.cs b/src/coreclr/src/mscorlib/src/System/Security/SecureString.Unix.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/System/Security/SecureString.Unix.cs rename to src/coreclr/src/mscorlib/src/System/Security/SecureString.Unix.cs diff --git a/src/coreclr/src/mscorlib/corefx/System/Security/SecureString.Windows.cs b/src/coreclr/src/mscorlib/src/System/Security/SecureString.Windows.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/System/Security/SecureString.Windows.cs rename to src/coreclr/src/mscorlib/src/System/Security/SecureString.Windows.cs diff --git a/src/coreclr/src/mscorlib/corefx/System/Security/SecureString.cs b/src/coreclr/src/mscorlib/src/System/Security/SecureString.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/System/Security/SecureString.cs rename to src/coreclr/src/mscorlib/src/System/Security/SecureString.cs diff --git a/src/coreclr/src/mscorlib/corefx/System/Threading/ClrThreadPoolBoundHandle.cs b/src/coreclr/src/mscorlib/src/System/Threading/ClrThreadPoolBoundHandle.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/System/Threading/ClrThreadPoolBoundHandle.cs rename to src/coreclr/src/mscorlib/src/System/Threading/ClrThreadPoolBoundHandle.cs diff --git a/src/coreclr/src/mscorlib/corefx/System/Threading/ClrThreadPoolBoundHandleOverlapped.cs b/src/coreclr/src/mscorlib/src/System/Threading/ClrThreadPoolBoundHandleOverlapped.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/System/Threading/ClrThreadPoolBoundHandleOverlapped.cs rename to src/coreclr/src/mscorlib/src/System/Threading/ClrThreadPoolBoundHandleOverlapped.cs diff --git a/src/coreclr/src/mscorlib/corefx/System/Threading/ClrThreadPoolPreAllocatedOverlapped.cs b/src/coreclr/src/mscorlib/src/System/Threading/ClrThreadPoolPreAllocatedOverlapped.cs similarity index 100% rename from src/coreclr/src/mscorlib/corefx/System/Threading/ClrThreadPoolPreAllocatedOverlapped.cs rename to src/coreclr/src/mscorlib/src/System/Threading/ClrThreadPoolPreAllocatedOverlapped.cs -- 2.7.4