You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
committed by
Jo Shields
parent
aa7da660d6
commit
c042cd0c52
36
external/referencesource/System.Configuration/Microsoft/Win32/SafeCryptContextHandle.cs
vendored
Normal file
36
external/referencesource/System.Configuration/Microsoft/Win32/SafeCryptContextHandle.cs
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="UnsafeNativeMethods.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Win32 {
|
||||
using System;
|
||||
using System.Security.Permissions;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System.Configuration;
|
||||
|
||||
// Safehandle for crypt context handles
|
||||
[System.Security.SuppressUnmanagedCodeSecurityAttribute()]
|
||||
internal sealed class SafeCryptContextHandle : SafeHandleZeroOrMinusOneIsInvalid {
|
||||
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
|
||||
internal SafeCryptContextHandle()
|
||||
: base(true) {
|
||||
}
|
||||
|
||||
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
|
||||
internal SafeCryptContextHandle(IntPtr handle, bool ownsHandle)
|
||||
: base(ownsHandle) {
|
||||
SetHandle(handle);
|
||||
}
|
||||
|
||||
override protected bool ReleaseHandle() {
|
||||
if (handle != IntPtr.Zero) {
|
||||
UnsafeNativeMethods.CryptReleaseContext(this, 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
53
external/referencesource/System.Configuration/Microsoft/Win32/SafeNativeMemoryHandle.cs
vendored
Normal file
53
external/referencesource/System.Configuration/Microsoft/Win32/SafeNativeMemoryHandle.cs
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="UnsafeNativeMethods.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Win32 {
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System.Security.Permissions;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System.Configuration;
|
||||
|
||||
// Safehandle for memory handles
|
||||
[System.Security.SuppressUnmanagedCodeSecurityAttribute()]
|
||||
internal sealed class SafeNativeMemoryHandle : SafeHandleZeroOrMinusOneIsInvalid {
|
||||
private bool _useLocalFree = false;
|
||||
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
|
||||
internal SafeNativeMemoryHandle()
|
||||
: this(false) {
|
||||
}
|
||||
|
||||
internal SafeNativeMemoryHandle(bool useLocalFree)
|
||||
: base(true) {
|
||||
_useLocalFree = useLocalFree;
|
||||
}
|
||||
|
||||
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
|
||||
internal SafeNativeMemoryHandle(IntPtr handle, bool ownsHandle)
|
||||
: base(ownsHandle) {
|
||||
SetHandle(handle);
|
||||
}
|
||||
|
||||
internal void SetDataHandle(IntPtr handle) {
|
||||
SetHandle(handle);
|
||||
}
|
||||
|
||||
override protected bool ReleaseHandle() {
|
||||
if (handle != IntPtr.Zero) {
|
||||
if (_useLocalFree == true)
|
||||
UnsafeNativeMethods.LocalFree(handle);
|
||||
else
|
||||
Marshal.FreeHGlobal(handle);
|
||||
handle = IntPtr.Zero;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
29
external/referencesource/System.Configuration/Microsoft/Win32/SafeNativeMethods.cs
vendored
Normal file
29
external/referencesource/System.Configuration/Microsoft/Win32/SafeNativeMethods.cs
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="SafeNativeMethods.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Win32 {
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System.Security.Permissions;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
[
|
||||
System.Security.SuppressUnmanagedCodeSecurityAttribute()
|
||||
]
|
||||
internal static class SafeNativeMethods {
|
||||
#if NOPERF
|
||||
[DllImport(ExternDll.Kernel32, SetLastError=true)]
|
||||
internal static extern bool QueryPerformanceCounter(out long value);
|
||||
|
||||
[DllImport(ExternDll.Kernel32, SetLastError=true)]
|
||||
internal static extern bool QueryPerformanceFrequency(out long value);
|
||||
#endif
|
||||
}
|
||||
}
|
66
external/referencesource/System.Configuration/Microsoft/Win32/UnsafeNativeMethods.cs
vendored
Normal file
66
external/referencesource/System.Configuration/Microsoft/Win32/UnsafeNativeMethods.cs
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="UnsafeNativeMethods.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Win32 {
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System;
|
||||
using System.Security.Permissions;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System.Configuration;
|
||||
|
||||
[
|
||||
System.Security.SuppressUnmanagedCodeSecurityAttribute()
|
||||
]
|
||||
internal static class UnsafeNativeMethods {
|
||||
[DllImport(ExternDll.Kernel32, SetLastError=true, CharSet=CharSet.Auto, BestFitMapping=false)]
|
||||
internal static extern bool GetFileAttributesEx(string name, int fileInfoLevel, out WIN32_FILE_ATTRIBUTE_DATA data);
|
||||
|
||||
internal const int GetFileExInfoStandard = 0;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct WIN32_FILE_ATTRIBUTE_DATA {
|
||||
internal int fileAttributes;
|
||||
internal uint ftCreationTimeLow;
|
||||
internal uint ftCreationTimeHigh;
|
||||
internal uint ftLastAccessTimeLow;
|
||||
internal uint ftLastAccessTimeHigh;
|
||||
internal uint ftLastWriteTimeLow;
|
||||
internal uint ftLastWriteTimeHigh;
|
||||
internal uint fileSizeHigh;
|
||||
internal uint fileSizeLow;
|
||||
}
|
||||
|
||||
[DllImport(ExternDll.Kernel32, CharSet=CharSet.Auto, BestFitMapping=false)]
|
||||
internal static extern int GetModuleFileName(HandleRef hModule, StringBuilder buffer, int length);
|
||||
|
||||
#if !FEATURE_PAL
|
||||
[DllImport(ExternDll.Crypt32, SetLastError=true, CharSet=CharSet.Unicode)]
|
||||
internal extern static bool CryptProtectData(ref DATA_BLOB inputData, string description, ref DATA_BLOB entropy, IntPtr pReserved, ref CRYPTPROTECT_PROMPTSTRUCT promptStruct, UInt32 flags, ref DATA_BLOB outputData);
|
||||
|
||||
[DllImport(ExternDll.Crypt32, SetLastError= true, CharSet=CharSet.Unicode)]
|
||||
internal extern static bool CryptUnprotectData(ref DATA_BLOB inputData, IntPtr description, ref DATA_BLOB entropy, IntPtr pReserved, ref CRYPTPROTECT_PROMPTSTRUCT promptStruct, UInt32 flags, ref DATA_BLOB outputData);
|
||||
|
||||
[DllImport(ExternDll.Advapi32, SetLastError=true, CharSet=CharSet.Unicode)]
|
||||
internal extern static int CryptAcquireContext(out SafeCryptContextHandle phProv, string pszContainer, string pszProvider, uint dwProvType, uint dwFlags);
|
||||
|
||||
[DllImport(ExternDll.Advapi32, SetLastError=true, CharSet=CharSet.Unicode)]
|
||||
internal extern static int CryptReleaseContext(SafeCryptContextHandle hProv, uint dwFlags);
|
||||
|
||||
[DllImport(ExternDll.Kernel32, CharSet=CharSet.Auto)]
|
||||
internal extern static IntPtr LocalFree(IntPtr buf);
|
||||
#endif
|
||||
|
||||
// MoveFile Parameter
|
||||
internal const int MOVEFILE_REPLACE_EXISTING = 0x00000001;
|
||||
|
||||
[DllImport(ExternDll.Kernel32, CharSet=CharSet.Auto, BestFitMapping=false)]
|
||||
internal static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, int dwFlags);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user