include: Add STORAGE_HOTPLUG_INFO structure.
[wine.git] / dlls / krnl386.exe16 / int26.c
blob9d08c1aeb461723a2ee26b360709ec406e14de5e
1 /*
2 * DOS interrupt 26h 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <fcntl.h>
25 #include "dosexe.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(int);
31 /***********************************************************************
32 * DOSVM_RawWrite
34 * Write raw sectors to a device.
36 BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL fake_success)
38 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
39 HANDLE h;
40 DWORD w;
42 TRACE( "abs diskwrite, drive %d, sector %ld, "
43 "count %ld, buffer %p\n",
44 drive, begin, nr_sect, dataptr );
46 root[4] += drive;
47 h = CreateFileW(root, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
48 0, NULL);
49 if (h != INVALID_HANDLE_VALUE)
51 SetFilePointer(h, begin * 512, NULL, SEEK_SET );
52 /* FIXME: check errors */
53 WriteFile( h, dataptr, nr_sect * 512, &w, NULL );
54 CloseHandle( h );
56 else if (!fake_success)
57 return FALSE;
59 return TRUE;
63 /**********************************************************************
64 * DOSVM_Int26Handler
66 * Handler for int 26h (absolute disk write).
68 void WINAPI DOSVM_Int26Handler( CONTEXT *context )
70 WCHAR drivespec[] = {'A', ':', '\\', 0};
71 BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Ebx );
72 DWORD begin;
73 DWORD length;
75 drivespec[0] += AL_reg( context );
77 if (GetDriveTypeW( drivespec ) == DRIVE_NO_ROOT_DIR ||
78 GetDriveTypeW( drivespec ) == DRIVE_UNKNOWN)
80 SET_CFLAG( context );
81 SET_AX( context, 0x0201 ); /* unknown unit */
82 return;
85 if (CX_reg( context ) == 0xffff)
87 begin = *(DWORD *)dataptr;
88 length = *(WORD *)(dataptr + 4);
89 dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context,
90 *(WORD *)(dataptr + 8),
91 *(DWORD *)(dataptr + 6) );
93 else
95 begin = DX_reg( context );
96 length = CX_reg( context );
99 DOSVM_RawWrite( AL_reg( context ), begin, length, dataptr, TRUE );
100 RESET_CFLAG( context );