示例#1
0
static void APIENTRY SoftModeThread( thread_data *thread )
{
    QMSG        qmsg;
    ULONG       rc;
    RECTL       rcl;
    HPS         ps;

    rc = WinThreadAssocQueue( HabDebugger, thread->hmq );
    rc = WinSetHook( HabDebugger, thread->hmq, HK_CALLHOOK, (PFN)CallHookProc, NULLHANDLE );
    PSetHmqDebugee( thread->hmq, HwndDummy );
    rc = WinSetHook( HabDebugger, NULLHANDLE, HK_SENDMSG, (PFN)PSendMsgHookProc, HookDLL );
    while( WinQuerySendMsg( HabDebugger, NULLHANDLE, thread->hmq, &qmsg ) ) {
        WinReplyMsg( HabDebugger, NULLHANDLE, thread->hmq, (MRESULT)0 );
    }
    while( WinGetMsg( HabDebugger, &qmsg, 0, 0, 0 ) ) { // handle messages for task
        switch( qmsg.msg ) {
            case WM_PAINT:
                // don't do any painting
                ps = WinBeginPaint( qmsg.hwnd, 0, &rcl );
                WinEndPaint( ps );
                break;
            default:
                // have the default window procedure handle the rest
                WinDefWindowProc( qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2 );
        }
    }
    WinReleaseHook( HabDebugger, NULLHANDLE, HK_SENDMSG, (PFN)PSendMsgHookProc, HookDLL );
    PSetHmqDebugee( thread->hmq, NULLHANDLE );
    WinReleaseHook( HabDebugger, thread->hmq, HK_CALLHOOK, (PFN)CallHookProc, NULLHANDLE );
    WinThreadAssocQueue( HabDebugger, NULLHANDLE );
    WinPostMsg( HwndDebugger, WM_QUIT, 0, 0 ); // tell debugger we're done
}
示例#2
0
文件: kimehook.c 项目: komh/kime
VOID EXPENTRY uninstallHook( VOID )
{
    WinSubclassWindow( hwndKime, oldKimeWndProc );

    WinReleaseHook( hab, NULLHANDLE, HK_INPUT, ( PFN )inputHook, hm );
    WinReleaseHook( hab, NULLHANDLE, HK_ACCEL, ( PFN )accelHook, hm );
    WinReleaseHook( hab, NULLHANDLE, HK_SENDMSG, ( PFN )sendMsgHook, hm );
    WinReleaseHook( hab, NULLHANDLE, HK_DESTROYWINDOW, (PFN)destroyWindowHook, hm );

    WinBroadcastMsg(HWND_DESKTOP, WM_NULL, 0, 0, BMSG_FRAMEONLY | BMSG_POST);

    IM32Term();
}
示例#3
0
/**
 *  DLL entry point.
 *
 *  @param aHandle  DLL module handle.
 *  @param aFlag    0 on initialization or 1 on termination.
 *
 *  @return Non-zero for success or 0 for failure.
 */
ULONG _System _DLL_InitTerm (HMODULE aHandle, ULONG aFlag)
{
    bool ok = true;

    if (aFlag == 0)
    {
        /* DLL initialization */

        gThisModule = aHandle;

        gGIS = GETGINFOSEG();
        gLIS = GETLINFOSEG();
    }
    else
    {
        /* DLL termination */

        /* Make sure we release the hook if the user forgets to do so. */
        if (gKbdHookHwnd != NULLHANDLE)
            WinReleaseHook (gKbdHookHab, NULLHANDLE, HK_PREACCEL,
                            (PFN) vboxInputHook, gThisModule);

        gThisModule = NULLHANDLE;
    }

    return (unsigned long) ok;
}
示例#4
0
 /****************************************************************\
 *  Destroys the help instance
 *--------------------------------------------------------------
 *
 *  Name:   DestroyHelpInstance(VOID)
 *
 *  Purpose: Destroys the help instance for the application
 *
 *  Usage:  Called after exit from message loop
 *
 *  Method: Calls WinDestroyHelpInstance() to destroy the
 *       help instance
 *
 *  Returns:
 *
\****************************************************************/
VOID DestroyHelpInstance(PAGECFG *pstCFG)
  {
  WinReleaseHook(pstCFG->hab,HMQ_CURRENT,HK_HELP,(PFN)pfnMessageBoxHelpHook,0L);
  if(hwndHelpInstance)
    WinDestroyHelpInstance(hwndHelpInstance);
  hwndHelpInstance = 0;
  }
示例#5
0
BOOL EXPENTRY PGPDLLExit(void)
{
    if (Hooked)
    {
        WinReleaseHook(hab, hmqType, HK_SENDMSG, (PFN)PGPHookSendMsg, hRessourceModule);
        WinDeleteAtom(hAtomTblSystem, Global.wmu_FloatToTop);
        Hooked = FALSE;
    }

    return TRUE;
}
示例#6
0
void GUIUnHookF1( void )
{
    if( F1Hooked == 1 ) {
#ifndef __OS2_PM__
        UnhookWindowsHookEx( F1HookHandle );
#else
        WinReleaseHook( GUIMainHInst.hab, HMQ_CURRENT, HK_INPUT,
                        (PFN) F1ProcInst, GUIMainHInst.mod_handle );
#endif
        _wpi_freeprocinstance( F1ProcInst );
    }

    if( F1Hooked != 0 ) {
        F1Hooked--;
    }
}
示例#7
0
/**
 *  Uninstalls the keyboard hook installed by VBoxHlpInstallKbdHook().
 *  All arguments must match arguments passed to VBoxHlpInstallKbdHook(),
 *  otherwise this method will do nothing and return @c false.
 *
 *  @return @c true on success and @c false otherwise.
 */
VBOXHLPDECL(bool) VBoxHlpUninstallKbdHook (HAB aHab, HWND aHwnd,
                                           unsigned long aMsg)
{
    if (gKbdHookHab != aHab ||
        gKbdHookHwnd != aHwnd ||
        gKbdHookMsg != aMsg)
        return false;

    BOOL ok = WinReleaseHook (aHab, NULLHANDLE, HK_PREACCEL,
                              (PFN) vboxInputHook, gThisModule);

    if (ok)
    {
        gKbdHookHab = NULLHANDLE;
        gKbdHookHwnd = NULLHANDLE;
        gKbdHookMsg = 0;
    }

    return (bool) ok;
}
BOOL EXPENTRY HookKill(void)
{
   loaded = FALSE;
   return WinReleaseHook(mainhab, NULLHANDLE, HK_INPUT, (PFN)WinHookProc, hmDll);
}
void main(int argc,char**argv) {
  QMSG qmsg;                            /* Message from message queue   */
  ULONG flCreate;                       /* Window creation control flags*/
  APIRET rc;
  flCreate = FCF_SYSMENU | FCF_SIZEBORDER | FCF_TITLEBAR | FCF_MINMAX
             | FCF_TASKLIST ;
  hab = WinInitialize(0);               /* Initialize PM                */
  hmq = WinCreateMsgQueue( hab, 0 );    /* Create a message queue       */
  SetSpy(0,0,0,0,0);
  rc=DosQueryModuleHandle("TRAPITH",&hModule);
  if (rc) {
      WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
                    "Could not Find DLL",
                    "TRAPIT",
                     1234,
                     MB_OK | MB_ERROR);
  } /* endif */
  WinSetHook( hab, NULLHANDLE, HK_SENDMSG, (PFN)HandleSend, hModule);
  WinRegisterClass(                     /* Register window class        */
     hab,                               /* Anchor block handle          */
     "MyWindow",                        /* Window class name            */
     MyWindowProc,                      /* Address of window procedure  */
     CS_SIZEREDRAW,                     /* No special class style       */
     4                                  /* 1  extra window double word  */
     );
  hwndFrame = WinCreateStdWindow(
               HWND_DESKTOP,            /* Desktop window is parent     */
               0L,                      /* No class style               */
               &flCreate,               /* Frame control flag           */
               "MyWindow",              /* Client window class name     */
               "TRAPIT PM",             /* No window text               */
               0,                       /* No special class style       */
               0,                       /* Resource is in .EXE file     */
               ID_WINDOW,               /* Frame window identifier      */
               &hwndClient              /* Client window handle         */
               );
  if (hwndFrame!=0) {
     ULONG Flags=SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_SHOW;
     if (argc>1) {
        if (stricmp(argv[1],"HIDE")==0) {
           Flags &=~(SWP_ACTIVATE | SWP_SHOW);
        } /* endif */
     } /* endif */
     WinSetWindowPos( hwndFrame,     /* Set the size and position of */
                   HWND_TOP,            /* the window before showing.   */
                   100, 50, 270, 230,
                   Flags
                 );
     /************************************************************************/
     /* Get and dispatch messages from the application message queue         */
     /* until WinGetMsg returns FALSE, indicating a WM_QUIT message.         */
     /************************************************************************/
     while( WinGetMsg( hab, &qmsg, 0, 0, 0 ) )
            WinDispatchMsg( hab, &qmsg );
  }
  WinDestroyWindow( hwndFrame );        /* Tidy up...                   */
  WinDestroyMsgQueue( hmq );            /* and                          */
  WinReleaseHook( hab, NULLHANDLE, HK_SENDMSG, (PFN)HandleSend, hModule);
  WinTerminate( hab );                  /* terminate the application    */
  DosExit(EXIT_PROCESS,0);
}
示例#10
0
文件: kiphook.c 项目: komh/kip
VOID EXPENTRY uninstallHook( VOID )
{
    WinReleaseHook( hab, NULLHANDLE, HK_SENDMSG, ( PFN )sendMsgHook, hm );

    WinBroadcastMsg(HWND_DESKTOP, WM_NULL, 0, 0, BMSG_FRAMEONLY | BMSG_POST);
}