Add stub for ShellDDEInit to let Windows explorer.exe get past the
[wine] / dlls / winedos / int25.c
1 /*
2  * DOS interrupt 25h handler
3  *
4  * Copyright 1997 Andreas Mohr
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22
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"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(int);
34
35
36 /***********************************************************************
37  *           DOSVM_RawRead
38  *
39  * Read raw sectors from a device.
40  */
41 BOOL DOSVM_RawRead(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL fake_success)
42 {    
43     WCHAR root[] = {'\\','\\','.','\\','A',':',0};
44     HANDLE h;
45
46     root[4] += drive;
47     h = CreateFileW(root, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
48                     FILE_FLAG_BACKUP_SEMANTICS, NULL);
49     if (h != INVALID_HANDLE_VALUE)
50     {
51         SetFilePointer(h, begin * 512, NULL, SEEK_SET );
52         /* FIXME: check errors */
53         ReadFile(h, dataptr, nr_sect * 512, NULL, NULL );
54         CloseHandle(h);
55     }
56     else
57     {
58         if (h != INVALID_HANDLE_VALUE) CloseHandle(h);
59         memset( dataptr, 0, nr_sect * 512 );
60         if (fake_success)
61         {
62             /* FIXME: explain what happens here */
63             if (begin == 0 && nr_sect > 1) *(dataptr + 512) = 0xf8;
64             if (begin == 1) *dataptr = 0xf8;
65         }
66         else
67             return FALSE;
68     }
69
70     return TRUE;
71 }
72
73
74 /**********************************************************************
75  *          DOSVM_Int25Handler (WINEDOS16.137)
76  *
77  * Handler for int 25h (absolute disk read).
78  */
79 void WINAPI DOSVM_Int25Handler( CONTEXT86 *context )
80 {
81     WCHAR drivespec[4] = {'A', ':', '\\', 0};
82     BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Ebx );
83     DWORD begin;
84     DWORD length;
85
86     drivespec[0] += AL_reg( context );
87
88     if (GetDriveTypeW( drivespec ) == DRIVE_NO_ROOT_DIR || 
89         GetDriveTypeW( drivespec ) == DRIVE_UNKNOWN)
90     {
91         SET_CFLAG( context );
92         SET_AX( context, 0x0201 ); /* unknown unit */
93         return;
94     }
95
96     if (CX_reg( context ) == 0xffff)
97     {
98         begin   = *(DWORD *)dataptr;
99         length  = *(WORD *)(dataptr + 4);
100         dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context,
101                                               *(WORD *)(dataptr + 8), 
102                                               *(DWORD *)(dataptr + 6) );
103     }
104     else
105     {
106         begin  = DX_reg( context );
107         length = CX_reg( context );
108     }
109
110     TRACE( "abs diskread, drive %d, sector %ld, "
111            "count %ld, buffer %p\n",
112            AL_reg( context ), begin, length, dataptr );
113
114     DOSVM_RawRead( AL_reg( context ), begin, length, dataptr, TRUE );
115     RESET_CFLAG( context );
116 }