2 * Emulation of privileged instructions
4 * Copyright 1995 Alexandre Julliard
5 * Copyright 2005 Ivan Leo Puoti
6 * Copyright 2005 Laurent Pinchart
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/port.h"
31 #include "wine/winuser16.h"
34 #include "wine/debug.h"
35 #include "kernel_private.h"
36 #include "kernel16_private.h"
37 #include "wine/exception.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(int);
40 WINE_DECLARE_DEBUG_CHANNEL(io);
42 /* macros to set parts of a DWORD */
43 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
44 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
45 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
46 #define ISV86(context) ((context)->EFlags & 0x00020000)
48 static inline void add_stack( CONTEXT86 *context, int offset )
50 if (ISV86(context) || !IS_SELECTOR_32BIT(context->SegSs))
51 ADD_LOWORD( context->Esp, offset );
53 context->Esp += offset;
56 static inline void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long_addr )
58 if (ISV86(context)) return (void *)((seg << 4) + LOWORD(off));
59 if (wine_ldt_is_system(seg)) return (void *)off;
60 if (!long_addr) off = LOWORD(off);
61 return (char *) MapSL( MAKESEGPTR( seg, 0 ) ) + off;
64 static inline void *get_stack( CONTEXT86 *context )
66 if (ISV86(context)) return (void *)((context->SegSs << 4) + LOWORD(context->Esp));
67 return wine_ldt_get_ptr( context->SegSs, context->Esp );
78 static LDT_ENTRY idt[256];
80 static inline struct idtr get_idtr(void)
83 #if defined(__i386__) && defined(__GNUC__)
84 __asm__( "sidtl %0" : "=m" (ret) );
86 ret.base = (BYTE *)idt;
87 ret.limit = sizeof(idt) - 1;
93 /***********************************************************************
94 * INSTR_ReplaceSelector
96 * Try to replace an invalid selector by a valid one.
97 * The only selector where it is allowed to do "mov ax,40;mov es,ax"
98 * is the so called 'bimodal' selector 0x40, which points to the BIOS
99 * data segment. Used by (at least) Borland products (and programs compiled
100 * using Borland products).
102 * See Undocumented Windows, Chapter 5, __0040.
104 static BOOL INSTR_ReplaceSelector( CONTEXT86 *context, WORD *sel )
108 static WORD sys_timer = 0;
111 if (!winedos.BiosTick) load_winedos();
112 if (winedos.BiosTick)
113 sys_timer = CreateSystemTimer( 55, winedos.BiosTick );
115 *sel = DOSMEM_BiosDataSeg;
118 return FALSE; /* Can't replace selector, crashdump */
122 /* store an operand into a register */
123 static void store_reg( CONTEXT86 *context, BYTE regmodrm, const BYTE *addr, int long_op )
125 switch((regmodrm >> 3) & 7)
128 if (long_op) context->Eax = *(const DWORD *)addr;
129 else SET_LOWORD(context->Eax, *(const WORD *)addr);
132 if (long_op) context->Ecx = *(const DWORD *)addr;
133 else SET_LOWORD(context->Ecx, *(const WORD *)addr);
136 if (long_op) context->Edx = *(const DWORD *)addr;
137 else SET_LOWORD(context->Edx, *(const WORD *)addr);
140 if (long_op) context->Ebx = *(const DWORD *)addr;
141 else SET_LOWORD(context->Ebx, *(const WORD *)addr);
144 if (long_op) context->Esp = *(const DWORD *)addr;
145 else SET_LOWORD(context->Esp, *(const WORD *)addr);
148 if (long_op) context->Ebp = *(const DWORD *)addr;
149 else SET_LOWORD(context->Ebp, *(const WORD *)addr);
152 if (long_op) context->Esi = *(const DWORD *)addr;
153 else SET_LOWORD(context->Esi, *(const WORD *)addr);
156 if (long_op) context->Edi = *(const DWORD *)addr;
157 else SET_LOWORD(context->Edi, *(const WORD *)addr);
162 /***********************************************************************
163 * INSTR_GetOperandAddr
165 * Return the address of an instruction operand (from the mod/rm byte).
167 static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
168 int long_addr, int segprefix, int *len )
170 int mod, rm, base = 0, index = 0, ss = 0, seg = 0, off;
173 #define GET_VAL(val,type) \
174 { *val = *(type *)instr; instr += sizeof(type); *len += sizeof(type); }
177 GET_VAL( &mod, BYTE );
185 case 0: return (BYTE *)&context->Eax;
186 case 1: return (BYTE *)&context->Ecx;
187 case 2: return (BYTE *)&context->Edx;
188 case 3: return (BYTE *)&context->Ebx;
189 case 4: return (BYTE *)&context->Esp;
190 case 5: return (BYTE *)&context->Ebp;
191 case 6: return (BYTE *)&context->Esi;
192 case 7: return (BYTE *)&context->Edi;
201 GET_VAL( &sib, BYTE );
206 case 0: index = context->Eax; break;
207 case 1: index = context->Ecx; break;
208 case 2: index = context->Edx; break;
209 case 3: index = context->Ebx; break;
210 case 4: index = 0; break;
211 case 5: index = context->Ebp; break;
212 case 6: index = context->Esi; break;
213 case 7: index = context->Edi; break;
219 case 0: base = context->Eax; seg = context->SegDs; break;
220 case 1: base = context->Ecx; seg = context->SegDs; break;
221 case 2: base = context->Edx; seg = context->SegDs; break;
222 case 3: base = context->Ebx; seg = context->SegDs; break;
223 case 4: base = context->Esp; seg = context->SegSs; break;
224 case 5: base = context->Ebp; seg = context->SegSs; break;
225 case 6: base = context->Esi; seg = context->SegDs; break;
226 case 7: base = context->Edi; seg = context->SegDs; break;
231 if (rm == 5) /* special case: ds:(disp32) */
233 GET_VAL( &base, DWORD );
234 seg = context->SegDs;
238 case 1: /* 8-bit disp */
239 GET_VAL( &off, BYTE );
240 base += (signed char)off;
243 case 2: /* 32-bit disp */
244 GET_VAL( &off, DWORD );
245 base += (signed long)off;
249 else /* short address */
253 case 0: /* ds:(bx,si) */
254 base = LOWORD(context->Ebx) + LOWORD(context->Esi);
255 seg = context->SegDs;
257 case 1: /* ds:(bx,di) */
258 base = LOWORD(context->Ebx) + LOWORD(context->Edi);
259 seg = context->SegDs;
261 case 2: /* ss:(bp,si) */
262 base = LOWORD(context->Ebp) + LOWORD(context->Esi);
263 seg = context->SegSs;
265 case 3: /* ss:(bp,di) */
266 base = LOWORD(context->Ebp) + LOWORD(context->Edi);
267 seg = context->SegSs;
269 case 4: /* ds:(si) */
270 base = LOWORD(context->Esi);
271 seg = context->SegDs;
273 case 5: /* ds:(di) */
274 base = LOWORD(context->Edi);
275 seg = context->SegDs;
277 case 6: /* ss:(bp) */
278 base = LOWORD(context->Ebp);
279 seg = context->SegSs;
281 case 7: /* ds:(bx) */
282 base = LOWORD(context->Ebx);
283 seg = context->SegDs;
290 if (rm == 6) /* special case: ds:(disp16) */
292 GET_VAL( &base, WORD );
293 seg = context->SegDs;
297 case 1: /* 8-bit disp */
298 GET_VAL( &off, BYTE );
299 base += (signed char)off;
302 case 2: /* 16-bit disp */
303 GET_VAL( &off, WORD );
304 base += (signed short)off;
309 if (segprefix != -1) seg = segprefix;
311 /* Make sure the segment and offset are valid */
312 if (wine_ldt_is_system(seg)) return (BYTE *)(base + (index << ss));
313 if ((seg & 7) != 7) return NULL;
314 wine_ldt_get_entry( seg, &entry );
315 if (wine_ldt_is_empty( &entry )) return NULL;
316 if (wine_ldt_get_limit(&entry) < (base + (index << ss))) return NULL;
317 return (BYTE *)wine_ldt_get_base(&entry) + base + (index << ss);
322 /***********************************************************************
325 * Emulate the LDS (and LES,LFS,etc.) instruction.
327 static BOOL INSTR_EmulateLDS( CONTEXT86 *context, BYTE *instr, int long_op,
328 int long_addr, int segprefix, int *len )
331 BYTE *regmodrm = instr + 1 + (*instr == 0x0f);
332 BYTE *addr = INSTR_GetOperandAddr( context, regmodrm,
333 long_addr, segprefix, len );
335 return FALSE; /* Unable to emulate it */
336 seg = *(WORD *)(addr + (long_op ? 4 : 2));
338 if (!INSTR_ReplaceSelector( context, &seg ))
339 return FALSE; /* Unable to emulate it */
341 /* Now store the offset in the correct register */
343 store_reg( context, *regmodrm, addr, long_op );
345 /* Store the correct segment in the segment register */
349 case 0xc4: context->SegEs = seg; break; /* les */
350 case 0xc5: context->SegDs = seg; break; /* lds */
351 case 0x0f: switch(instr[1])
353 case 0xb2: context->SegSs = seg; break; /* lss */
354 case 0xb4: context->SegFs = seg; break; /* lfs */
355 case 0xb5: context->SegGs = seg; break; /* lgs */
360 /* Add the opcode size to the total length */
362 *len += 1 + (*instr == 0x0f);
366 /***********************************************************************
369 * input on an I/O port
371 static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context )
375 if (!winedos.inport) load_winedos();
376 if (winedos.inport) res = winedos.inport( port, size );
383 TRACE_(io)( "0x%x < %02x @ %04x:%04x\n", port, LOBYTE(res),
384 (WORD)context->SegCs, LOWORD(context->Eip));
387 TRACE_(io)( "0x%x < %04x @ %04x:%04x\n", port, LOWORD(res),
388 (WORD)context->SegCs, LOWORD(context->Eip));
391 TRACE_(io)( "0x%x < %08x @ %04x:%04x\n", port, res,
392 (WORD)context->SegCs, LOWORD(context->Eip));
400 /***********************************************************************
403 * output on an I/O port
405 static void INSTR_outport( WORD port, int size, DWORD val, CONTEXT86 *context )
407 if (!winedos.outport) load_winedos();
408 if (winedos.outport) winedos.outport( port, size, val );
415 TRACE_(io)("0x%x > %02x @ %04x:%04x\n", port, LOBYTE(val),
416 (WORD)context->SegCs, LOWORD(context->Eip));
419 TRACE_(io)("0x%x > %04x @ %04x:%04x\n", port, LOWORD(val),
420 (WORD)context->SegCs, LOWORD(context->Eip));
423 TRACE_(io)("0x%x > %08x @ %04x:%04x\n", port, val,
424 (WORD)context->SegCs, LOWORD(context->Eip));
431 /***********************************************************************
432 * INSTR_EmulateInstruction
434 * Emulate a privileged instruction.
435 * Returns exception continuation status.
437 DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context )
439 int prefix, segprefix, prefixlen, len, repX, long_op, long_addr;
442 long_op = long_addr = (!ISV86(context) && IS_SELECTOR_32BIT(context->SegCs));
443 instr = make_ptr( context, context->SegCs, context->Eip, TRUE );
444 if (!instr) return ExceptionContinueSearch;
446 /* First handle any possible prefix */
448 segprefix = -1; /* no prefix */
457 segprefix = context->SegCs;
460 segprefix = context->SegSs;
463 segprefix = context->SegDs;
466 segprefix = context->SegEs;
469 segprefix = context->SegFs;
472 segprefix = context->SegGs;
475 long_op = !long_op; /* opcode size prefix */
478 long_addr = !long_addr; /* addr size prefix */
480 case 0xf0: /* lock */
482 case 0xf2: /* repne */
485 case 0xf3: /* repe */
489 prefix = 0; /* no more prefixes */
499 /* Now look at the actual instruction */
503 case 0x07: /* pop es */
504 case 0x17: /* pop ss */
505 case 0x1f: /* pop ds */
507 WORD seg = *(WORD *)get_stack( context );
508 if (INSTR_ReplaceSelector( context, &seg ))
512 case 0x07: context->SegEs = seg; break;
513 case 0x17: context->SegSs = seg; break;
514 case 0x1f: context->SegDs = seg; break;
516 add_stack(context, long_op ? 4 : 2);
517 context->Eip += prefixlen + 1;
518 return ExceptionContinueExecution;
521 break; /* Unable to emulate it */
523 case 0x0f: /* extended instruction */
526 case 0x22: /* mov eax, crX */
530 ERR("mov eax,cr0 at 0x%08x, EAX=0x%08x\n",
531 context->Eip,context->Eax );
532 context->Eip += prefixlen+3;
533 return ExceptionContinueExecution;
535 break; /*fallthrough to bad instruction handling */
537 break; /*fallthrough to bad instruction handling */
538 case 0x20: /* mov crX, eax */
541 case 0xe0: /* mov cr4, eax */
542 /* CR4 register . See linux/arch/i386/mm/init.c, X86_CR4_ defs
543 * bit 0: VME Virtual Mode Exception ?
544 * bit 1: PVI Protected mode Virtual Interrupt
545 * bit 2: TSD Timestamp disable
546 * bit 3: DE Debugging extensions
547 * bit 4: PSE Page size extensions
548 * bit 5: PAE Physical address extension
549 * bit 6: MCE Machine check enable
550 * bit 7: PGE Enable global pages
551 * bit 8: PCE Enable performance counters at IPL3
553 ERR("mov cr4,eax at 0x%08x\n",context->Eip);
555 context->Eip += prefixlen+3;
556 return ExceptionContinueExecution;
557 case 0xc0: /* mov cr0, eax */
558 ERR("mov cr0,eax at 0x%08x\n",context->Eip);
559 context->Eax = 0x10; /* FIXME: set more bits ? */
560 context->Eip += prefixlen+3;
561 return ExceptionContinueExecution;
562 default: /* fallthrough to illegal instruction */
565 /* fallthrough to illegal instruction */
567 case 0x21: /* mov drX, eax */
570 case 0xc8: /* mov dr1, eax */
571 TRACE("mov dr1,eax at 0x%08x\n",context->Eip);
572 context->Eax = context->Dr1;
573 context->Eip += prefixlen+3;
574 return ExceptionContinueExecution;
575 case 0xf8: /* mov dr7, eax */
576 TRACE("mov dr7,eax at 0x%08x\n",context->Eip);
577 context->Eax = 0x400;
578 context->Eip += prefixlen+3;
579 return ExceptionContinueExecution;
581 ERR("Unsupported DR register, eip+2 is %02x\n", instr[2]);
582 /* fallthrough to illegal instruction */
584 case 0x23: /* mov eax drX */
587 case 0xc8: /* mov eax, dr1 */
588 context->Dr1 = context->Eax;
589 context->Eip += prefixlen+3;
590 return ExceptionContinueExecution;
592 ERR("Unsupported DR register, eip+2 is %02x\n", instr[2]);
593 /* fallthrough to illegal instruction */
595 case 0xa1: /* pop fs */
597 WORD seg = *(WORD *)get_stack( context );
598 if (INSTR_ReplaceSelector( context, &seg ))
600 context->SegFs = seg;
601 add_stack(context, long_op ? 4 : 2);
602 context->Eip += prefixlen + 2;
603 return ExceptionContinueExecution;
607 case 0xa9: /* pop gs */
609 WORD seg = *(WORD *)get_stack( context );
610 if (INSTR_ReplaceSelector( context, &seg ))
612 context->SegGs = seg;
613 add_stack(context, long_op ? 4 : 2);
614 context->Eip += prefixlen + 2;
615 return ExceptionContinueExecution;
619 case 0xb2: /* lss addr,reg */
620 case 0xb4: /* lfs addr,reg */
621 case 0xb5: /* lgs addr,reg */
622 if (INSTR_EmulateLDS( context, instr, long_op,
623 long_addr, segprefix, &len ))
625 context->Eip += prefixlen + len;
626 return ExceptionContinueExecution;
630 break; /* Unable to emulate it */
632 case 0x6c: /* insb */
633 case 0x6d: /* insw/d */
634 case 0x6e: /* outsb */
635 case 0x6f: /* outsw/d */
637 int typ = *instr; /* Just in case it's overwritten. */
638 int outp = (typ >= 0x6e);
639 unsigned long count = repX ?
640 (long_addr ? context->Ecx : LOWORD(context->Ecx)) : 1;
641 int opsize = (typ & 1) ? (long_op ? 4 : 2) : 1;
642 int step = (context->EFlags & 0x400) ? -opsize : +opsize;
643 int seg = outp ? context->SegDs : context->SegEs; /* FIXME: is this right? */
646 /* FIXME: Check segment is readable. */
649 /* FIXME: Check segment is writable. */
654 if (long_addr) context->Ecx = 0;
655 else SET_LOWORD(context->Ecx,0);
661 WORD dx = LOWORD(context->Edx);
664 data = make_ptr( context, seg, context->Esi, long_addr );
665 if (long_addr) context->Esi += step;
666 else ADD_LOWORD(context->Esi,step);
670 data = make_ptr( context, seg, context->Edi, long_addr );
671 if (long_addr) context->Edi += step;
672 else ADD_LOWORD(context->Edi,step);
678 *(BYTE *)data = INSTR_inport( dx, 1, context );
682 *(DWORD *)data = INSTR_inport( dx, 4, context );
684 *(WORD *)data = INSTR_inport( dx, 2, context );
687 INSTR_outport( dx, 1, *(BYTE *)data, context );
691 INSTR_outport( dx, 4, *(DWORD *)data, context );
693 INSTR_outport( dx, 2, *(WORD *)data, context );
697 context->Eip += prefixlen + 1;
699 return ExceptionContinueExecution;
701 case 0x8b: /* mov Ev, Gv */
703 BYTE *addr = INSTR_GetOperandAddr(context, instr + 1, long_addr,
705 struct idtr idtr = get_idtr();
706 unsigned int offset = addr - idtr.base;
708 if (offset <= idtr.limit + 1 - (long_op ? 4 : 2))
710 idt[1].LimitLow = 0x100; /* FIXME */
711 idt[2].LimitLow = 0x11E; /* FIXME */
712 idt[3].LimitLow = 0x500; /* FIXME */
713 store_reg( context, instr[1], (BYTE *)&idt + offset, long_op );
714 context->Eip += prefixlen + len + 1;
715 return ExceptionContinueExecution;
718 break; /* Unable to emulate it */
720 case 0x8e: /* mov XX,segment_reg */
723 BYTE *addr = INSTR_GetOperandAddr(context, instr + 1,
724 long_addr, segprefix, &len );
726 break; /* Unable to emulate it */
728 if (!INSTR_ReplaceSelector( context, &seg ))
729 break; /* Unable to emulate it */
731 switch((instr[1] >> 3) & 7)
734 context->SegEs = seg;
735 context->Eip += prefixlen + len + 1;
736 return ExceptionContinueExecution;
740 context->SegSs = seg;
741 context->Eip += prefixlen + len + 1;
742 return ExceptionContinueExecution;
744 context->SegDs = seg;
745 context->Eip += prefixlen + len + 1;
746 return ExceptionContinueExecution;
748 context->SegFs = seg;
749 context->Eip += prefixlen + len + 1;
750 return ExceptionContinueExecution;
752 context->SegGs = seg;
753 context->Eip += prefixlen + len + 1;
754 return ExceptionContinueExecution;
760 break; /* Unable to emulate it */
762 case 0xc4: /* les addr,reg */
763 case 0xc5: /* lds addr,reg */
764 if (INSTR_EmulateLDS( context, instr, long_op,
765 long_addr, segprefix, &len ))
767 context->Eip += prefixlen + len;
768 return ExceptionContinueExecution;
770 break; /* Unable to emulate it */
772 case 0xcd: /* int <XX> */
773 if (wine_ldt_is_system(context->SegCs)) break; /* don't emulate it in 32-bit code */
774 if (!winedos.EmulateInterruptPM) load_winedos();
775 if (winedos.EmulateInterruptPM)
777 context->Eip += prefixlen + 2;
778 winedos.EmulateInterruptPM( context, instr[1] );
779 return ExceptionContinueExecution;
781 break; /* Unable to emulate it */
783 case 0xcf: /* iret */
784 if (wine_ldt_is_system(context->SegCs)) break; /* don't emulate it in 32-bit code */
787 DWORD *stack = get_stack( context );
788 context->Eip = *stack++;
789 context->SegCs = *stack++;
790 context->EFlags = *stack;
791 add_stack(context, 3*sizeof(DWORD)); /* Pop the return address and flags */
795 WORD *stack = get_stack( context );
796 context->Eip = *stack++;
797 context->SegCs = *stack++;
798 SET_LOWORD(context->EFlags,*stack);
799 add_stack(context, 3*sizeof(WORD)); /* Pop the return address and flags */
801 return ExceptionContinueExecution;
803 case 0xe4: /* inb al,XX */
804 SET_LOBYTE(context->Eax,INSTR_inport( instr[1], 1, context ));
805 context->Eip += prefixlen + 2;
806 return ExceptionContinueExecution;
808 case 0xe5: /* in (e)ax,XX */
810 context->Eax = INSTR_inport( instr[1], 4, context );
812 SET_LOWORD(context->Eax, INSTR_inport( instr[1], 2, context ));
813 context->Eip += prefixlen + 2;
814 return ExceptionContinueExecution;
816 case 0xe6: /* outb XX,al */
817 INSTR_outport( instr[1], 1, LOBYTE(context->Eax), context );
818 context->Eip += prefixlen + 2;
819 return ExceptionContinueExecution;
821 case 0xe7: /* out XX,(e)ax */
823 INSTR_outport( instr[1], 4, context->Eax, context );
825 INSTR_outport( instr[1], 2, LOWORD(context->Eax), context );
826 context->Eip += prefixlen + 2;
827 return ExceptionContinueExecution;
829 case 0xec: /* inb al,dx */
830 SET_LOBYTE(context->Eax, INSTR_inport( LOWORD(context->Edx), 1, context ) );
831 context->Eip += prefixlen + 1;
832 return ExceptionContinueExecution;
834 case 0xed: /* in (e)ax,dx */
836 context->Eax = INSTR_inport( LOWORD(context->Edx), 4, context );
838 SET_LOWORD(context->Eax, INSTR_inport( LOWORD(context->Edx), 2, context ));
839 context->Eip += prefixlen + 1;
840 return ExceptionContinueExecution;
842 case 0xee: /* outb dx,al */
843 INSTR_outport( LOWORD(context->Edx), 1, LOBYTE(context->Eax), context );
844 context->Eip += prefixlen + 1;
845 return ExceptionContinueExecution;
847 case 0xef: /* out dx,(e)ax */
849 INSTR_outport( LOWORD(context->Edx), 4, context->Eax, context );
851 INSTR_outport( LOWORD(context->Edx), 2, LOWORD(context->Eax), context );
852 context->Eip += prefixlen + 1;
853 return ExceptionContinueExecution;
856 NtCurrentTeb()->dpmi_vif = 0;
857 context->Eip += prefixlen + 1;
858 return ExceptionContinueExecution;
861 NtCurrentTeb()->dpmi_vif = 1;
862 context->Eip += prefixlen + 1;
863 if (NtCurrentTeb()->vm86_pending)
865 NtCurrentTeb()->vm86_pending = 0;
866 rec->ExceptionCode = EXCEPTION_VM86_STI;
867 break; /* Handle the pending event. */
869 return ExceptionContinueExecution;
871 return ExceptionContinueSearch; /* Unable to emulate it */
875 /***********************************************************************
876 * INSTR_vectored_handler
878 * Vectored exception handler used to emulate protected instructions
881 LONG CALLBACK INSTR_vectored_handler( EXCEPTION_POINTERS *ptrs )
883 EXCEPTION_RECORD *record = ptrs->ExceptionRecord;
884 CONTEXT86 *context = ptrs->ContextRecord;
886 if (wine_ldt_is_system(context->SegCs) &&
887 (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
888 record->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION))
890 if (INSTR_EmulateInstruction( record, context ) == ExceptionContinueExecution)
891 return EXCEPTION_CONTINUE_EXECUTION;
893 return EXCEPTION_CONTINUE_SEARCH;
897 /***********************************************************************
898 * INSTR_CallBuiltinHandler
900 void INSTR_CallBuiltinHandler( CONTEXT86 *context, BYTE intnum )
902 if (!winedos.CallBuiltinHandler) load_winedos();
903 if (winedos.CallBuiltinHandler) winedos.CallBuiltinHandler( context, intnum );
907 /***********************************************************************
908 * DOS3Call (KERNEL.102)
910 void WINAPI DOS3Call( CONTEXT86 *context )
912 INSTR_CallBuiltinHandler( context, 0x21 );
916 /***********************************************************************
917 * NetBIOSCall (KERNEL.103)
919 void WINAPI NetBIOSCall16( CONTEXT86 *context )
921 INSTR_CallBuiltinHandler( context, 0x5c );
925 /***********************************************************************
926 * GetSetKernelDOSProc (KERNEL.311)
928 FARPROC16 WINAPI GetSetKernelDOSProc16( FARPROC16 DosProc )
930 FIXME("(DosProc=%p): stub\n", DosProc);