master
md 48 lines 1.05 KB
Rendered Raw
1 # WslcLoadSessionImage
2
3 ```c
4 STDAPI WslcLoadSessionImage(
5 _In_ WslcSession session,
6 _In_ HANDLE imageContent,
7 _In_ uint64_t imageContentBytes,
8 _In_opt_ const WslcLoadImageOptions* options,
9 _Outptr_opt_result_z_ PWSTR* errorMessage);
10 ```
11
12 | Parameter | Type | Direction |
13 |---|---|---|
14 | `session` | `WslcSession` | in |
15 | `imageContent` | `HANDLE` | in |
16 | `imageContentBytes` | `uint64_t` | in |
17 | `options` | `const WslcLoadImageOptions*` | in, optional |
18 | `errorMessage` | `PWSTR*` | out, optional |
19
20 Return value: `HRESULT`.
21
22 Important: the header declares `imageContent` as `HANDLE`, not `void*`.
23
24 Example:
25
26 ```c
27 HANDLE imageContent = CreateFileW(
28 L"C:\\images\\demo-load.tar",
29 GENERIC_READ,
30 FILE_SHARE_READ,
31 NULL,
32 OPEN_EXISTING,
33 FILE_ATTRIBUTE_NORMAL,
34 NULL);
35
36 LARGE_INTEGER size = { 0 };
37 GetFileSizeEx(imageContent, &size);
38
39 WslcLoadImageOptions loadOptions = { 0 };
40 HRESULT hr = WslcLoadSessionImage(
41 session,
42 imageContent,
43 (uint64_t)size.QuadPart,
44 &loadOptions,
45 NULL);
46
47 CloseHandle(imageContent);
48 ```