VirtualBox

Changeset 10265 in vbox for trunk/src/VBox/HostDrivers


Ignore:
Timestamp:
Jul 5, 2008 12:47:50 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
32871
Message:

Some more IDC code.

Location:
trunk/src/VBox/HostDrivers/Support
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r10263 r10265  
    11621162 * Inter-Driver Communcation (IDC) worker.
    11631163 *
    1164  * @returns 0 on success.
    1165  * @returns VERR_INVALID_PARAMETER if the request is invalid.
     1164 * @returns VBox status code.
     1165 * @retval  VINF_SUCCESS on success.
     1166 * @retval  VERR_NOT_SUPPORTED if the request isn't supported.
     1167 * @retval  VERR_NOT_IMPLEMENTED if during development.
     1168 * @retval  VERR_INVALID_PARAMETER if the request is invalid.
    11661169 *
    11671170 * @param   uReq        The request (function) code.
     
    11721175int VBOXCALL supdrvIDC(uintptr_t uReq, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQHDR pReqHdr)
    11731176{
    1174     return VERR_NOT_IMPLEMENTED;
     1177    /*
     1178     * The OS specific code has already validated the pSession
     1179     * pointer, and the request size being greater or equal to
     1180     * size of the header.
     1181     *
     1182     * So, just check that pSession is a kernel context session.
     1183     */
     1184    if (RT_UNLIKELY(    pSession
     1185                    &&  pSession->R0Process != NIL_RTR0PROCESS))
     1186        return VERR_INVALID_PARAMETER;
     1187
     1188/*
     1189 * Validation macro.
     1190 */
     1191#define REQ_CHECK_IDC_SIZE(Name, cbExpect) \
     1192    do { \
     1193        if (RT_UNLIKELY(pReqHdr->cb != (cbExpect))) \
     1194        { \
     1195            OSDBGPRINT(( #Name ": Invalid input/output sizes. cb=%ld expected %ld.\n", \
     1196                        (long)pReqHdr->cb, (long)(cbExpect))); \
     1197            return pReqHdr->rc = VERR_INVALID_PARAMETER; \
     1198        } \
     1199    } while (0)
     1200
     1201    switch (uReq)
     1202    {
     1203        case SUPDRV_IDC_REQ_CONNECT:
     1204        {
     1205            PSUPDRVIDCREQCONNECT pReq = (PSUPDRVIDCREQCONNECT)pReqHdr;
     1206            REQ_CHECK_IDC_SIZE(SUPDRV_IDC_REQ_CONNECT, sizeof(*pReq));
     1207
     1208            return VERR_NOT_IMPLEMENTED;
     1209        }
     1210
     1211        case SUPDRV_IDC_REQ_DISCONNECT:
     1212        {
     1213            REQ_CHECK_IDC_SIZE(SUPDRV_IDC_REQ_DISCONNECT, sizeof(*pReqHdr));
     1214
     1215            return VERR_NOT_IMPLEMENTED;
     1216        }
     1217
     1218        case SUPDRV_IDC_REQ_GET_SYMBOL:
     1219        {
     1220            PSUPDRVIDCREQGETSYM pReq;
     1221            REQ_CHECK_IDC_SIZE(SUPDRV_IDC_REQ_GET_SYMBOL, sizeof(*pReq));
     1222
     1223            return VERR_NOT_IMPLEMENTED;
     1224        }
     1225
     1226        case SUPDRV_IDC_REQ_COMPONENT_REGISTER_FACTORY:
     1227        {
     1228            PSUPDRVIDCREQCOMPREGFACTORY pReq;
     1229            REQ_CHECK_IDC_SIZE(SUPDRV_IDC_REQ_COMPONENT_REGISTER_FACTORY, sizeof(*pReq));
     1230
     1231            return VERR_NOT_IMPLEMENTED;
     1232        }
     1233
     1234        case SUPDRV_IDC_REQ_COMPONENT_DEREGISTER_FACTORY:
     1235        {
     1236            PSUPDRVIDCREQCOMPDEREGFACTORY pReq;
     1237            REQ_CHECK_IDC_SIZE(SUPDRV_IDC_REQ_COMPONENT_DEREGISTER_FACTORY, sizeof(*pReq));
     1238
     1239            return VERR_NOT_IMPLEMENTED;
     1240        }
     1241
     1242        default:
     1243            Log(("Unknown IDC %#lx\n", (long)uReq));
     1244            break;
     1245    }
     1246
     1247#undef REQ_CHECK_IDC_SIZE
     1248    return VERR_NOT_SUPPORTED;
    11751249}
    11761250
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r10263 r10265  
    541541    /** The process (id) of the session. (Set by the OS part.) */
    542542    RTPROCESS                   Process;
    543     /** Which process this session is associated with. */
     543    /** Which process this session is associated with.
     544     * This is NIL_RTR0PROCESS for kernel sessions and valid for user ones. */
    544545    RTR0PROCESS                 R0Process;
    545546#if defined(RT_OS_OS2)
  • trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp

    r10263 r10265  
    430430             pStack->Parameters.DeviceIoControl.OutputBufferLength, pSession));
    431431
    432     if (pSession)
    433     {
    434         /* Verify that it's a buffered CTL. */
    435         if ((pStack->Parameters.DeviceIoControl.IoControlCode & 0x3) == METHOD_BUFFERED)
     432/** @todo IDC on NT: figure when to create the session and that stuff... */
     433
     434    /* Verify that it's a buffered CTL. */
     435    if ((pStack->Parameters.DeviceIoControl.IoControlCode & 0x3) == METHOD_BUFFERED)
     436    {
     437        /* Verify the pDevExt in the session. */
     438        if (    (   !pSession
     439                 && pStack->Parameters.DeviceIoControl.IoControlCode == SUPDRV_IDC_REQ_CONNECT)
     440            ||  (   VALID_PTR(pSession)
     441                 && pSession->pDevExt == pDevExt))
    436442        {
    437443            /* Verify that the size in the request header is correct. */
     
    465471        }
    466472        else
    467         {
    468             dprintf(("VBoxDrvNtInternalDeviceControl: not buffered request (%#x) - not supported\n",
    469                      pStack->Parameters.DeviceIoControl.IoControlCode));
    470473            rcNt = STATUS_NOT_SUPPORTED;
    471         }
     474    }
     475    else
     476    {
     477        dprintf(("VBoxDrvNtInternalDeviceControl: not buffered request (%#x) - not supported\n",
     478                 pStack->Parameters.DeviceIoControl.IoControlCode));
     479        rcNt = STATUS_NOT_SUPPORTED;
    472480    }
    473481
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette