Fixed CreateDC to work properly when it is called with a device.
[wine] / msdos / int25.c
1 /*
2  * DOS interrupt 25h handler
3  */
4
5 #include <stdlib.h>
6 #include <string.h>
7 #include <fcntl.h>
8 #include <unistd.h>
9 #include "msdos.h"
10 #include "ldt.h"
11 #include "miscemu.h"
12 #include "drive.h"
13 #include "debugtools.h"
14
15 DEFAULT_DEBUG_CHANNEL(int)
16
17
18 /**********************************************************************
19  *          INT_Int25Handler
20  *
21  * Handler for int 25h (absolute disk read).
22  */
23 void WINAPI INT_Int25Handler( CONTEXT86 *context )
24 {
25     BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EBX_reg(context) );
26     DWORD begin, length;
27
28     if (!DRIVE_IsValid(AL_reg(context)))
29     {
30         SET_CFLAG(context);
31         AX_reg(context) = 0x0201;        /* unknown unit */
32         return;
33     }
34
35     if (CX_reg(context) == 0xffff)
36     {
37         begin   = *(DWORD *)dataptr;
38         length  = *(WORD *)(dataptr + 4);
39         dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context,
40                                         *(WORD *)(dataptr + 8), *(DWORD *)(dataptr + 6) );
41     }
42     else
43     {
44         begin  = DX_reg(context);
45         length = CX_reg(context);
46     }
47     TRACE("int25: abs diskread, drive %d, sector %ld, "
48                  "count %ld, buffer %p\n",
49                  AL_reg(context), begin, length, dataptr);
50
51         DRIVE_RawRead(AL_reg(context), begin, length, dataptr, TRUE);
52     RESET_CFLAG(context);
53 }
54