ReactOS 0.4.15-dev-8219-ge8b88cf
cicbase.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Cicero
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Cicero base
5 * COPYRIGHT: Copyright 2023-2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#pragma once
9
11{
12 return LocalAlloc(0, size);
13}
14
16{
18}
19
20static inline LPVOID cicMemReAlloc(LPVOID ptr, SIZE_T newSize)
21{
22 if (!ptr)
23 return LocalAlloc(LMEM_ZEROINIT, newSize);
24 return LocalReAlloc(ptr, newSize, LMEM_ZEROINIT);
25}
26
27static inline void cicMemFree(LPVOID ptr)
28{
29 if (ptr)
31}
32
33struct CicNoThrow { };
34#define cicNoThrow CicNoThrow{}
35
36void* operator new(size_t size, const CicNoThrow&) noexcept;
37void* operator new[](size_t size, const CicNoThrow&) noexcept;
38void operator delete(void* ptr) noexcept;
39void operator delete[](void* ptr) noexcept;
40void operator delete(void* ptr, size_t size) noexcept;
41void operator delete[](void* ptr, size_t size) noexcept;
42
43/* The flags of cicGetOSInfo() */
44#define CIC_OSINFO_NT 0x01
45#define CIC_OSINFO_2KPLUS 0x02
46#define CIC_OSINFO_95 0x04
47#define CIC_OSINFO_98PLUS 0x08
48#define CIC_OSINFO_CJK 0x10
49#define CIC_OSINFO_IMM 0x20
50#define CIC_OSINFO_DBCS 0x40
51#define CIC_OSINFO_XPPLUS 0x80
52
54void cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo);
55
56#ifdef __cplusplus
57struct CicSystemModulePath
58{
59 TCHAR m_szPath[MAX_PATH + 2];
60 SIZE_T m_cchPath;
61
62 CicSystemModulePath()
63 {
64 m_szPath[0] = UNICODE_NULL;
65 m_cchPath = 0;
66 }
67
69};
70#endif
71
72// Get an instance handle that is already loaded
77 _In_ BOOL bSysWinDir);
78
79// Load a system library
84 _In_ BOOL bSysWinDir);
85
86#ifdef __cplusplus
87template <typename T_FN>
88static inline BOOL
89cicGetFN(HINSTANCE& hinstDLL, T_FN& fn, LPCTSTR pszDllName, LPCSTR pszFuncName)
90{
91 if (fn)
92 return TRUE;
93 if (!hinstDLL)
95 if (!hinstDLL)
96 return FALSE;
97 fn = reinterpret_cast<T_FN>(GetProcAddress(hinstDLL, pszFuncName));
98 return !!fn;
99}
100#endif
101
102/* Is the current process on WoW64? */
105
109 _In_ REFCLSID rclsid,
110 _In_ LPUNKNOWN pUnkOuter,
111 _In_ DWORD dwClsContext,
112 _In_ REFIID iid,
113 _Out_ LPVOID *ppv);
114
118 _In_ REFCLSID rclsid,
119 _In_ LPUNKNOWN pUnkOuter,
120 _In_ DWORD dwClsContext,
121 _In_ REFIID iid,
122 _Out_ LPVOID *ppv);
123
124// ole32!CoCreateInstance
126 REFCLSID rclsid,
127 LPUNKNOWN pUnkOuter,
128 DWORD dwClsContext,
129 REFIID iid,
130 LPVOID *ppv);
131
132EXTERN_C BOOL TFInitLib(FN_CoCreateInstance fnCoCreateInstance = NULL);
#define EXTERN_C
Definition: basetyps.h:12
EXTERN_C VOID TFUninitLib(VOID)
Definition: msctfime.cpp:914
EXTERN_C BOOL TFInitLib(FN_CoCreateInstance fnCoCreateInstance=NULL)
Definition: cicbase.cpp:251
static LPVOID cicMemAlloc(SIZE_T size)
Definition: cicbase.h:10
static void cicMemFree(LPVOID ptr)
Definition: cicbase.h:27
HRESULT(WINAPI * FN_CoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: cicbase.h:125
static LPVOID cicMemReAlloc(LPVOID ptr, SIZE_T newSize)
Definition: cicbase.h:20
EXTERN_C BOOL cicIsWow64(VOID)
Definition: cicbase.cpp:58
EXTERN_C HINSTANCE cicLoadSystemLibrary(_In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir)
Definition: cicbase.cpp:143
EXTERN_C HRESULT cicRealCoCreateInstance(_In_ REFCLSID rclsid, _In_ LPUNKNOWN pUnkOuter, _In_ DWORD dwClsContext, _In_ REFIID iid, _Out_ LPVOID *ppv)
Definition: cicbase.cpp:206
EXTERN_C HRESULT cicCoCreateInstance(_In_ REFCLSID rclsid, _In_ LPUNKNOWN pUnkOuter, _In_ DWORD dwClsContext, _In_ REFIID iid, _Out_ LPVOID *ppv)
Definition: cicbase.cpp:231
EXTERN_C HINSTANCE cicGetSystemModuleHandle(_In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir)
Definition: cicbase.cpp:130
EXTERN_C void cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo)
Definition: cicbase.cpp:82
static LPVOID cicMemAllocClear(SIZE_T size)
Definition: cicbase.h:15
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
#define MAX_PATH
Definition: compat.h:34
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1625
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
REFIID LPVOID * ppv
Definition: atlbase.h:39
static PVOID ptr
Definition: dispmode.c:27
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
static LPUNKNOWN
Definition: ndr_ole.c:49
#define UNICODE_NULL
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
char * pszDllName
Definition: spec2def.c:73
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t * LPDWORD
Definition: typedefs.h:59
uint32_t * LPUINT
Definition: typedefs.h:59
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define LMEM_ZEROINIT
Definition: winbase.h:375
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
char TCHAR
Definition: xmlstorage.h:189
const char * LPCSTR
Definition: xmlstorage.h:183
const CHAR * LPCTSTR
Definition: xmlstorage.h:193