Added one safety check to AFM parsing.
[wine.git] / msdos / int26.c
blobdf861df449efda7141eff31462271dd9c5c3f32e
1 /*
2 * DOS interrupt 26h handler
3 */
5 #include <stdlib.h>
6 #include <fcntl.h>
7 #include <unistd.h>
8 #include "msdos.h"
9 #include "miscemu.h"
10 #include "drive.h"
11 #include "debugtools.h"
13 DEFAULT_DEBUG_CHANNEL(int);
15 /**********************************************************************
16 * INT_Int26Handler
18 * Handler for int 26h (absolute disk read).
20 void WINAPI INT_Int26Handler( CONTEXT86 *context )
22 BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Ebx );
23 DWORD begin, length;
25 if (!DRIVE_IsValid(LOBYTE(context->Eax)))
27 SET_CFLAG(context);
28 AX_reg(context) = 0x0201; /* unknown unit */
29 return;
32 if (LOWORD(context->Ecx) == 0xffff)
34 begin = *(DWORD *)dataptr;
35 length = *(WORD *)(dataptr + 4);
36 dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context,
37 *(WORD *)(dataptr + 8), *(DWORD *)(dataptr + 6) );
39 else
41 begin = LOWORD(context->Edx);
42 length = LOWORD(context->Ecx);
45 TRACE("int26: abs diskwrite, drive %d, sector %ld, "
46 "count %ld, buffer %p\n",
47 AL_reg(context), begin, length, dataptr );
49 DRIVE_RawWrite(LOBYTE(context->Eax), begin, length, dataptr, TRUE);
50 RESET_CFLAG(context);