WS2_register_async_shutdown(): Try immediate completion, in case an
[wine.git] / msdos / int13.c
blobdba23a39de45369f5b3a41e1dcf17239c6583cbd
1 /*
2 * BIOS interrupt 13h handler
4 * Copyright 1997 Andreas Mohr
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.
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.
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
21 #include "config.h"
23 #include <stdlib.h>
24 #include <sys/types.h>
25 #ifdef HAVE_UNISTD_H
26 # include <unistd.h>
27 #endif
29 #include "winbase.h"
30 #include "winioctl.h"
31 #include "miscemu.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(int);
36 static void DIOCRegs_2_CONTEXT( DIOC_REGISTERS *pIn, CONTEXT86 *pCxt )
38 memset( pCxt, 0, sizeof(*pCxt) );
39 /* Note: segment registers == 0 means that CTX_SEG_OFF_TO_LIN
40 will interpret 32-bit register contents as linear pointers */
42 pCxt->ContextFlags=CONTEXT86_INTEGER|CONTEXT86_CONTROL;
43 pCxt->Eax = pIn->reg_EAX;
44 pCxt->Ebx = pIn->reg_EBX;
45 pCxt->Ecx = pIn->reg_ECX;
46 pCxt->Edx = pIn->reg_EDX;
47 pCxt->Esi = pIn->reg_ESI;
48 pCxt->Edi = pIn->reg_EDI;
50 /* FIXME: Only partial CONTEXT86_CONTROL */
51 pCxt->EFlags = pIn->reg_Flags;
54 static void CONTEXT_2_DIOCRegs( CONTEXT86 *pCxt, DIOC_REGISTERS *pOut )
56 memset( pOut, 0, sizeof(DIOC_REGISTERS) );
58 pOut->reg_EAX = pCxt->Eax;
59 pOut->reg_EBX = pCxt->Ebx;
60 pOut->reg_ECX = pCxt->Ecx;
61 pOut->reg_EDX = pCxt->Edx;
62 pOut->reg_ESI = pCxt->Esi;
63 pOut->reg_EDI = pCxt->Edi;
65 /* FIXME: Only partial CONTEXT86_CONTROL */
66 pOut->reg_Flags = pCxt->EFlags;
69 /**********************************************************************
70 * INT_Int13Handler (WPROCS.119)
72 * Handler for int 13h (disk I/O).
74 void WINAPI INT_Int13Handler( CONTEXT86 *context )
76 HANDLE hVWin32;
77 DIOC_REGISTERS regs;
78 DWORD dwRet;
80 hVWin32 = CreateFileA("\\\\.\\VWIN32", GENERIC_READ|GENERIC_WRITE,
81 0, NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, 0);
83 if(hVWin32!=INVALID_HANDLE_VALUE)
85 CONTEXT_2_DIOCRegs( context, &regs);
87 if(!DeviceIoControl(hVWin32, VWIN32_DIOC_DOS_INT13,
88 &regs, sizeof regs, &regs, sizeof regs, &dwRet, NULL))
89 DIOCRegs_2_CONTEXT(&regs, context);
90 else
91 SET_CFLAG(context);
93 CloseHandle(hVWin32);
95 else
97 ERR("Failed to open device VWIN32\n");
98 SET_CFLAG(context);