master
cpp 86 lines 2.25 KB
Raw
1 // Copyright (C) Microsoft Corporation. All rights reserved.
2
3 #include "precomp.h"
4 #include "WSLCPluginNotifier.h"
5
6 using wsl::windows::common::COMServiceExecutionContext;
7 using wsl::windows::service::wslc::WSLCPluginNotifier;
8
9 WSLCPluginNotifier::WSLCPluginNotifier(
10 wsl::windows::service::PluginManager& Plugins,
11 ULONG SessionId,
12 DWORD CreatorPid,
13 std::wstring DisplayName,
14 wil::shared_handle UserToken,
15 std::vector<BYTE>&& UserSid) :
16 m_plugins(Plugins), m_displayName(std::move(DisplayName)), m_userToken(std::move(UserToken)), m_userSid(std::move(UserSid))
17 {
18 m_sessionInfo.SessionId = static_cast<WSLCSessionId>(SessionId);
19 m_sessionInfo.DisplayName = m_displayName.c_str();
20 m_sessionInfo.ApplicationPid = CreatorPid;
21 m_sessionInfo.UserToken = m_userToken.get();
22 m_sessionInfo.UserSid = m_userSid.empty() ? nullptr : reinterpret_cast<PSID>(m_userSid.data());
23 }
24
25 HRESULT WSLCPluginNotifier::OnContainerStarted(LPCSTR InspectJson)
26 try
27 {
28 COMServiceExecutionContext context;
29
30 RETURN_HR_IF(E_POINTER, InspectJson == nullptr);
31 return m_plugins.OnWslcContainerStarted(&m_sessionInfo, InspectJson);
32 }
33 CATCH_RETURN();
34
35 HRESULT WSLCPluginNotifier::OnContainerStopping(LPCSTR ContainerId)
36 try
37 {
38 COMServiceExecutionContext context;
39
40 RETURN_HR_IF(E_POINTER, ContainerId == nullptr);
41 m_plugins.OnWslcContainerStopping(&m_sessionInfo, ContainerId);
42 return S_OK;
43 }
44 CATCH_RETURN();
45
46 HRESULT WSLCPluginNotifier::OnImageCreated(LPCSTR InspectJson)
47 try
48 {
49 COMServiceExecutionContext context;
50
51 RETURN_HR_IF(E_POINTER, InspectJson == nullptr);
52 m_plugins.OnWslcImageCreated(&m_sessionInfo, InspectJson);
53 return S_OK;
54 }
55 CATCH_RETURN();
56
57 HRESULT WSLCPluginNotifier::OnImageDeleted(LPCSTR ImageId)
58 try
59 {
60 COMServiceExecutionContext context;
61
62 RETURN_HR_IF(E_POINTER, ImageId == nullptr);
63 m_plugins.OnWslcImageDeleted(&m_sessionInfo, ImageId);
64 return S_OK;
65 }
66 CATCH_RETURN();
67
68 HRESULT WSLCPluginNotifier::OnVmStarted()
69 try
70 {
71 COMServiceExecutionContext context;
72
73 m_plugins.OnWslcVmStarted(&m_sessionInfo);
74 return S_OK;
75 }
76 CATCH_RETURN();
77
78 HRESULT WSLCPluginNotifier::OnVmStopping()
79 try
80 {
81 COMServiceExecutionContext context;
82
83 m_plugins.OnWslcVmStopping(&m_sessionInfo);
84 return S_OK;
85 }
86 CATCH_RETURN();