User exception handler in C (Developers)
Thanks, it led me to this example:
http://www.delorie.com/djgpp/doc/libc/libc_641.html
It seems DJGPP have good tools for exception handling.
CPU context is probably saved automatically in __djgpp_exception_state structure from where I can check the opcode caused exception, read an manipulate registers and also skip "bad" opcode and resume program execution by longjmp(__djgpp_exception_state, 0);
I'm not sure what all functions I can call from the handler, I would need just printf.
I would also need to implement this mechanism in my windows kernel driver because it's anoying to let exception BSOD and restart whole computer. I don't know if kernel winapi have support of similar function to hook exception handler or would I have to do it in assembler.
Also I'm thinking about an idea of using exception handler to emulate missing CMOV instruction on some CPUs that caused lot of problems as many libs and programs are compiled with CMOV (without recompiling all code). But the problem is that every program replaces/installs it's own default exception handler. It would need to make some TSR that will monitor that exception vector has changed and it would hook it again to be the 1st handler to be executed to properly emulate CMOV. Or could me make as a patch for DJGPP binaries that will find default exception handler code and inject CMOV handling code there but it would need extra space for additional code in binary, more uneversal and cleaner would be the TSR way...
---
DOS gives me freedom to unlimited HW access.
Complete thread:
- User exception handler in C - RayeR, 24.07.2020, 13:15 (Developers)
- User exception handler in C - Japheth, 24.07.2020, 18:07
- User exception handler in C - Rugxulo, 24.07.2020, 18:39
- User exception handler in C - tkchia, 24.07.2020, 20:47
- User exception handler in C - RayeR, 30.07.2020, 13:18
- User exception handler in C - tom, 30.07.2020, 23:54
- User exception handler in C - RayeR, 01.08.2020, 02:13
- User exception handler in C - Laaca, 16.08.2020, 21:27
- User exception handler in C - Laaca, 16.08.2020, 22:38
- User exception handler in C - Rugxulo, 17.08.2020, 22:35
- User exception handler in C - marcov, 18.08.2020, 12:23
- User exception handler in C - Laaca, 18.08.2020, 20:15
- User exception handler in C - Rugxulo, 19.08.2020, 19:44
- User exception handler in C - Laaca, 19.08.2020, 21:50
- User exception handler in C - Rugxulo, 23.08.2020, 17:32
- User exception handler in C - Japheth, 23.08.2020, 20:36
- User exception handler in C - Rugxulo, 23.08.2020, 17:32
- User exception handler in C - Laaca, 19.08.2020, 21:50
- User exception handler in C - Rugxulo, 19.08.2020, 19:44
- User exception handler in C - Laaca, 18.08.2020, 20:15
- User exception handler in C - marcov, 18.08.2020, 12:23
- User exception handler in C - Rugxulo, 17.08.2020, 22:35
- User exception handler in C - Rugxulo, 17.08.2020, 22:26
- User exception handler in C - tkchia, 19.08.2020, 18:52
- User exception handler in C - marcov, 20.08.2020, 00:00
- User exception handler in C - Laaca, 20.08.2020, 15:31
- User exception handler in C - marcov, 20.08.2020, 00:00
- User exception handler in C - Laaca, 16.08.2020, 22:38
- User exception handler in C - Laaca, 16.08.2020, 21:27
- User exception handler in C - RayeR, 01.08.2020, 02:13
- User exception handler in C - tkchia, 31.07.2020, 19:36
- User exception handler in C - RayeR, 01.08.2020, 02:16
- User exception handler in C - tom, 30.07.2020, 23:54
- User exception handler in C - RayeR, 30.07.2020, 13:18
- User exception handler in C - Guti, 27.07.2020, 08:22