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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "wine/port.h"
32 #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 inline static 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 inline static 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 inline static 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 inline static 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 static WORD sys_timer = 0;
112 if (!winedos.BiosTick) load_winedos();
113 if (winedos.BiosTick)
114 sys_timer = CreateSystemTimer( 55, winedos.BiosTick );
116 *sel = DOSMEM_BiosDataSeg;
119 return FALSE; /* Can't replace selector, crashdump */
123 /* store an operand into a register */
124 static void store_reg( CONTEXT86 *context, BYTE regmodrm, const BYTE *addr, int long_op )
126 switch((regmodrm >> 3) & 7)
129 if (long_op) context->Eax = *(DWORD *)addr;
130 else SET_LOWORD(context->Eax,*(WORD *)addr);
133 if (long_op) context->Ecx = *(DWORD *)addr;
134 else SET_LOWORD(context->Ecx,*(WORD *)addr);
137 if (long_op) context->Edx = *(DWORD *)addr;
138 else SET_LOWORD(context->Edx,*(WORD *)addr);
141 if (long_op) context->Ebx = *(DWORD *)addr;
142 else SET_LOWORD(context->Ebx,*(WORD *)addr);
145 if (long_op) context->Esp = *(DWORD *)addr;
146 else SET_LOWORD(context->Esp,*(WORD *)addr);
149 if (long_op) context->Ebp = *(DWORD *)addr;
150 else SET_LOWORD(context->Ebp,*(WORD *)addr);
153 if (long_op) context->Esi = *(DWORD *)addr;
154 else SET_LOWORD(context->Esi,*(WORD *)addr);
157 if (long_op) context->Edi = *(DWORD *)addr;
158 else SET_LOWORD(context->Edi,*(WORD *)addr);
163 /***********************************************************************
164 * INSTR_GetOperandAddr
166 * Return the address of an instruction operand (from the mod/rm byte).
168 static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
169 int long_addr, int segprefix, int *len )
171 int mod, rm, base = 0, index = 0, ss = 0, seg = 0, off;
174 #define GET_VAL(val,type) \
175 { *val = *(type *)instr; instr += sizeof(type); *len += sizeof(type); }
178 GET_VAL( &mod, BYTE );
186 case 0: return (BYTE *)&context->Eax;
187 case 1: return (BYTE *)&context->Ecx;
188 case 2: return (BYTE *)&context->Edx;
189 case 3: return (BYTE *)&context->Ebx;
190 case 4: return (BYTE *)&context->Esp;
191 case 5: return (BYTE *)&context->Ebp;
192 case 6: return (BYTE *)&context->Esi;
193 case 7: return (BYTE *)&context->Edi;
202 GET_VAL( &sib, BYTE );
207 case 0: index = context->Eax; break;
208 case 1: index = context->Ecx; break;
209 case 2: index = context->Edx; break;
210 case 3: index = context->Ebx; break;
211 case 4: index = 0; break;
212 case 5: index = context->Ebp; break;
213 case 6: index = context->Esi; break;
214 case 7: index = context->Edi; break;
220 case 0: base = context->Eax; seg = context->SegDs; break;
221 case 1: base = context->Ecx; seg = context->SegDs; break;
222 case 2: base = context->Edx; seg = context->SegDs; break;
223 case 3: base = context->Ebx; seg = context->SegDs; break;
224 case 4: base = context->Esp; seg = context->SegSs; break;
225 case 5: base = context->Ebp; seg = context->SegSs; break;
226 case 6: base = context->Esi; seg = context->SegDs; break;
227 case 7: base = context->Edi; seg = context->SegDs; break;
232 if (rm == 5) /* special case: ds:(disp32) */
234 GET_VAL( &base, DWORD );
235 seg = context->SegDs;
239 case 1: /* 8-bit disp */
240 GET_VAL( &off, BYTE );
241 base += (signed char)off;
244 case 2: /* 32-bit disp */
245 GET_VAL( &off, DWORD );
246 base += (signed long)off;
250 else /* short address */
254 case 0: /* ds:(bx,si) */
255 base = LOWORD(context->Ebx) + LOWORD(context->Esi);
256 seg = context->SegDs;
258 case 1: /* ds:(bx,di) */
259 base = LOWORD(context->Ebx) + LOWORD(context->Edi);
260 seg = context->SegDs;
262 case 2: /* ss:(bp,si) */
263 base = LOWORD(context->Ebp) + LOWORD(context->Esi);
264 seg = context->SegSs;
266 case 3: /* ss:(bp,di) */
267 base = LOWORD(context->Ebp) + LOWORD(context->Edi);
268 seg = context->SegSs;
270 case 4: /* ds:(si) */
271 base = LOWORD(context->Esi);
272 seg = context->SegDs;
274 case 5: /* ds:(di) */
275 base = LOWORD(context->Edi);
276 seg = context->SegDs;
278 case 6: /* ss:(bp) */
279 base = LOWORD(context->Ebp);
280 seg = context->SegSs;
282 case 7: /* ds:(bx) */
283 base = LOWORD(context->Ebx);
284 seg = context->SegDs;
291 if (rm == 6) /* special case: ds:(disp16) */
293 GET_VAL( &base, WORD );
294 seg = context->SegDs;
298 case 1: /* 8-bit disp */
299 GET_VAL( &off, BYTE );
300 base += (signed char)off;
303 case 2: /* 16-bit disp */
304 GET_VAL( &off, WORD );
305 base += (signed short)off;
310 if (segprefix != -1) seg = segprefix;
312 /* Make sure the segment and offset are valid */
313 if (wine_ldt_is_system(seg)) return (BYTE *)(base + (index << ss));
314 if ((seg & 7) != 7) return NULL;
315 wine_ldt_get_entry( seg, &entry );
316 if (wine_ldt_is_empty( &entry )) return NULL;
317 if (wine_ldt_get_limit(&entry) < (base + (index << ss))) return NULL;
318 return (BYTE *)wine_ldt_get_base(&entry) + base + (index << ss);
323 /***********************************************************************
326 * Emulate the LDS (and LES,LFS,etc.) instruction.
328 static BOOL INSTR_EmulateLDS( CONTEXT86 *context, BYTE *instr, int long_op,
329 int long_addr, int segprefix, int *len )
332 BYTE *regmodrm = instr + 1 + (*instr == 0x0f);
333 BYTE *addr = INSTR_GetOperandAddr( context, regmodrm,
334 long_addr, segprefix, len );
336 return FALSE; /* Unable to emulate it */
337 seg = *(WORD *)(addr + (long_op ? 4 : 2));
339 if (!INSTR_ReplaceSelector( context, &seg ))
340 return FALSE; /* Unable to emulate it */
342 /* Now store the offset in the correct register */
344 store_reg( context, *regmodrm, addr, long_op );
346 /* Store the correct segment in the segment register */
350 case 0xc4: context->SegEs = seg; break; /* les */
351 case 0xc5: context->SegDs = seg; break; /* lds */
352 case 0x0f: switch(instr[1])
354 case 0xb2: context->SegSs = seg; break; /* lss */
355 case 0xb4: context->SegFs = seg; break; /* lfs */
356 case 0xb5: context->SegGs = seg; break; /* lgs */
361 /* Add the opcode size to the total length */
363 *len += 1 + (*instr == 0x0f);
367 /***********************************************************************
370 * input on an I/O port
372 static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context )
376 if (!winedos.inport) load_winedos();
377 if (winedos.inport) res = winedos.inport( port, size );
384 DPRINTF( "0x%x < %02x @ %04x:%04x\n", port, LOBYTE(res),
385 (WORD)context->SegCs, LOWORD(context->Eip));
388 DPRINTF( "0x%x < %04x @ %04x:%04x\n", port, LOWORD(res),
389 (WORD)context->SegCs, LOWORD(context->Eip));
392 DPRINTF( "0x%x < %08lx @ %04x:%04x\n", port, res,
393 (WORD)context->SegCs, LOWORD(context->Eip));
401 /***********************************************************************
404 * output on an I/O port
406 static void INSTR_outport( WORD port, int size, DWORD val, CONTEXT86 *context )
408 if (!winedos.outport) load_winedos();
409 if (winedos.outport) winedos.outport( port, size, val );
416 DPRINTF("0x%x > %02x @ %04x:%04x\n", port, LOBYTE(val),
417 (WORD)context->SegCs, LOWORD(context->Eip));
420 DPRINTF("0x%x > %04x @ %04x:%04x\n", port, LOWORD(val),
421 (WORD)context->SegCs, LOWORD(context->Eip));
424 DPRINTF("0x%x > %08lx @ %04x:%04x\n", port, val,
425 (WORD)context->SegCs, LOWORD(context->Eip));
432 /***********************************************************************
433 * INSTR_EmulateInstruction
435 * Emulate a privileged instruction.
436 * Returns exception continuation status.
438 DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context )
440 int prefix, segprefix, prefixlen, len, repX, long_op, long_addr;
443 long_op = long_addr = (!ISV86(context) && IS_SELECTOR_32BIT(context->SegCs));
444 instr = make_ptr( context, context->SegCs, context->Eip, TRUE );
445 if (!instr) return ExceptionContinueSearch;
447 /* First handle any possible prefix */
449 segprefix = -1; /* no prefix */
458 segprefix = context->SegCs;
461 segprefix = context->SegSs;
464 segprefix = context->SegDs;
467 segprefix = context->SegEs;
470 segprefix = context->SegFs;
473 segprefix = context->SegGs;
476 long_op = !long_op; /* opcode size prefix */
479 long_addr = !long_addr; /* addr size prefix */
481 case 0xf0: /* lock */
483 case 0xf2: /* repne */
486 case 0xf3: /* repe */
490 prefix = 0; /* no more prefixes */
500 /* Now look at the actual instruction */
504 case 0x07: /* pop es */
505 case 0x17: /* pop ss */
506 case 0x1f: /* pop ds */
508 WORD seg = *(WORD *)get_stack( context );
509 if (INSTR_ReplaceSelector( context, &seg ))
513 case 0x07: context->SegEs = seg; break;
514 case 0x17: context->SegSs = seg; break;
515 case 0x1f: context->SegDs = seg; break;
517 add_stack(context, long_op ? 4 : 2);
518 context->Eip += prefixlen + 1;
519 return ExceptionContinueExecution;
522 break; /* Unable to emulate it */
524 case 0x0f: /* extended instruction */
527 case 0x22: /* mov eax, crX */
531 ERR("mov eax,cr0 at 0x%08lx, EAX=0x%08lx\n",
532 context->Eip,context->Eax );
533 context->Eip += prefixlen+3;
534 return ExceptionContinueExecution;
536 break; /*fallthrough to bad instruction handling */
538 break; /*fallthrough to bad instruction handling */
539 case 0x20: /* mov crX, eax */
542 case 0xe0: /* mov cr4, eax */
543 /* CR4 register . See linux/arch/i386/mm/init.c, X86_CR4_ defs
544 * bit 0: VME Virtual Mode Exception ?
545 * bit 1: PVI Protected mode Virtual Interrupt
546 * bit 2: TSD Timestamp disable
547 * bit 3: DE Debugging extensions
548 * bit 4: PSE Page size extensions
549 * bit 5: PAE Physical address extension
550 * bit 6: MCE Machine check enable
551 * bit 7: PGE Enable global pages
552 * bit 8: PCE Enable performance counters at IPL3
554 ERR("mov cr4,eax at 0x%08lx\n",context->Eip);
556 context->Eip += prefixlen+3;
557 return ExceptionContinueExecution;
558 case 0xc0: /* mov cr0, eax */
559 ERR("mov cr0,eax at 0x%08lx\n",context->Eip);
560 context->Eax = 0x10; /* FIXME: set more bits ? */
561 context->Eip += prefixlen+3;
562 return ExceptionContinueExecution;
563 default: /* fallthrough to illegal instruction */
566 /* fallthrough to illegal instruction */
568 case 0x21: /* mov drX, eax */
571 case 0xc8: /* mov dr1, eax */
572 context->ContextFlags = CONTEXT_DEBUG_REGISTERS;
573 NtGetContextThread( GetCurrentThread(), context );
574 TRACE("mov dr1,eax at 0x%08lx\n",context->Eip);
575 context->Eax = context->Dr1;
576 context->Eip += prefixlen+3;
577 return ExceptionContinueExecution;
578 case 0xf8: /* mov dr7, eax */
579 TRACE("mov dr7,eax at 0x%08lx\n",context->Eip);
580 context->Eax = 0x400;
581 context->Eip += prefixlen+3;
582 return ExceptionContinueExecution;
584 ERR("Unsupported DR register, eip+2 is %02x\n", instr[2]);
585 /* fallthrough to illegal instruction */
587 case 0x23: /* mov eax drX */
590 case 0xc8: /* mov eax, dr1 */
591 context->ContextFlags = CONTEXT_DEBUG_REGISTERS;
592 NtGetContextThread( GetCurrentThread(), context );
593 context->Dr1 = context->Eax;
594 context->Eip += prefixlen+3;
595 context->ContextFlags = CONTEXT_DEBUG_REGISTERS;
596 NtSetContextThread( GetCurrentThread(), context );
597 return ExceptionContinueExecution;
599 ERR("Unsupported DR register, eip+2 is %02x\n", instr[2]);
600 /* fallthrough to illegal instruction */
602 case 0xa1: /* pop fs */
604 WORD seg = *(WORD *)get_stack( context );
605 if (INSTR_ReplaceSelector( context, &seg ))
607 context->SegFs = seg;
608 add_stack(context, long_op ? 4 : 2);
609 context->Eip += prefixlen + 2;
610 return ExceptionContinueExecution;
614 case 0xa9: /* pop gs */
616 WORD seg = *(WORD *)get_stack( context );
617 if (INSTR_ReplaceSelector( context, &seg ))
619 context->SegGs = seg;
620 add_stack(context, long_op ? 4 : 2);
621 context->Eip += prefixlen + 2;
622 return ExceptionContinueExecution;
626 case 0xb2: /* lss addr,reg */
627 case 0xb4: /* lfs addr,reg */
628 case 0xb5: /* lgs addr,reg */
629 if (INSTR_EmulateLDS( context, instr, long_op,
630 long_addr, segprefix, &len ))
632 context->Eip += prefixlen + len;
633 return ExceptionContinueExecution;
637 break; /* Unable to emulate it */
639 case 0x6c: /* insb */
640 case 0x6d: /* insw/d */
641 case 0x6e: /* outsb */
642 case 0x6f: /* outsw/d */
644 int typ = *instr; /* Just in case it's overwritten. */
645 int outp = (typ >= 0x6e);
646 unsigned long count = repX ?
647 (long_addr ? context->Ecx : LOWORD(context->Ecx)) : 1;
648 int opsize = (typ & 1) ? (long_op ? 4 : 2) : 1;
649 int step = (context->EFlags & 0x400) ? -opsize : +opsize;
650 int seg = outp ? context->SegDs : context->SegEs; /* FIXME: is this right? */
653 /* FIXME: Check segment readable. */
656 /* FIXME: Check segment writeable. */
661 if (long_addr) context->Ecx = 0;
662 else SET_LOWORD(context->Ecx,0);
668 WORD dx = LOWORD(context->Edx);
671 data = make_ptr( context, seg, context->Esi, long_addr );
672 if (long_addr) context->Esi += step;
673 else ADD_LOWORD(context->Esi,step);
677 data = make_ptr( context, seg, context->Edi, long_addr );
678 if (long_addr) context->Edi += step;
679 else ADD_LOWORD(context->Edi,step);
685 *(BYTE *)data = INSTR_inport( dx, 1, context );
689 *(DWORD *)data = INSTR_inport( dx, 4, context );
691 *(WORD *)data = INSTR_inport( dx, 2, context );
694 INSTR_outport( dx, 1, *(BYTE *)data, context );
698 INSTR_outport( dx, 4, *(DWORD *)data, context );
700 INSTR_outport( dx, 2, *(WORD *)data, context );
704 context->Eip += prefixlen + 1;
706 return ExceptionContinueExecution;
708 case 0x8b: /* mov Ev, Gv */
710 BYTE *addr = INSTR_GetOperandAddr(context, instr + 1, long_addr,
712 struct idtr idtr = get_idtr();
713 unsigned int offset = addr - idtr.base;
715 if (offset <= idtr.limit + 1 - (long_op ? 4 : 2))
717 idt[1].LimitLow = 0x100; /* FIXME */
718 idt[3].LimitLow = 0x500; /* FIXME */
719 store_reg( context, instr[1], (BYTE *)&idt + offset, long_op );
720 context->Eip += prefixlen + len + 1;
721 return ExceptionContinueExecution;
724 break; /* Unable to emulate it */
726 case 0x8e: /* mov XX,segment_reg */
729 BYTE *addr = INSTR_GetOperandAddr(context, instr + 1,
730 long_addr, segprefix, &len );
732 break; /* Unable to emulate it */
734 if (!INSTR_ReplaceSelector( context, &seg ))
735 break; /* Unable to emulate it */
737 switch((instr[1] >> 3) & 7)
740 context->SegEs = seg;
741 context->Eip += prefixlen + len + 1;
742 return ExceptionContinueExecution;
746 context->SegSs = seg;
747 context->Eip += prefixlen + len + 1;
748 return ExceptionContinueExecution;
750 context->SegDs = seg;
751 context->Eip += prefixlen + len + 1;
752 return ExceptionContinueExecution;
754 context->SegFs = seg;
755 context->Eip += prefixlen + len + 1;
756 return ExceptionContinueExecution;
758 context->SegGs = seg;
759 context->Eip += prefixlen + len + 1;
760 return ExceptionContinueExecution;
766 break; /* Unable to emulate it */
768 case 0xc4: /* les addr,reg */
769 case 0xc5: /* lds addr,reg */
770 if (INSTR_EmulateLDS( context, instr, long_op,
771 long_addr, segprefix, &len ))
773 context->Eip += prefixlen + len;
774 return ExceptionContinueExecution;
776 break; /* Unable to emulate it */
778 case 0xcd: /* int <XX> */
779 if (wine_ldt_is_system(context->SegCs)) break; /* don't emulate it in 32-bit code */
780 if (!winedos.EmulateInterruptPM) load_winedos();
781 if (winedos.EmulateInterruptPM)
783 context->Eip += prefixlen + 2;
784 winedos.EmulateInterruptPM( context, instr[1] );
785 return ExceptionContinueExecution;
787 break; /* Unable to emulate it */
789 case 0xcf: /* iret */
790 if (wine_ldt_is_system(context->SegCs)) break; /* don't emulate it in 32-bit code */
793 DWORD *stack = get_stack( context );
794 context->Eip = *stack++;
795 context->SegCs = *stack++;
796 context->EFlags = *stack;
797 add_stack(context, 3*sizeof(DWORD)); /* Pop the return address and flags */
801 WORD *stack = get_stack( context );
802 context->Eip = *stack++;
803 context->SegCs = *stack++;
804 SET_LOWORD(context->EFlags,*stack);
805 add_stack(context, 3*sizeof(WORD)); /* Pop the return address and flags */
807 return ExceptionContinueExecution;
809 case 0xe4: /* inb al,XX */
810 SET_LOBYTE(context->Eax,INSTR_inport( instr[1], 1, context ));
811 context->Eip += prefixlen + 2;
812 return ExceptionContinueExecution;
814 case 0xe5: /* in (e)ax,XX */
816 context->Eax = INSTR_inport( instr[1], 4, context );
818 SET_LOWORD(context->Eax, INSTR_inport( instr[1], 2, context ));
819 context->Eip += prefixlen + 2;
820 return ExceptionContinueExecution;
822 case 0xe6: /* outb XX,al */
823 INSTR_outport( instr[1], 1, LOBYTE(context->Eax), context );
824 context->Eip += prefixlen + 2;
825 return ExceptionContinueExecution;
827 case 0xe7: /* out XX,(e)ax */
829 INSTR_outport( instr[1], 4, context->Eax, context );
831 INSTR_outport( instr[1], 2, LOWORD(context->Eax), context );
832 context->Eip += prefixlen + 2;
833 return ExceptionContinueExecution;
835 case 0xec: /* inb al,dx */
836 SET_LOBYTE(context->Eax, INSTR_inport( LOWORD(context->Edx), 1, context ) );
837 context->Eip += prefixlen + 1;
838 return ExceptionContinueExecution;
840 case 0xed: /* in (e)ax,dx */
842 context->Eax = INSTR_inport( LOWORD(context->Edx), 4, context );
844 SET_LOWORD(context->Eax, INSTR_inport( LOWORD(context->Edx), 2, context ));
845 context->Eip += prefixlen + 1;
846 return ExceptionContinueExecution;
848 case 0xee: /* outb dx,al */
849 INSTR_outport( LOWORD(context->Edx), 1, LOBYTE(context->Eax), context );
850 context->Eip += prefixlen + 1;
851 return ExceptionContinueExecution;
853 case 0xef: /* out dx,(e)ax */
855 INSTR_outport( LOWORD(context->Edx), 4, context->Eax, context );
857 INSTR_outport( LOWORD(context->Edx), 2, LOWORD(context->Eax), context );
858 context->Eip += prefixlen + 1;
859 return ExceptionContinueExecution;
862 NtCurrentTeb()->dpmi_vif = 0;
863 context->Eip += prefixlen + 1;
864 return ExceptionContinueExecution;
867 NtCurrentTeb()->dpmi_vif = 1;
868 context->Eip += prefixlen + 1;
869 if (NtCurrentTeb()->vm86_pending)
871 NtCurrentTeb()->vm86_pending = 0;
872 rec->ExceptionCode = EXCEPTION_VM86_STI;
873 break; /* Handle the pending event. */
875 return ExceptionContinueExecution;
877 return ExceptionContinueSearch; /* Unable to emulate it */
881 /***********************************************************************
882 * INSTR_CallBuiltinHandler
884 void INSTR_CallBuiltinHandler( CONTEXT86 *context, BYTE intnum )
886 if (!winedos.CallBuiltinHandler) load_winedos();
887 if (winedos.CallBuiltinHandler) winedos.CallBuiltinHandler( context, intnum );
891 /***********************************************************************
892 * DOS3Call (KERNEL.102)
894 void WINAPI DOS3Call( CONTEXT86 *context )
896 INSTR_CallBuiltinHandler( context, 0x21 );
900 /***********************************************************************
901 * NetBIOSCall (KERNEL.103)
903 void WINAPI NetBIOSCall16( CONTEXT86 *context )
905 INSTR_CallBuiltinHandler( context, 0x5c );
909 /***********************************************************************
910 * GetSetKernelDOSProc (KERNEL.311)
912 FARPROC16 WINAPI GetSetKernelDOSProc16( FARPROC16 DosProc )
914 FIXME("(DosProc=0x%08x): stub\n", (UINT)DosProc);