VirtualBox

Ignore:
Timestamp:
Sep 15, 2007 2:06:39 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
24533
Message:

Made OS/2 build.

Location:
trunk/src/VBox/HostDrivers/Support/os2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp

    r2980 r4826  
    3333*   Header Files                                                               *
    3434*******************************************************************************/
     35#define __STDC_CONSTANT_MACROS
     36#define __STDC_LIMIT_MACROS
     37
    3538#include <os2ddk/bsekee.h>
    3639#undef RT_MAX
     
    4447#include <iprt/assert.h>
    4548#include <iprt/log.h>
     49#include <iprt/param.h>
    4650
    4751
     
    297301
    298302        /*
    299          * Lock the buffers.
     303         * Lock the header.
    300304         */
    301         PSUPDRVIOCTLDATA pArgs = (PSUPDRVIOCTLDATA)pvParm;
    302         AssertReturn(*pcbParm == sizeof(*pArgs), VERR_INVALID_PARAMETER);
    303         KernVMLock_t ParmLock;
    304         int rc = KernVMLock(VMDHL_WRITE, pvParm, *pcbParm, &ParmLock, (KernPageList_t *)-1, NULL);
    305         AssertMsgReturn(!rc, ("KernVMLock(VMDHL_WRITE, %p, %#x, &p, NULL, NULL) -> %d\n", pvParm, *pcbParm, &ParmLock, rc), VERR_LOCK_FAILED);
    306 
    307         /* lock the in and out buffers. */
    308         KernVMLock_t    InLock;
    309         bool            fInLocked = pArgs->pvIn && pArgs->cbIn;
    310         if (fInLocked)
     305        PSUPREQHDR pHdr = (PSUPREQHDR)pvParm;
     306        AssertReturn(*pcbParm == sizeof(*pHdr), VERR_INVALID_PARAMETER);
     307        KernVMLock_t Lock;
     308        int rc = KernVMLock(VMDHL_WRITE, pHdr, *pcbParm, &Lock, (KernPageList_t *)-1, NULL);
     309        AssertMsgReturn(!rc, ("KernVMLock(VMDHL_WRITE, %p, %#x, &p, NULL, NULL) -> %d\n", pHdr, *pcbParm, &Lock, rc), VERR_LOCK_FAILED);
     310
     311        /*
     312         * Validate the header.
     313         */
     314        if (RT_LIKELY((pHdr->fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) == SUPREQHDR_FLAGS_MAGIC))
    311315        {
    312             rc = KernVMLock(VMDHL_WRITE, pArgs->pvIn, pArgs->cbIn, &InLock, (KernPageList_t *)-1, NULL);
    313             if (rc)
     316            uint32_t cbReq = RT_MAX(pHdr->cbIn, pHdr->cbOut);
     317            if (RT_LIKELY(    pHdr->cbIn >= sizeof(*pHdr)
     318                          &&  pHdr->cbOut >= sizeof(*pHdr)
     319                          &&  cbReq <= _1M*16))
    314320            {
    315                 AssertMsgFailed(("KernVMLock(VMDHL_WRITE, %p, %#x, &p, NULL, NULL) -> %d\n", pArgs->pvIn, pArgs->cbIn, &InLock, rc));
    316                 KernVMUnlock(&ParmLock);
    317                 return VERR_LOCK_FAILED;
     321                /*
     322                 * Lock the rest of the buffer if necessary.
     323                 */
     324                if (((uintptr_t)pHdr & PAGE_OFFSET_MASK) + cbReq > PAGE_SIZE)
     325                {
     326                    rc = KernVMUnlock(&Lock);
     327                    AssertMsgReturn(!rc, ("KernVMUnlock(Lock) -> %#x\n", rc), VERR_LOCK_FAILED);
     328
     329                    rc = KernVMLock(VMDHL_WRITE, pHdr, cbReq, &Lock, (KernPageList_t *)-1, NULL);
     330                    AssertMsgReturn(!rc, ("KernVMLock(VMDHL_WRITE, %p, %#x, &p, NULL, NULL) -> %d\n", pHdr, cbReq, &Lock, rc), VERR_LOCK_FAILED);
     331                }
     332
     333                /*
     334                 * Process the IOCtl.
     335                 */
     336                rc = supdrvIOCtl(iFunction, &g_DevExt, pSession, pHdr);
     337            }
     338            else
     339            {
     340                OSDBGPRINT(("VBoxDrvIOCtl: max(%#x,%#x); iCmd=%#x\n", pHdr->cbIn, pHdr->cbOut, iFunction));
     341                rc = VERR_INVALID_PARAMETER;
    318342            }
    319343        }
    320 
    321         KernVMLock_t    OutLock;
    322         bool            fOutLocked = pArgs->pvOut && pArgs->cbOut;
    323         if (fOutLocked)
     344        else
    324345        {
    325             rc = KernVMLock(VMDHL_WRITE, pArgs->pvOut, pArgs->cbOut, &OutLock, (KernPageList_t *)-1, NULL);
    326             if (rc)
    327             {
    328                 AssertMsgFailed(("KernVMLock(VMDHL_WRITE, %p, %#x, &p, NULL, NULL) -> %d\n", pArgs->pvOut, pArgs->cbOut, &OutLock, rc));
    329                 KernVMUnlock(&ParmLock);
    330                 if (fInLocked)
    331                     KernVMUnlock(&InLock);
    332                 return VERR_LOCK_FAILED;
    333             }
     346            OSDBGPRINT(("VBoxDrvIOCtl: bad magic fFlags=%#x; iCmd=%#x\n", pHdr->fFlags, iFunction));
     347            rc = VERR_INVALID_PARAMETER;
    334348        }
    335349
    336350        /*
    337          * Process the IOCtl.
     351         * Unlock and return.
    338352         */
    339         unsigned cbReturned = 0;
    340         pArgs->rc = rc = supdrvIOCtl(iFunction, &g_DevExt, pSession, pArgs->pvIn, pArgs->cbIn, pArgs->pvOut, pArgs->cbOut, &cbReturned);
    341 
    342         /*
    343          * Unlock the buffers.
    344          */
    345         if (fOutLocked)
    346         {
    347             int rc2 = KernVMUnlock(&OutLock);
    348             AssertMsg(!rc2, ("rc2=%d\n", rc2));
    349         }
    350         if (fInLocked)
    351         {
    352             int rc2 = KernVMUnlock(&InLock);
    353             AssertMsg(!rc2, ("rc2=%d\n", rc2));
    354         }
    355         int rc2 = KernVMUnlock(&ParmLock);
     353        int rc2 = KernVMUnlock(&Lock);
    356354        AssertMsg(!rc2, ("rc2=%d\n", rc2));
    357355
    358         dprintf2(("VBoxDrvIOCtl: returns VINF_SUCCESS / %d\n", rc));
    359         return VINF_SUCCESS;
     356        dprintf2(("VBoxDrvIOCtl: returns %d\n", rc));
     357        return rc;
    360358    }
    361359    return VERR_NOT_SUPPORTED;
  • trunk/src/VBox/HostDrivers/Support/os2/SUPLib-os2.cpp

    r4811 r4826  
     1/* $Id$ */
    12/** @file
    2  *
    3  * VBox host drivers - Ring-0 support drivers - OS/2 host:
    4  * OS/2 implementations for support library
     3 * SUPLib - Support Library, OS/2 backend.
    54 */
    65
     
    137136    ULONG cbReturned = sizeof(SUPREQHDR);
    138137    int rc = DosDevIOCtl(g_hDevice, SUP_CTL_CATEGORY, uFunction,
    139                          &cbIn, cbReturned, &cbReturned,
     138                         &cbReq, cbReturned, &cbReturned,
    140139                         NULL, 0, NULL);
    141140    if (RT_LIKELY(rc == NO_ERROR))
Note: See TracChangeset for help on using the changeset viewer.

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