d3d8: Cleanup the pixelshader handling code a bit.
[wine] / dlls / ifsmgr.vxd / ifsmgr.c
1 /*
2  * IFSMGR VxD implementation
3  *
4  * Copyright 1998 Marcus Meissner
5  * Copyright 1998 Ulrich Weigand
6  * Copyright 1998 Patrik Stridvall
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 /* NOTES
24  *   These ioctls are used by 'MSNET32.DLL'.
25  *
26  *   I have been unable to uncover any documentation about the ioctls so
27  *   the implementation of the cases IFS_IOCTL_21 and IFS_IOCTL_2F are
28  *   based on reasonable guesses on information found in the Windows 95 DDK.
29  */
30
31 #include <stdarg.h>
32
33 #include "windef.h"
34 #include "winbase.h"
35 #include "wine/debug.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(vxd);
38
39 /*
40  * IFSMgr DeviceIO service
41  */
42
43 #define IFS_IOCTL_21                100
44 #define IFS_IOCTL_2F                101
45 #define IFS_IOCTL_GET_RES           102
46 #define IFS_IOCTL_GET_NETPRO_NAME_A 103
47
48 struct win32apireq {
49         unsigned long   ar_proid;
50         unsigned long   ar_eax;
51         unsigned long   ar_ebx;
52         unsigned long   ar_ecx;
53         unsigned long   ar_edx;
54         unsigned long   ar_esi;
55         unsigned long   ar_edi;
56         unsigned long   ar_ebp;
57         unsigned short  ar_error;
58         unsigned short  ar_pad;
59 };
60
61 static void win32apieq_2_CONTEXT(const struct win32apireq *pIn, CONTEXT86 *pCxt)
62 {
63         memset(pCxt,0,sizeof(*pCxt));
64
65         pCxt->ContextFlags=CONTEXT86_INTEGER|CONTEXT86_CONTROL;
66         pCxt->Eax = pIn->ar_eax;
67         pCxt->Ebx = pIn->ar_ebx;
68         pCxt->Ecx = pIn->ar_ecx;
69         pCxt->Edx = pIn->ar_edx;
70         pCxt->Esi = pIn->ar_esi;
71         pCxt->Edi = pIn->ar_edi;
72
73         /* FIXME: Only partial CONTEXT86_CONTROL */
74         pCxt->Ebp = pIn->ar_ebp;
75
76         /* FIXME: pIn->ar_proid ignored */
77         /* FIXME: pIn->ar_error ignored */
78         /* FIXME: pIn->ar_pad ignored */
79 }
80
81 static void CONTEXT_2_win32apieq(const CONTEXT86 *pCxt, struct win32apireq *pOut)
82 {
83         memset(pOut,0,sizeof(struct win32apireq));
84
85         pOut->ar_eax = pCxt->Eax;
86         pOut->ar_ebx = pCxt->Ebx;
87         pOut->ar_ecx = pCxt->Ecx;
88         pOut->ar_edx = pCxt->Edx;
89         pOut->ar_esi = pCxt->Esi;
90         pOut->ar_edi = pCxt->Edi;
91
92         /* FIXME: Only partial CONTEXT86_CONTROL */
93         pOut->ar_ebp = pCxt->Ebp;
94
95         /* FIXME: pOut->ar_proid ignored */
96         /* FIXME: pOut->ar_error ignored */
97         /* FIXME: pOut->ar_pad ignored */
98 }
99
100 typedef void (WINAPI *CallBuiltinHandler)( CONTEXT *context, BYTE intnum );
101
102 static CallBuiltinHandler load_builtin_handler(void)
103 {
104     static CallBuiltinHandler handler;
105     static BOOL init_done;
106
107     if (!init_done)
108     {
109         HMODULE mod = LoadLibraryA( "winedos.dll" );
110         if (mod) handler = (void *)GetProcAddress( mod, "CallBuiltinHandler" );
111         if (!handler) FIXME( "DOS calls not supported\n" );
112         init_done = TRUE;
113     }
114     return handler;
115 }
116
117 /***********************************************************************
118  *           DeviceIoControl   (IFSMGR.VXD.@)
119  */
120 BOOL WINAPI IFSMGR_DeviceIoControl(DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuffer,
121                                   LPVOID lpvOutBuffer, DWORD cbOutBuffer,
122                                   LPDWORD lpcbBytesReturned,
123                                   LPOVERLAPPED lpOverlapped)
124 {
125     TRACE("(%d,%p,%d,%p,%d,%p,%p): stub\n",
126           dwIoControlCode, lpvInBuffer,cbInBuffer, lpvOutBuffer,cbOutBuffer,
127           lpcbBytesReturned, lpOverlapped);
128
129     switch (dwIoControlCode)
130     {
131     case IFS_IOCTL_21:
132     case IFS_IOCTL_2F:
133         {
134             CONTEXT86 cxt;
135             struct win32apireq *pIn=lpvInBuffer;
136             struct win32apireq *pOut=lpvOutBuffer;
137             CallBuiltinHandler handler;
138
139             if (!(handler = load_builtin_handler())) return FALSE;
140
141             TRACE( "Control '%s': "
142                    "proid=0x%08lx, eax=0x%08lx, ebx=0x%08lx, ecx=0x%08lx, "
143                    "edx=0x%08lx, esi=0x%08lx, edi=0x%08lx, ebp=0x%08lx, "
144                    "error=0x%04x, pad=0x%04x\n",
145                    (dwIoControlCode==IFS_IOCTL_21)?"IFS_IOCTL_21":"IFS_IOCTL_2F",
146                    pIn->ar_proid, pIn->ar_eax, pIn->ar_ebx, pIn->ar_ecx,
147                    pIn->ar_edx, pIn->ar_esi, pIn->ar_edi, pIn->ar_ebp,
148                    pIn->ar_error, pIn->ar_pad );
149
150             win32apieq_2_CONTEXT(pIn,&cxt);
151
152             if(dwIoControlCode==IFS_IOCTL_21)
153                 handler( &cxt, 0x21 );
154             else
155                 handler( &cxt, 0x2f );
156
157             CONTEXT_2_win32apieq(&cxt,pOut);
158             return TRUE;
159         }
160     case IFS_IOCTL_GET_RES:
161         FIXME( "Control 'IFS_IOCTL_GET_RES' not implemented\n");
162         return FALSE;
163     case IFS_IOCTL_GET_NETPRO_NAME_A:
164         FIXME( "Control 'IFS_IOCTL_GET_NETPRO_NAME_A' not implemented\n");
165         return FALSE;
166     default:
167         FIXME( "Control %d not implemented\n", dwIoControlCode);
168         return FALSE;
169     }
170 }