Tell the user if winedefault.reg is not loaded.
[wine] / msdos / int13.c
1 /*
2  * BIOS interrupt 13h handler
3  *
4  * Copyright 1997 Andreas Mohr
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <stdlib.h>
22 #include <sys/types.h>
23 #include <unistd.h>
24
25 #include "winbase.h"
26 #include "winioctl.h"
27 #include "miscemu.h"
28 #include "wine/debug.h"
29
30 WINE_DEFAULT_DEBUG_CHANNEL(int);
31
32 static void DIOCRegs_2_CONTEXT( DIOC_REGISTERS *pIn, CONTEXT86 *pCxt )
33 {
34     memset( pCxt, 0, sizeof(*pCxt) );
35     /* Note: segment registers == 0 means that CTX_SEG_OFF_TO_LIN
36              will interpret 32-bit register contents as linear pointers */
37
38     pCxt->ContextFlags=CONTEXT86_INTEGER|CONTEXT86_CONTROL;
39     pCxt->Eax = pIn->reg_EAX;
40     pCxt->Ebx = pIn->reg_EBX;
41     pCxt->Ecx = pIn->reg_ECX;
42     pCxt->Edx = pIn->reg_EDX;
43     pCxt->Esi = pIn->reg_ESI;
44     pCxt->Edi = pIn->reg_EDI;
45
46     /* FIXME: Only partial CONTEXT86_CONTROL */
47     pCxt->EFlags = pIn->reg_Flags;
48 }
49
50 static void CONTEXT_2_DIOCRegs( CONTEXT86 *pCxt, DIOC_REGISTERS *pOut )
51 {
52     memset( pOut, 0, sizeof(DIOC_REGISTERS) );
53
54     pOut->reg_EAX = pCxt->Eax;
55     pOut->reg_EBX = pCxt->Ebx;
56     pOut->reg_ECX = pCxt->Ecx;
57     pOut->reg_EDX = pCxt->Edx;
58     pOut->reg_ESI = pCxt->Esi;
59     pOut->reg_EDI = pCxt->Edi;
60
61     /* FIXME: Only partial CONTEXT86_CONTROL */
62     pOut->reg_Flags = pCxt->EFlags;
63 }
64
65 /**********************************************************************
66  *          INT_Int13Handler (WPROCS.119)
67  *
68  * Handler for int 13h (disk I/O).
69  */
70 void WINAPI INT_Int13Handler( CONTEXT86 *context )
71 {
72     HANDLE hVWin32;
73     DIOC_REGISTERS regs;
74     DWORD dwRet;
75
76     hVWin32 = CreateFileA("\\\\.\\VWIN32", GENERIC_READ|GENERIC_WRITE,
77                0, NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, 0);
78
79     if(hVWin32!=INVALID_HANDLE_VALUE)
80     {
81         CONTEXT_2_DIOCRegs( context, &regs);
82
83         if(!DeviceIoControl(hVWin32, VWIN32_DIOC_DOS_INT13,
84                 &regs, sizeof regs, &regs, sizeof regs, &dwRet, NULL))
85             DIOCRegs_2_CONTEXT(&regs, context);
86         else
87             SET_CFLAG(context);
88
89         CloseHandle(hVWin32);
90     }
91     else
92     {
93         ERR("Failed to open device VWIN32\n");
94         SET_CFLAG(context);
95     }
96 }