I am trying to replace a keyboard key press with other key. The terminal crashes as soon as I type 'A'. How do I replace the key press in write syscall.
unsigned long hacked_write_test( struct pt_regs *regs ) {
int r, i;
unsigned int fd = regs->di;
char *buf = (char*) regs->si;
if (fd == 1 || fd == 3 || fd == 4) {
if (buf[0] == 0x61) {
printk("in write: A received");
regs->si = 0x62;
}
}
r = original_write(regs);
return r;
}