master
h 65 lines 1.76 KB
Raw
1 /*++
2
3 Copyright (c) Microsoft. All rights reserved.
4
5 Module Name:
6
7 LxssUserSessionFactory.h
8
9 Abstract:
10
11 This file contains user session factory function declarations.
12
13 --*/
14
15 #pragma once
16 #include <wil/resource.h>
17 #include "LxssUserSession.h"
18
19 class LxssUserSessionImpl;
20
21 /// <summary>
22 /// WRL supports caching of class factories, but doesn't have a notion of a "singleton" COM object.
23 /// By providing our own class factory for creating LxssUserSession objects, we can control the lifetime
24 /// of the handed-out session object and ensure there's only one.
25 /// </summary>
26 class LxssUserSessionFactory : public Microsoft::WRL::ClassFactory<>
27 {
28 public:
29 LxssUserSessionFactory() = default;
30
31 /// <summary>
32 /// IClassFactory::CreateInstance - creates or hands out the LxssUserSession object to use.
33 /// </summary>
34 STDMETHODIMP CreateInstance(_In_ IUnknown* pUnkOuter, _In_ REFIID riid, _Out_ void** ppCreated) override;
35 };
36
37 /// <summary>
38 /// Clean shutdown - clear all active sessions and prevent new sessions from being created.
39 /// </summary>
40 void ClearSessionsAndBlockNewInstances();
41
42 /// <summary>
43 /// Create a new session for the current user.
44 /// </summary>
45 std::weak_ptr<LxssUserSessionImpl> CreateInstanceForCurrentUser();
46
47 /// <summary>
48 /// Set session creation policy. This is controlled by WSL enterprise policy keys.
49 /// </summary>
50 void SetSessionPolicy(_In_ bool enabled);
51
52 /// <summary>
53 /// Clean shutdown - terminate a specific session.
54 /// </summary>
55 void TerminateSession(_In_ DWORD sessionId);
56
57 /// <summary>
58 /// Find a session for a given user.
59 /// </summary>
60 std::shared_ptr<LxssUserSessionImpl> FindSession(PSID User);
61
62 /// <summary>
63 /// Find a session for a given cookie.
64 /// </summary>
65 std::shared_ptr<LxssUserSessionImpl> FindSessionByCookie(DWORD Cookie);