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
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(int);
31 /***********************************************************************
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};
42 TRACE( "abs diskwrite, drive %d, sector %ld, "
43 "count %ld, buffer %p\n",
44 drive
, begin
, nr_sect
, dataptr
);
47 h
= CreateFileW(root
, GENERIC_WRITE
, FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
,
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
);
56 else if (!fake_success
)
63 /**********************************************************************
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
);
75 drivespec
[0] += AL_reg( context
);
77 if (GetDriveTypeW( drivespec
) == DRIVE_NO_ROOT_DIR
||
78 GetDriveTypeW( drivespec
) == DRIVE_UNKNOWN
)
81 SET_AX( context
, 0x0201 ); /* unknown unit */
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) );
95 begin
= DX_reg( context
);
96 length
= CX_reg( context
);
99 DOSVM_RawWrite( AL_reg( context
), begin
, length
, dataptr
, TRUE
);
100 RESET_CFLAG( context
);