@@ -43,18 +43,18 @@ UINT gfsModOnlyCandidate;
4343#define IsWindowHotKey (pHK ) ( (pHK)->pti == NULL && (pHK)->id == IDHK_WNDKEY )
4444
4545VOID FASTCALL
46- StartDebugHotKeys (VOID )
46+ SetDebugHotKeys (VOID )
4747{
4848 UINT vk = VK_F12 ;
49- UserUnregisterHotKey (PWND_BOTTOM , IDHK_F12 );
50- UserUnregisterHotKey (PWND_BOTTOM , IDHK_SHIFTF12 );
5149 if (!ENHANCED_KEYBOARD (gKeyboardInfo .KeyboardIdentifier ))
52- {
5350 vk = VK_SUBTRACT ;
54- }
51+
52+ UserUnregisterHotKey (PWND_BOTTOM , IDHK_F12 );
53+ UserUnregisterHotKey (PWND_BOTTOM , IDHK_SHIFTF12 );
5554 UserRegisterHotKey (PWND_BOTTOM , IDHK_SHIFTF12 , MOD_SHIFT , vk );
5655 UserRegisterHotKey (PWND_BOTTOM , IDHK_F12 , 0 , vk );
57- TRACE ("Start up the debugger hotkeys!! If you see this you enabled debugprints. Congrats!\n" );
56+
57+ TRACE ("Debugger hotkeys set up! If you see this you enabled Debug Prints. Congrats!\n" );
5858}
5959
6060/*
@@ -456,25 +456,29 @@ UserRegisterHotKey(PWND pWnd,
456456 PHOT_KEY pHotKey ;
457457 PTHREADINFO pHotKeyThread ;
458458
459- /* Find hotkey thread */
459+ /* Find the hotkey thread */
460460 if (pWnd == NULL || pWnd == PWND_BOTTOM )
461461 {
462- pHotKeyThread = PsGetCurrentThreadWin32Thread ();
462+ pHotKeyThread = PsGetCurrentThreadWin32Thread (); // gptiCurrent;
463463 }
464464 else
465465 {
466466 pHotKeyThread = pWnd -> head .pti ;
467467 }
468468
469- /* Check for existing hotkey */
469+ /* Ignore the VK_PACKET key since it is not a real keyboard input */
470+ if (vk == VK_PACKET )
471+ return FALSE;
472+
473+ /* Check whether we modify an existing hotkey */
470474 if (IsHotKey (fsModifiers , vk ))
471475 {
472476 EngSetLastError (ERROR_HOTKEY_ALREADY_REGISTERED );
473477 WARN ("Hotkey already exists\n" );
474478 return FALSE;
475479 }
476480
477- /* Create new hotkey */
481+ /* Create a new hotkey */
478482 pHotKey = ExAllocatePoolWithTag (PagedPool , sizeof (HOT_KEY ), USERTAG_HOTKEY );
479483 if (pHotKey == NULL )
480484 {
@@ -488,7 +492,7 @@ UserRegisterHotKey(PWND pWnd,
488492 pHotKey -> vk = vk ;
489493 pHotKey -> id = id ;
490494
491- /* Insert hotkey to the global list */
495+ /* Insert the hotkey into the global list */
492496 pHotKey -> pNext = gphkFirst ;
493497 gphkFirst = pHotKey ;
494498
@@ -515,132 +519,85 @@ UserUnregisterHotKey(PWND pWnd, int id)
515519
516520 bRet = TRUE;
517521 }
518- else /* This hotkey will stay, use its next ptr */
522+ else
523+ {
524+ /* This hotkey will stay, use its next ptr */
519525 pLink = & pHotKey -> pNext ;
526+ }
520527
521528 /* Move to the next entry */
522529 pHotKey = phkNext ;
523530 }
531+
524532 return bRet ;
525533}
526534
527535
528536/* SYSCALLS *****************************************************************/
529537
530-
531538BOOL APIENTRY
532539NtUserRegisterHotKey (HWND hWnd ,
533540 int id ,
534541 UINT fsModifiers ,
535542 UINT vk )
536543{
537- PHOT_KEY pHotKey ;
538544 PWND pWnd = NULL ;
539- PTHREADINFO pHotKeyThread ;
540545 BOOL bRet = FALSE;
541546
542547 TRACE ("Enter NtUserRegisterHotKey\n" );
543548
544- if (fsModifiers & ~(MOD_ALT |MOD_CONTROL |MOD_SHIFT |MOD_WIN )) // FIXME: Does Win2k3 support MOD_NOREPEAT?
549+ // FIXME: Does Win2k3 support MOD_NOREPEAT?
550+ if (fsModifiers & ~(MOD_ALT | MOD_CONTROL | MOD_SHIFT | MOD_WIN ))
545551 {
546552 WARN ("Invalid modifiers: %x\n" , fsModifiers );
547553 EngSetLastError (ERROR_INVALID_FLAGS );
548- return 0 ;
554+ return FALSE ;
549555 }
550556
551557 UserEnterExclusive ();
552558
553- /* Find hotkey thread */
559+ /* Check the hotkey thread */
554560 if (hWnd == NULL )
555561 {
556- pHotKeyThread = gptiCurrent ;
562+ pWnd = NULL ;
557563 }
558564 else
559565 {
560566 pWnd = UserGetWindowObject (hWnd );
561567 if (!pWnd )
562568 goto cleanup ;
563569
564- pHotKeyThread = pWnd -> head .pti ;
565-
566- /* Fix wine msg "Window on another thread" test_hotkey */
570+ /* FIXME?? "Fix" wine msg "Window on another thread" test_hotkey */
567571 if (pWnd -> head .pti != gptiCurrent )
568572 {
569- EngSetLastError (ERROR_WINDOW_OF_OTHER_THREAD );
570- WARN ("Must be from the same Thread.\n" );
571- goto cleanup ;
573+ EngSetLastError (ERROR_WINDOW_OF_OTHER_THREAD );
574+ WARN ("Must be from the same Thread.\n" );
575+ goto cleanup ;
572576 }
573577 }
574578
575- /* Check for existing hotkey */
576- if (IsHotKey (fsModifiers , vk ))
577- {
578- EngSetLastError (ERROR_HOTKEY_ALREADY_REGISTERED );
579- WARN ("Hotkey already exists\n" );
580- goto cleanup ;
581- }
582-
583- /* Create new hotkey */
584- pHotKey = ExAllocatePoolWithTag (PagedPool , sizeof (HOT_KEY ), USERTAG_HOTKEY );
585- if (pHotKey == NULL )
586- {
587- EngSetLastError (ERROR_NOT_ENOUGH_MEMORY );
588- goto cleanup ;
589- }
590-
591- pHotKey -> pti = pHotKeyThread ;
592- pHotKey -> pWnd = pWnd ;
593- pHotKey -> fsModifiers = fsModifiers ;
594- pHotKey -> vk = vk ;
595- pHotKey -> id = id ;
596-
597- /* Insert hotkey to the global list */
598- pHotKey -> pNext = gphkFirst ;
599- gphkFirst = pHotKey ;
600-
601- bRet = TRUE;
579+ bRet = UserRegisterHotKey (pWnd , id , fsModifiers , vk );
602580
603581cleanup :
604582 TRACE ("Leave NtUserRegisterHotKey, ret=%i\n" , bRet );
605583 UserLeave ();
606584 return bRet ;
607585}
608586
609-
610587BOOL APIENTRY
611588NtUserUnregisterHotKey (HWND hWnd , int id )
612589{
613- PHOT_KEY pHotKey = gphkFirst , phkNext , * pLink = & gphkFirst ;
614590 BOOL bRet = FALSE;
615591 PWND pWnd = NULL ;
616592
617593 TRACE ("Enter NtUserUnregisterHotKey\n" );
618594 UserEnterExclusive ();
619595
620- /* Fail if given window is invalid */
596+ /* Fail if the given window is invalid */
621597 if (hWnd && !(pWnd = UserGetWindowObject (hWnd )))
622598 goto cleanup ;
623599
624- while (pHotKey )
625- {
626- /* Save next ptr for later use */
627- phkNext = pHotKey -> pNext ;
628-
629- /* Should we delete this hotkey? */
630- if (pHotKey -> pWnd == pWnd && pHotKey -> id == id )
631- {
632- /* Update next ptr for previous hotkey and free memory */
633- * pLink = phkNext ;
634- ExFreePoolWithTag (pHotKey , USERTAG_HOTKEY );
635-
636- bRet = TRUE;
637- }
638- else /* This hotkey will stay, use its next ptr */
639- pLink = & pHotKey -> pNext ;
640-
641- /* Move to the next entry */
642- pHotKey = phkNext ;
643- }
600+ bRet = UserUnregisterHotKey (pWnd , id );
644601
645602cleanup :
646603 TRACE ("Leave NtUserUnregisterHotKey, ret=%i\n" , bRet );
0 commit comments