Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,6 @@
<Compile Include="$(CommonSourceRoot)\Interop\Windows\NtDll\SecurityQualityOfService.cs">
<Link>Interop\Windows\NtDll\SecurityQualityOfService.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)\Interop\Windows\Secur32\CredHandle.netfx.cs">
<Link>Interop\Windows\Secur32\CredHandle.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)\Interop\Windows\Secur32\ContextAttribute.netfx.cs">
<Link>Interop\Windows\Secur32\ContextAttribute.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)\Interop\Windows\Secur32\Secur32.netfx.cs">
<Link>Interop\Windows\Secur32\Secur32.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)\Interop\Windows\Sni\AuthProviderInfo.cs">
<Link>Interop\Windows\Sni\AuthProviderInfo.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,10 @@ internal static class Kernel32Safe
{
private const string Kernel32 = "kernel32.dll";

// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getcomputernameex.asp
[DllImport(Kernel32, CharSet = CharSet.Unicode, EntryPoint = "GetComputerNameExW", SetLastError = true)]
[ResourceExposure(ResourceScope.None)]
internal static extern int GetComputerNameEx(int nameType, StringBuilder nameBuffer, ref int bufferSize);

[DllImport(Kernel32, CharSet = CharSet.Auto)]
[ResourceExposure(ResourceScope.Process)]
internal static extern int GetCurrentProcessId();

[DllImport(Kernel32, CharSet = CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true)]
[ResourceExposure(ResourceScope.Process)]
internal static extern IntPtr GetModuleHandle([MarshalAs(UnmanagedType.LPTStr), In] string moduleName);

[DllImport(Kernel32, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true, SetLastError = true)]
[ResourceExposure(ResourceScope.None)]
internal static extern IntPtr GetProcAddress(IntPtr HModule, [MarshalAs(UnmanagedType.LPStr), In] string funcName);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,6 @@ internal static InvalidOperationException MethodCalledTwice(string method)
return e;
}

internal static ArgumentOutOfRangeException ArgumentOutOfRange(string message, string parameterName, object value)
{
ArgumentOutOfRangeException e = new(parameterName, value, message);
TraceExceptionAsReturnValue(e);
return e;
}

internal static AuthenticationException SSLCertificateAuthenticationException(string message)
{
AuthenticationException e = new(message);
Expand Down Expand Up @@ -457,9 +450,6 @@ internal static ArgumentOutOfRangeException InvalidUserDefinedTypeSerializationF
return InvalidEnumerationValue(typeof(Format), (int)value);
}

internal static ArgumentOutOfRangeException NotSupportedUserDefinedTypeSerializationFormat(Format value, string method)
=> NotSupportedEnumerationValue(typeof(Format), value.ToString(), method);

internal static ArgumentException InvalidArgumentLength(string argumentName, int limit)
=> Argument(StringsHelper.GetString(Strings.ADP_InvalidArgumentLength, argumentName, limit));

Expand Down Expand Up @@ -1079,9 +1069,6 @@ internal static Exception InvalidDataLength(long length)
internal static bool CompareInsensitiveInvariant(string strvalue, string strconst)
=> 0 == CultureInfo.InvariantCulture.CompareInfo.Compare(strvalue, strconst, CompareOptions.IgnoreCase);

internal static int DstCompare(string strA, string strB) // this is null safe
=> CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, ADP.DefaultCompareOptions);

internal static void SetCurrentTransaction(Transaction transaction) => Transaction.Current = transaction;

internal static Exception NonSeqByteAccess(long badIndex, long currIndex, string method)
Expand Down Expand Up @@ -1237,11 +1224,6 @@ internal static Exception UndefinedCollection(string collectionName)
internal static Exception AmbiguousCollectionName(string collectionName)
=> Argument(StringsHelper.GetString(Strings.MDF_AmbiguousCollectionName, collectionName));

internal static Exception MissingDataSourceInformationColumn() => Argument(StringsHelper.GetString(Strings.MDF_MissingDataSourceInformationColumn));

internal static Exception IncorrectNumberOfDataSourceInformationRows()
=> Argument(StringsHelper.GetString(Strings.MDF_IncorrectNumberOfDataSourceInformationRows));

internal static Exception MissingRestrictionColumn() => Argument(StringsHelper.GetString(Strings.MDF_MissingRestrictionColumn));

internal static Exception MissingRestrictionRow() => Argument(StringsHelper.GetString(Strings.MDF_MissingRestrictionRow));
Expand Down Expand Up @@ -1398,13 +1380,6 @@ internal static Exception InvalidMixedUsageOfAccessTokenCallbackAndIntegratedSec
internal static readonly IntPtr s_ptrZero = IntPtr.Zero;
#if NETFRAMEWORK
#region netfx project only
internal static Task<T> CreatedTaskWithException<T>(Exception ex)
{
TaskCompletionSource<T> completion = new();
completion.SetException(ex);
return completion.Task;
}

//
// Helper Functions
//
Expand Down Expand Up @@ -1501,14 +1476,6 @@ internal static Exception PermissionTypeMismatch()
return Argument(StringsHelper.GetString(Strings.ADP_PermissionTypeMismatch));
}

//
// DbDataReader
//
internal static Exception NumericToDecimalOverflow()
{
return InvalidCast(StringsHelper.GetString(Strings.ADP_NumericToDecimalOverflow));
}

//
// DbDataAdapter
//
Expand All @@ -1526,79 +1493,12 @@ internal static InvalidOperationException ComputerNameEx(int lastError)
internal const float FailoverTimeoutStepForTnir = 0.125F; // Fraction of timeout to use in case of Transparent Network IP resolution.
internal const int MinimumTimeoutForTnirMs = 500; // The first login attempt in Transparent network IP Resolution

internal static readonly int s_ptrSize = IntPtr.Size;
internal static readonly IntPtr s_invalidPtr = new(-1); // use for INVALID_HANDLE

internal static readonly bool s_isWindowsNT = (PlatformID.Win32NT == Environment.OSVersion.Platform);
internal static readonly bool s_isPlatformNT5 = (ADP.s_isWindowsNT && (Environment.OSVersion.Version.Major >= 5));

[FileIOPermission(SecurityAction.Assert, AllFiles = FileIOPermissionAccess.PathDiscovery)]
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
internal static string GetFullPath(string filename)
{ // MDAC 77686
return Path.GetFullPath(filename);
}

// TODO: cache machine name and listen to longhorn event to reset it
internal static string GetComputerNameDnsFullyQualified()
{
const int ComputerNameDnsFullyQualified = 3; // winbase.h, enum COMPUTER_NAME_FORMAT
const int ERROR_MORE_DATA = 234; // winerror.h

string value;
if (s_isPlatformNT5)
{
int length = 0; // length parameter must be zero if buffer is null
// query for the required length
// VSTFDEVDIV 479551 - ensure that GetComputerNameEx does not fail with unexpected values and that the length is positive
int getComputerNameExError = 0;
if (0 == Kernel32Safe.GetComputerNameEx(ComputerNameDnsFullyQualified, null, ref length))
{
getComputerNameExError = Marshal.GetLastWin32Error();
}
if ((getComputerNameExError != 0 && getComputerNameExError != ERROR_MORE_DATA) || length <= 0)
{
throw ADP.ComputerNameEx(getComputerNameExError);
}

StringBuilder buffer = new(length);
length = buffer.Capacity;
if (0 == Kernel32Safe.GetComputerNameEx(ComputerNameDnsFullyQualified, buffer, ref length))
{
throw ADP.ComputerNameEx(Marshal.GetLastWin32Error());
}

// Note: In Longhorn you'll be able to rename a machine without
// rebooting. Therefore, don't cache this machine name.
value = buffer.ToString();
}
else
{
value = ADP.MachineName();
}
return value;
}

internal static IntPtr IntPtrOffset(IntPtr pbase, int offset)
{
if (4 == ADP.s_ptrSize)
{
return (IntPtr)checked(pbase.ToInt32() + offset);
}
Debug.Assert(8 == ADP.s_ptrSize, "8 != IntPtr.Size"); // MDAC 73747
return (IntPtr)checked(pbase.ToInt64() + offset);
}

#endregion
#else
#region netcore project only

//
// COM+ exceptions
//
internal static PlatformNotSupportedException DbTypeNotSupported(string dbType) => new(StringsHelper.GetString(Strings.SQL_DbTypeNotSupportedOnThisPlatform, dbType));

// IDbConnection.BeginTransaction, OleDbTransaction.Begin
internal static ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ internal DbConnectionString(
string value,
string restrictions,
KeyRestrictionBehavior behavior,
IReadOnlyDictionary<string, string> synonyms,
bool useOdbcRules)
IReadOnlyDictionary<string, string> synonyms)
: this(new DbConnectionOptions(value, synonyms), restrictions, behavior, synonyms, false)
{
// useOdbcRules is only used to parse the connection string, not to parse restrictions because values don't apply there
// the hashtable doesn't need clone since it isn't shared with anything else
// The IReadOnlyDictionary doesn't need to be cloned since it isn't shared with anything else
}

internal DbConnectionString(DbConnectionOptions connectionOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,9 +675,6 @@ internal void MakePooledConnection(IDbConnectionPool connectionPool)
Pool = connectionPool;
}

internal void NotifyWeakReference(int message) =>
ReferenceCollection?.Notify(message);

internal virtual void OpenConnection(DbConnection outerConnection, SqlConnectionFactory connectionFactory)
{
if (!TryOpenConnection(outerConnection, connectionFactory, null, null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ internal T FindItem<T>(int refInfo, Func<T, bool> filterMethod) where T : class
return null;
}

public void Notify(int message)
public void Deactivate()
{
bool lockObtained = false;
try
Expand All @@ -186,14 +186,14 @@ public void Notify(int message)
{
_isNotifying = true;

// Loop through each live item and notify it
// Loop through each live item and notify it of its parent's deactivation
if (_estimatedCount > 0)
{
for (int index = 0; index <= _lastItemIndex; ++index)
{
if (_items[index].TryGetTarget(out object value))
{
NotifyItem(message, _items[index].RefInfo, value);
NotifyItem(_items[index].RefInfo, value);
_items[index].RemoveTarget();
}
Debug.Assert(!_items[index].TryGetTarget(out _), "Unexpected target after notifying");
Expand All @@ -220,7 +220,7 @@ public void Notify(int message)
}
}

abstract protected void NotifyItem(int message, int refInfo, object value);
abstract protected void NotifyItem(int refInfo, object value);

abstract public void Remove(object value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private bool _IsUnrestricted
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientPermission.xml' path='docs/members[@name="SqlClientPermission"]/Add[@name="connectionStringAndrestrictionsStringAndBehavior"]/*' />
public override void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
{
DbConnectionString constr = new DbConnectionString(connectionString, restrictions, behavior, SqlConnectionString.KeywordMap, false);
DbConnectionString constr = new DbConnectionString(connectionString, restrictions, behavior, SqlConnectionString.KeywordMap);
AddPermissionEntry(constr);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,5 @@ internal virtual byte[] RootKey
return _rootKey;
}
}

/// <summary>
/// Computes SHA256 value of the plain text key bytes
/// </summary>
/// <returns>A string containing SHA256 hash of the root key</returns>
internal virtual string GetKeyHash()
{
return SqlSecurityUtility.GetSHA256Hash(RootKey);
}

/// <summary>
/// Gets the length of the root key
/// </summary>
/// <returns>
/// Returns the length of the root key
/// </returns>
internal virtual int Length()
{
return _rootKey.Length;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ public override void Add(object value, int tag)
base.AddItem(value, tag);
}

internal void Deactivate()
{
base.Notify(0);
}

internal SqlDataReader FindLiveReader(SqlCommand command)
{
if (command is null)
Expand All @@ -67,9 +62,8 @@ internal SqlDataReader FindLiveReader(SqlCommand command)
}
}

protected override void NotifyItem(int message, int tag, object value)
protected override void NotifyItem(int tag, object value)
{
Debug.Assert(0 == message, "unexpected message?");
Debug.Assert(DataReaderTag == tag || CommandTag == tag || BulkCopyTag == tag, "unexpected tag?");

if (tag == DataReaderTag)
Expand Down
Loading
Loading