+VOID CALLBACK FuzzTimerProc(
+ _In_ HWND hwnd,
+ _In_ UINT uMsg,
+ _In_ UINT_PTR idEvent,
+ _In_ DWORD dwTime
+ )
+{
+ INPUT input[16];
+ int i_pos = 0;
+ int c = randomkey();
+ SHORT k = VkKeyScanA(c);
+ BOOL gen_alt = (rn2(50) == 0) && isalpha(c);
+
+ if (!iflags.debug_fuzzer) {
+ KillTimer(hwnd, IDT_FUZZ_TIMER);
+ return;
+ }
+
+ if (!GetFocus())
+ return;
+
+ ZeroMemory(input, sizeof(input));
+ if (gen_alt) {
+ input[i_pos].type = INPUT_KEYBOARD;
+ input[i_pos].ki.dwFlags = KEYEVENTF_SCANCODE;
+ input[i_pos].ki.wScan = MapVirtualKey(VK_MENU, 0);
+ i_pos++;
+ }
+
+ if (HIBYTE(k) & 1) {
+ input[i_pos].type = INPUT_KEYBOARD;
+ input[i_pos].ki.dwFlags = KEYEVENTF_SCANCODE;
+ input[i_pos].ki.wScan = MapVirtualKey(VK_LSHIFT, 0);
+ i_pos++;
+ }
+
+ input[i_pos].type = INPUT_KEYBOARD;
+ input[i_pos].ki.dwFlags = KEYEVENTF_SCANCODE;
+ input[i_pos].ki.wScan = MapVirtualKey(LOBYTE(k), 0);
+ i_pos++;
+
+ if (HIBYTE(k) & 1) {
+ input[i_pos].type = INPUT_KEYBOARD;
+ input[i_pos].ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
+ input[i_pos].ki.wScan = MapVirtualKey(VK_LSHIFT, 0);
+ i_pos++;
+ }
+ if (gen_alt) {
+ input[i_pos].type = INPUT_KEYBOARD;
+ input[i_pos].ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
+ input[i_pos].ki.wScan = MapVirtualKey(VK_MENU, 0);
+ i_pos++;
+ }
+ SendInput(i_pos, input, sizeof(input[0]));
+}
+