ReactOS 0.4.15-dev-8236-g99f0937
cicbase.cpp File Reference
#include "precomp.h"
#include "cicbase.h"
#include <shlwapi.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>
#include <strsafe.h>
Include dependency graph for cicbase.cpp:

Go to the source code of this file.

Typedefs

typedef enum _PROCESSINFOCLASS PROCESSINFOCLASS
 
typedef LONG NTSTATUS
 
typedef NTSTATUS(WINAPIFN_NtQueryInformationProcess) (HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG)
 

Enumerations

enum  _PROCESSINFOCLASS {
  ProcessBasicInformation = 0 , ProcessDebugPort = 7 , ProcessWow64Information = 26 , ProcessImageFileName = 27 ,
  ProcessBreakOnTermination = 29 , ProcessBasicInformation = 0 , ProcessQuotaLimits = 1 , ProcessIoCounters = 2 ,
  ProcessVmCounters = 3 , ProcessTimes = 4 , ProcessBasePriority = 5 , ProcessRaisePriority = 6 ,
  ProcessDebugPort = 7 , ProcessExceptionPort = 8 , ProcessAccessToken = 9 , ProcessLdtInformation = 10 ,
  ProcessLdtSize = 11 , ProcessDefaultHardErrorMode = 12 , ProcessIoPortHandlers = 13 , ProcessPooledUsageAndLimits = 14 ,
  ProcessWorkingSetWatch = 15 , ProcessUserModeIOPL = 16 , ProcessEnableAlignmentFaultFixup = 17 , ProcessPriorityClass = 18 ,
  ProcessWx86Information = 19 , ProcessHandleCount = 20 , ProcessAffinityMask = 21 , ProcessPriorityBoost = 22 ,
  ProcessDeviceMap = 23 , ProcessSessionInformation = 24 , ProcessForegroundInformation = 25 , ProcessWow64Information = 26 ,
  ProcessImageFileName = 27 , ProcessLUIDDeviceMapsEnabled = 28 , ProcessBreakOnTermination = 29 , ProcessDebugObjectHandle = 30 ,
  ProcessDebugFlags = 31 , ProcessHandleTracing = 32 , ProcessExecuteFlags = 34 , ProcessTlsInformation = 35 ,
  ProcessCookie = 36 , ProcessImageInformation = 37 , ProcessCycleTime = 38 , ProcessPagePriority = 39 ,
  ProcessInstrumentationCallback = 40 , ProcessThreadStackAllocation = 41 , ProcessWorkingSetWatchEx = 42 , ProcessImageFileNameWin32 = 43 ,
  ProcessImageFileMapping = 44 , ProcessAffinityUpdateMode = 45 , ProcessMemoryAllocationMode = 46 , ProcessGroupInformation = 47 ,
  ProcessTokenVirtualizationEnabled = 48 , ProcessConsoleHostProcess = 49 , ProcessWindowInformation = 50 , MaxProcessInfoClass ,
  ProcessBasicInformation , ProcessQuotaLimits , ProcessIoCounters , ProcessVmCounters ,
  ProcessTimes , ProcessBasePriority , ProcessRaisePriority , ProcessDebugPort ,
  ProcessExceptionPort , ProcessAccessToken , ProcessLdtInformation , ProcessLdtSize ,
  ProcessDefaultHardErrorMode , ProcessIoPortHandlers , ProcessPooledUsageAndLimits , ProcessWorkingSetWatch ,
  ProcessUserModeIOPL , ProcessEnableAlignmentFaultFixup , ProcessPriorityClass , ProcessWx86Information ,
  ProcessHandleCount , ProcessAffinityMask , ProcessPriorityBoost , ProcessDeviceMap ,
  ProcessSessionInformation , ProcessForegroundInformation , ProcessWow64Information , ProcessImageFileName ,
  ProcessLUIDDeviceMapsEnabled , ProcessBreakOnTermination , ProcessDebugObjectHandle , ProcessDebugFlags ,
  ProcessHandleTracing , ProcessIoPriority , ProcessExecuteFlags , ProcessTlsInformation ,
  ProcessCookie , ProcessImageInformation , ProcessCycleTime , ProcessPagePriority ,
  ProcessInstrumentationCallback , ProcessThreadStackAllocation , ProcessWorkingSetWatchEx , ProcessImageFileNameWin32 ,
  ProcessImageFileMapping , ProcessAffinityUpdateMode , ProcessMemoryAllocationMode , ProcessGroupInformation ,
  ProcessTokenVirtualizationEnabled , ProcessConsoleHostProcess , ProcessWindowInformation , MaxProcessInfoClass ,
  ProcessBasicInformation = 0 , ProcessDebugPort = 7 , ProcessWow64Information = 26 , ProcessImageFileName = 27 ,
  ProcessBreakOnTermination = 29
}
 

Functions

voidoperator new (size_t size, const CicNoThrow &) noexcept
 
voidoperator new[] (size_t size, const CicNoThrow &) noexcept
 
void operator delete (void *ptr) noexcept
 
void operator delete[] (void *ptr) noexcept
 
void operator delete (void *ptr, size_t size) noexcept
 
void operator delete[] (void *ptr, size_t size) noexcept
 
EXTERN_C BOOL cicIsWow64 (VOID)
 
EXTERN_C void cicGetOSInfo (LPUINT puACP, LPDWORD pdwOSInfo)
 
EXTERN_C HINSTANCE cicGetSystemModuleHandle (_In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir)
 
EXTERN_C HINSTANCE cicLoadSystemLibrary (_In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir)
 
static FN_CoCreateInstance _cicGetSetUserCoCreateInstance (FN_CoCreateInstance fnUserCoCreateInstance)
 
EXTERN_C HRESULT cicRealCoCreateInstance (_In_ REFCLSID rclsid, _In_ LPUNKNOWN pUnkOuter, _In_ DWORD dwClsContext, _In_ REFIID iid, _Out_ LPVOID *ppv)
 
HRESULT cicCoCreateInstance (_In_ REFCLSID rclsid, _In_ LPUNKNOWN pUnkOuter, _In_ DWORD dwClsContext, _In_ REFIID iid, _Out_ LPVOID *ppv)
 
EXTERN_C BOOL TFInitLib (FN_CoCreateInstance fnCoCreateInstance)
 

Typedef Documentation

◆ FN_NtQueryInformationProcess

typedef NTSTATUS(WINAPI * FN_NtQueryInformationProcess) (HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG)

Definition at line 55 of file cicbase.cpp.

◆ NTSTATUS

typedef LONG NTSTATUS

Definition at line 52 of file cicbase.cpp.

◆ PROCESSINFOCLASS

Enumeration Type Documentation

◆ _PROCESSINFOCLASS

Enumerator
ProcessBasicInformation 
ProcessDebugPort 
ProcessWow64Information 
ProcessImageFileName 
ProcessBreakOnTermination 
ProcessBasicInformation 
ProcessQuotaLimits 
ProcessIoCounters 
ProcessVmCounters 
ProcessTimes 
ProcessBasePriority 
ProcessRaisePriority 
ProcessDebugPort 
ProcessExceptionPort 
ProcessAccessToken 
ProcessLdtInformation 
ProcessLdtSize 
ProcessDefaultHardErrorMode 
ProcessIoPortHandlers 
ProcessPooledUsageAndLimits 
ProcessWorkingSetWatch 
ProcessUserModeIOPL 
ProcessEnableAlignmentFaultFixup 
ProcessPriorityClass 
ProcessWx86Information 
ProcessHandleCount 
ProcessAffinityMask 
ProcessPriorityBoost 
ProcessDeviceMap 
ProcessSessionInformation 
ProcessForegroundInformation 
ProcessWow64Information 
ProcessImageFileName 
ProcessLUIDDeviceMapsEnabled 
ProcessBreakOnTermination 
ProcessDebugObjectHandle 
ProcessDebugFlags 
ProcessHandleTracing 
ProcessExecuteFlags 
ProcessTlsInformation 
ProcessCookie 
ProcessImageInformation 
ProcessCycleTime 
ProcessPagePriority 
ProcessInstrumentationCallback 
ProcessThreadStackAllocation 
ProcessWorkingSetWatchEx 
ProcessImageFileNameWin32 
ProcessImageFileMapping 
ProcessAffinityUpdateMode 
ProcessMemoryAllocationMode 
ProcessGroupInformation 
ProcessTokenVirtualizationEnabled 
ProcessConsoleHostProcess 
ProcessWindowInformation 
MaxProcessInfoClass 
ProcessBasicInformation 
ProcessQuotaLimits 
ProcessIoCounters 
ProcessVmCounters 
ProcessTimes 
ProcessBasePriority 
ProcessRaisePriority 
ProcessDebugPort 
ProcessExceptionPort 
ProcessAccessToken 
ProcessLdtInformation 
ProcessLdtSize 
ProcessDefaultHardErrorMode 
ProcessIoPortHandlers 
ProcessPooledUsageAndLimits 
ProcessWorkingSetWatch 
ProcessUserModeIOPL 
ProcessEnableAlignmentFaultFixup 
ProcessPriorityClass 
ProcessWx86Information 
ProcessHandleCount 
ProcessAffinityMask 
ProcessPriorityBoost 
ProcessDeviceMap 
ProcessSessionInformation 
ProcessForegroundInformation 
ProcessWow64Information 
ProcessImageFileName 
ProcessLUIDDeviceMapsEnabled 
ProcessBreakOnTermination 
ProcessDebugObjectHandle 
ProcessDebugFlags 
ProcessHandleTracing 
ProcessIoPriority 
ProcessExecuteFlags 
ProcessTlsInformation 
ProcessCookie 
ProcessImageInformation 
ProcessCycleTime 
ProcessPagePriority 
ProcessInstrumentationCallback 
ProcessThreadStackAllocation 
ProcessWorkingSetWatchEx 
ProcessImageFileNameWin32 
ProcessImageFileMapping 
ProcessAffinityUpdateMode 
ProcessMemoryAllocationMode 
ProcessGroupInformation 
ProcessTokenVirtualizationEnabled 
ProcessConsoleHostProcess 
ProcessWindowInformation 
MaxProcessInfoClass 
ProcessBasicInformation 
ProcessDebugPort 
ProcessWow64Information 
ProcessImageFileName 
ProcessBreakOnTermination 

Definition at line 42 of file cicbase.cpp.

43{
enum _PROCESSINFOCLASS PROCESSINFOCLASS
@ ProcessDebugPort
Definition: cicbase.cpp:45
@ ProcessBreakOnTermination
Definition: cicbase.cpp:48
@ ProcessBasicInformation
Definition: cicbase.cpp:44
@ ProcessWow64Information
Definition: cicbase.cpp:46
@ ProcessImageFileName
Definition: cicbase.cpp:47

Function Documentation

◆ _cicGetSetUserCoCreateInstance()

static FN_CoCreateInstance _cicGetSetUserCoCreateInstance ( FN_CoCreateInstance  fnUserCoCreateInstance)
static

Definition at line 196 of file cicbase.cpp.

197{
198 static FN_CoCreateInstance s_fn = NULL;
199 if (fnUserCoCreateInstance)
200 s_fn = fnUserCoCreateInstance;
201 return s_fn;
202}
HRESULT(WINAPI * FN_CoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: cicbase.h:125
#define NULL
Definition: types.h:112

Referenced by cicCoCreateInstance(), and TFInitLib().

◆ cicCoCreateInstance()

HRESULT cicCoCreateInstance ( _In_ REFCLSID  rclsid,
_In_ LPUNKNOWN  pUnkOuter,
_In_ DWORD  dwClsContext,
_In_ REFIID  iid,
_Out_ LPVOID ppv 
)

@implemented

Definition at line 231 of file cicbase.cpp.

237{
238 // NOTE: It looks like Cicero wants to hook CoCreateInstance
240 if (fnUserCoCreateInstance)
241 return fnUserCoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, ppv);
242
243 return cicRealCoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, ppv);
244}
EXTERN_C HRESULT cicRealCoCreateInstance(_In_ REFCLSID rclsid, _In_ LPUNKNOWN pUnkOuter, _In_ DWORD dwClsContext, _In_ REFIID iid, _Out_ LPVOID *ppv)
Definition: cicbase.cpp:206
static FN_CoCreateInstance _cicGetSetUserCoCreateInstance(FN_CoCreateInstance fnUserCoCreateInstance)
Definition: cicbase.cpp:196
REFIID LPVOID * ppv
Definition: atlbase.h:39

Referenced by GetUIMCat(), and InitDisplayAttrbuteLib().

◆ cicGetOSInfo()

EXTERN_C void cicGetOSInfo ( LPUINT  puACP,
LPDWORD  pdwOSInfo 
)

Definition at line 82 of file cicbase.cpp.

83{
84 *pdwOSInfo = 0;
85
86 /* Check OS version info */
87 OSVERSIONINFO VerInfo;
88 VerInfo.dwOSVersionInfoSize = sizeof(VerInfo);
89 GetVersionEx(&VerInfo);
90 if (VerInfo.dwPlatformId == DLLVER_PLATFORM_NT)
91 {
92 *pdwOSInfo |= CIC_OSINFO_NT;
93 if (VerInfo.dwMajorVersion >= 5)
94 {
95 *pdwOSInfo |= CIC_OSINFO_2KPLUS;
96 if (VerInfo.dwMinorVersion > 0)
97 *pdwOSInfo |= CIC_OSINFO_XPPLUS;
98 }
99 }
100 else
101 {
102 if (VerInfo.dwMinorVersion >= 10)
103 *pdwOSInfo |= CIC_OSINFO_98PLUS;
104 else
105 *pdwOSInfo |= CIC_OSINFO_95;
106 }
107
108 /* Check codepage */
109 *puACP = GetACP();
110 switch (*puACP)
111 {
112 case 932: /* Japanese (Japan) */
113 case 936: /* Chinese (PRC, Singapore) */
114 case 949: /* Korean (Korea) */
115 case 950: /* Chinese (Taiwan, Hong Kong) */
116 *pdwOSInfo |= CIC_OSINFO_CJK;
117 break;
118 }
119
120 if (GetSystemMetrics(SM_IMMENABLED))
121 *pdwOSInfo |= CIC_OSINFO_IMM;
122
124 *pdwOSInfo |= CIC_OSINFO_DBCS;
125}
#define CIC_OSINFO_IMM
Definition: cicbase.h:49
#define CIC_OSINFO_NT
Definition: cicbase.h:44
#define CIC_OSINFO_DBCS
Definition: cicbase.h:50
#define CIC_OSINFO_2KPLUS
Definition: cicbase.h:45
#define CIC_OSINFO_XPPLUS
Definition: cicbase.h:51
#define CIC_OSINFO_95
Definition: cicbase.h:46
#define CIC_OSINFO_CJK
Definition: cicbase.h:48
#define CIC_OSINFO_98PLUS
Definition: cicbase.h:47
UINT WINAPI GetACP(void)
Definition: locale.c:2020
#define DLLVER_PLATFORM_NT
Definition: shlwapi.h:1962
ULONG dwPlatformId
Definition: rtltypes.h:241
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:237
ULONG dwMajorVersion
Definition: rtltypes.h:238
ULONG dwMinorVersion
Definition: rtltypes.h:239
#define GetVersionEx
Definition: winbase.h:3852
#define SM_DBCSENABLED
Definition: winuser.h:1005
int WINAPI GetSystemMetrics(_In_ int)

Referenced by InitApp(), and ProcessAttach().

◆ cicGetSystemModuleHandle()

EXTERN_C HINSTANCE cicGetSystemModuleHandle ( _In_ LPCTSTR  pszFileName,
_In_ BOOL  bSysWinDir 
)

Definition at line 130 of file cicbase.cpp.

133{
134 CicSystemModulePath ModPath;
135 if (!ModPath.Init(pszFileName, bSysWinDir))
136 return NULL;
137 return GetModuleHandle(ModPath.m_szPath);
138}
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
#define GetModuleHandle
Definition: winbase.h:3827

Referenced by CheckX64System(), cicIsWow64(), DelayedRegNotifyChangeKeyValue(), DllShutdownInProgress(), and InitApp().

◆ cicIsWow64()

EXTERN_C BOOL cicIsWow64 ( VOID  )

Definition at line 58 of file cicbase.cpp.

59{
60 static FN_NtQueryInformationProcess s_fnNtQueryInformationProcess = NULL;
62
63 if (!s_fnNtQueryInformationProcess)
64 {
65 HMODULE hNTDLL = cicGetSystemModuleHandle(TEXT("ntdll.dll"), FALSE);
66 if (!hNTDLL)
67 return FALSE;
68
69 s_fnNtQueryInformationProcess =
70 (FN_NtQueryInformationProcess)GetProcAddress(hNTDLL, "NtQueryInformationProcess");
71 if (!s_fnNtQueryInformationProcess)
72 return FALSE;
73 }
74
75 Value = 0;
76 s_fnNtQueryInformationProcess(GetCurrentProcess(), ProcessWow64Information,
77 &Value, sizeof(Value), NULL);
78 return !!Value;
79}
NTSTATUS(WINAPI * FN_NtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG)
Definition: cicbase.cpp:55
EXTERN_C HINSTANCE cicGetSystemModuleHandle(_In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir)
Definition: cicbase.cpp:130
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
#define GetCurrentProcess()
Definition: compat.h:759
#define TEXT(s)
Definition: k32.h:26
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by InitApp(), and ProcessAttach().

◆ cicLoadSystemLibrary()

EXTERN_C HINSTANCE cicLoadSystemLibrary ( _In_ LPCTSTR  pszFileName,
_In_ BOOL  bSysWinDir 
)

Definition at line 143 of file cicbase.cpp.

146{
147 CicSystemModulePath ModPath;
148 if (!ModPath.Init(pszFileName, bSysWinDir))
149 return NULL;
150 return ::LoadLibrary(ModPath.m_szPath);
151}

Referenced by cicRealCoCreateInstance(), and CRegWatcher::UpdateSpTip().

◆ cicRealCoCreateInstance()

EXTERN_C HRESULT cicRealCoCreateInstance ( _In_ REFCLSID  rclsid,
_In_ LPUNKNOWN  pUnkOuter,
_In_ DWORD  dwClsContext,
_In_ REFIID  iid,
_Out_ LPVOID ppv 
)

Definition at line 206 of file cicbase.cpp.

212{
213 static HINSTANCE s_hOle32 = NULL;
214 static FN_CoCreateInstance s_fnCoCreateInstance = NULL;
215 if (!s_fnCoCreateInstance)
216 {
217 if (!s_hOle32)
218 s_hOle32 = cicLoadSystemLibrary(TEXT("ole32.dll"), FALSE);
219 s_fnCoCreateInstance = (FN_CoCreateInstance)GetProcAddress(s_hOle32, "CoCreateInstance");
220 if (!s_fnCoCreateInstance)
221 return E_NOTIMPL;
222 }
223
224 return s_fnCoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, ppv);
225}
EXTERN_C HINSTANCE cicLoadSystemLibrary(_In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir)
Definition: cicbase.cpp:143
#define E_NOTIMPL
Definition: ddrawi.h:99

Referenced by cicCoCreateInstance(), and MsUtbCoCreateInstance().

◆ operator delete() [1/2]

void operator delete ( void ptr)
noexcept

Definition at line 24 of file cicbase.cpp.

25{
27}
static void cicMemFree(LPVOID ptr)
Definition: cicbase.h:27
static PVOID ptr
Definition: dispmode.c:27

◆ operator delete() [2/2]

void operator delete ( void ptr,
size_t  size 
)
noexcept

Definition at line 32 of file cicbase.cpp.

33{
35}

◆ operator delete[]() [1/2]

void operator delete[] ( void ptr)
noexcept

Definition at line 28 of file cicbase.cpp.

29{
31}

◆ operator delete[]() [2/2]

void operator delete[] ( void ptr,
size_t  size 
)
noexcept

Definition at line 36 of file cicbase.cpp.

37{
39}

◆ operator new()

void * operator new ( size_t  size,
const CicNoThrow  
)
noexcept

Definition at line 16 of file cicbase.cpp.

17{
18 return cicMemAllocClear(size);
19}
static LPVOID cicMemAllocClear(SIZE_T size)
Definition: cicbase.h:15
GLsizeiptr size
Definition: glext.h:5919

◆ operator new[]()

void * operator new[] ( size_t  size,
const CicNoThrow  
)
noexcept

Definition at line 20 of file cicbase.cpp.

21{
22 return cicMemAllocClear(size);
23}

◆ TFInitLib()

EXTERN_C BOOL TFInitLib ( FN_CoCreateInstance  fnCoCreateInstance)

@implemented

Definition at line 251 of file cicbase.cpp.

252{
253 if (fnCoCreateInstance)
254 _cicGetSetUserCoCreateInstance(fnCoCreateInstance);
255 return TRUE;
256}
#define TRUE
Definition: types.h:120

Referenced by ProcessAttach().