xref: /reactos/sdk/lib/cicero/cicfmap.h (revision fc3eeb61)
1 /*
2  * PROJECT:     ReactOS Cicero
3  * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4  * PURPOSE:     Cicero file mapping
5  * COPYRIGHT:   Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6  */
7 
8 #pragma once
9 
10 #include "cicmutex.h"
11 
12 // class CicFileMappingStatic;
13 // class CicFileMapping;
14 
15 class CicFileMappingStatic
16 {
17 protected:
18     LPCTSTR m_pszName;
19     LPVOID m_pView;
20     HANDLE m_hMapping;
21     BOOL m_bCreated;
22     BOOL m_bHasMutex;
23     CicMutex *m_pMutex;
24 
25     LPVOID _Map();
26 
27 public:
CicFileMappingStatic()28     CicFileMappingStatic() { }
~CicFileMappingStatic()29     ~CicFileMappingStatic() { }
30 
31     void Init(LPCTSTR pszName, CicMutex *pMutex);
32 
33     LPVOID Create(LPSECURITY_ATTRIBUTES pSA, DWORD dwMaximumSizeLow, LPBOOL pbAlreadyExists);
34     LPVOID Open();
35     void Close();
36 
37     BOOL Enter();
38     void Leave();
39     BOOL Flush(SIZE_T dwNumberOfBytesToFlush);
40     void Finalize();
41 };
42 
43 class CicFileMapping : public CicFileMappingStatic
44 {
45 public:
46     CicFileMapping(LPCTSTR pszName, CicMutex *pMutex);
~CicFileMapping()47     virtual ~CicFileMapping() { Finalize(); }
48 };
49