summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/Microsoft/Win32/Win32Native.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/Microsoft/Win32/Win32Native.cs')
-rw-r--r--src/mscorlib/src/Microsoft/Win32/Win32Native.cs115
1 files changed, 2 insertions, 113 deletions
diff --git a/src/mscorlib/src/Microsoft/Win32/Win32Native.cs b/src/mscorlib/src/Microsoft/Win32/Win32Native.cs
index ebe53f45af..b5b808b424 100644
--- a/src/mscorlib/src/Microsoft/Win32/Win32Native.cs
+++ b/src/mscorlib/src/Microsoft/Win32/Win32Native.cs
@@ -90,9 +90,6 @@
namespace Microsoft.Win32 {
using System;
using System.Security;
-#if FEATURE_IMPERSONATION
- using System.Security.Principal;
-#endif
using System.Text;
using System.Configuration.Assemblies;
using System.Runtime.Remoting;
@@ -113,7 +110,6 @@ namespace Microsoft.Win32 {
// Remove the default demands for all P/Invoke methods with this
// global declaration on the class.
- [System.Security.SecurityCritical]
[SuppressUnmanagedCodeSecurityAttribute()]
internal static class Win32Native {
@@ -327,7 +323,7 @@ namespace Microsoft.Win32 {
// } REG_TZI_FORMAT;
//
if (bytes == null || bytes.Length != 44) {
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidREG_TZI_FORMAT"), "bytes");
+ throw new ArgumentException(Environment.GetResourceString("Argument_InvalidREG_TZI_FORMAT"), nameof(bytes));
}
Bias = BitConverter.ToInt32(bytes, 0);
StandardBias = BitConverter.ToInt32(bytes, 4);
@@ -454,7 +450,6 @@ namespace Microsoft.Win32 {
internal int fileSizeHigh;
internal int fileSizeLow;
- [System.Security.SecurityCritical]
internal void PopulateFrom(WIN32_FIND_DATA findData) {
// Copy the information to data
fileAttributes = findData.dwFileAttributes;
@@ -516,7 +511,6 @@ namespace Microsoft.Win32 {
/// strings created with this version of the constructor will be unsafe to use after the buffer
/// has been freed.
/// </remarks>
- [System.Security.SecurityCritical] // auto-generated
internal UNICODE_INTPTR_STRING (int stringBytes, SafeLocalAllocHandle buffer) {
BCLDebug.Assert(buffer == null || (stringBytes >= 0 && (ulong)stringBytes <= buffer.ByteLength),
"buffer == null || (stringBytes >= 0 && stringBytes <= buffer.ByteLength)");
@@ -802,7 +796,6 @@ namespace Microsoft.Win32 {
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private static extern IntPtr GetModuleHandle(String moduleName);
- [System.Security.SecurityCritical] // auto-generated
internal static bool DoesWin32MethodExist(String moduleName, String methodName)
{
// GetModuleHandle does not increment the module's ref count, so we don't need to call FreeLibrary.
@@ -910,56 +903,6 @@ namespace Microsoft.Win32 {
[DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
internal static extern uint GetLongPathNameW(string lpszShortPath, SafeHandle lpszLongPath, uint cchBuffer);
- // Disallow access to all non-file devices from methods that take
- // a String. 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.
- [System.Security.SecurityCritical] // auto-generated
- internal static SafeFileHandle SafeCreateFile(String lpFileName,
- int dwDesiredAccess, System.IO.FileShare dwShareMode,
- SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition,
- int dwFlagsAndAttributes, IntPtr hTemplateFile)
- {
- SafeFileHandle handle = CreateFile( lpFileName, dwDesiredAccess, dwShareMode,
- securityAttrs, dwCreationDisposition,
- dwFlagsAndAttributes, hTemplateFile );
-
- if (!handle.IsInvalid)
- {
- int fileType = Win32Native.GetFileType(handle);
- if (fileType != Win32Native.FILE_TYPE_DISK) {
- handle.Dispose();
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_FileStreamOnNonFiles"));
- }
- }
-
- return handle;
- }
-
- [System.Security.SecurityCritical] // auto-generated
- internal static SafeFileHandle UnsafeCreateFile(String lpFileName,
- int dwDesiredAccess, System.IO.FileShare dwShareMode,
- SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition,
- int dwFlagsAndAttributes, IntPtr hTemplateFile)
- {
- SafeFileHandle handle = CreateFile( lpFileName, dwDesiredAccess, dwShareMode,
- securityAttrs, dwCreationDisposition,
- dwFlagsAndAttributes, hTemplateFile );
-
- return handle;
- }
-
- // Do not use these directly, use the safe or unsafe versions above.
- // The safe version does not support devices (aka if will only open
- // files on disk), while the unsafe version give you the full semantic
- // of the native version.
- [DllImport(KERNEL32, SetLastError=true, CharSet=CharSet.Auto, BestFitMapping=false)]
- private static extern SafeFileHandle CreateFile(String lpFileName,
- int dwDesiredAccess, System.IO.FileShare dwShareMode,
- SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition,
- int dwFlagsAndAttributes, IntPtr hTemplateFile);
-
[DllImport(KERNEL32, SetLastError=true, CharSet=CharSet.Auto, BestFitMapping=false)]
internal static extern SafeFileMappingHandle CreateFileMapping(SafeFileHandle hFile, IntPtr lpAttributes, uint fProtect, uint dwMaximumSizeHigh, uint dwMaximumSizeLow, String lpName);
@@ -988,7 +931,6 @@ namespace Microsoft.Win32 {
[DllImport(KERNEL32, SetLastError=true, EntryPoint="SetFilePointer")]
private unsafe static extern int SetFilePointerWin32(SafeFileHandle handle, int lo, int * hi, int origin);
- [System.Security.SecurityCritical] // auto-generated
internal unsafe static long SetFilePointer(SafeFileHandle handle, long offset, System.IO.SeekOrigin origin, out int hr) {
hr = 0;
int lo = (int) offset;
@@ -1070,7 +1012,6 @@ namespace Microsoft.Win32 {
internal const int FIND_FROMSTART = 0x00400000; // look for value in source, starting at the beginning
internal const int FIND_FROMEND = 0x00800000; // look for value in source, starting at the end
-#if !FEATURE_CORECLR
[StructLayout(LayoutKind.Sequential)]
internal struct NlsVersionInfoEx
{
@@ -1080,7 +1021,6 @@ namespace Microsoft.Win32 {
internal int dwEffectiveId;
internal Guid guidCustomVersion;
}
-#endif
[DllImport(KERNEL32, CharSet=CharSet.Auto, SetLastError=true, BestFitMapping=false)]
internal static extern int GetWindowsDirectory([Out]StringBuilder sb, int length);
@@ -1797,18 +1737,11 @@ namespace Microsoft.Win32 {
[In] uint dwFlags);
#endif // FEATURE_LEGACYSURFACE
-#if FEATURE_CORECLR
[DllImport(NTDLL, CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern
int RtlNtStatusToDosError (
[In] int status);
-#else
- // identical to RtlNtStatusToDosError, but we are in ask mode for desktop CLR
- [DllImport(ADVAPI32, CharSet = CharSet.Unicode, SetLastError = true)]
- internal static extern
- int LsaNtStatusToWinError (
- [In] int status);
-#endif
+
// Get the current FIPS policy setting on Vista and above
[DllImport("bcrypt.dll")]
internal static extern uint BCryptGetFipsAlgorithmMode(
@@ -1930,28 +1863,6 @@ namespace Microsoft.Win32 {
[In] bool bInheritHandle,
[In] uint dwOptions);
-#if FEATURE_IMPERSONATION
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- [DllImport(ADVAPI32, CharSet=CharSet.Auto, SetLastError=true)]
- internal static extern
- bool DuplicateTokenEx (
- [In] SafeAccessTokenHandle ExistingTokenHandle,
- [In] TokenAccessLevels DesiredAccess,
- [In] IntPtr TokenAttributes,
- [In] SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
- [In] System.Security.Principal.TokenType TokenType,
- [In,Out] ref SafeAccessTokenHandle DuplicateTokenHandle );
-
- [DllImport(ADVAPI32, CharSet=CharSet.Auto, SetLastError=true)]
- internal static extern
- bool DuplicateTokenEx (
- [In] SafeAccessTokenHandle hExistingToken,
- [In] uint dwDesiredAccess,
- [In] IntPtr lpTokenAttributes, // LPSECURITY_ATTRIBUTES
- [In] uint ImpersonationLevel,
- [In] uint TokenType,
- [In,Out] ref SafeAccessTokenHandle phNewToken);
-#endif
[DllImport(
ADVAPI32,
EntryPoint="EqualDomainSid",
@@ -2345,15 +2256,6 @@ namespace Microsoft.Win32 {
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern int LsaFreeReturnBuffer(IntPtr handle);
-#if FEATURE_IMPERSONATION
- [DllImport (ADVAPI32, CharSet=CharSet.Unicode, SetLastError=true)]
- internal static extern
- bool OpenProcessToken (
- [In] IntPtr ProcessToken,
- [In] TokenAccessLevels DesiredAccess,
- [Out] out SafeAccessTokenHandle TokenHandle);
-#endif
-
[DllImport(
ADVAPI32,
EntryPoint="SetNamedSecurityInfoW",
@@ -2386,16 +2288,6 @@ namespace Microsoft.Win32 {
byte[] dacl,
byte[] sacl );
- // Fusion APIs
-#if FEATURE_FUSION
- [DllImport(MSCORWKS, CharSet=CharSet.Unicode)]
- internal static extern int CreateAssemblyNameObject(out IAssemblyName ppEnum, String szAssemblyName, uint dwFlags, IntPtr pvReserved);
-
- [DllImport(MSCORWKS, CharSet=CharSet.Auto)]
- internal static extern int CreateAssemblyEnum(out IAssemblyEnum ppEnum, IApplicationContext pAppCtx, IAssemblyName pName, uint dwFlags, IntPtr pvReserved);
-#endif // FEATURE_FUSION
-
-#if FEATURE_CORECLR
[DllImport(KERNEL32, CharSet=CharSet.Unicode)]
[SuppressUnmanagedCodeSecurityAttribute()]
internal unsafe static extern int WideCharToMultiByte(
@@ -2417,13 +2309,11 @@ namespace Microsoft.Win32 {
int cchMultiByte,
char* lpWideCharStr,
int cchWideChar);
-#endif // FEATURE_CORECLR
[DllImport(KERNEL32, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal extern static bool QueryUnbiasedInterruptTime(out ulong UnbiasedTime);
-#if FEATURE_CORECLR
#if FEATURE_PAL
[DllImport(KERNEL32, EntryPoint = "PAL_Random")]
internal extern static bool Random(bool bStrong,
@@ -2450,6 +2340,5 @@ namespace Microsoft.Win32 {
}
}
#endif
-#endif
}
}