Created
September 2, 2020 01:53
-
-
Save therealkenc/15575525957b59f3f93d556a53544850 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Data; | |
using System.Windows.Documents; | |
using System.Windows.Input; | |
using System.Windows.Media; | |
using System.Windows.Media.Imaging; | |
using System.Windows.Navigation; | |
using System.Windows.Shapes; | |
using System.Runtime.InteropServices; | |
using System.ComponentModel; | |
namespace enumwslwpf | |
{ | |
public enum RpcAuthnLevel | |
{ | |
Default = 0, | |
None = 1, | |
Connect = 2, | |
Call = 3, | |
Pkt = 4, | |
PktIntegrity = 5, | |
PktPrivacy = 6 | |
} | |
public enum RpcImpLevel | |
{ | |
Default = 0, | |
Anonymous = 1, | |
Identify = 2, | |
Impersonate = 3, | |
Delegate = 4 | |
} | |
public enum EoAuthnCap | |
{ | |
None = 0x00, | |
MutualAuth = 0x01, | |
StaticCloaking = 0x20, | |
DynamicCloaking = 0x40, | |
AnyAuthority = 0x80, | |
MakeFullSIC = 0x100, | |
Default = 0x800, | |
SecureRefs = 0x02, | |
AccessControl = 0x04, | |
AppID = 0x08, | |
Dynamic = 0x10, | |
RequireFullSIC = 0x200, | |
AutoImpersonate = 0x400, | |
NoCustomMarshal = 0x2000, | |
DisableAAA = 0x1000 | |
} | |
/// <summary> | |
/// Interaction logic for MainWindow.xaml | |
/// </summary> | |
public partial class MainWindow : Window | |
{ | |
[DllImport("ole32.dll")] | |
public static extern int CoInitializeSecurity(IntPtr pVoid, int | |
cAuthSvc, IntPtr asAuthSvc, IntPtr pReserved1, RpcAuthnLevel level, | |
RpcImpLevel impers, IntPtr pAuthList, EoAuthnCap dwCapabilities, IntPtr | |
pReserved3); | |
[DllImport("wslapi.dll", CharSet = CharSet.Unicode)] | |
public static extern uint WslGetDistributionConfiguration(string distributionName, ref ulong distributionVersion, | |
ref ulong defaultUID, ref int wslDistributionFlags, ref string[] defaultEnvironmentVariables, ref ulong defaultEnvironmentVariableCount); | |
[DllImport("wslapi.dll", CharSet = CharSet.Unicode)] | |
public static extern bool WslIsDistributionRegistered(string distributionName); | |
public MainWindow() | |
{ | |
string[] vars = new string[10]; | |
ulong ver = 0, uid = 0, varcnt = 0; | |
int flags = 0; | |
InitializeComponent(); | |
CoInitializeSecurity(IntPtr.Zero, -1, IntPtr.Zero, IntPtr.Zero, RpcAuthnLevel.Default, RpcImpLevel.Impersonate, | |
IntPtr.Zero, EoAuthnCap.StaticCloaking, IntPtr.Zero); | |
uint ret = WslGetDistributionConfiguration("Debian", ref ver, ref uid, ref flags, ref vars, ref varcnt); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment