summaryrefslogtreecommitdiff
path: root/src/mscorlib/shared/Interop
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2017-06-13 18:47:36 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2017-06-13 18:47:36 +0900
commit61d6a817e39d3bae0f47dbc09838d51db22a5d30 (patch)
treecb37caa1784bc738b976273335d6ed04a7cc80b0 /src/mscorlib/shared/Interop
parent5b975f8233e8c8d17b215372f89ca713b45d6a0b (diff)
downloadcoreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.tar.gz
coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.tar.bz2
coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.zip
Imported Upstream version 2.0.0.11992upstream/2.0.0.11992
Diffstat (limited to 'src/mscorlib/shared/Interop')
-rw-r--r--src/mscorlib/shared/Interop/Unix/System.Globalization.Native/Interop.Collation.cs69
-rw-r--r--src/mscorlib/shared/Interop/Windows/Interop.Libraries.cs1
-rw-r--r--src/mscorlib/shared/Interop/Windows/Kernel32/Interop.Globalization.cs131
-rw-r--r--src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs (renamed from src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SetErrorMode.cs)4
-rw-r--r--src/mscorlib/shared/Interop/Windows/NtDll/Interop.ZeroMemory.cs16
5 files changed, 202 insertions, 19 deletions
diff --git a/src/mscorlib/shared/Interop/Unix/System.Globalization.Native/Interop.Collation.cs b/src/mscorlib/shared/Interop/Unix/System.Globalization.Native/Interop.Collation.cs
new file mode 100644
index 0000000000..79aedd74d3
--- /dev/null
+++ b/src/mscorlib/shared/Interop/Unix/System.Globalization.Native/Interop.Collation.cs
@@ -0,0 +1,69 @@
+// 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.Globalization;
+using System.Runtime.InteropServices;
+using System.Security;
+
+internal static partial class Interop
+{
+ internal static partial class GlobalizationInterop
+ {
+ [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetSortHandle")]
+ internal unsafe static extern ResultCode GetSortHandle(byte[] localeName, out SafeSortHandle sortHandle);
+
+ [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_CloseSortHandle")]
+ internal unsafe static extern void CloseSortHandle(IntPtr handle);
+
+ [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_CompareString")]
+ internal unsafe static extern int CompareString(SafeSortHandle sortHandle, char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len, CompareOptions options);
+
+ [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOf")]
+ internal unsafe static extern int IndexOf(SafeSortHandle sortHandle, string target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr);
+
+ [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_LastIndexOf")]
+ internal unsafe static extern int LastIndexOf(SafeSortHandle sortHandle, string target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options);
+
+ [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOfOrdinalIgnoreCase")]
+ internal unsafe static extern int IndexOfOrdinalIgnoreCase(string target, int cwTargetLength, char* pSource, int cwSourceLength, bool findLast);
+
+ [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_StartsWith")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal unsafe static extern bool StartsWith(SafeSortHandle sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options);
+
+ [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EndsWith")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal unsafe static extern bool EndsWith(SafeSortHandle sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options);
+
+ [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetSortKey")]
+ internal unsafe static extern int GetSortKey(SafeSortHandle sortHandle, string str, int strLength, byte* sortKey, int sortKeyLength, CompareOptions options);
+
+ [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_CompareStringOrdinalIgnoreCase")]
+ internal unsafe static extern int CompareStringOrdinalIgnoreCase(char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len);
+
+ [DllImport(Libraries.GlobalizationInterop, EntryPoint = "GlobalizationNative_GetSortVersion")]
+ internal static extern int GetSortVersion();
+
+ internal class SafeSortHandle : SafeHandle
+ {
+ private SafeSortHandle() :
+ base(IntPtr.Zero, true)
+ {
+ }
+
+ public override bool IsInvalid
+ {
+ get { return handle == IntPtr.Zero; }
+ }
+
+ protected override bool ReleaseHandle()
+ {
+ CloseSortHandle(handle);
+ SetHandle(IntPtr.Zero);
+ return true;
+ }
+ }
+ }
+}
diff --git a/src/mscorlib/shared/Interop/Windows/Interop.Libraries.cs b/src/mscorlib/shared/Interop/Windows/Interop.Libraries.cs
index 58bb12d637..bf07a6815b 100644
--- a/src/mscorlib/shared/Interop/Windows/Interop.Libraries.cs
+++ b/src/mscorlib/shared/Interop/Windows/Interop.Libraries.cs
@@ -9,7 +9,6 @@ internal static partial class Interop
internal const string BCrypt = "BCrypt.dll";
internal const string Crypt32 = "crypt32.dll";
internal const string Kernel32 = "kernel32.dll";
- internal const string NtDll = "ntdll.dll";
internal const string OleAut32 = "oleaut32.dll";
}
}
diff --git a/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.Globalization.cs b/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.Globalization.cs
new file mode 100644
index 0000000000..7d3287fe1a
--- /dev/null
+++ b/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.Globalization.cs
@@ -0,0 +1,131 @@
+// 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.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static unsafe partial class Kernel32
+ {
+ internal const int LOCALE_NAME_MAX_LENGTH = 85;
+ internal const uint LOCALE_ALLOW_NEUTRAL_NAMES = 0x08000000; // Flag to allow returning neutral names/lcids for name conversion
+ internal const uint LOCALE_SUPPLEMENTAL = 0x00000002;
+ internal const uint LOCALE_REPLACEMENT = 0x00000008;
+ internal const uint LOCALE_NEUTRALDATA = 0x00000010;
+ internal const uint LOCALE_SPECIFICDATA = 0x00000020;
+ internal const int COMPARE_STRING = 0x0001;
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ internal extern static unsafe int LCIDToLocaleName(int locale, char *pLocaleName, int cchName, uint dwFlags);
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ internal extern static int LocaleNameToLCID(string lpName, uint dwFlags);
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ internal extern static unsafe int LCMapStringEx(
+ string lpLocaleName,
+ uint dwMapFlags,
+ char* lpSrcStr,
+ int cchSrc,
+ void* lpDestStr,
+ int cchDest,
+ void* lpVersionInformation,
+ void* lpReserved,
+ IntPtr sortHandle);
+
+ [DllImport("kernel32.dll", EntryPoint = "FindNLSStringEx")]
+ internal extern static unsafe int FindNLSStringEx(
+ char* lpLocaleName,
+ uint dwFindNLSStringFlags,
+ char* lpStringSource,
+ int cchSource,
+ char* lpStringValue,
+ int cchValue,
+ int* pcchFound,
+ void* lpVersionInformation,
+ void* lpReserved,
+ IntPtr sortHandle);
+
+ [DllImport("kernel32.dll", EntryPoint = "CompareStringEx")]
+ internal extern static unsafe int CompareStringEx(
+ char* lpLocaleName,
+ uint dwCmpFlags,
+ char* lpString1,
+ int cchCount1,
+ char* lpString2,
+ int cchCount2,
+ void* lpVersionInformation,
+ void* lpReserved,
+ IntPtr lParam);
+
+ [DllImport("kernel32.dll", EntryPoint = "CompareStringOrdinal")]
+ internal extern static unsafe int CompareStringOrdinal(
+ char* lpString1,
+ int cchCount1,
+ char* lpString2,
+ int cchCount2,
+ bool bIgnoreCase);
+
+ [DllImport("kernel32.dll", EntryPoint = "FindStringOrdinal")]
+ internal extern static unsafe int FindStringOrdinal(
+ uint dwFindStringOrdinalFlags,
+ char* lpStringSource,
+ int cchSource,
+ char* lpStringValue,
+ int cchValue,
+ int bIgnoreCase);
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ internal extern static unsafe bool IsNLSDefinedString(
+ int Function,
+ uint dwFlags,
+ IntPtr lpVersionInformation,
+ char* lpString,
+ int cchStr);
+
+ [DllImport("Kernel32.dll", CharSet = CharSet.Auto)]
+ internal static extern bool GetUserPreferredUILanguages(uint dwFlags, out uint pulNumLanguages, char [] pwszLanguagesBuffer, ref uint pcchLanguagesBuffer);
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ internal static extern int GetLocaleInfoEx(string lpLocaleName, uint LCType, void* lpLCData, int cchData);
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ internal extern static bool EnumSystemLocalesEx(EnumLocalesProcEx lpLocaleEnumProcEx, uint dwFlags, void* lParam, IntPtr reserved);
+
+ internal delegate BOOL EnumLocalesProcEx(char* lpLocaleString, uint dwFlags, void* lParam);
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ internal extern static int ResolveLocaleName(string lpNameToResolve, char* lpLocaleName, int cchLocaleName);
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ internal extern static bool EnumTimeFormatsEx(EnumTimeFormatsProcEx lpTimeFmtEnumProcEx, string lpLocaleName, uint dwFlags, void* lParam);
+
+ internal delegate BOOL EnumTimeFormatsProcEx(char* lpTimeFormatString, void* lParam);
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ internal extern static int GetCalendarInfoEx(string lpLocaleName, uint Calendar, IntPtr lpReserved, uint CalType, IntPtr lpCalData, int cchData, out int lpValue);
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ internal extern static int GetCalendarInfoEx(string lpLocaleName, uint Calendar, IntPtr lpReserved, uint CalType, IntPtr lpCalData, int cchData, IntPtr lpValue);
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ internal extern static bool EnumCalendarInfoExEx(EnumCalendarInfoProcExEx pCalInfoEnumProcExEx, string lpLocaleName, uint Calendar, string lpReserved, uint CalType, void* lParam);
+
+ internal delegate BOOL EnumCalendarInfoProcExEx(char* lpCalendarInfoString, uint Calendar, IntPtr lpReserved, void* lParam);
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct NlsVersionInfoEx
+ {
+ internal int dwNLSVersionInfoSize;
+ internal int dwNLSVersion;
+ internal int dwDefinedVersion;
+ internal int dwEffectiveId;
+ internal Guid guidCustomVersion;
+ }
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ internal extern static unsafe bool GetNLSVersionEx(int function, string localeName, NlsVersionInfoEx* lpVersionInformation);
+ }
+}
diff --git a/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SetErrorMode.cs b/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs
index 276f49c519..123eb75d7b 100644
--- a/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.SetErrorMode.cs
+++ b/src/mscorlib/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/mscorlib/shared/Interop/Windows/NtDll/Interop.ZeroMemory.cs b/src/mscorlib/shared/Interop/Windows/NtDll/Interop.ZeroMemory.cs
deleted file mode 100644
index 9bf7321f2a..0000000000
--- a/src/mscorlib/shared/Interop/Windows/NtDll/Interop.ZeroMemory.cs
+++ /dev/null
@@ -1,16 +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.Runtime.InteropServices;
-using System.Security;
-
-internal partial class Interop
-{
- internal partial class NtDll
- {
- [DllImport(Libraries.NtDll, CharSet = CharSet.Unicode, EntryPoint = "RtlZeroMemory")]
- internal static extern void ZeroMemory(IntPtr address, UIntPtr length);
- }
-}