master
h 63 lines 1.95 KB
Raw
1 /*++
2
3 Copyright (c) Microsoft. All rights reserved.
4
5 Module Name:
6
7 WSLCSessionFactory.h
8
9 Abstract:
10
11 IWSLCSessionFactory implementation.
12
13 This factory runs in the per-user COM server process and is created by
14 the SYSTEM service via CoCreateInstanceAsUser. It creates WSLCSession
15 objects and their corresponding IWSLCSessionReference weak references.
16
17 The factory is responsible for:
18 - Creating the WSLCSession in the per-user security context
19 - Creating the IWSLCSessionReference that holds a weak reference
20 - Providing the process handle for job object management
21
22 --*/
23
24 #pragma once
25 #include "wslc.h"
26 #include <wrl/implements.h>
27 #include <wil/com.h>
28 #include <functional>
29
30 namespace wsl::windows::service::wslc {
31
32 class DECLSPEC_UUID("9FCD2067-9FC6-4EFA-9EB0-698169EBF7D3") WSLCSessionFactory
33 : public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, IWSLCSessionFactory, IFastRundown, ISupportErrorInfo>
34 {
35 public:
36 NON_COPYABLE(WSLCSessionFactory);
37 NON_MOVABLE(WSLCSessionFactory);
38
39 WSLCSessionFactory() = default;
40
41 // Sets a callback invoked when the session in this process is destroyed.
42 // Used by the COM server host to signal process exit.
43 void SetDestructionCallback(std::function<void()>&& callback);
44
45 // IWSLCSessionFactory
46 IFACEMETHOD(CreateSession)
47 (_In_ const WSLCSessionInitSettings* Settings,
48 _In_ IWSLCVirtualMachineFactory* VmFactory,
49 _In_ IWSLCPluginNotifier* PluginNotifier,
50 _In_opt_ IWarningCallback* WarningCallback,
51 _Out_ IWSLCSession** Session,
52 _Out_ IWSLCSessionReference** ServiceRef) override;
53
54 IFACEMETHOD(GetProcessHandle)(_Out_ HANDLE* ProcessHandle) override;
55
56 // ISupportErrorInfo: enables IErrorInfo marshaling across COM boundaries.
57 IFACEMETHOD(InterfaceSupportsErrorInfo)(_In_ REFIID riid) override;
58
59 private:
60 std::function<void()> m_destructionCallback;
61 };
62
63 } // namespace wsl::windows::service::wslc