-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathLxssUserSession.h
257 lines (227 loc) · 7.72 KB
/
LxssUserSession.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#ifndef LXSSUSERSESSION_H
#define LXSSUSERSESSION_H
static const GUID CLSID_LxssUserSession = {
0x4F476546,
0xB412,
0x4579,
{ 0xB6, 0x4C, 0x12, 0x3D, 0xF3, 0x31, 0xE3, 0xD6 } };
static const GUID IID_ILxssUserSession = {
0x536A6BCF,
0xFE04,
0x41D9,
{ 0xB9, 0x78, 0xDC, 0xAC, 0xA9, 0xA9, 0xB5, 0xB9 } };
typedef enum _LXSS_DISTRIBUTION_STATES {
Stopped = 1,
Running,
Installing,
Uninstalling,
Converting
} LXSS_DISTRIBUTION_STATES;
typedef struct _LXSS_ENUMERATE_INFO {
GUID DistributionID;
LXSS_DISTRIBUTION_STATES State;
ULONG Version;
ULONG Default;
} LXSS_ENUMERATE_INFO, *PLXSS_ENUMERATE_INFO;
typedef enum _WSL_DISTRIBUTION_FLAGS {
WSL_DISTRIBUTION_FLAGS_NONE = 0,
WSL_DISTRIBUTION_FLAGS_ENABLE_INTEROP = 1,
WSL_DISTRIBUTION_FLAGS_APPEND_NT_PATH = 2,
WSL_DISTRIBUTION_FLAGS_ENABLE_DRIVE_MOUNTING = 4,
WSL_DISTRIBUTION_FLAGS_DEFAULT = 7
} WSL_DISTRIBUTION_FLAGS;
typedef struct _LXSS_STD_HANDLE {
ULONG Handle;
ULONG Pipe;
} LXSS_STD_HANDLE, *PLXSS_STD_HANDLE;
typedef struct _LXSS_STD_HANDLES {
LXSS_STD_HANDLE StdIn;
LXSS_STD_HANDLE StdOut;
LXSS_STD_HANDLE StdErr;
} LXSS_STD_HANDLES, *PLXSS_STD_HANDLES;
typedef struct _ILxssUserSession ILxssUserSession;
struct _ILxssUserSessionVtbl
{
HRESULT(STDMETHODCALLTYPE *QueryInterface)(
_In_ ILxssUserSession* wslSession,
_In_ GUID* riid,
_Out_ PVOID* ppv);
ULONG(STDMETHODCALLTYPE *AddRef)(
_In_ ILxssUserSession* This);
ULONG(STDMETHODCALLTYPE *Release)(
_In_ ILxssUserSession* This);
/**
* PVOID ObjectStublessClient3;
* Create new LxssInstance or get the running one
* If no DistroId is provided get the default distribuiton GUID
**/
HRESULT(STDMETHODCALLTYPE *CreateInstance)(
_In_ ILxssUserSession* wslSession,
_In_opt_ GUID* DistroId,
_In_ ULONG InitializeCount);
/**
* PVOID ObjectStublessClient4;
* If Version is not provided DefaultVersion (REG_DWORD) is used
* Version greater than 2 (Two) results invalid parameter
* Command: "System32/lxss/tools/bsdtar -C /rootfs -x -p --xattrs --no-acls -f -"
**/
HRESULT(STDMETHODCALLTYPE *RegisterDistribution)(
_In_ ILxssUserSession* wslSession,
_In_ PWSTR DistributionName,
_In_opt_ ULONG Version,
_In_ HANDLE TarGzFileHandle,
_In_ PWSTR BasePath,
_Out_ GUID* DistroId);
/* PVOID ObjectStublessClient5; */
HRESULT(STDMETHODCALLTYPE *RegisterDistributionFromPipe)(
_In_ ILxssUserSession* wslSession,
_In_ PWSTR DistributionName,
_In_opt_ ULONG Version,
_In_ HANDLE TarGzFileHandle,
_In_ PWSTR BasePath,
_Out_ GUID* DistroId);
/**
* PVOID ObjectStublessClient6;
* Query State registry value in Lxss registry key
* Allows only if that value is ONE means installed
**/
HRESULT(STDMETHODCALLTYPE *GetDistributionId)(
_In_ ILxssUserSession* wslSession,
_In_ PWSTR DistroName,
_In_ ULONG EnableEnumerate,
_Out_ GUID* DistroId);
/**
* PVOID ObjectStublessClient7;
* If DistroId is NULL it will be default distribution
**/
HRESULT(STDMETHODCALLTYPE *TerminateDistribution)(
_In_ ILxssUserSession* wslSession,
_In_opt_ GUID* DistroId);
/**
* PVOID ObjectStublessClient8;
* Query GUID with already registered in Lxss key
* Write State registry value as FOUR means uninstalling
**/
HRESULT(STDMETHODCALLTYPE *UnregisterDistribution)(
_In_ ILxssUserSession* wslSession,
_In_ GUID* DistroId);
/**
* PVOID ObjectStublessClient9;
* Flags should be less than or equal to SEVEN
* Writes Environment variables iff EnvironmentCount present
**/
HRESULT(STDMETHODCALLTYPE *ConfigureDistribution)(
_In_ ILxssUserSession* wslSession,
_In_ GUID* DistroId,
_In_opt_ PCSTR KernelCommandLine,
_In_opt_ ULONG DefaultUid,
_In_opt_ ULONG EnvironmentCount,
_In_opt_ PCSTR* DefaultEnvironment,
_In_ ULONG Flags);
/* PVOID ObjectStublessClient10; */
HRESULT(STDMETHODCALLTYPE *GetDistributionConfiguration)(
_In_ ILxssUserSession* wslSession,
_In_ GUID* DistroId,
_Out_ PWSTR* DistributionName,
_Out_ PULONG Version,
_Out_ PWSTR* BasePath,
_Out_ PSTR* KernelCommandLine,
_Out_ PULONG DefaultUid,
_Out_ PULONG EnvironmentCount,
_Out_ PSTR** DefaultEnvironment,
_Out_ PULONG Flags);
/**
* PVOID ObjectStublessClient11;
* Query DefaultDistribution registry string
* Delete that if BasePath doesn't exist
**/
HRESULT(STDMETHODCALLTYPE *GetDefaultDistribution)(
_In_ ILxssUserSession* wslSession,
_Out_ GUID* DistroId);
/**
* PVOID ObjectStublessClient12;
* Query State registry value should be ONE
* Write DefaultDistribution registry with provided GUID
**/
HRESULT(STDMETHODCALLTYPE *SetDefaultDistribution)(
_In_ ILxssUserSession* wslSession,
_In_ GUID* DistroId);
/**
* PVOID ObjectStublessClient13;
* Free allocated memory with CoTaskMemFree
**/
HRESULT(STDMETHODCALLTYPE *EnumerateDistributions)(
_In_ ILxssUserSession* wslSession,
_Out_ PULONG DistroCount,
_Out_ PLXSS_ENUMERATE_INFO* DistroInfo);
/**
* PVOID ObjectStublessClient14;
* LxInstanceId is same with HyperV VM ID
* LxProcessHandle and ServerHandle are NULL when SOCKETs are not aka. WSL2
**/
HRESULT(STDMETHODCALLTYPE *CreateLxProcess)(
_In_ ILxssUserSession* wslSession,
_In_opt_ GUID* DistroId,
_In_opt_ PSTR CommandLine,
_In_opt_ ULONG ArgumentCount,
_In_opt_ PSTR* Arguments,
_In_opt_ PWSTR CurrentDirectory,
_In_opt_ PWSTR SharedEnvironment,
_In_opt_ PWSTR ProcessEnvironment,
_In_opt_ SIZE_T EnvironmentLength,
_In_opt_ PWSTR LinuxUserName,
_In_opt_ USHORT WindowWidthX,
_In_opt_ USHORT WindowHeightY,
_In_ ULONG ConsoleHandle,
_In_ PLXSS_STD_HANDLES StdHandles,
_Out_ GUID* InitiatedDistroId,
_Out_ GUID* LxInstanceId,
_Out_ PHANDLE LxProcessHandle,
_Out_ PHANDLE ServerHandle,
_Out_ SOCKET* VmModeSocketA,
_Out_ SOCKET* VmModeSocketB,
_Out_ SOCKET* VmModeSocketC,
_Out_ SOCKET* IpcServerSocket);
/**
* PVOID ObjectStublessClient15;
* E_NOINTERFACE No such interface supported
**/
HRESULT(STDMETHODCALLTYPE *SetVersion)(
_In_ ILxssUserSession* wslSession,
_In_ GUID* DistroId,
_In_ ULONG Version);
/**
* PVOID ObjectStublessClient16;
* Allow only when RootLxBusAccess REG_DWORD enabled
* Not for WSL2 i.e. Hyper-V VM
**/
HRESULT(STDMETHODCALLTYPE *RegisterLxBusServer)(
_In_ ILxssUserSession* wslSession,
_In_opt_ GUID* DistroId,
_In_ PSTR LxBusServerName,
_Out_ PHANDLE ServerHandle);
/**
* PVOID ObjectStublessClient17;
* Command: "System32/lxss/tools/bsdtar -C /rootfs -c --one-file-system --xattrs -f - ."
**/
HRESULT(STDMETHODCALLTYPE *ExportDistribution)(
_In_ ILxssUserSession* wslSession,
_In_ GUID* DistroId,
_In_ HANDLE FileHandle);
/**
* PVOID ObjectStublessClient18;
* The filename from standard output.
**/
HRESULT(STDMETHODCALLTYPE *ExportDistributionFromPipe)(
_In_ ILxssUserSession* wslSession,
_In_ GUID* DistroId,
_In_ HANDLE FileHandle);
/* PVOID ObjectStublessClient19; */
HRESULT(STDMETHODCALLTYPE *Shutdown)(
_In_ ILxssUserSession *wslSession);
};
struct _ILxssUserSession
{
struct _ILxssUserSessionVtbl* lpVtbl;
};
#endif // LXSSUSERSESSION_H