Restored MakeCriticalSectionGlobal that got lost somewhere.
[wine/wine64.git] / msdos / int13.c
blob76c6f06c4fb55e940af71fa4ec6a28f317924732
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 <stdlib.h>
22 #include <sys/types.h>
23 #include <unistd.h>
25 #include "winbase.h"
26 #include "winioctl.h"
27 #include "miscemu.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(int);
32 static void DIOCRegs_2_CONTEXT( DIOC_REGISTERS *pIn, CONTEXT86 *pCxt )
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 */
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;
46 /* FIXME: Only partial CONTEXT86_CONTROL */
47 pCxt->EFlags = pIn->reg_Flags;
50 static void CONTEXT_2_DIOCRegs( CONTEXT86 *pCxt, DIOC_REGISTERS *pOut )
52 memset( pOut, 0, sizeof(DIOC_REGISTERS) );
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;
61 /* FIXME: Only partial CONTEXT86_CONTROL */
62 pOut->reg_Flags = pCxt->EFlags;
65 /**********************************************************************
66 * INT_Int13Handler (WPROCS.119)
68 * Handler for int 13h (disk I/O).
70 void WINAPI INT_Int13Handler( CONTEXT86 *context )
72 HANDLE hVWin32;
73 DIOC_REGISTERS regs;
74 DWORD dwRet;
76 hVWin32 = CreateFileA("\\\\.\\VWIN32", GENERIC_READ|GENERIC_WRITE,
77 0, NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, 0);
79 if(hVWin32!=INVALID_HANDLE_VALUE)
81 CONTEXT_2_DIOCRegs( context, &regs);
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);
89 CloseHandle(hVWin32);
91 else
93 ERR("Failed to open device VWIN32\n");
94 SET_CFLAG(context);