Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
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
16 changes: 16 additions & 0 deletions src/Common/src/Interop/Unix/System.Native/Interop.GetEnviron.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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 Microsoft.Win32.SafeHandles;

internal static partial class Interop
{
internal static partial class Sys
{
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetEnviron", SetLastError = true)]
internal static unsafe extern byte** GetEnviron();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class Sys
{
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixRelease", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern string GetUnixRelease();
}
}
15 changes: 11 additions & 4 deletions src/Common/src/Interop/Unix/System.Native/Interop.MountPoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,25 @@ internal static partial class Sys
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetAllMountPoints", SetLastError = true)]
private static extern int GetAllMountPoints(MountPointFound mpf);

internal static List<string> GetAllMountPoints()
internal static string[] GetAllMountPoints()
{
List<string> lst = new List<string>();
int count = 0;
var found = new string[4];

unsafe
{
int result = GetAllMountPoints((byte* name) =>
{
lst.Add(Marshal.PtrToStringAnsi((IntPtr)name));
if (count == found.Length)
{
Array.Resize(ref found, count * 2);
}
found[count++] = Marshal.PtrToStringAnsi((IntPtr)name);
});
}

return lst;
Array.Resize(ref found, count);
return found;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal enum SysConfName
{
_SC_CLK_TCK = 1,
_SC_PAGESIZE = 2,
_SC_NPROCESSORS_ONLN = 3,
}

[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SysConf", SetLastError = true)]
Expand Down
1 change: 1 addition & 0 deletions src/Common/src/Interop/Windows/Interop.Libraries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ internal static class Libraries
internal const string Synch = "api-ms-win-core-synch-l1-1-0.dll";
internal const string SystemInfo_L1_1 = "api-ms-win-core-sysinfo-l1-1-0.dll";
internal const string SystemInfo_L1_2 = "api-ms-win-core-sysinfo-l1-2-0.dll";
internal const string SystemInfo_L2_1 = "api-ms-win-core-sysinfo-l2-1-0.dll";
internal const string ThreadPool = "api-ms-win-core-threadpool-l1-2-0.dll";
internal const string User32 = "user32.dll";
internal const string Util = "api-ms-win-core-util-l1-1-0.dll";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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.Runtime.InteropServices;
using System.Text;

internal partial class Interop
{
internal partial class mincore
{
[DllImport(Libraries.ProcessEnvironment, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int ExpandEnvironmentStringsW(string lpSrc, [Out] StringBuilder lpDst, int nSize);

[DllImport(Libraries.ProcessEnvironment, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int GetEnvironmentVariableW(string lpName, [Out] StringBuilder lpValue, int size);

[DllImport(Libraries.ProcessEnvironment, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool SetEnvironmentVariableW(string lpName, string lpValue);

[DllImport(Libraries.ProcessEnvironment, CharSet = CharSet.Unicode)]
internal static extern unsafe char* GetEnvironmentStringsW();

[DllImport(Libraries.ProcessEnvironment, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern unsafe bool FreeEnvironmentStringsW(char* pStrings);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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;

#pragma warning disable 0649 // fields never explicitly assigned to
#pragma warning disable 0169 // fields never used

internal partial class Interop
{
internal partial class mincore
{
[DllImport(Libraries.SystemInfo_L1_1, SetLastError = true)]
internal static extern bool GetLogicalProcessorInformationEx(LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType, IntPtr Buffer, ref uint ReturnedLength);

internal enum LOGICAL_PROCESSOR_RELATIONSHIP
{
RelationGroup = 4
}

internal struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
{
public LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
public uint Size;
public GROUP_RELATIONSHIP Group; // part of a union, but we only need the Group
}

internal unsafe struct GROUP_RELATIONSHIP
{
private byte MaximumGroupCount;
public ushort ActiveGroupCount;
private fixed byte Reserved[20];
public PROCESSOR_GROUP_INFO GroupInfo; // actually a GroupInfo[ANYSIZE_ARRAY], so used for its address
}

internal unsafe struct PROCESSOR_GROUP_INFO
{
public byte MaximumProcessorCount;
public byte ActiveProcessorCount;
public fixed byte Reserved[38];
public IntPtr ActiveProcessorMask;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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.Runtime.InteropServices;
using System.Text;

internal static partial class Interop
{
internal static partial class mincore
{
[DllImport(Libraries.SystemInfo_L1_1, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int GetSystemDirectoryW([Out] StringBuilder lpBuffer, int jSize);
}
}
14 changes: 14 additions & 0 deletions src/Common/src/Interop/Windows/mincore/Interop.GetTickCount64.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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.Runtime.InteropServices;

internal partial class Interop
{
internal partial class mincore
{
[DllImport(Libraries.SystemInfo_L1_1)]
internal static extern long GetTickCount64();
}
}
17 changes: 17 additions & 0 deletions src/Common/src/Interop/Windows/mincore/Interop.GetUserNameExW.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.Runtime.InteropServices;
using System.Text;

internal partial class Interop
{
internal partial class mincore
{
[DllImport(Libraries.Sspi, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern byte GetUserNameExW(int NameFormat, [Out] StringBuilder lpNameBuffer, ref uint lpnSize);

internal const int NameSamCompatible = 2;
}
}
17 changes: 17 additions & 0 deletions src/Common/src/Interop/Windows/mincore/Interop.GetUserNameW.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.Runtime.InteropServices;
using System.Text;

internal partial class Interop
{
internal partial class mincore
{
#pragma warning disable BCL0015 // not available on Windows 7
[DllImport(Libraries.SystemInfo_L2_1, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool GetUserNameW([Out] StringBuilder lpBuffer, ref int lpnSize);
#pragma warning restore BCL0015
}
}
30 changes: 30 additions & 0 deletions src/Common/src/Interop/Windows/mincore/Interop.GetVersionExW.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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.Runtime.InteropServices;

internal partial class Interop
{
internal partial class mincore
{
[DllImport(Libraries.SystemInfo_L1_1, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool GetVersionExW(ref OSVERSIONINFOEX osvi);

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal unsafe struct OSVERSIONINFOEX
{
public int dwOSVersionInfoSize;
public int dwMajorVersion;
public int dwMinorVersion;
public int dwBuildNumber;
public int dwPlatformId;
public fixed char szCSDVersion[128];
public ushort wServicePackMajor;
public ushort wServicePackMinor;
public ushort wSuiteMask;
public byte wProductType;
public byte wReserved;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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 partial class Interop
{
internal partial class mincore
{
[DllImport(Libraries.Wow64, SetLastError = true)]
internal static extern bool IsWow64Process(IntPtr hProcess, out bool Wow64Process);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.Runtime.InteropServices;
using System.Text;

internal partial class Interop
{
internal partial class mincore
{
[DllImport(Libraries.SecurityLsa, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool LookupAccountNameW(
string machineName, string accountName, byte[] sid,
ref int sidLen,
[Out] StringBuilder domainName, ref uint domainNameLen, out int peUse);
}
}
Loading