Lines Matching refs:pSession

105 static int                  supdrvMemAdd(PSUPDRVMEMREF pMem, PSUPDRVSESSION pSession);
106 static int supdrvMemRelease(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr, SUPDRVMEMREFTYPE eType);
107 static int supdrvIOCtl_LdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDROPEN pReq);
108 static int supdrvIOCtl_LdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRLOAD pReq);
109 static int supdrvIOCtl_LdrFree(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRFREE pReq);
111 static int supdrvIOCtl_LdrGetSymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRGETSYMBOL pReq);
112 static int supdrvIDC_LdrGetSymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQGETSYM pReq);
115 static int supdrvLdrAddUsage(PSUPDRVSESSION pSession, PSUPDRVLDRIMAGE pImage);
119 static int supdrvIOCtl_CallServiceModule(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPCALLSERVICE pReq);
120 static int supdrvIOCtl_LoggerSettings(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLOGGERSETTINGS pReq);
707 PSUPDRVSESSION pSession;
715 pSession = *ppSession = (PSUPDRVSESSION)RTMemAllocZ(pDevExt->cbSession);
716 if (pSession)
719 rc = RTSpinlockCreate(&pSession->Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "SUPDrvSession");
722 rc = RTHandleTableCreateEx(&pSession->hHandleTable,
724 1 /*uBase*/, 32768 /*cMax*/, supdrvSessionObjHandleRetain, pSession);
727 Assert(pSession->Spinlock != NIL_RTSPINLOCK);
728 pSession->pDevExt = pDevExt;
729 pSession->u32Cookie = BIRD_INV;
730 pSession->fUnrestricted = fUnrestricted;
731 /*pSession->fInHashTable = false; */
732 pSession->cRefs = 1;
733 /*pSession->pCommonNextHash = NULL;
734 pSession->ppOsSessionPtr = NULL; */
737 pSession->Process = RTProcSelf();
738 pSession->R0Process = RTR0ProcHandleSelf();
742 pSession->Process = NIL_RTPROCESS;
743 pSession->R0Process = NIL_RTR0PROCESS;
745 /*pSession->pLdrUsage = NULL;
746 pSession->pVM = NULL;
747 pSession->pUsage = NULL;
748 pSession->pGip = NULL;
749 pSession->fGipReferenced = false;
750 pSession->Bundle.cUsed = 0; */
751 pSession->Uid = NIL_RTUID;
752 pSession->Gid = NIL_RTGID;
753 /*pSession->uTracerData = 0;*/
754 pSession->hTracerCaller = NIL_RTNATIVETHREAD;
755 RTListInit(&pSession->TpProviders);
756 /*pSession->cTpProviders = 0;*/
757 /*pSession->cTpProbesFiring = 0;*/
758 RTListInit(&pSession->TpUmods);
759 /*RT_ZERO(pSession->apTpLookupTable);*/
761 VBOXDRV_SESSION_CREATE(pSession, fUser);
762 LogFlow(("Created session %p initial cookie=%#x\n", pSession, pSession->u32Cookie));
766 RTSpinlockDestroy(pSession->Spinlock);
768 RTMemFree(pSession);
789 * @param pSession Session data.
791 static void supdrvCleanupSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession)
795 LogFlow(("supdrvCleanupSession: pSession=%p\n", pSession));
797 Assert(!pSession->fInHashTable);
798 Assert(!pSession->ppOsSessionPtr);
799 AssertReleaseMsg(pSession->R0Process == RTR0ProcHandleSelf() || pSession->R0Process == NIL_RTR0PROCESS,
805 RTLogSetDefaultInstanceThread(NULL, (uintptr_t)pSession);
810 rc = RTHandleTableDestroy(pSession->hHandleTable, supdrvSessionObjHandleDelete, pSession);
812 pSession->hHandleTable = NIL_RTHANDLETABLE;
819 if (pSession->pUsage)
824 while ((pUsage = pSession->pUsage) != NULL)
827 pSession->pUsage = pUsage->pNext;
867 AssertMsg(!pSession->pUsage, ("Some buster reregistered an object during desturction!\n"));
875 supdrvTracerCleanupSession(pDevExt, pSession);
885 pBundle = &pSession->Bundle;
921 if (pToFree != &pSession->Bundle)
937 if (pCur->pSession == pSession)
948 pCur->pSession = NULL;
971 if (pSession->pLdrUsage)
973 PSUPDRVLDRUSAGE pUsage = pSession->pLdrUsage;
974 pSession->pLdrUsage = NULL;
995 if (pSession->GipMapObjR3 != NIL_RTR0MEMOBJ)
997 SUPR0GipUnmap(pSession);
998 pSession->fGipReferenced = 0;
1008 * @param pSession Session data.
1011 static void supdrvDestroySession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession)
1013 VBOXDRV_SESSION_CLOSE(pSession);
1018 supdrvCleanupSession(pDevExt, pSession);
1019 supdrvOSCleanupSession(pDevExt, pSession);
1024 RTSpinlockDestroy(pSession->Spinlock);
1025 pSession->Spinlock = NIL_RTSPINLOCK;
1026 pSession->pDevExt = NULL;
1027 RTMemFree(pSession);
1042 * @param pSession The session.
1051 int VBOXCALL supdrvSessionHashTabInsert(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVSESSION *ppOsSessionPtr,
1060 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
1061 AssertReturn(pSession->R0Process != NIL_RTR0PROCESS, VERR_INVALID_PARAMETER);
1066 iHash = SUPDRV_SESSION_HASH(pSession->Process);
1077 while (pCur && pCur->Process != pSession->Process)
1083 if (pCur == pSession)
1085 Assert(pSession->fInHashTable);
1089 Assert(!pSession->fInHashTable);
1090 if (pCur->R0Process == pSession->R0Process)
1095 Assert(!pSession->fInHashTable);
1096 Assert(!pSession->ppOsSessionPtr);
1102 pSession->pCommonNextHash = pDevExt->apSessionHashTab[iHash];
1103 pDevExt->apSessionHashTab[iHash] = pSession;
1104 pSession->fInHashTable = true;
1107 pSession->ppOsSessionPtr = ppOsSessionPtr;
1109 ASMAtomicWritePtr(ppOsSessionPtr, pSession);
1111 supdrvOSSessionHashTabInserted(pDevExt, pSession, pvUser);
1116 ASMAtomicIncU32(&pSession->cRefs);
1132 * @param pSession The session. The caller is expected to have a reference
1138 int VBOXCALL supdrvSessionHashTabRemove(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser)
1147 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
1148 AssertReturn(pSession->R0Process != NIL_RTR0PROCESS, VERR_INVALID_PARAMETER);
1153 iHash = SUPDRV_SESSION_HASH(pSession->Process);
1161 if (pCur == pSession)
1162 pDevExt->apSessionHashTab[iHash] = pSession->pCommonNextHash;
1166 while (pCur && pCur != pSession)
1175 Assert(!pSession->fInHashTable);
1181 pSession->pCommonNextHash = NULL;
1182 pSession->fInHashTable = false;
1189 if (pSession->ppOsSessionPtr)
1191 ASMAtomicCmpXchgPtr(pSession->ppOsSessionPtr, NULL, pSession);
1192 pSession->ppOsSessionPtr = NULL;
1195 supdrvOSSessionHashTabRemoved(pDevExt, pSession, pvUser);
1203 cRefs = ASMAtomicDecU32(&pSession->cRefs);
1206 supdrvDestroySession(pDevExt, pSession);
1291 * @param pSession Session data.
1293 uint32_t VBOXCALL supdrvSessionRetain(PSUPDRVSESSION pSession)
1296 AssertPtrReturn(pSession, UINT32_MAX);
1297 AssertReturn(SUP_IS_SESSION_VALID(pSession), UINT32_MAX);
1299 cRefs = ASMAtomicIncU32(&pSession->cRefs);
1300 AssertMsg(cRefs > 1 && cRefs < _1M, ("%#x %p\n", cRefs, pSession));
1309 * @param pSession Session data.
1311 uint32_t VBOXCALL supdrvSessionRelease(PSUPDRVSESSION pSession)
1314 AssertPtrReturn(pSession, UINT32_MAX);
1315 AssertReturn(SUP_IS_SESSION_VALID(pSession), UINT32_MAX);
1317 cRefs = ASMAtomicDecU32(&pSession->cRefs);
1318 AssertMsg(cRefs < _1M, ("%#x %p\n", cRefs, pSession));
1320 supdrvDestroySession(pSession->pDevExt, pSession);
1367 * @param pSession Session data.
1369 int VBOXCALL supdrvIOCtlFast(uintptr_t uIOCtl, VMCPUID idCpu, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession)
1374 if (RT_LIKELY( RT_VALID_PTR(pSession)
1375 && pSession->pVM
1381 pDevExt->pfnVMMR0EntryFast(pSession->pVM, idCpu, SUP_VMMR0_DO_RAW_RUN);
1384 pDevExt->pfnVMMR0EntryFast(pSession->pVM, idCpu, SUP_VMMR0_DO_HM_RUN);
1387 pDevExt->pfnVMMR0EntryFast(pSession->pVM, idCpu, SUP_VMMR0_DO_NOP);
1432 * @param pSession Session data.
1435 static int supdrvIOCtlInnerUnrestricted(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr)
1511 if (!supdrvOSValidateClientProcess(pDevExt, pSession))
1517 pReq->u.Out.pSession = NULL;
1537 pReq->u.Out.pSession = NULL;
1550 pReq->u.Out.u32SessionCookie = pSession->u32Cookie;
1553 pReq->u.Out.pSession = pSession;
1582 pReq->Hdr.rc = SUPR0LockMem(pSession, pReq->u.In.pvR3, pReq->u.In.cPages, &pReq->u.Out.aPages[0]);
1595 pReq->Hdr.rc = SUPR0UnlockMem(pSession, pReq->u.In.pvR3);
1606 pReq->Hdr.rc = SUPR0ContAlloc(pSession, pReq->u.In.cPages, &pReq->u.Out.pvR0, &pReq->u.Out.pvR3, &pReq->u.Out.HCPhys);
1619 pReq->Hdr.rc = SUPR0ContFree(pSession, (RTHCUINTPTR)pReq->u.In.pvR3);
1639 pReq->Hdr.rc = supdrvIOCtl_LdrOpen(pDevExt, pSession, pReq);
1679 pReq->Hdr.rc = supdrvIOCtl_LdrLoad(pDevExt, pSession, pReq);
1690 pReq->Hdr.rc = supdrvIOCtl_LdrFree(pDevExt, pSession, pReq);
1712 pReq->Hdr.rc = supdrvIOCtl_LdrGetSymbol(pDevExt, pSession, pReq);
1729 pReq->Hdr.rc = pDevExt->pfnVMMR0EntryEx(pReq->u.In.pVMR0, pReq->u.In.idCpu, pReq->u.In.uOperation, NULL, pReq->u.In.u64Arg, pSession);
1743 pReq->Hdr.rc = pDevExt->pfnVMMR0EntryEx(pReq->u.In.pVMR0, pReq->u.In.idCpu, pReq->u.In.uOperation, pVMMReq, pReq->u.In.u64Arg, pSession);
1775 pReq->Hdr.rc = pDevExt->pfnVMMR0EntryEx(pReq->u.In.pVMR0, pReq->u.In.idCpu, pReq->u.In.uOperation, pVMMReq, pReq->u.In.u64Arg, pSession);
1810 pReq->Hdr.rc = SUPR0LowAlloc(pSession, pReq->u.In.cPages, &pReq->u.Out.pvR0, &pReq->u.Out.pvR3, &pReq->u.Out.aPages[0]);
1823 pReq->Hdr.rc = SUPR0LowFree(pSession, (RTHCUINTPTR)pReq->u.In.pvR3);
1834 pReq->Hdr.rc = SUPR0GipMap(pSession, &pReq->u.Out.pGipR3, &pReq->u.Out.HCPhysGip);
1847 pReq->Hdr.rc = SUPR0GipUnmap(pSession);
1861 pSession->pVM = pReq->u.In.pVMR0;
1880 pReq->Hdr.rc = SUPR0PageAllocEx(pSession, pReq->u.In.cPages, 0 /* fFlags */,
1900 pReq->Hdr.rc = SUPR0PageMapKernel(pSession, pReq->u.In.pvR3, pReq->u.In.offSub, pReq->u.In.cbSub,
1919 pReq->Hdr.rc = SUPR0PageProtect(pSession, pReq->u.In.pvR3, pReq->u.In.pvR0, pReq->u.In.offSub, pReq->u.In.cbSub, pReq->u.In.fProt);
1930 pReq->Hdr.rc = SUPR0PageFree(pSession, pReq->u.In.pvR3);
1954 pReq->Hdr.rc = supdrvIOCtl_CallServiceModule(pDevExt, pSession, pReq);
1976 pReq->Hdr.rc = supdrvIOCtl_LoggerSettings(pDevExt, pSession, pReq);
1996 pReq->Hdr.rc = SUPSemEventWaitNoResume(pSession, hEvent, pReq->u.In.uArg.cRelMsTimeout);
1999 pReq->Hdr.rc = SUPSemEventWaitNsAbsIntr(pSession, hEvent, pReq->u.In.uArg.uAbsNsTimeout);
2002 pReq->Hdr.rc = SUPSemEventWaitNsRelIntr(pSession, hEvent, pReq->u.In.uArg.cRelNsTimeout);
2005 pReq->Hdr.rc = SUPSemEventSignal(pSession, hEvent);
2008 pReq->Hdr.rc = SUPSemEventClose(pSession, hEvent);
2024 pReq->Hdr.rc = SUPSemEventMultiWaitNoResume(pSession, hEventMulti, pReq->u.In.uArg.cRelMsTimeout);
2027 pReq->Hdr.rc = SUPSemEventMultiWaitNsAbsIntr(pSession, hEventMulti, pReq->u.In.uArg.uAbsNsTimeout);
2030 pReq->Hdr.rc = SUPSemEventMultiWaitNsRelIntr(pSession, hEventMulti, pReq->u.In.uArg.cRelNsTimeout);
2033 pReq->Hdr.rc = SUPSemEventMultiSignal(pSession, hEventMulti);
2036 pReq->Hdr.rc = SUPSemEventMultiClose(pSession, hEventMulti);
2039 pReq->Hdr.rc = SUPSemEventMultiReset(pSession, hEventMulti);
2072 pReq->Hdr.rc = SUPSemEventCreate(pSession, &hEvent);
2079 pReq->u.Out.cNsResolution = SUPSemEventGetResolution(pSession);
2095 pReq->Hdr.rc = SUPSemEventMultiCreate(pSession, &hEventMulti);
2101 pReq->u.Out.cNsResolution = SUPSemEventMultiGetResolution(pSession);
2124 pReq->Hdr.rc = SUPR0QueryVTCaps(pSession, &pReq->u.Out.Caps);
2137 pReq->Hdr.rc = supdrvIOCtl_TracerOpen(pDevExt, pSession, pReq->u.In.uCookie, pReq->u.In.uArg);
2147 pReqHdr->rc = supdrvIOCtl_TracerClose(pDevExt, pSession);
2158 pReqHdr->rc = supdrvIOCtl_TracerIOCtl(pDevExt, pSession, pReq->u.In.uCmd, pReq->u.In.uArg, &pReq->u.Out.iRetVal);
2171 pReqHdr->rc = supdrvIOCtl_TracerUmodRegister(pDevExt, pSession,
2185 pReqHdr->rc = supdrvIOCtl_TracerUmodDeregister(pDevExt, pSession, pReq->u.In.pVtgHdr);
2195 supdrvIOCtl_TracerUmodProbeFire(pDevExt, pSession, &pReq->u.In);
2227 pReqHdr->rc = supdrvIOCtl_TscDeltaMeasure(pDevExt, pSession, pReq);
2237 pReqHdr->rc = supdrvIOCtl_TscRead(pDevExt, pSession, pReq);
2257 * @param pSession Session data.
2260 static int supdrvIOCtlInnerRestricted(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr)
2291 pReq->u.Out.pSession = NULL;
2304 pReq->u.Out.u32SessionCookie = pSession->u32Cookie;
2307 pReq->u.Out.pSession = pSession;
2320 pReq->Hdr.rc = SUPR0QueryVTCaps(pSession, &pReq->u.Out.Caps);
2342 * @param pSession Session data.
2345 int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr, size_t cbReq)
2348 VBOXDRV_IOCTL_ENTRY(pSession, uIOCtl, pReqHdr);
2356 VBOXDRV_IOCTL_RETURN(pSession, uIOCtl, pReqHdr, VERR_INVALID_PARAMETER, VINF_SUCCESS);
2367 VBOXDRV_IOCTL_RETURN(pSession, uIOCtl, pReqHdr, VERR_INVALID_PARAMETER, VINF_SUCCESS);
2370 if (RT_UNLIKELY(!RT_VALID_PTR(pSession)))
2372 OSDBGPRINT(("vboxdrv: Invalid pSession value %p (ioctl=%p)\n", pSession, (void *)uIOCtl));
2373 VBOXDRV_IOCTL_RETURN(pSession, uIOCtl, pReqHdr, VERR_INVALID_PARAMETER, VINF_SUCCESS);
2381 VBOXDRV_IOCTL_RETURN(pSession, uIOCtl, pReqHdr, VERR_INVALID_PARAMETER, VINF_SUCCESS);
2386 || pReqHdr->u32SessionCookie != pSession->u32Cookie))
2389 VBOXDRV_IOCTL_RETURN(pSession, uIOCtl, pReqHdr, VERR_INVALID_PARAMETER, VINF_SUCCESS);
2396 if (pSession->fUnrestricted)
2397 rc = supdrvIOCtlInnerUnrestricted(uIOCtl, pDevExt, pSession, pReqHdr);
2399 rc = supdrvIOCtlInnerRestricted(uIOCtl, pDevExt, pSession, pReqHdr);
2401 VBOXDRV_IOCTL_RETURN(pSession, uIOCtl, pReqHdr, pReqHdr->rc, rc);
2416 * @param pSession Session data.
2419 int VBOXCALL supdrvIDC(uintptr_t uReq, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQHDR pReqHdr)
2422 * The OS specific code has already validated the pSession
2426 * So, just check that pSession is a kernel context session.
2428 if (RT_UNLIKELY( pSession
2429 && pSession->R0Process != NIL_RTR0PROCESS))
2455 if (pReq->Hdr.pSession != NULL)
2457 OSDBGPRINT(("SUPDRV_IDC_REQ_CONNECT: Hdr.pSession=%p expected NULL!\n", pReq->Hdr.pSession));
2473 if (pSession != NULL)
2475 OSDBGPRINT(("SUPDRV_IDC_REQ_CONNECT: pSession=%p expected NULL!\n", pSession));
2488 pReq->u.Out.pSession = NULL;
2496 pReq->u.Out.pSession = NULL;
2501 pReq->Hdr.rc = supdrvCreateSession(pDevExt, false /* fUser */, true /*fUnrestricted*/, &pSession);
2508 pReq->u.Out.pSession = pSession;
2509 pReq->Hdr.pSession = pSession;
2518 supdrvSessionRelease(pSession);
2527 pReq->Hdr.rc = supdrvIDC_LdrGetSymbol(pDevExt, pSession, pReq);
2536 pReq->Hdr.rc = SUPR0ComponentRegisterFactory(pSession, pReq->u.In.pFactory);
2545 pReq->Hdr.rc = SUPR0ComponentDeregisterFactory(pSession, pReq->u.In.pFactory);
2570 SUPR0DECL(void *) SUPR0ObjRegister(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2)
2572 PSUPDRVDEVEXT pDevExt = pSession->pDevExt;
2579 AssertReturn(SUP_IS_SESSION_VALID(pSession), NULL);
2596 pObj->CreatorUid = pSession->Uid;
2597 pObj->CreatorGid = pSession->Gid;
2598 pObj->CreatorProcess= pSession->Process;
2599 supdrvOSObjInitCreator(pObj, pSession);
2632 pUsage->pNext = pSession->pUsage;
2634 pSession->pUsage = pUsage;
2649 * @param pSession The session which is referencing the object.
2655 SUPR0DECL(int) SUPR0ObjAddRef(void *pvObj, PSUPDRVSESSION pSession)
2657 return SUPR0ObjAddRefEx(pvObj, pSession, false /* fNoBlocking */);
2671 * @param pSession The session which is referencing the object.
2680 SUPR0DECL(int) SUPR0ObjAddRefEx(void *pvObj, PSUPDRVSESSION pSession, bool fNoBlocking)
2682 PSUPDRVDEVEXT pDevExt = pSession->pDevExt;
2693 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
2740 for (pUsage = pSession->pUsage; pUsage; pUsage = pUsage->pNext)
2753 pUsagePre->pNext = pSession->pUsage;
2754 pSession->pUsage = pUsagePre;
2792 * @param pSession The session which is referencing the object.
2794 SUPR0DECL(int) SUPR0ObjRelease(void *pvObj, PSUPDRVSESSION pSession)
2796 PSUPDRVDEVEXT pDevExt = pSession->pDevExt;
2805 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
2815 for (pUsagePrev = NULL, pUsage = pSession->pUsage;
2837 pSession->pUsage = pUsage->pNext;
2898 * @param pSession The session which wishes to access the object.
2904 SUPR0DECL(int) SUPR0ObjVerifyAccess(void *pvObj, PSUPDRVSESSION pSession, const char *pszObjName)
2912 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
2921 if (supdrvOSObjCanAccess(pObj, pSession, pszObjName, &rc))
2928 if (pObj->CreatorUid == pSession->Uid)
2938 * @param pSession Session to which the locked memory should be associated.
2944 SUPR0DECL(int) SUPR0LockMem(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t cPages, PRTHCPHYS paPages)
2949 LogFlow(("SUPR0LockMem: pSession=%p pvR3=%p cPages=%d paPages=%p\n", pSession, (void *)pvR3, cPages, paPages));
2954 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
2985 rc = supdrvMemAdd(&Mem, pSession);
3001 * @param pSession Session to which the memory was locked.
3004 SUPR0DECL(int) SUPR0UnlockMem(PSUPDRVSESSION pSession, RTR3PTR pvR3)
3006 LogFlow(("SUPR0UnlockMem: pSession=%p pvR3=%p\n", pSession, (void *)pvR3));
3007 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
3008 return supdrvMemRelease(pSession, (RTHCUINTPTR)pvR3, MEMREF_TYPE_LOCKED);
3017 * @param pSession Session data.
3023 SUPR0DECL(int) SUPR0ContAlloc(PSUPDRVSESSION pSession, uint32_t cPages, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys)
3027 LogFlow(("SUPR0ContAlloc: pSession=%p cPages=%d ppvR0=%p ppvR3=%p pHCPhys=%p\n", pSession, cPages, ppvR0, ppvR3, pHCPhys));
3032 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
3035 Log(("Null pointer. All of these should be set: pSession=%p ppvR0=%p ppvR3=%p pHCPhys=%p\n",
3036 pSession, ppvR0, ppvR3, pHCPhys));
3058 rc = supdrvMemAdd(&Mem, pSession);
3082 * @param pSession The session to which the memory was allocated.
3085 SUPR0DECL(int) SUPR0ContFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr)
3087 LogFlow(("SUPR0ContFree: pSession=%p uPtr=%p\n", pSession, (void *)uPtr));
3088 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
3089 return supdrvMemRelease(pSession, uPtr, MEMREF_TYPE_CONT);
3099 * @param pSession Session data.
3105 SUPR0DECL(int) SUPR0LowAlloc(PSUPDRVSESSION pSession, uint32_t cPages, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS paPages)
3110 LogFlow(("SUPR0LowAlloc: pSession=%p cPages=%d ppvR3=%p ppvR0=%p paPages=%p\n", pSession, cPages, ppvR3, ppvR0, paPages));
3115 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
3118 Log(("Null pointer. All of these should be set: pSession=%p ppvR3=%p ppvR0=%p paPages=%p\n",
3119 pSession, ppvR3, ppvR0, paPages));
3141 rc = supdrvMemAdd(&Mem, pSession);
3170 * @param pSession The session to which the memory was allocated.
3173 SUPR0DECL(int) SUPR0LowFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr)
3175 LogFlow(("SUPR0LowFree: pSession=%p uPtr=%p\n", pSession, (void *)uPtr));
3176 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
3177 return supdrvMemRelease(pSession, uPtr, MEMREF_TYPE_LOW);
3187 * @param pSession The session to associated the allocation with.
3192 SUPR0DECL(int) SUPR0MemAlloc(PSUPDRVSESSION pSession, uint32_t cb, PRTR0PTR ppvR0, PRTR3PTR ppvR3)
3196 LogFlow(("SUPR0MemAlloc: pSession=%p cb=%d ppvR0=%p ppvR3=%p\n", pSession, cb, ppvR0, ppvR3));
3201 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
3222 rc = supdrvMemAdd(&Mem, pSession);
3246 * @param pSession The session to which the memory was allocated.
3250 SUPR0DECL(int) SUPR0MemGetPhys(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr, PSUPPAGE paPages) /** @todo switch this bugger to RTHCPHYS */
3253 LogFlow(("SUPR0MemGetPhys: pSession=%p uPtr=%p paPages=%p\n", pSession, (void *)uPtr, paPages));
3258 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
3265 RTSpinlockAcquire(pSession->Spinlock);
3266 for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext)
3288 RTSpinlockRelease(pSession->Spinlock);
3294 RTSpinlockRelease(pSession->Spinlock);
3304 * @param pSession The session owning the allocation.
3307 SUPR0DECL(int) SUPR0MemFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr)
3309 LogFlow(("SUPR0MemFree: pSession=%p uPtr=%p\n", pSession, (void *)uPtr));
3310 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
3311 return supdrvMemRelease(pSession, uPtr, MEMREF_TYPE_MEM);
3322 * @param pSession The session to associated the allocation with.
3331 SUPR0DECL(int) SUPR0PageAllocEx(PSUPDRVSESSION pSession, uint32_t cPages, uint32_t fFlags, PRTR3PTR ppvR3, PRTR0PTR ppvR0, PRTHCPHYS paPages)
3335 LogFlow(("SUPR0PageAlloc: pSession=%p cb=%d ppvR3=%p\n", pSession, cPages, ppvR3));
3340 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
3369 rc = supdrvMemAdd(&Mem, pSession);
3404 * @param pSession The session to associated the allocation with.
3412 SUPR0DECL(int) SUPR0PageMapKernel(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t offSub, uint32_t cbSub,
3418 LogFlow(("SUPR0PageMapKernel: pSession=%p pvR3=%p offSub=%#x cbSub=%#x\n", pSession, pvR3, offSub, cbSub));
3423 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
3433 RTSpinlockAcquire(pSession->Spinlock);
3434 for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext)
3456 RTSpinlockRelease(pSession->Spinlock);
3489 * @param pSession The session to associated the allocation with.
3498 SUPR0DECL(int) SUPR0PageProtect(PSUPDRVSESSION pSession, RTR3PTR pvR3, RTR0PTR pvR0, uint32_t offSub, uint32_t cbSub, uint32_t fProt)
3504 LogFlow(("SUPR0PageProtect: pSession=%p pvR3=%p pvR0=%p offSub=%#x cbSub=%#x fProt-%#x\n", pSession, pvR3, pvR0, offSub, cbSub, fProt));
3509 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
3518 RTSpinlockAcquire(pSession->Spinlock);
3519 for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext)
3544 RTSpinlockRelease(pSession->Spinlock);
3577 * @param pSession The session owning the allocation.
3581 SUPR0DECL(int) SUPR0PageFree(PSUPDRVSESSION pSession, RTR3PTR pvR3)
3583 LogFlow(("SUPR0PageFree: pSession=%p pvR3=%p\n", pSession, (void *)pvR3));
3584 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
3585 return supdrvMemRelease(pSession, (RTHCUINTPTR)pvR3, MEMREF_TYPE_PAGE);
3899 * @param pSession The session handle.
3902 SUPR0DECL(int) SUPR0QueryVTCaps(PSUPDRVSESSION pSession, uint32_t *pfCaps)
3911 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
4008 * @param pSession The SUPDRV session (must be a ring-0 session).
4013 SUPR0DECL(int) SUPR0ComponentRegisterFactory(PSUPDRVSESSION pSession, PCSUPDRVFACTORY pFactory)
4022 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
4023 AssertReturn(pSession->R0Process == NIL_RTR0PROCESS, VERR_ACCESS_DENIED);
4037 pNewReg->pSession = pSession;
4043 rc = RTSemFastMutexRequest(pSession->pDevExt->mtxComponentFactory);
4047 PSUPDRVFACTORYREG pCur = pSession->pDevExt->pComponentFactoryHead;
4058 pSession->pDevExt->pComponentFactoryHead = pNewReg;
4064 RTSemFastMutexRelease(pSession->pDevExt->mtxComponentFactory);
4086 * @param pSession The SUPDRV session (must be a ring-0 session).
4092 SUPR0DECL(int) SUPR0ComponentDeregisterFactory(PSUPDRVSESSION pSession, PCSUPDRVFACTORY pFactory)
4099 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
4100 AssertReturn(pSession->R0Process == NIL_RTR0PROCESS, VERR_ACCESS_DENIED);
4106 rc = RTSemFastMutexRequest(pSession->pDevExt->mtxComponentFactory);
4110 PSUPDRVFACTORYREG pCur = pSession->pDevExt->pComponentFactoryHead;
4119 pSession->pDevExt->pComponentFactoryHead = pCur->pNext;
4125 pCur->pSession = NULL;
4131 RTSemFastMutexRelease(pSession->pDevExt->mtxComponentFactory);
4148 * @param pSession The SUPDRV session.
4153 SUPR0DECL(int) SUPR0ComponentQueryFactory(PSUPDRVSESSION pSession, const char *pszName, const char *pszInterfaceUuid, void **ppvFactoryIf)
4162 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
4179 rc = RTSemFastMutexRequest(pSession->pDevExt->mtxComponentFactory);
4182 PSUPDRVFACTORYREG pCur = pSession->pDevExt->pComponentFactoryHead;
4189 void *pvFactory = pCur->pFactory->pfnQueryFactoryInterface(pCur->pFactory, pSession, pszInterfaceUuid);
4203 RTSemFastMutexRelease(pSession->pDevExt->mtxComponentFactory);
4215 * @param pSession The session.
4217 static int supdrvMemAdd(PSUPDRVMEMREF pMem, PSUPDRVSESSION pSession)
4224 RTSpinlockAcquire(pSession->Spinlock);
4225 for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext)
4236 RTSpinlockRelease(pSession->Spinlock);
4243 RTSpinlockRelease(pSession->Spinlock);
4258 RTSpinlockAcquire(pSession->Spinlock);
4259 pBundle->pNext = pSession->Bundle.pNext;
4260 pSession->Bundle.pNext = pBundle;
4261 RTSpinlockRelease(pSession->Spinlock);
4271 * @param pSession Session data.
4275 static int supdrvMemRelease(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr, SUPDRVMEMREFTYPE eType)
4291 RTSpinlockAcquire(pSession->Spinlock);
4292 for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext)
4311 RTSpinlockRelease(pSession->Spinlock);
4328 RTSpinlockRelease(pSession->Spinlock);
4342 * @param pSession Session data.
4345 static int supdrvIOCtl_LdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDROPEN pReq)
4369 supdrvLdrAddUsage(pSession, pImage);
4448 supdrvLdrAddUsage(pSession, pImage);
4507 * @param pSession Session data.
4510 static int supdrvIOCtl_LdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRLOAD pReq)
4521 pUsage = pSession->pLdrUsage;
4718 * @param pSession Session data.
4721 static int supdrvIOCtl_LdrFree(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRFREE pReq)
4734 pUsage = pSession->pLdrUsage;
4773 for (pGenUsage = pSession->pUsage; pGenUsage; pGenUsage = pGenUsage->pNext)
4787 pSession->pLdrUsage = pUsage->pNext;
4849 * @param pSession Session data.
4852 static int supdrvIOCtl_LdrGetSymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRGETSYMBOL pReq)
4868 pUsage = pSession->pLdrUsage;
4916 * @param pSession Session data.
4919 static int supdrvIDC_LdrGetSymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQGETSYM pReq)
4986 rc = supdrvLdrAddUsage(pSession, pImage);
5005 * @param pSession Session data.
5067 * @param pSession Session in question.
5070 static int supdrvLdrAddUsage(PSUPDRVSESSION pSession, PSUPDRVLDRIMAGE pImage)
5078 pUsage = pSession->pLdrUsage;
5096 pUsage->pNext = pSession->pLdrUsage;
5097 pSession->pLdrUsage = pUsage;
5229 * @param pSession The calling session.
5232 static int supdrvIOCtl_CallServiceModule(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPCALLSERVICE pReq)
5246 for (pUsage = pSession->pLdrUsage; pUsage; pUsage = pUsage->pNext)
5261 rc = pfnServiceReqHandler(pSession, pReq->u.In.uOperation, pReq->u.In.u64Arg, NULL);
5263 rc = pfnServiceReqHandler(pSession, pReq->u.In.uOperation, pReq->u.In.u64Arg, (PSUPR0SERVICEREQHDR)&pReq->abReqPkt[0]);
5290 * @param pSession The caller's session.
5293 static int supdrvIOCtl_LoggerSettings(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLOGGERSETTINGS pReq)