Changeset 4826 in vbox for trunk/src/VBox/HostDrivers/Support/os2
- Timestamp:
- Sep 15, 2007 2:06:39 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 24533
- 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 33 33 * Header Files * 34 34 *******************************************************************************/ 35 #define __STDC_CONSTANT_MACROS 36 #define __STDC_LIMIT_MACROS 37 35 38 #include <os2ddk/bsekee.h> 36 39 #undef RT_MAX … … 44 47 #include <iprt/assert.h> 45 48 #include <iprt/log.h> 49 #include <iprt/param.h> 46 50 47 51 … … 297 301 298 302 /* 299 * Lock the buffers.303 * Lock the header. 300 304 */ 301 PSUP DRVIOCTLDATA pArgs = (PSUPDRVIOCTLDATA)pvParm;302 AssertReturn(*pcbParm == sizeof(*p Args), VERR_INVALID_PARAMETER);303 KernVMLock_t ParmLock;304 int rc = KernVMLock(VMDHL_WRITE, p vParm, *pcbParm, &ParmLock, (KernPageList_t *)-1, NULL);305 AssertMsgReturn(!rc, ("KernVMLock(VMDHL_WRITE, %p, %#x, &p, NULL, NULL) -> %d\n", p vParm, *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)) 311 315 { 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)) 314 320 { 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; 318 342 } 319 343 } 320 321 KernVMLock_t OutLock; 322 bool fOutLocked = pArgs->pvOut && pArgs->cbOut; 323 if (fOutLocked) 344 else 324 345 { 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; 334 348 } 335 349 336 350 /* 337 * Process the IOCtl.351 * Unlock and return. 338 352 */ 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); 356 354 AssertMsg(!rc2, ("rc2=%d\n", rc2)); 357 355 358 dprintf2(("VBoxDrvIOCtl: returns VINF_SUCCESS /%d\n", rc));359 return VINF_SUCCESS;356 dprintf2(("VBoxDrvIOCtl: returns %d\n", rc)); 357 return rc; 360 358 } 361 359 return VERR_NOT_SUPPORTED; -
trunk/src/VBox/HostDrivers/Support/os2/SUPLib-os2.cpp
r4811 r4826 1 /* $Id$ */ 1 2 /** @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. 5 4 */ 6 5 … … 137 136 ULONG cbReturned = sizeof(SUPREQHDR); 138 137 int rc = DosDevIOCtl(g_hDevice, SUP_CTL_CATEGORY, uFunction, 139 &cb In, cbReturned, &cbReturned,138 &cbReq, cbReturned, &cbReturned, 140 139 NULL, 0, NULL); 141 140 if (RT_LIKELY(rc == NO_ERROR))
Note:
See TracChangeset
for help on using the changeset viewer.