Ignore:
Timestamp:
Oct 22, 2003, 2:43:14 PM (22 years ago)
Author:
sandervl
Message:

Use WC_FRAME for the Odin frame window and subclass it; Updates for new keyboard hook

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/inituser32.cpp

    r10277 r10284  
    1 /* $Id: inituser32.cpp,v 1.15 2003-10-20 17:18:30 sandervl Exp $ */
     1/* $Id: inituser32.cpp,v 1.16 2003-10-22 12:43:13 sandervl Exp $ */
    22/*
    33 * USER32 DLL entry point
     
    4242#include <spy.h>
    4343#include <monitor.h>
     44#include <kbdhook.h>
    4445#include "pmwindow.h"
    4546#include "win32wdesktop.h"
     
    7071extern INT __cdecl wsnprintfA(LPSTR,UINT,LPCSTR,...);
    7172
    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"
     73static char PMKBDHK_MODULE[16] = STD_PMKBDHK_MODULE;
    8074
    8175static BOOL pmkbdhk_installed = FALSE;
    8276static HMODULE hmodPMKBDHK;
    8377
    84 static PVOID (*APIENTRY pfnHookInit)(HAB);
    85 static BOOL  (*APIENTRY pfnHookTerm)(void);
     78static PFN_HOOKINIT pfnHookInit = NULL;
     79static PFN_HOOKTERM pfnHookTerm = NULL;
    8680
    8781// defined initialized in pmwindow.cpp: InitPM()
     
    9488   strcpy(PMKBDHK_MODULE, pszKbdDllName);
    9589}
    96 
     90//******************************************************************************
     91//******************************************************************************
     92void 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//******************************************************************************
     147void 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//******************************************************************************
    97172#define FONTSDIRECTORY "Fonts"
    98173#define REGPATH "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"
    99 
    100 //******************************************************************************
    101174//******************************************************************************
    102175void MigrateWindowsFonts()
     
    145218  }
    146219}
    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 DLL
    159     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 points
    173     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 again
    190       DosFreeModule(hmodPMKBDHK);
    191       hmodPMKBDHK = NULLHANDLE;
    192 
    193       return;
    194     }
    195 
    196     // now finally call the initializer function
    197     pfnHookInit(_hab);
    198 
    199     // OK, hook is armed
    200     pmkbdhk_installed = TRUE;
    201   }
    202 }
    203 //******************************************************************************
    204 //******************************************************************************
    205 void pmkbdhk_terminate(void)
    206 {
    207   if (pmkbdhk_installed == TRUE)
    208   {
    209     // call the terminator function
    210     pfnHookTerm();
    211 
    212     // OK, hook is disarmed
    213     pmkbdhk_installed = FALSE;
    214   }
    215 
    216   // unload the dll
    217   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 }
    229220/****************************************************************************/
    230221/* _DLL_InitTerm is the function that gets called by the operating system   */
Note: See TracChangeset for help on using the changeset viewer.