Something like this: (16 bits)
Code: Select all
67 66 9A gg gg 00 00 01 00
CD 66 9A gg gg 00 00 01 00
Code: Select all
3E 67 9A gg gg 00 00 01 00
CD 67 9A gg gg 00 00 01 00
Code: Select all
mov al,instr´
cmp al,90h
je reexecute
;
cmp al,0CDh
je wait_patch
;
cmp al,67h
je lock
;
cmp al,3Eh
je lock
;
goto default GPF handler
lock:
setup alias selector that can modify code-segment
mov al,0CDh
xchg al,instr
cmp al,0CDh
je wait_patch
;
check if instruction that should be patched. Goto patch if true
;
xchg al,instr
goto default GPF handler
patch:
wait until prefetch queue is drained
patch instruction
reexecute
wait_patch:
xor cx,cx
wait_patch_loop:
mov al,instr
cmp al,90h
je reexecute
pause
loop wait_patch_loop
;
goto default GPF handler
int_66:
int_67:
save and setup address (back up EIP two steps)
wait_int:
mov al,instr
cmp al,90h
je wait_done
pause
jmp wait_int
wait_done:
restore
iretd