Changeset 10284 for trunk/src/user32/inituser32.cpp
- Timestamp:
- Oct 22, 2003, 2:43:14 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/inituser32.cpp
r10277 r10284 1 /* $Id: inituser32.cpp,v 1.1 5 2003-10-20 17:18:30sandervl Exp $ */1 /* $Id: inituser32.cpp,v 1.16 2003-10-22 12:43:13 sandervl Exp $ */ 2 2 /* 3 3 * USER32 DLL entry point … … 42 42 #include <spy.h> 43 43 #include <monitor.h> 44 #include <kbdhook.h> 44 45 #include "pmwindow.h" 45 46 #include "win32wdesktop.h" … … 70 71 extern INT __cdecl wsnprintfA(LPSTR,UINT,LPCSTR,...); 71 72 72 /**************************************************************/ 73 /* Try to load the Presentation Manager Keyboard Hook module. */ 74 /* If this fails, some hotkeys may not arrive properly at the */ 75 /* targetted window, but no more harmful things will happen. */ 76 /**************************************************************/ 77 static char PMKBDHK_MODULE[16] = "PMKBDHK"; 78 #define PMKBDHK_HOOK_INIT "hookInit" 79 #define PMKBDHK_HOOK_TERM "hookKill" 73 static char PMKBDHK_MODULE[16] = STD_PMKBDHK_MODULE; 80 74 81 75 static BOOL pmkbdhk_installed = FALSE; 82 76 static HMODULE hmodPMKBDHK; 83 77 84 static P VOID (*APIENTRY pfnHookInit)(HAB);85 static BOOL (*APIENTRY pfnHookTerm)(void);78 static PFN_HOOKINIT pfnHookInit = NULL; 79 static PFN_HOOKTERM pfnHookTerm = NULL; 86 80 87 81 // defined initialized in pmwindow.cpp: InitPM() … … 94 88 strcpy(PMKBDHK_MODULE, pszKbdDllName); 95 89 } 96 90 //****************************************************************************** 91 //****************************************************************************** 92 void pmkbdhk_initialize(HAB _hab) 93 { 94 APIRET rc; 95 96 if ((pmkbdhk_installed == FALSE) && PMKBDHK_MODULE[0]) 97 { 98 CHAR szBuf[260]; 99 100 // load the DLL 101 rc = DosLoadModule(szBuf, 102 sizeof(szBuf), 103 PMKBDHK_MODULE, 104 &hmodPMKBDHK); 105 if (NO_ERROR != rc) 106 { 107 dprintf(("USER32: pmkbdhk_initalize(%08xh) failed rc=%d\n", 108 _hab, 109 rc)); 110 111 return; 112 } 113 114 // get the entry points 115 rc = DosQueryProcAddr(hmodPMKBDHK, 116 0, 117 PMKBDHK_HOOK_INIT, 118 (PFN*)&pfnHookInit); 119 if (NO_ERROR == rc) 120 rc = DosQueryProcAddr(hmodPMKBDHK, 121 0, 122 PMKBDHK_HOOK_TERM, 123 (PFN*)&pfnHookTerm); 124 125 if (NO_ERROR != rc) 126 { 127 dprintf(("USER32: pmkbdhk_initalize(%08xh) failed importing functions, rc=%d\n", 128 _hab, 129 rc)); 130 131 // free the DLL again 132 DosFreeModule(hmodPMKBDHK); 133 hmodPMKBDHK = NULLHANDLE; 134 135 return; 136 } 137 138 // now finally call the initializer function 139 if(pfnHookInit(_hab, WIN32_STDCLASS) == FALSE) DebugInt3(); 140 141 // OK, hook is armed 142 pmkbdhk_installed = TRUE; 143 } 144 } 145 //****************************************************************************** 146 //****************************************************************************** 147 void pmkbdhk_terminate(void) 148 { 149 if (pmkbdhk_installed == TRUE) 150 { 151 // call the terminator function 152 pfnHookTerm(); 153 154 // OK, hook is disarmed 155 pmkbdhk_installed = FALSE; 156 } 157 158 // unload the dll 159 if (NULLHANDLE != hmodPMKBDHK) 160 { 161 APIRET rc = DosFreeModule(hmodPMKBDHK); 162 if (NO_ERROR != rc) 163 { 164 dprintf(("USER32: pmkbdhk_terminate() failed rc=%d\n", 165 rc)); 166 167 hmodPMKBDHK = NULLHANDLE; 168 } 169 } 170 } 171 //****************************************************************************** 97 172 #define FONTSDIRECTORY "Fonts" 98 173 #define REGPATH "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts" 99 100 //******************************************************************************101 174 //****************************************************************************** 102 175 void MigrateWindowsFonts() … … 145 218 } 146 219 } 147 148 //******************************************************************************149 //******************************************************************************150 void pmkbdhk_initialize(HAB _hab)151 {152 APIRET rc;153 154 if ((pmkbdhk_installed == FALSE) && PMKBDHK_MODULE[0])155 {156 CHAR szBuf[260];157 158 // load the DLL159 rc = DosLoadModule(szBuf,160 sizeof(szBuf),161 PMKBDHK_MODULE,162 &hmodPMKBDHK);163 if (NO_ERROR != rc)164 {165 dprintf(("USER32: pmkbdhk_initalize(%08xh) failed rc=%d\n",166 _hab,167 rc));168 169 return;170 }171 172 // get the entry points173 rc = DosQueryProcAddr(hmodPMKBDHK,174 0,175 PMKBDHK_HOOK_INIT,176 (PFN*)&pfnHookInit);177 if (NO_ERROR == rc)178 rc = DosQueryProcAddr(hmodPMKBDHK,179 0,180 PMKBDHK_HOOK_TERM,181 (PFN*)&pfnHookTerm);182 183 if (NO_ERROR != rc)184 {185 dprintf(("USER32: pmkbdhk_initalize(%08xh) failed importing functions, rc=%d\n",186 _hab,187 rc));188 189 // free the DLL again190 DosFreeModule(hmodPMKBDHK);191 hmodPMKBDHK = NULLHANDLE;192 193 return;194 }195 196 // now finally call the initializer function197 pfnHookInit(_hab);198 199 // OK, hook is armed200 pmkbdhk_installed = TRUE;201 }202 }203 //******************************************************************************204 //******************************************************************************205 void pmkbdhk_terminate(void)206 {207 if (pmkbdhk_installed == TRUE)208 {209 // call the terminator function210 pfnHookTerm();211 212 // OK, hook is disarmed213 pmkbdhk_installed = FALSE;214 }215 216 // unload the dll217 if (NULLHANDLE != hmodPMKBDHK)218 {219 APIRET rc = DosFreeModule(hmodPMKBDHK);220 if (NO_ERROR != rc)221 {222 dprintf(("USER32: pmkbdhk_terminate() failed rc=%d\n",223 rc));224 225 hmodPMKBDHK = NULLHANDLE;226 }227 }228 }229 220 /****************************************************************************/ 230 221 /* _DLL_InitTerm is the function that gets called by the operating system */
Note:
See TracChangeset
for help on using the changeset viewer.