Returning to execution after handling invalid instruction
Posted: Tue Jun 03, 2014 5:59 pm
Ok. Here is the thing. I am working on a Windows driver that is designed
to emulate Pentium (+MMX?) on 486 class CPUs to allow you to run newer software
I successfully was able to catch the illegal instructions, but cannot figure out how to return to normal execution
Keeping it simple, I am trying to just skip the "cpuid" instruction. But the program either crashes or the whole OS BSoDs
Anybody help please?
to emulate Pentium (+MMX?) on 486 class CPUs to allow you to run newer software
I successfully was able to catch the illegal instructions, but cannot figure out how to return to normal execution
Code: Select all
__declspec(naked) void illegal_operand_handler (void) {
__asm{
push ebp
mov ebp, esp
pushad
pushfd
push ds
mov ds, ax
mov esi, [ebp+4]
cld
lods byte ptr [esi]
cmp al, 0xf
je handle_0xf
GoPrevTrap01:
pop ds
popfd
popad
pop ebp
jmp dword ptr [prevIllegalOpHandler]
handle_0xf:
lods byte ptr [esi] //Find out what the faulting instruction is
cmp al, 0xA2
jne not_cpuid
add dword ptr [ebp+3], 4
pop ds
popfd
popad
pop ebp
iretd
not_cpuid:
jmp short GoPrevTrap01
};
}
Anybody help please?