2002-11-27 20:18:50 +00:00
|
|
|
/*
|
|
|
|
* DOS interrupt 26h handler
|
|
|
|
*
|
|
|
|
* Copyright 1997 Andreas Mohr
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-11-27 20:18:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2003-11-27 00:59:36 +00:00
|
|
|
#include <stdio.h>
|
2002-11-27 20:18:50 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2003-11-15 00:13:20 +00:00
|
|
|
#include "dosexe.h"
|
2002-11-27 20:18:50 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(int);
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DOSVM_RawWrite
|
|
|
|
*
|
|
|
|
* Write raw sectors to a device.
|
|
|
|
*/
|
|
|
|
BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL fake_success)
|
|
|
|
{
|
2003-11-25 01:51:07 +00:00
|
|
|
WCHAR root[] = {'\\','\\','.','\\','A',':',0};
|
|
|
|
HANDLE h;
|
2004-12-22 18:38:31 +00:00
|
|
|
DWORD w;
|
2002-11-27 20:18:50 +00:00
|
|
|
|
2006-10-03 12:04:49 +00:00
|
|
|
TRACE( "abs diskwrite, drive %d, sector %d, "
|
|
|
|
"count %d, buffer %p\n",
|
2004-09-07 20:26:58 +00:00
|
|
|
drive, begin, nr_sect, dataptr );
|
|
|
|
|
2003-11-25 01:51:07 +00:00
|
|
|
root[4] += drive;
|
|
|
|
h = CreateFileW(root, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
|
|
|
0, NULL);
|
|
|
|
if (h != INVALID_HANDLE_VALUE)
|
2002-11-27 20:18:50 +00:00
|
|
|
{
|
2003-11-25 01:51:07 +00:00
|
|
|
SetFilePointer(h, begin * 512, NULL, SEEK_SET );
|
2002-11-27 20:18:50 +00:00
|
|
|
/* FIXME: check errors */
|
2004-12-22 18:38:31 +00:00
|
|
|
WriteFile( h, dataptr, nr_sect * 512, &w, NULL );
|
2003-11-25 01:51:07 +00:00
|
|
|
CloseHandle( h );
|
2002-11-27 20:18:50 +00:00
|
|
|
}
|
|
|
|
else if (!fake_success)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2010-01-04 15:29:19 +00:00
|
|
|
* DOSVM_Int26Handler
|
2002-11-27 20:18:50 +00:00
|
|
|
*
|
2004-09-07 20:26:58 +00:00
|
|
|
* Handler for int 26h (absolute disk write).
|
2002-11-27 20:18:50 +00:00
|
|
|
*/
|
2010-10-20 13:48:31 +00:00
|
|
|
void WINAPI DOSVM_Int26Handler( CONTEXT *context )
|
2002-11-27 20:18:50 +00:00
|
|
|
{
|
2011-11-21 18:19:48 +00:00
|
|
|
WCHAR drivespec[] = {'A', ':', '\\', 0};
|
2002-11-27 20:18:50 +00:00
|
|
|
BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Ebx );
|
|
|
|
DWORD begin;
|
|
|
|
DWORD length;
|
|
|
|
|
|
|
|
drivespec[0] += AL_reg( context );
|
|
|
|
|
|
|
|
if (GetDriveTypeW( drivespec ) == DRIVE_NO_ROOT_DIR ||
|
|
|
|
GetDriveTypeW( drivespec ) == DRIVE_UNKNOWN)
|
|
|
|
{
|
|
|
|
SET_CFLAG( context );
|
|
|
|
SET_AX( context, 0x0201 ); /* unknown unit */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CX_reg( context ) == 0xffff)
|
|
|
|
{
|
|
|
|
begin = *(DWORD *)dataptr;
|
|
|
|
length = *(WORD *)(dataptr + 4);
|
|
|
|
dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context,
|
|
|
|
*(WORD *)(dataptr + 8),
|
|
|
|
*(DWORD *)(dataptr + 6) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
begin = DX_reg( context );
|
|
|
|
length = CX_reg( context );
|
|
|
|
}
|
|
|
|
|
|
|
|
DOSVM_RawWrite( AL_reg( context ), begin, length, dataptr, TRUE );
|
|
|
|
RESET_CFLAG( context );
|
|
|
|
}
|