ifsmgr.c 5.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * IFSMGR VxD implementation
 *
 * Copyright 1998 Marcus Meissner
 * Copyright 1998 Ulrich Weigand
 * Copyright 1998 Patrik Stridvall
 *
 * 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
20
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
 */

/* NOTES
 *   These ioctls are used by 'MSNET32.DLL'.
 *
 *   I have been unable to uncover any documentation about the ioctls so
 *   the implementation of the cases IFS_IOCTL_21 and IFS_IOCTL_2F are
 *   based on reasonable guesses on information found in the Windows 95 DDK.
 */

#include <stdarg.h>

#include "windef.h"
#include "winbase.h"
#include "wine/debug.h"

WINE_DEFAULT_DEBUG_CHANNEL(vxd);

/*
 * IFSMgr DeviceIO service
 */

#define IFS_IOCTL_21                100
#define IFS_IOCTL_2F                101
#define IFS_IOCTL_GET_RES           102
#define IFS_IOCTL_GET_NETPRO_NAME_A 103

struct win32apireq {
        unsigned long   ar_proid;
        unsigned long   ar_eax;
        unsigned long   ar_ebx;
        unsigned long   ar_ecx;
        unsigned long   ar_edx;
        unsigned long   ar_esi;
        unsigned long   ar_edi;
        unsigned long   ar_ebp;
        unsigned short  ar_error;
        unsigned short  ar_pad;
};

61
static void win32apieq_2_CONTEXT(const struct win32apireq *pIn, CONTEXT86 *pCxt)
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
{
        memset(pCxt,0,sizeof(*pCxt));

        pCxt->ContextFlags=CONTEXT86_INTEGER|CONTEXT86_CONTROL;
        pCxt->Eax = pIn->ar_eax;
        pCxt->Ebx = pIn->ar_ebx;
        pCxt->Ecx = pIn->ar_ecx;
        pCxt->Edx = pIn->ar_edx;
        pCxt->Esi = pIn->ar_esi;
        pCxt->Edi = pIn->ar_edi;

        /* FIXME: Only partial CONTEXT86_CONTROL */
        pCxt->Ebp = pIn->ar_ebp;

        /* FIXME: pIn->ar_proid ignored */
        /* FIXME: pIn->ar_error ignored */
        /* FIXME: pIn->ar_pad ignored */
}

81
static void CONTEXT_2_win32apieq(const CONTEXT86 *pCxt, struct win32apireq *pOut)
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
{
        memset(pOut,0,sizeof(struct win32apireq));

        pOut->ar_eax = pCxt->Eax;
        pOut->ar_ebx = pCxt->Ebx;
        pOut->ar_ecx = pCxt->Ecx;
        pOut->ar_edx = pCxt->Edx;
        pOut->ar_esi = pCxt->Esi;
        pOut->ar_edi = pCxt->Edi;

        /* FIXME: Only partial CONTEXT86_CONTROL */
        pOut->ar_ebp = pCxt->Ebp;

        /* FIXME: pOut->ar_proid ignored */
        /* FIXME: pOut->ar_error ignored */
        /* FIXME: pOut->ar_pad ignored */
}

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
typedef void (WINAPI *CallBuiltinHandler)( CONTEXT *context, BYTE intnum );

static CallBuiltinHandler load_builtin_handler(void)
{
    static CallBuiltinHandler handler;
    static BOOL init_done;

    if (!init_done)
    {
        HMODULE mod = LoadLibraryA( "winedos.dll" );
        if (mod) handler = (void *)GetProcAddress( mod, "CallBuiltinHandler" );
        if (!handler) FIXME( "DOS calls not supported\n" );
        init_done = TRUE;
    }
    return handler;
}

117 118 119 120 121 122 123 124
/***********************************************************************
 *           DeviceIoControl   (IFSMGR.VXD.@)
 */
BOOL WINAPI IFSMGR_DeviceIoControl(DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuffer,
                                  LPVOID lpvOutBuffer, DWORD cbOutBuffer,
                                  LPDWORD lpcbBytesReturned,
                                  LPOVERLAPPED lpOverlapped)
{
125
    TRACE("(%d,%p,%d,%p,%d,%p,%p): stub\n",
126 127 128 129 130 131 132 133 134
          dwIoControlCode, lpvInBuffer,cbInBuffer, lpvOutBuffer,cbOutBuffer,
          lpcbBytesReturned, lpOverlapped);

    switch (dwIoControlCode)
    {
    case IFS_IOCTL_21:
    case IFS_IOCTL_2F:
        {
            CONTEXT86 cxt;
135 136
            struct win32apireq *pIn=lpvInBuffer;
            struct win32apireq *pOut=lpvOutBuffer;
137 138 139
            CallBuiltinHandler handler;

            if (!(handler = load_builtin_handler())) return FALSE;
140 141 142 143 144 145 146 147 148 149 150 151 152

            TRACE( "Control '%s': "
                   "proid=0x%08lx, eax=0x%08lx, ebx=0x%08lx, ecx=0x%08lx, "
                   "edx=0x%08lx, esi=0x%08lx, edi=0x%08lx, ebp=0x%08lx, "
                   "error=0x%04x, pad=0x%04x\n",
                   (dwIoControlCode==IFS_IOCTL_21)?"IFS_IOCTL_21":"IFS_IOCTL_2F",
                   pIn->ar_proid, pIn->ar_eax, pIn->ar_ebx, pIn->ar_ecx,
                   pIn->ar_edx, pIn->ar_esi, pIn->ar_edi, pIn->ar_ebp,
                   pIn->ar_error, pIn->ar_pad );

            win32apieq_2_CONTEXT(pIn,&cxt);

            if(dwIoControlCode==IFS_IOCTL_21)
153
                handler( &cxt, 0x21 );
154
            else
155
                handler( &cxt, 0x2f );
156 157 158 159 160 161 162 163 164 165 166

            CONTEXT_2_win32apieq(&cxt,pOut);
            return TRUE;
        }
    case IFS_IOCTL_GET_RES:
        FIXME( "Control 'IFS_IOCTL_GET_RES' not implemented\n");
        return FALSE;
    case IFS_IOCTL_GET_NETPRO_NAME_A:
        FIXME( "Control 'IFS_IOCTL_GET_NETPRO_NAME_A' not implemented\n");
        return FALSE;
    default:
167
        FIXME( "Control %d not implemented\n", dwIoControlCode);
168 169 170
        return FALSE;
    }
}