Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

imminit.c

Go to the documentation of this file.
00001 /****************************** Module Header ******************************\ 00002 * Module Name: imminit.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * This module implements IMM32 initialization 00007 * 00008 * History: 00009 * 03-Jan-1996 wkwok Created 00010 \**************************************************************************/ 00011 00012 #include "precomp.h" 00013 #pragma hdrstop 00014 00015 // required for wow.obj in userrtl.lib 00016 extern ULONG_PTR gHighestUserAddress; 00017 00018 00019 BOOL ImmInitializeGlobals(HINSTANCE hmod) 00020 { 00021 SYSTEM_BASIC_INFORMATION SystemInformation; 00022 00023 if (hmod) { 00024 /* 00025 * Remember IMM32.DLL's hmodule so we can grab resources from it later. 00026 */ 00027 ghInst = hmod; 00028 } 00029 if (gfInitialized) { 00030 return TRUE; 00031 } 00032 if (!NT_SUCCESS(RtlInitializeCriticalSection(&gcsImeDpi))) { 00033 RIPMSG0(RIP_WARNING, "ImmInitializeGlobals: failed to initialize critical section at startup. Just bail."); 00034 return FALSE; 00035 } 00036 if (!NT_SUCCESS(NtQuerySystemInformation(SystemBasicInformation, 00037 &SystemInformation, 00038 sizeof(SystemInformation), 00039 NULL))) { 00040 RIPMSG0(RIP_WARNING, "ImmInitializeGlobals: failed to query system information. Just bail."); 00041 return FALSE; 00042 } 00043 gHighestUserAddress = SystemInformation.MaximumUserModeAddress; 00044 00045 gfInitialized = TRUE; 00046 00047 return TRUE; 00048 } 00049 00050 00051 BOOL ImmRegisterClient( 00052 IN PSHAREDINFO psiClient, HINSTANCE hmod) 00053 { 00054 gSharedInfo = *psiClient; 00055 gpsi = gSharedInfo.psi; 00056 /* Raid #97316 00057 * Dlls loaded earlier than imm32.dll could make 00058 * user32 call which calls back imm routines. 00059 * ImmRegisterClient() is called from User32's init routine, 00060 * so we can expect to reach here early enough. 00061 * We need to initialize globals as much as possible 00062 * here. 00063 */ 00064 return ImmInitializeGlobals(hmod); 00065 } 00066 00067 BOOL ImmDllInitialize( 00068 IN PVOID hmod, 00069 IN DWORD Reason, 00070 IN PCONTEXT pctx OPTIONAL) 00071 { 00072 UNREFERENCED_PARAMETER(pctx); 00073 00074 switch ( Reason ) { 00075 00076 case DLL_PROCESS_ATTACH: 00077 UserAssert(!gfInitialized || hmod == ghInst); 00078 00079 if (!ImmInitializeGlobals(hmod)) 00080 return FALSE; 00081 00082 UserAssert(hmod != NULL); 00083 00084 // Initialize USER32.DLL in case if USER32 has not bound itself to IMM32 00085 if (!User32InitializeImmEntryTable(IMM_MAGIC_CALLER_ID)) 00086 return FALSE; 00087 break; 00088 00089 case DLL_PROCESS_DETACH: 00090 if (gfInitialized) { 00091 RtlDeleteCriticalSection(&gcsImeDpi); 00092 } 00093 break; 00094 00095 case DLL_THREAD_DETACH: 00096 if (IS_IME_ENABLED()) { 00097 DestroyInputContext( 00098 (HIMC)NtUserGetThreadState(UserThreadStateDefaultInputContext), 00099 GetKeyboardLayout(0), 00100 TRUE); 00101 } 00102 break; 00103 00104 default: 00105 break; 00106 } 00107 00108 return TRUE; 00109 } 00110 00111 00112 /***************************************************************************\ 00113 * Allocation routines for RTL functions. 00114 * 00115 * 00116 \***************************************************************************/ 00117 00118 PVOID UserRtlAllocMem( 00119 ULONG uBytes) 00120 { 00121 return LocalAlloc(LPTR, uBytes); 00122 } 00123 00124 VOID UserRtlFreeMem( 00125 PVOID pMem) 00126 { 00127 LocalFree(pMem); 00128 } 00129 00130 VOID UserRtlRaiseStatus( 00131 NTSTATUS Status) 00132 { 00133 RtlRaiseStatus(Status); 00134 } 00135 00136 DWORD GetRipComponent(VOID) { return RIP_IMM; } 00137 00138 DWORD GetDbgTagFlags(int tag) 00139 { 00140 #if DEBUGTAGS 00141 return (gpsi != NULL ? gpsi->adwDBGTAGFlags[tag] : 0); 00142 #else 00143 return 0; 00144 UNREFERENCED_PARAMETER(tag); 00145 #endif // DEBUGTAGS 00146 } 00147 00148 DWORD GetRipPID(VOID) { return (gpsi != NULL ? gpsi->wRIPPID : 0); } 00149 DWORD GetRipFlags(VOID) { return (gpsi != NULL ? gpsi->wRIPFlags : RIPF_DEFAULT); } 00150 00151 extern VOID NtUserSetRipFlags(DWORD, DWORD); 00152 00153 VOID SetRipFlags(DWORD dwRipFlags, DWORD dwRipPID) 00154 { 00155 NtUserSetRipFlags(dwRipFlags, dwRipPID); 00156 } 00157 00158 VOID SetDbgTag(int tag, DWORD dwBitFlags) 00159 { 00160 RIPMSG0(RIP_ERROR, "SetDbgTag not available in imm32.dll"); 00161 return; 00162 UNREFERENCED_PARAMETER(tag); 00163 UNREFERENCED_PARAMETER(dwBitFlags); 00164 } 00165

Generated on Sat May 15 19:40:21 2004 for test by doxygen 1.3.7