4 * Copyright 2009 Andrew Hill <ash77@reactos.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 #define ATLASSERT(expr) _ASSERTE(expr)
36 class CComCriticalSection
39 CRITICAL_SECTION m_sec
;
43 memset(&m_sec
, 0, sizeof(CRITICAL_SECTION
));
46 ~CComCriticalSection()
52 EnterCriticalSection(&m_sec
);
58 LeaveCriticalSection(&m_sec
);
64 InitializeCriticalSection(&m_sec
);
70 DeleteCriticalSection(&m_sec
);
75 class CComFakeCriticalSection
99 class CComAutoCriticalSection
: public CComCriticalSection
102 CComAutoCriticalSection()
106 hResult
= CComCriticalSection::Init();
107 ATLASSERT(SUCCEEDED(hResult
));
109 ~CComAutoCriticalSection()
111 CComCriticalSection::Term();
115 class CComSafeDeleteCriticalSection
: public CComCriticalSection
120 CComSafeDeleteCriticalSection()
122 m_bInitialized
= false;
125 ~CComSafeDeleteCriticalSection()
132 ATLASSERT(m_bInitialized
);
133 return CComCriticalSection::Lock();
140 ATLASSERT(!m_bInitialized
);
141 hResult
= CComCriticalSection::Init();
142 if (SUCCEEDED(hResult
))
143 m_bInitialized
= true;
151 m_bInitialized
= false;
152 return CComCriticalSection::Term();
156 class CComAutoDeleteCriticalSection
: public CComSafeDeleteCriticalSection
159 // CComAutoDeleteCriticalSection::Term should never be called
163 struct _ATL_BASE_MODULE70
167 HINSTANCE m_hInstResource
;
171 CRITICAL_SECTION m_csResource
;
173 CSimpleArray
<HINSTANCE
> m_rgResourceInstance
;
176 typedef _ATL_BASE_MODULE70 _ATL_BASE_MODULE
;
178 class CAtlBaseModule
: public _ATL_BASE_MODULE
181 static bool m_bInitFailed
;
185 cbSize
= sizeof(_ATL_BASE_MODULE
);
186 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
, (LPCWSTR
)this, &m_hInst
);
187 m_hInstResource
= m_hInst
;
190 HINSTANCE
GetModuleInstance()
195 HINSTANCE
GetResourceInstance()
197 return m_hInstResource
;
201 extern CAtlBaseModule _AtlBaseModule
;