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"
33 #include "wine/winuser16.h"
35 #include "wine/debug.h"
36 #include "kernel_private.h"
37 #include "kernel16_private.h"
38 #include "wine/exception.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(int);
41 WINE_DECLARE_DEBUG_CHANNEL(io);
43 /* macros to set parts of a DWORD */
44 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
45 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
46 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
47 #define ISV86(context) ((context)->EFlags & 0x00020000)
49 static inline void add_stack( CONTEXT86 *context, int offset )
51 if (ISV86(context) || !IS_SELECTOR_32BIT(context->SegSs))
52 ADD_LOWORD( context->Esp, offset );
54 context->Esp += offset;
57 static inline void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long_addr )
59 if (ISV86(context)) return (void *)((seg << 4) + LOWORD(off));
60 if (wine_ldt_is_system(seg)) return (void *)off;
61 if (!long_addr) off = LOWORD(off);
62 return (char *) MapSL( MAKESEGPTR( seg, 0 ) ) + off;
65 static inline void *get_stack( CONTEXT86 *context )
67 if (ISV86(context)) return (void *)((context->SegSs << 4) + LOWORD(context->Esp));
68 return wine_ldt_get_ptr( context->SegSs, context->Esp );
79 static LDT_ENTRY idt[256];
81 static inline struct idtr get_idtr(void)
84 #if defined(__i386__) && defined(__GNUC__)
85 __asm__( "sidtl %0" : "=m" (ret) );
87 ret.base = (BYTE *)idt;
88 ret.limit = sizeof(idt) - 1;
94 /***********************************************************************
95 * INSTR_ReplaceSelector
97 * Try to replace an invalid selector by a valid one.
98 * The only selector where it is allowed to do "mov ax,40;mov es,ax"
99 * is the so called 'bimodal' selector 0x40, which points to the BIOS
100 * data segment. Used by (at least) Borland products (and programs compiled
101 * using Borland products).
103 * See Undocumented Windows, Chapter 5, __0040.
105 static BOOL INSTR_ReplaceSelector( CONTEXT86 *context, WORD *sel )
109 *sel = DOSMEM_BiosDataSeg;
112 return FALSE; /* Can't replace selector, crashdump */
116 /* store an operand into a register */
117 static void store_reg( CONTEXT86 *context, BYTE regmodrm, const BYTE *addr, int long_op )
119 switch((regmodrm >> 3) & 7)
122 if (long_op) context->Eax = *(const DWORD *)addr;
123 else SET_LOWORD(context->Eax, *(const WORD *)addr);
126 if (long_op) context->Ecx = *(const DWORD *)addr;
127 else SET_LOWORD(context->Ecx, *(const WORD *)addr);
130 if (long_op) context->Edx = *(const DWORD *)addr;
131 else SET_LOWORD(context->Edx, *(const WORD *)addr);
134 if (long_op) context->Ebx = *(const DWORD *)addr;
135 else SET_LOWORD(context->Ebx, *(const WORD *)addr);
138 if (long_op) context->Esp = *(const DWORD *)addr;
139 else SET_LOWORD(context->Esp, *(const WORD *)addr);
142 if (long_op) context->Ebp = *(const DWORD *)addr;
143 else SET_LOWORD(context->Ebp, *(const WORD *)addr);
146 if (long_op) context->Esi = *(const DWORD *)addr;
147 else SET_LOWORD(context->Esi, *(const WORD *)addr);
150 if (long_op) context->Edi = *(const DWORD *)addr;
151 else SET_LOWORD(context->Edi, *(const WORD *)addr);
156 /***********************************************************************
157 * INSTR_GetOperandAddr
159 * Return the address of an instruction operand (from the mod/rm byte).
161 static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
162 int long_addr, int segprefix, int *len )
164 int mod, rm, base = 0, index = 0, ss = 0, seg = 0, off;
167 #define GET_VAL(val,type) \
168 { *val = *(type *)instr; instr += sizeof(type); *len += sizeof(type); }
171 GET_VAL( &mod, BYTE );
179 case 0: return (BYTE *)&context->Eax;
180 case 1: return (BYTE *)&context->Ecx;
181 case 2: return (BYTE *)&context->Edx;
182 case 3: return (BYTE *)&context->Ebx;
183 case 4: return (BYTE *)&context->Esp;
184 case 5: return (BYTE *)&context->Ebp;
185 case 6: return (BYTE *)&context->Esi;
186 case 7: return (BYTE *)&context->Edi;
195 GET_VAL( &sib, BYTE );
200 case 0: index = context->Eax; break;
201 case 1: index = context->Ecx; break;
202 case 2: index = context->Edx; break;
203 case 3: index = context->Ebx; break;
204 case 4: index = 0; break;
205 case 5: index = context->Ebp; break;
206 case 6: index = context->Esi; break;
207 case 7: index = context->Edi; break;
213 case 0: base = context->Eax; seg = context->SegDs; break;
214 case 1: base = context->Ecx; seg = context->SegDs; break;
215 case 2: base = context->Edx; seg = context->SegDs; break;
216 case 3: base = context->Ebx; seg = context->SegDs; break;
217 case 4: base = context->Esp; seg = context->SegSs; break;
218 case 5: base = context->Ebp; seg = context->SegSs; break;
219 case 6: base = context->Esi; seg = context->SegDs; break;
220 case 7: base = context->Edi; seg = context->SegDs; break;
225 if (rm == 5) /* special case: ds:(disp32) */
227 GET_VAL( &base, DWORD );
228 seg = context->SegDs;
232 case 1: /* 8-bit disp */
233 GET_VAL( &off, BYTE );
234 base += (signed char)off;
237 case 2: /* 32-bit disp */
238 GET_VAL( &off, DWORD );
239 base += (signed long)off;
243 else /* short address */
247 case 0: /* ds:(bx,si) */
248 base = LOWORD(context->Ebx) + LOWORD(context->Esi);
249 seg = context->SegDs;
251 case 1: /* ds:(bx,di) */
252 base = LOWORD(context->Ebx) + LOWORD(context->Edi);
253 seg = context->SegDs;
255 case 2: /* ss:(bp,si) */
256 base = LOWORD(context->Ebp) + LOWORD(context->Esi);
257 seg = context->SegSs;
259 case 3: /* ss:(bp,di) */
260 base = LOWORD(context->Ebp) + LOWORD(context->Edi);
261 seg = context->SegSs;
263 case 4: /* ds:(si) */
264 base = LOWORD(context->Esi);
265 seg = context->SegDs;
267 case 5: /* ds:(di) */
268 base = LOWORD(context->Edi);
269 seg = context->SegDs;
271 case 6: /* ss:(bp) */
272 base = LOWORD(context->Ebp);
273 seg = context->SegSs;
275 case 7: /* ds:(bx) */
276 base = LOWORD(context->Ebx);
277 seg = context->SegDs;
284 if (rm == 6) /* special case: ds:(disp16) */
286 GET_VAL( &base, WORD );
287 seg = context->SegDs;
291 case 1: /* 8-bit disp */
292 GET_VAL( &off, BYTE );
293 base += (signed char)off;
296 case 2: /* 16-bit disp */
297 GET_VAL( &off, WORD );
298 base += (signed short)off;
303 if (segprefix != -1) seg = segprefix;
305 /* Make sure the segment and offset are valid */
306 if (wine_ldt_is_system(seg)) return (BYTE *)(base + (index << ss));
307 if ((seg & 7) != 7) return NULL;
308 wine_ldt_get_entry( seg, &entry );
309 if (wine_ldt_is_empty( &entry )) return NULL;
310 if (wine_ldt_get_limit(&entry) < (base + (index << ss))) return NULL;
311 return (BYTE *)wine_ldt_get_base(&entry) + base + (index << ss);
316 /***********************************************************************
319 * Emulate the LDS (and LES,LFS,etc.) instruction.
321 static BOOL INSTR_EmulateLDS( CONTEXT86 *context, BYTE *instr, int long_op,
322 int long_addr, int segprefix, int *len )
325 BYTE *regmodrm = instr + 1 + (*instr == 0x0f);
326 BYTE *addr = INSTR_GetOperandAddr( context, regmodrm,
327 long_addr, segprefix, len );
329 return FALSE; /* Unable to emulate it */
330 seg = *(WORD *)(addr + (long_op ? 4 : 2));
332 if (!INSTR_ReplaceSelector( context, &seg ))
333 return FALSE; /* Unable to emulate it */
335 /* Now store the offset in the correct register */
337 store_reg( context, *regmodrm, addr, long_op );
339 /* Store the correct segment in the segment register */
343 case 0xc4: context->SegEs = seg; break; /* les */
344 case 0xc5: context->SegDs = seg; break; /* lds */
345 case 0x0f: switch(instr[1])
347 case 0xb2: context->SegSs = seg; break; /* lss */
348 case 0xb4: context->SegFs = seg; break; /* lfs */
349 case 0xb5: context->SegGs = seg; break; /* lgs */
354 /* Add the opcode size to the total length */
356 *len += 1 + (*instr == 0x0f);
360 /***********************************************************************
363 * input on an I/O port
365 static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context )
369 if (!winedos.inport) load_winedos();
370 if (winedos.inport) res = winedos.inport( port, size );
377 TRACE_(io)( "0x%x < %02x @ %04x:%04x\n", port, LOBYTE(res),
378 (WORD)context->SegCs, LOWORD(context->Eip));
381 TRACE_(io)( "0x%x < %04x @ %04x:%04x\n", port, LOWORD(res),
382 (WORD)context->SegCs, LOWORD(context->Eip));
385 TRACE_(io)( "0x%x < %08x @ %04x:%04x\n", port, res,
386 (WORD)context->SegCs, LOWORD(context->Eip));
394 /***********************************************************************
397 * output on an I/O port
399 static void INSTR_outport( WORD port, int size, DWORD val, CONTEXT86 *context )
401 if (!winedos.outport) load_winedos();
402 if (winedos.outport) winedos.outport( port, size, val );
409 TRACE_(io)("0x%x > %02x @ %04x:%04x\n", port, LOBYTE(val),
410 (WORD)context->SegCs, LOWORD(context->Eip));
413 TRACE_(io)("0x%x > %04x @ %04x:%04x\n", port, LOWORD(val),
414 (WORD)context->SegCs, LOWORD(context->Eip));
417 TRACE_(io)("0x%x > %08x @ %04x:%04x\n", port, val,
418 (WORD)context->SegCs, LOWORD(context->Eip));
425 /***********************************************************************
426 * __wine_emulate_instruction
428 * Emulate a privileged instruction.
429 * Returns exception continuation status.
431 DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT86 *context )
433 int prefix, segprefix, prefixlen, len, repX, long_op, long_addr;
436 long_op = long_addr = (!ISV86(context) && IS_SELECTOR_32BIT(context->SegCs));
437 instr = make_ptr( context, context->SegCs, context->Eip, TRUE );
438 if (!instr) return ExceptionContinueSearch;
440 /* First handle any possible prefix */
442 segprefix = -1; /* no prefix */
451 segprefix = context->SegCs;
454 segprefix = context->SegSs;
457 segprefix = context->SegDs;
460 segprefix = context->SegEs;
463 segprefix = context->SegFs;
466 segprefix = context->SegGs;
469 long_op = !long_op; /* opcode size prefix */
472 long_addr = !long_addr; /* addr size prefix */
474 case 0xf0: /* lock */
476 case 0xf2: /* repne */
479 case 0xf3: /* repe */
483 prefix = 0; /* no more prefixes */
493 /* Now look at the actual instruction */
497 case 0x07: /* pop es */
498 case 0x17: /* pop ss */
499 case 0x1f: /* pop ds */
501 WORD seg = *(WORD *)get_stack( context );
502 if (INSTR_ReplaceSelector( context, &seg ))
506 case 0x07: context->SegEs = seg; break;
507 case 0x17: context->SegSs = seg; break;
508 case 0x1f: context->SegDs = seg; break;
510 add_stack(context, long_op ? 4 : 2);
511 context->Eip += prefixlen + 1;
512 return ExceptionContinueExecution;
515 break; /* Unable to emulate it */
517 case 0x0f: /* extended instruction */
520 case 0x22: /* mov eax, crX */
524 ERR("mov eax,cr0 at 0x%08x, EAX=0x%08x\n",
525 context->Eip,context->Eax );
526 context->Eip += prefixlen+3;
527 return ExceptionContinueExecution;
529 break; /*fallthrough to bad instruction handling */
531 break; /*fallthrough to bad instruction handling */
532 case 0x20: /* mov crX, eax */
535 case 0xe0: /* mov cr4, eax */
536 /* CR4 register . See linux/arch/i386/mm/init.c, X86_CR4_ defs
537 * bit 0: VME Virtual Mode Exception ?
538 * bit 1: PVI Protected mode Virtual Interrupt
539 * bit 2: TSD Timestamp disable
540 * bit 3: DE Debugging extensions
541 * bit 4: PSE Page size extensions
542 * bit 5: PAE Physical address extension
543 * bit 6: MCE Machine check enable
544 * bit 7: PGE Enable global pages
545 * bit 8: PCE Enable performance counters at IPL3
547 ERR("mov cr4,eax at 0x%08x\n",context->Eip);
549 context->Eip += prefixlen+3;
550 return ExceptionContinueExecution;
551 case 0xc0: /* mov cr0, eax */
552 ERR("mov cr0,eax at 0x%08x\n",context->Eip);
553 context->Eax = 0x10; /* FIXME: set more bits ? */
554 context->Eip += prefixlen+3;
555 return ExceptionContinueExecution;
556 default: /* fallthrough to illegal instruction */
559 /* fallthrough to illegal instruction */
561 case 0x21: /* mov drX, eax */
564 case 0xc8: /* mov dr1, eax */
565 TRACE("mov dr1,eax at 0x%08x\n",context->Eip);
566 context->Eax = context->Dr1;
567 context->Eip += prefixlen+3;
568 return ExceptionContinueExecution;
569 case 0xf8: /* mov dr7, eax */
570 TRACE("mov dr7,eax at 0x%08x\n",context->Eip);
571 context->Eax = 0x400;
572 context->Eip += prefixlen+3;
573 return ExceptionContinueExecution;
575 ERR("Unsupported DR register, eip+2 is %02x\n", instr[2]);
576 /* fallthrough to illegal instruction */
578 case 0x23: /* mov eax drX */
581 case 0xc8: /* mov eax, dr1 */
582 context->Dr1 = context->Eax;
583 context->Eip += prefixlen+3;
584 return ExceptionContinueExecution;
586 ERR("Unsupported DR register, eip+2 is %02x\n", instr[2]);
587 /* fallthrough to illegal instruction */
589 case 0xa1: /* pop fs */
591 WORD seg = *(WORD *)get_stack( context );
592 if (INSTR_ReplaceSelector( context, &seg ))
594 context->SegFs = seg;
595 add_stack(context, long_op ? 4 : 2);
596 context->Eip += prefixlen + 2;
597 return ExceptionContinueExecution;
601 case 0xa9: /* pop gs */
603 WORD seg = *(WORD *)get_stack( context );
604 if (INSTR_ReplaceSelector( context, &seg ))
606 context->SegGs = seg;
607 add_stack(context, long_op ? 4 : 2);
608 context->Eip += prefixlen + 2;
609 return ExceptionContinueExecution;
613 case 0xb2: /* lss addr,reg */
614 case 0xb4: /* lfs addr,reg */
615 case 0xb5: /* lgs addr,reg */
616 if (INSTR_EmulateLDS( context, instr, long_op,
617 long_addr, segprefix, &len ))
619 context->Eip += prefixlen + len;
620 return ExceptionContinueExecution;
624 break; /* Unable to emulate it */
626 case 0x6c: /* insb */
627 case 0x6d: /* insw/d */
628 case 0x6e: /* outsb */
629 case 0x6f: /* outsw/d */
631 int typ = *instr; /* Just in case it's overwritten. */
632 int outp = (typ >= 0x6e);
633 unsigned long count = repX ?
634 (long_addr ? context->Ecx : LOWORD(context->Ecx)) : 1;
635 int opsize = (typ & 1) ? (long_op ? 4 : 2) : 1;
636 int step = (context->EFlags & 0x400) ? -opsize : +opsize;
637 int seg = outp ? context->SegDs : context->SegEs; /* FIXME: is this right? */
640 /* FIXME: Check segment is readable. */
643 /* FIXME: Check segment is writable. */
648 if (long_addr) context->Ecx = 0;
649 else SET_LOWORD(context->Ecx,0);
655 WORD dx = LOWORD(context->Edx);
658 data = make_ptr( context, seg, context->Esi, long_addr );
659 if (long_addr) context->Esi += step;
660 else ADD_LOWORD(context->Esi,step);
664 data = make_ptr( context, seg, context->Edi, long_addr );
665 if (long_addr) context->Edi += step;
666 else ADD_LOWORD(context->Edi,step);
672 *(BYTE *)data = INSTR_inport( dx, 1, context );
676 *(DWORD *)data = INSTR_inport( dx, 4, context );
678 *(WORD *)data = INSTR_inport( dx, 2, context );
681 INSTR_outport( dx, 1, *(BYTE *)data, context );
685 INSTR_outport( dx, 4, *(DWORD *)data, context );
687 INSTR_outport( dx, 2, *(WORD *)data, context );
691 context->Eip += prefixlen + 1;
693 return ExceptionContinueExecution;
695 case 0x8b: /* mov Ev, Gv */
697 BYTE *addr = INSTR_GetOperandAddr(context, instr + 1, long_addr,
699 struct idtr idtr = get_idtr();
700 unsigned int offset = addr - idtr.base;
702 if (offset <= idtr.limit + 1 - (long_op ? 4 : 2))
704 idt[1].LimitLow = 0x100; /* FIXME */
705 idt[2].LimitLow = 0x11E; /* FIXME */
706 idt[3].LimitLow = 0x500; /* FIXME */
707 store_reg( context, instr[1], (BYTE *)idt + offset, long_op );
708 context->Eip += prefixlen + len + 1;
709 return ExceptionContinueExecution;
712 break; /* Unable to emulate it */
714 case 0x8e: /* mov XX,segment_reg */
717 BYTE *addr = INSTR_GetOperandAddr(context, instr + 1,
718 long_addr, segprefix, &len );
720 break; /* Unable to emulate it */
722 if (!INSTR_ReplaceSelector( context, &seg ))
723 break; /* Unable to emulate it */
725 switch((instr[1] >> 3) & 7)
728 context->SegEs = seg;
729 context->Eip += prefixlen + len + 1;
730 return ExceptionContinueExecution;
734 context->SegSs = seg;
735 context->Eip += prefixlen + len + 1;
736 return ExceptionContinueExecution;
738 context->SegDs = seg;
739 context->Eip += prefixlen + len + 1;
740 return ExceptionContinueExecution;
742 context->SegFs = seg;
743 context->Eip += prefixlen + len + 1;
744 return ExceptionContinueExecution;
746 context->SegGs = seg;
747 context->Eip += prefixlen + len + 1;
748 return ExceptionContinueExecution;
754 break; /* Unable to emulate it */
756 case 0xc4: /* les addr,reg */
757 case 0xc5: /* lds addr,reg */
758 if (INSTR_EmulateLDS( context, instr, long_op,
759 long_addr, segprefix, &len ))
761 context->Eip += prefixlen + len;
762 return ExceptionContinueExecution;
764 break; /* Unable to emulate it */
766 case 0xcd: /* int <XX> */
767 if (!winedos.EmulateInterruptPM) load_winedos();
768 if (winedos.EmulateInterruptPM)
770 context->Eip += prefixlen + 2;
771 if (winedos.EmulateInterruptPM( context, instr[1] )) return ExceptionContinueExecution;
772 context->Eip -= prefixlen + 2; /* restore eip */
774 break; /* Unable to emulate it */
776 case 0xcf: /* iret */
777 if (wine_ldt_is_system(context->SegCs)) break; /* don't emulate it in 32-bit code */
780 DWORD *stack = get_stack( context );
781 context->Eip = *stack++;
782 context->SegCs = *stack++;
783 context->EFlags = *stack;
784 add_stack(context, 3*sizeof(DWORD)); /* Pop the return address and flags */
788 WORD *stack = get_stack( context );
789 context->Eip = *stack++;
790 context->SegCs = *stack++;
791 SET_LOWORD(context->EFlags,*stack);
792 add_stack(context, 3*sizeof(WORD)); /* Pop the return address and flags */
794 return ExceptionContinueExecution;
796 case 0xe4: /* inb al,XX */
797 SET_LOBYTE(context->Eax,INSTR_inport( instr[1], 1, context ));
798 context->Eip += prefixlen + 2;
799 return ExceptionContinueExecution;
801 case 0xe5: /* in (e)ax,XX */
803 context->Eax = INSTR_inport( instr[1], 4, context );
805 SET_LOWORD(context->Eax, INSTR_inport( instr[1], 2, context ));
806 context->Eip += prefixlen + 2;
807 return ExceptionContinueExecution;
809 case 0xe6: /* outb XX,al */
810 INSTR_outport( instr[1], 1, LOBYTE(context->Eax), context );
811 context->Eip += prefixlen + 2;
812 return ExceptionContinueExecution;
814 case 0xe7: /* out XX,(e)ax */
816 INSTR_outport( instr[1], 4, context->Eax, context );
818 INSTR_outport( instr[1], 2, LOWORD(context->Eax), context );
819 context->Eip += prefixlen + 2;
820 return ExceptionContinueExecution;
822 case 0xec: /* inb al,dx */
823 SET_LOBYTE(context->Eax, INSTR_inport( LOWORD(context->Edx), 1, context ) );
824 context->Eip += prefixlen + 1;
825 return ExceptionContinueExecution;
827 case 0xed: /* in (e)ax,dx */
829 context->Eax = INSTR_inport( LOWORD(context->Edx), 4, context );
831 SET_LOWORD(context->Eax, INSTR_inport( LOWORD(context->Edx), 2, context ));
832 context->Eip += prefixlen + 1;
833 return ExceptionContinueExecution;
835 case 0xee: /* outb dx,al */
836 INSTR_outport( LOWORD(context->Edx), 1, LOBYTE(context->Eax), context );
837 context->Eip += prefixlen + 1;
838 return ExceptionContinueExecution;
840 case 0xef: /* out dx,(e)ax */
842 INSTR_outport( LOWORD(context->Edx), 4, context->Eax, context );
844 INSTR_outport( LOWORD(context->Edx), 2, LOWORD(context->Eax), context );
845 context->Eip += prefixlen + 1;
846 return ExceptionContinueExecution;
849 get_vm86_teb_info()->dpmi_vif = 0;
850 context->Eip += prefixlen + 1;
851 return ExceptionContinueExecution;
854 get_vm86_teb_info()->dpmi_vif = 1;
855 context->Eip += prefixlen + 1;
856 if (get_vm86_teb_info()->vm86_pending)
858 get_vm86_teb_info()->vm86_pending = 0;
859 rec->ExceptionCode = EXCEPTION_VM86_STI;
860 break; /* Handle the pending event. */
862 return ExceptionContinueExecution;
864 return ExceptionContinueSearch; /* Unable to emulate it */
868 /***********************************************************************
869 * INSTR_vectored_handler
871 * Vectored exception handler used to emulate protected instructions
874 LONG CALLBACK INSTR_vectored_handler( EXCEPTION_POINTERS *ptrs )
876 EXCEPTION_RECORD *record = ptrs->ExceptionRecord;
877 CONTEXT86 *context = ptrs->ContextRecord;
879 if (wine_ldt_is_system(context->SegCs) &&
880 (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
881 record->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION))
883 if (__wine_emulate_instruction( record, context ) == ExceptionContinueExecution)
884 return EXCEPTION_CONTINUE_EXECUTION;
886 return EXCEPTION_CONTINUE_SEARCH;
890 /***********************************************************************
891 * INSTR_CallBuiltinHandler
893 static void INSTR_CallBuiltinHandler( CONTEXT86 *context, BYTE intnum )
895 if (!winedos.CallBuiltinHandler) load_winedos();
896 if (winedos.CallBuiltinHandler) winedos.CallBuiltinHandler( context, intnum );
900 /***********************************************************************
901 * DOS3Call (KERNEL.102)
903 void WINAPI DOS3Call( CONTEXT86 *context )
905 INSTR_CallBuiltinHandler( context, 0x21 );
909 /***********************************************************************
910 * NetBIOSCall (KERNEL.103)
912 void WINAPI NetBIOSCall16( CONTEXT86 *context )
914 INSTR_CallBuiltinHandler( context, 0x5c );
918 /***********************************************************************
919 * GetSetKernelDOSProc (KERNEL.311)
921 FARPROC16 WINAPI GetSetKernelDOSProc16( FARPROC16 DosProc )
923 FIXME("(DosProc=%p): stub\n", DosProc);
927 #endif /* __i386__ */