summaryrefslogtreecommitdiff
path: root/src/pal/src/objmgr/shmobjectmanager.hpp
blob: 6e11b2095e941e4fef52aec224dbd6d0bc372104 (plain)
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*++



Module Name:

    shmobjectmanager.hpp

Abstract:
    Shared memory based object manager



--*/

#ifndef _PAL_SHMOBJECTMANAGER_HPP_
#define _PAL_SHMOBJECTMANAGER_HPP_

#include "pal/corunix.hpp"
#include "pal/handlemgr.hpp"
#include "pal/list.h"    
#include "shmobject.hpp"

namespace CorUnix
{
    class CSharedMemoryObjectManager : public IPalObjectManager
    {
    protected:

        CRITICAL_SECTION m_csListLock;
        bool m_fListLockInitialized;
        LIST_ENTRY m_leNamedObjects;
        LIST_ENTRY m_leAnonymousObjects;
        
        CSimpleHandleManager m_HandleManager;

        PAL_ERROR
        ImportSharedObjectIntoProcess(
            CPalThread *pthr,
            CObjectType *pot,
            CObjectAttributes *poa,
            SHMPTR shmSharedObjectData,
            SHMObjData *psmod,
            bool fAddRefSharedData,
            CSharedMemoryObject **ppshmobj
            );
        
    public:

        CSharedMemoryObjectManager()
            :
            m_fListLockInitialized(FALSE)
        {
        };

        virtual ~CSharedMemoryObjectManager()
        {
        };

        PAL_ERROR
        Initialize(
            void
            );

        PAL_ERROR
        Shutdown(
            CPalThread *pthr
            );

        //
        // IPalObjectManager routines
        //
        
        virtual
        PAL_ERROR
        AllocateObject(
            CPalThread *pthr,
            CObjectType *pot,
            CObjectAttributes *poa,
            IPalObject **ppobjNew
            );

        virtual
        PAL_ERROR
        RegisterObject(
            CPalThread *pthr,
            IPalObject *pobjToRegister,
            CAllowedObjectTypes *paot,
            DWORD dwRightsRequested,
            HANDLE *pHandle,
            IPalObject **ppobjRegistered
            );

        virtual            
        PAL_ERROR
        LocateObject(
            CPalThread *pthr,
            CPalString *psObjectToLocate,
            CAllowedObjectTypes *paot,
            IPalObject **ppobj
            );

        virtual
        PAL_ERROR   
        ObtainHandleForObject(
            CPalThread *pthr,
            IPalObject *pobj,
            DWORD dwRightsRequested,
            bool fInheritHandle,
            IPalProcess *pProcessForHandle,     // IN, OPTIONAL
            HANDLE *pNewHandle
            );

        virtual
        PAL_ERROR
        RevokeHandle(
            CPalThread *pthr,
            HANDLE hHandleToRevoke
            );

        virtual
        PAL_ERROR
        ReferenceObjectByHandle(
            CPalThread *pthr,
            HANDLE hHandleToReference,
            CAllowedObjectTypes *paot,
            DWORD dwRightsRequired,
            IPalObject **ppobj
            );

        virtual
        PAL_ERROR
        ReferenceMultipleObjectsByHandleArray(
            CPalThread *pthr,
            HANDLE rghHandlesToReference[],
            DWORD dwHandleCount,
            CAllowedObjectTypes *paot,
            DWORD dwRightsRequired,
            IPalObject *rgpobjs[]
            );

        virtual
        PAL_ERROR
        ReferenceObjectByForeignHandle(
            CPalThread *pthr,
            HANDLE hForeignHandle,
            IPalProcess *pForeignProcess,
            CAllowedObjectTypes *paot,
            DWORD dwRightsRequired,
            IPalObject **ppobj
            );
    };
}

#endif // _PAL_SHMOBJECTMANAGER_HPP_