Mitmgate v0.0.0+dev.3
Man in the Middle Keylogger and Injector
Loading...
Searching...
No Matches
usb_keyboard.h File Reference

Interface for USB Keyboard HID operations. More...

#include "../typedef.h"

Go to the source code of this file.

Classes

struct  hid_keyboard_packet
 The standard 8-byte packet used by USB Keyboards (Boot Protocol). More...

Enumerations

enum  usb_status { USB_OK = 0 , USB_ERROR_NO_DEVICE = -1 , USB_ERROR_READ_FAIL = -2 , USB_END_OF_STREAM = -3 }
 Status codes for USB keyboard operations. More...

Functions

int usb_keyboard_init (void)
 Initializes the keyboard subsystem.
int usb_keyboard_read_packet (hid_keyboard_packet *out_packet)
 Reads a single HID packet from the input stream.
void usb_keyboard_cleanup (void)
 Cleans up resources and disconnects the keyboard subsystem.

Detailed Description

Interface for USB Keyboard HID operations.

Defines the standard HID structures and function prototypes for initializing, reading from, and cleaning up a virtual or physical USB keyboard interface.

Enumeration Type Documentation

◆ usb_status

enum usb_status

Status codes for USB keyboard operations.

Enumerator
USB_OK 

Operation successful

USB_ERROR_NO_DEVICE 

Device not found or failed to open

USB_ERROR_READ_FAIL 

Failed to read packet data

USB_END_OF_STREAM 

No more data available (End of Simulation)

Function Documentation

◆ usb_keyboard_cleanup()

void usb_keyboard_cleanup ( void )

Cleans up resources and disconnects the keyboard subsystem.

Cleans up resources and disconnects the keyboard subsystem.

◆ usb_keyboard_init()

int usb_keyboard_init ( void )

Initializes the keyboard subsystem.

Returns
int 0 (USB_OK) on success, negative error code on failure.

Initializes the keyboard subsystem.

Resets the mock data index to the beginning.

Returns
int Always returns USB_OK.

◆ usb_keyboard_read_packet()

int usb_keyboard_read_packet ( hid_keyboard_packet * out_packet)

Reads a single HID packet from the input stream.

Parameters
out_packetPointer to the structure where the packet data will be written.
Returns
int 0 (USB_OK) on success, or error code.

Reads a single HID packet from the input stream.

Simulates a USB polling delay using Sleep(100).

Parameters
out_packetDestination for the key data.
Returns
int USB_OK on success, USB_END_OF_STREAM when data is exhausted.