mountmgr: Add a Wine-specific ioctl to define a drive for a Unix path.
[wine/multimedia.git] / dlls / winedos / int25.c
bloba0e5b10408b7a86571354e1455e96fbfc046f9b5
1 /*
2 * DOS interrupt 25h 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 "config.h"
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 #include <fcntl.h>
27 #ifdef HAVE_UNISTD_H
28 # include <unistd.h>
29 #endif
30 #include "dosexe.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(int);
36 /***********************************************************************
37 * DOSVM_RawRead
39 * Read raw sectors from a device.
41 BOOL DOSVM_RawRead(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL fake_success)
43 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
44 HANDLE h;
46 TRACE( "abs diskread, drive %d, sector %d, "
47 "count %d, buffer %p\n",
48 drive, begin, nr_sect, dataptr );
50 root[4] += drive;
51 h = CreateFileW(root, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
52 FILE_FLAG_BACKUP_SEMANTICS, NULL);
53 if (h != INVALID_HANDLE_VALUE)
55 DWORD r;
56 SetFilePointer(h, begin * 512, NULL, SEEK_SET );
57 /* FIXME: check errors */
58 ReadFile(h, dataptr, nr_sect * 512, &r, NULL );
59 CloseHandle(h);
61 else
63 memset( dataptr, 0, nr_sect * 512 );
64 if (fake_success)
66 /* FIXME: explain what happens here */
67 if (begin == 0 && nr_sect > 1) *(dataptr + 512) = 0xf8;
68 if (begin == 1) *dataptr = 0xf8;
70 else
71 return FALSE;
74 return TRUE;
78 /**********************************************************************
79 * DOSVM_Int25Handler (WINEDOS16.137)
81 * Handler for int 25h (absolute disk read).
83 void WINAPI DOSVM_Int25Handler( CONTEXT86 *context )
85 WCHAR drivespec[4] = {'A', ':', '\\', 0};
86 BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Ebx );
87 DWORD begin;
88 DWORD length;
90 drivespec[0] += AL_reg( context );
92 if (GetDriveTypeW( drivespec ) == DRIVE_NO_ROOT_DIR ||
93 GetDriveTypeW( drivespec ) == DRIVE_UNKNOWN)
95 SET_CFLAG( context );
96 SET_AX( context, 0x0201 ); /* unknown unit */
97 return;
100 if (CX_reg( context ) == 0xffff)
102 begin = *(DWORD *)dataptr;
103 length = *(WORD *)(dataptr + 4);
104 dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context,
105 *(WORD *)(dataptr + 8),
106 *(DWORD *)(dataptr + 6) );
108 else
110 begin = DX_reg( context );
111 length = CX_reg( context );
114 DOSVM_RawRead( AL_reg( context ), begin, length, dataptr, TRUE );
115 RESET_CFLAG( context );