MCPcopy Index your code
hub / github.com/NetHack/NetHack / FuzzTimerProc

Function FuzzTimerProc

win/win32/mhmain.c:764–817  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

762 _In_ DWORD dwTime);
763
764VOID CALLBACK FuzzTimerProc(
765 _In_ HWND hwnd,
766 _In_ UINT uMsg UNUSED,
767 _In_ UINT_PTR idEvent UNUSED,
768 _In_ DWORD dwTime UNUSED)
769{
770 INPUT input[16];
771 int i_pos = 0;
772 int c = randomkey();
773 SHORT k = VkKeyScanA(c);
774 BOOL gen_alt = (rn2(50) == 0) && isalpha(c);
775
776 if (!iflags.debug_fuzzer) {
777 KillTimer(hwnd, IDT_FUZZ_TIMER);
778 return;
779 }
780
781 if (!GetFocus())
782 return;
783
784 ZeroMemory(input, sizeof(input));
785 if (gen_alt) {
786 input[i_pos].type = INPUT_KEYBOARD;
787 input[i_pos].ki.dwFlags = KEYEVENTF_SCANCODE;
788 input[i_pos].ki.wScan = MapVirtualKey(VK_MENU, 0);
789 i_pos++;
790 }
791
792 if (HIBYTE(k) & 1) {
793 input[i_pos].type = INPUT_KEYBOARD;
794 input[i_pos].ki.dwFlags = KEYEVENTF_SCANCODE;
795 input[i_pos].ki.wScan = MapVirtualKey(VK_LSHIFT, 0);
796 i_pos++;
797 }
798
799 input[i_pos].type = INPUT_KEYBOARD;
800 input[i_pos].ki.dwFlags = KEYEVENTF_SCANCODE;
801 input[i_pos].ki.wScan = MapVirtualKey(LOBYTE(k), 0);
802 i_pos++;
803
804 if (HIBYTE(k) & 1) {
805 input[i_pos].type = INPUT_KEYBOARD;
806 input[i_pos].ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
807 input[i_pos].ki.wScan = MapVirtualKey(VK_LSHIFT, 0);
808 i_pos++;
809 }
810 if (gen_alt) {
811 input[i_pos].type = INPUT_KEYBOARD;
812 input[i_pos].ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
813 input[i_pos].ki.wScan = MapVirtualKey(VK_MENU, 0);
814 i_pos++;
815 }
816 SendInput(i_pos, input, sizeof(input[0]));
817}
818
819LRESULT
820onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)

Callers

nothing calls this directly

Calls 2

randomkeyFunction · 0.85
rn2Function · 0.85

Tested by

no test coverage detected