Changeset 57378 in vbox for trunk/src/VBox/HostDrivers
- Timestamp:
- Aug 17, 2015 11:54:27 AM (9 years ago)
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.cpp
r57358 r57378 141 141 static int supdrvIOCtl_LdrGetSymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRGETSYMBOL pReq); 142 142 static int supdrvIDC_LdrGetSymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQGETSYM pReq); 143 static int supdrvLdrSetVMMR0EPs(PSUPDRVDEVEXT pDevExt, void *pvVMMR0, void *pvVMMR0Entry Int,void *pvVMMR0EntryFast, void *pvVMMR0EntryEx);143 static int supdrvLdrSetVMMR0EPs(PSUPDRVDEVEXT pDevExt, void *pvVMMR0, void *pvVMMR0EntryFast, void *pvVMMR0EntryEx); 144 144 static void supdrvLdrUnsetVMMR0EPs(PSUPDRVDEVEXT pDevExt); 145 145 static int supdrvLdrAddUsage(PSUPDRVSESSION pSession, PSUPDRVLDRIMAGE pImage); … … 4693 4693 4694 4694 /** 4695 * Formats a load error message. 4696 * 4697 * @returns @a rc 4698 * @param rc Return code. 4699 * @param pReq The request. 4700 * @param pszFormat The error message format string. 4701 * @param ... Argument to the format string. 4702 */ 4703 int VBOXCALL supdrvLdrLoadError(int rc, PSUPLDRLOAD pReq, const char *pszFormat, ...) 4704 { 4705 va_list va; 4706 va_start(va, pszFormat); 4707 pReq->u.Out.uErrorMagic = SUPLDRLOAD_ERROR_MAGIC; 4708 RTStrPrintfV(pReq->u.Out.szError, sizeof(pReq->u.Out.szError), pszFormat, va); 4709 va_end(va); 4710 Log(("SUP_IOCTL_LDR_LOAD: %s [rc=%Rrc]\n", pReq->u.Out.szError, rc)); 4711 return rc; 4712 } 4713 4714 4715 /** 4695 4716 * Loads the image bits. 4696 4717 * … … 4723 4744 { 4724 4745 supdrvLdrUnlock(pDevExt); 4725 Log(("SUP_IOCTL_LDR_LOAD: couldn't find image!\n")); 4726 return VERR_INVALID_HANDLE; 4746 return supdrvLdrLoadError(VERR_INVALID_HANDLE, pReq, "Image not found"); 4727 4747 } 4728 4748 pImage = pUsage->pImage; … … 4735 4755 { 4736 4756 supdrvLdrUnlock(pDevExt); 4737 Log(("SUP_IOCTL_LDR_LOAD: image size mismatch!! %d(prep) != %d(load) or %d != %d\n", 4738 pImage->cbImageWithTabs, pReq->u.In.cbImageWithTabs, pImage->cbImageBits, pReq->u.In.cbImageBits)); 4739 return VERR_INVALID_HANDLE; 4757 return supdrvLdrLoadError(VERR_INVALID_HANDLE, pReq, "Image size mismatch found: %d(prep) != %d(load) or %d != %d", 4758 pImage->cbImageWithTabs, pReq->u.In.cbImageWithTabs, pImage->cbImageBits, pReq->u.In.cbImageBits); 4740 4759 } 4741 4760 … … 4746 4765 if (uState != SUP_IOCTL_LDR_LOAD) 4747 4766 AssertMsgFailed(("SUP_IOCTL_LDR_LOAD: invalid image state %d (%#x)!\n", uState, uState)); 4767 pReq->u.Out.uErrorMagic = 0; 4748 4768 return VERR_ALREADY_LOADED; 4749 4769 } … … 4753 4773 { 4754 4774 supdrvLdrUnlock(pDevExt); 4755 Log(("SUP_IOCTL_LDR_LOAD: Not loading '%s' image bits, loader interface is locked down!\n", pImage->szName)); 4756 return VERR_PERMISSION_DENIED; 4775 return supdrvLdrLoadError(VERR_PERMISSION_DENIED, pReq, "Loader is locked down"); 4757 4776 } 4758 4777 … … 4764 4783 case SUPLDRLOADEP_VMMR0: 4765 4784 rc = supdrvLdrValidatePointer( pDevExt, pImage, pReq->u.In.EP.VMMR0.pvVMMR0, false, pReq->u.In.abImage, "pvVMMR0"); 4766 if (RT_SUCCESS(rc))4767 rc = supdrvLdrValidatePointer(pDevExt, pImage, pReq->u.In.EP.VMMR0.pvVMMR0EntryInt, false, pReq->u.In.abImage, "pvVMMR0EntryInt");4768 4785 if (RT_SUCCESS(rc)) 4769 4786 rc = supdrvLdrValidatePointer(pDevExt, pImage, pReq->u.In.EP.VMMR0.pvVMMR0EntryFast, false, pReq->u.In.abImage, "pvVMMR0EntryFast"); … … 4771 4788 rc = supdrvLdrValidatePointer(pDevExt, pImage, pReq->u.In.EP.VMMR0.pvVMMR0EntryEx, false, pReq->u.In.abImage, "pvVMMR0EntryEx"); 4772 4789 if (RT_FAILURE(rc)) 4773 return rc;4790 return supdrvLdrLoadError(rc, pReq, "Invalid VMMR0 pointer"); 4774 4791 break; 4775 4792 … … 4777 4794 rc = supdrvLdrValidatePointer(pDevExt, pImage, pReq->u.In.EP.Service.pfnServiceReq, false, pReq->u.In.abImage, "pfnServiceReq"); 4778 4795 if (RT_FAILURE(rc)) 4779 return rc;4796 return supdrvLdrLoadError(rc, pReq, "Invalid pfnServiceReq pointer: %p", pReq->u.In.EP.Service.pfnServiceReq); 4780 4797 if ( pReq->u.In.EP.Service.apvReserved[0] != NIL_RTR0PTR 4781 4798 || pReq->u.In.EP.Service.apvReserved[1] != NIL_RTR0PTR … … 4783 4800 { 4784 4801 supdrvLdrUnlock(pDevExt); 4785 Log(("Out of range (%p LB %#x): apvReserved={%p,%p,%p} MBZ!\n",4786 pImage->pvImage, pReq->u.In.cbImageWithTabs,4787 pReq->u.In.EP.Service.apvReserved[0],4788 pReq->u.In.EP.Service.apvReserved[1],4789 pReq->u.In.EP.Service.apvReserved[2]));4790 return VERR_INVALID_PARAMETER;4802 return supdrvLdrLoadError(VERR_INVALID_PARAMETER, pReq, 4803 "Out of range (%p LB %#x): apvReserved={%p,%p,%p} MBZ!", 4804 pImage->pvImage, pReq->u.In.cbImageWithTabs, 4805 pReq->u.In.EP.Service.apvReserved[0], 4806 pReq->u.In.EP.Service.apvReserved[1], 4807 pReq->u.In.EP.Service.apvReserved[2]); 4791 4808 } 4792 4809 break; … … 4794 4811 default: 4795 4812 supdrvLdrUnlock(pDevExt); 4796 Log(("Invalid eEPType=%d\n", pReq->u.In.eEPType)); 4797 return VERR_INVALID_PARAMETER; 4813 return supdrvLdrLoadError(VERR_INVALID_PARAMETER, pReq, "Invalid eEPType=%d", pReq->u.In.eEPType); 4798 4814 } 4799 4815 4800 4816 rc = supdrvLdrValidatePointer(pDevExt, pImage, pReq->u.In.pfnModuleInit, true, pReq->u.In.abImage, "pfnModuleInit"); 4801 4817 if (RT_FAILURE(rc)) 4802 return rc;4818 return supdrvLdrLoadError(rc, pReq, "Invalid pfnModuleInit pointer: %p", pReq->u.In.pfnModuleInit); 4803 4819 rc = supdrvLdrValidatePointer(pDevExt, pImage, pReq->u.In.pfnModuleTerm, true, pReq->u.In.abImage, "pfnModuleTerm"); 4804 4820 if (RT_FAILURE(rc)) 4805 return rc;4821 return supdrvLdrLoadError(rc, pReq, "Invalid pfnModuleTerm pointer: %p", pReq->u.In.pfnModuleTerm); 4806 4822 SUPDRV_CHECK_SMAP_CHECK(pDevExt, RT_NOTHING); 4807 4823 … … 4817 4833 memcpy(pImage->pachStrTab, &pReq->u.In.abImage[pReq->u.In.offStrTab], pImage->cbStrTab); 4818 4834 else 4819 rc = /*VERR_NO_MEMORY*/ VERR_INTERNAL_ERROR_3;4835 rc = supdrvLdrLoadError(VERR_NO_MEMORY, pReq, "Out of memory for string table: %#x", pImage->cbStrTab); 4820 4836 SUPDRV_CHECK_SMAP_CHECK(pDevExt, RT_NOTHING); 4821 4837 } … … 4829 4845 memcpy(pImage->paSymbols, &pReq->u.In.abImage[pReq->u.In.offSymbols], cbSymbols); 4830 4846 else 4831 rc = /*VERR_NO_MEMORY*/ VERR_INTERNAL_ERROR_4;4847 rc = supdrvLdrLoadError(VERR_NO_MEMORY, pReq, "Out of memory for symbol table: %#x", cbSymbols); 4832 4848 SUPDRV_CHECK_SMAP_CHECK(pDevExt, RT_NOTHING); 4833 4849 } … … 4864 4880 break; 4865 4881 case SUPLDRLOADEP_VMMR0: 4866 rc = supdrvLdrSetVMMR0EPs(pDevExt, pReq->u.In.EP.VMMR0.pvVMMR0, pReq->u.In.EP.VMMR0.pvVMMR0EntryInt,4882 rc = supdrvLdrSetVMMR0EPs(pDevExt, pReq->u.In.EP.VMMR0.pvVMMR0, 4867 4883 pReq->u.In.EP.VMMR0.pvVMMR0EntryFast, pReq->u.In.EP.VMMR0.pvVMMR0EntryEx); 4868 4884 break; … … 4888 4904 pDevExt->pLdrInitImage = NULL; 4889 4905 pDevExt->hLdrInitThread = NIL_RTNATIVETHREAD; 4890 if (RT_FAILURE(rc) && pDevExt->pvVMMR0 == pImage->pvImage) 4891 supdrvLdrUnsetVMMR0EPs(pDevExt); 4906 if (RT_FAILURE(rc)) 4907 { 4908 if (pDevExt->pvVMMR0 == pImage->pvImage) 4909 supdrvLdrUnsetVMMR0EPs(pDevExt); 4910 supdrvLdrLoadError(rc, pReq, "ModuleInit failed: %Rrc", rc); 4911 } 4892 4912 } 4893 4913 SUPR0Printf("vboxdrv: %p %s\n", pImage->pvImage, pImage->szName); … … 5210 5230 * @param pSession Session data. 5211 5231 * @param pVMMR0 VMMR0 image handle. 5212 * @param pvVMMR0EntryInt VMMR0EntryInt address.5213 5232 * @param pvVMMR0EntryFast VMMR0EntryFast address. 5214 5233 * @param pvVMMR0EntryEx VMMR0EntryEx address. 5215 5234 * @remark Caller must own the loader mutex. 5216 5235 */ 5217 static int supdrvLdrSetVMMR0EPs(PSUPDRVDEVEXT pDevExt, void *pvVMMR0, void *pvVMMR0Entry Int, void *pvVMMR0EntryFast, void *pvVMMR0EntryEx)5236 static int supdrvLdrSetVMMR0EPs(PSUPDRVDEVEXT pDevExt, void *pvVMMR0, void *pvVMMR0EntryFast, void *pvVMMR0EntryEx) 5218 5237 { 5219 5238 int rc = VINF_SUCCESS; 5220 LogFlow(("supdrvLdrSetR0EP pvVMMR0=%p pvVMMR0Entry Int=%p\n", pvVMMR0, pvVMMR0EntryInt));5239 LogFlow(("supdrvLdrSetR0EP pvVMMR0=%p pvVMMR0EntryFast=%p\n", pvVMMR0, pvVMMR0EntryFast)); 5221 5240 5222 5241 … … 5227 5246 { 5228 5247 pDevExt->pvVMMR0 = pvVMMR0; 5229 *(void **)&pDevExt->pfnVMMR0EntryInt = pvVMMR0EntryInt;5230 5248 *(void **)&pDevExt->pfnVMMR0EntryFast = pvVMMR0EntryFast; 5231 5249 *(void **)&pDevExt->pfnVMMR0EntryEx = pvVMMR0EntryEx; … … 5238 5256 */ 5239 5257 if ( pDevExt->pvVMMR0 != pvVMMR0 5240 || (void *)pDevExt->pfnVMMR0EntryInt != pvVMMR0EntryInt5241 5258 || (void *)pDevExt->pfnVMMR0EntryFast != pvVMMR0EntryFast 5242 5259 || (void *)pDevExt->pfnVMMR0EntryEx != pvVMMR0EntryEx) … … 5258 5275 { 5259 5276 pDevExt->pvVMMR0 = NULL; 5260 pDevExt->pfnVMMR0EntryInt = NULL;5261 5277 pDevExt->pfnVMMR0EntryFast = NULL; 5262 5278 pDevExt->pfnVMMR0EntryEx = NULL; -
trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h
r57229 r57378 215 215 * - nothing. 216 216 */ 217 #define SUPDRV_IOC_VERSION 0x002 30003217 #define SUPDRV_IOC_VERSION 0x00240000 218 218 219 219 /** SUP_IOCTL_COOKIE. */ … … 338 338 */ 339 339 #define SUP_IOCTL_LDR_LOAD SUP_CTL_CODE_BIG(4) 340 #define SUP_IOCTL_LDR_LOAD_SIZE(cbImage) RT_ UOFFSETOF(SUPLDRLOAD, u.In.abImage[cbImage])340 #define SUP_IOCTL_LDR_LOAD_SIZE(cbImage) RT_MAX(RT_UOFFSETOF(SUPLDRLOAD, u.In.abImage[cbImage]), SUP_IOCTL_LDR_LOAD_SIZE_OUT) 341 341 #define SUP_IOCTL_LDR_LOAD_SIZE_IN(cbImage) RT_UOFFSETOF(SUPLDRLOAD, u.In.abImage[cbImage]) 342 #define SUP_IOCTL_LDR_LOAD_SIZE_OUT sizeof(SUPREQHDR)342 #define SUP_IOCTL_LDR_LOAD_SIZE_OUT (RT_UOFFSETOF(SUPLDRLOAD, u.Out.szError) + RT_SIZEOFMEMB(SUPLDRLOAD, u.Out.szError)) 343 343 344 344 /** … … 414 414 /** The module handle (i.e. address). */ 415 415 RTR0PTR pvVMMR0; 416 /** Address of VMMR0EntryInt function. */417 RTR0PTR pvVMMR0EntryInt;418 416 /** Address of VMMR0EntryFast function. */ 419 417 RTR0PTR pvVMMR0EntryFast; … … 451 449 uint8_t abImage[1]; 452 450 } In; 451 struct 452 { 453 /** Magic value indicating whether extended error information is 454 * present or not (SUPLDRLOAD_ERROR_MAGIC). */ 455 uint64_t uErrorMagic; 456 /** Extended error information. */ 457 char szError[2048]; 458 } Out; 453 459 } u; 454 460 } SUPLDRLOAD, *PSUPLDRLOAD; 461 /** Magic value that indicates that there is a valid error information string 462 * present on SUP_IOCTL_LDR_LOAD failure. 463 * @remarks The value is choosen to be an unlikely init and term address. */ 464 #define SUPLDRLOAD_ERROR_MAGIC UINT64_C(0xabcdefef0feddcb9) 455 465 /** @} */ 456 466 -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r57229 r57378 603 603 * 0 if the code VMM isn't loaded and Idt are nops. */ 604 604 void * volatile pvVMMR0; 605 /** VMMR0EntryInt() pointer. */606 DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryInt, (PVM pVM, unsigned uOperation, void *pvArg));607 605 /** VMMR0EntryFast() pointer. */ 608 606 DECLR0CALLBACKMEMBER(void, pfnVMMR0EntryFast, (PVM pVM, VMCPUID idCpu, unsigned uOperation)); … … 957 955 void VBOXCALL supdrvBadContext(PSUPDRVDEVEXT pDevExt, const char *pszFile, uint32_t uLine, const char *pszExtra); 958 956 int VBOXCALL supdrvQueryVTCapsInternal(uint32_t *pfCaps); 957 int VBOXCALL supdrvLdrLoadError(int rc, PSUPLDRLOAD pReq, const char *pszFormat, ...); 959 958 960 959 /* SUPDrvGip.cpp */ -
trunk/src/VBox/HostDrivers/Support/SUPLibLdr.cpp
r57358 r57378 112 112 { 113 113 rc = supLoadModule(pszFilename, pszModule, NULL, pErrInfo, ppvImageBase); 114 if (RT_FAILURE(rc) )114 if (RT_FAILURE(rc) && !RTErrInfoIsSet(pErrInfo)) 115 115 RTErrInfoSetF(pErrInfo, rc, "SUPR3LoadModule: supLoadModule returned %Rrc", rc); 116 116 } … … 445 445 * Get the entry points. 446 446 */ 447 RTUINTPTR VMMR0EntryInt = 0;448 447 RTUINTPTR VMMR0EntryFast = 0; 449 448 RTUINTPTR VMMR0EntryEx = 0; … … 451 450 RTUINTPTR ModuleInit = 0; 452 451 RTUINTPTR ModuleTerm = 0; 452 const char *pszEp = NULL; 453 453 if (fIsVMMR0) 454 454 { 455 rc = RTLdrGetSymbolEx(hLdrMod, &pLoadReq->u.In.abImage[0], (uintptr_t)OpenReq.u.Out.pvImageBase, UINT32_MAX, "VMMR0EntryInt", &VMMR0EntryInt); 455 rc = RTLdrGetSymbolEx(hLdrMod, &pLoadReq->u.In.abImage[0], (uintptr_t)OpenReq.u.Out.pvImageBase, 456 UINT32_MAX, pszEp = "VMMR0EntryFast", &VMMR0EntryFast); 456 457 if (RT_SUCCESS(rc)) 457 rc = RTLdrGetSymbolEx(hLdrMod, &pLoadReq->u.In.abImage[0], (uintptr_t)OpenReq.u.Out.pvImageBase, UINT32_MAX, "VMMR0EntryFast", &VMMR0EntryFast); 458 if (RT_SUCCESS(rc)) 459 rc = RTLdrGetSymbolEx(hLdrMod, &pLoadReq->u.In.abImage[0], (uintptr_t)OpenReq.u.Out.pvImageBase, UINT32_MAX, "VMMR0EntryEx", &VMMR0EntryEx); 458 rc = RTLdrGetSymbolEx(hLdrMod, &pLoadReq->u.In.abImage[0], (uintptr_t)OpenReq.u.Out.pvImageBase, 459 UINT32_MAX, pszEp = "VMMR0EntryEx", &VMMR0EntryEx); 460 460 } 461 461 else if (pszSrvReqHandler) 462 rc = RTLdrGetSymbolEx(hLdrMod, &pLoadReq->u.In.abImage[0], (uintptr_t)OpenReq.u.Out.pvImageBase, UINT32_MAX, pszSrvReqHandler, &SrvReqHandler); 462 rc = RTLdrGetSymbolEx(hLdrMod, &pLoadReq->u.In.abImage[0], (uintptr_t)OpenReq.u.Out.pvImageBase, 463 UINT32_MAX, pszEp = pszSrvReqHandler, &SrvReqHandler); 463 464 if (RT_SUCCESS(rc)) 464 465 { 465 int rc2 = RTLdrGetSymbolEx(hLdrMod, &pLoadReq->u.In.abImage[0], (uintptr_t)OpenReq.u.Out.pvImageBase, UINT32_MAX, "ModuleInit", &ModuleInit); 466 int rc2 = RTLdrGetSymbolEx(hLdrMod, &pLoadReq->u.In.abImage[0], (uintptr_t)OpenReq.u.Out.pvImageBase, 467 UINT32_MAX, pszEp = "ModuleInit", &ModuleInit); 466 468 if (RT_FAILURE(rc2)) 467 469 ModuleInit = 0; 468 470 469 rc2 = RTLdrGetSymbolEx(hLdrMod, &pLoadReq->u.In.abImage[0], (uintptr_t)OpenReq.u.Out.pvImageBase, UINT32_MAX, "ModuleTerm", &ModuleTerm); 471 rc2 = RTLdrGetSymbolEx(hLdrMod, &pLoadReq->u.In.abImage[0], (uintptr_t)OpenReq.u.Out.pvImageBase, 472 UINT32_MAX, pszEp = "ModuleTerm", &ModuleTerm); 470 473 if (RT_FAILURE(rc2)) 471 474 ModuleTerm = 0; … … 503 506 pLoadReq->u.In.eEPType = SUPLDRLOADEP_VMMR0; 504 507 pLoadReq->u.In.EP.VMMR0.pvVMMR0 = OpenReq.u.Out.pvImageBase; 505 pLoadReq->u.In.EP.VMMR0.pvVMMR0EntryInt = (RTR0PTR)VMMR0EntryInt;506 508 pLoadReq->u.In.EP.VMMR0.pvVMMR0EntryFast= (RTR0PTR)VMMR0EntryFast; 507 509 pLoadReq->u.In.EP.VMMR0.pvVMMR0EntryEx = (RTR0PTR)VMMR0EntryEx; … … 545 547 { 546 548 g_pvVMMR0 = OpenReq.u.Out.pvImageBase; 547 LogRel(("SUP: VMMR0EntryEx located at %RTptr, VMMR0EntryFast at %RTptr and VMMR0EntryInt at %RTptr\n", 548 VMMR0EntryEx, VMMR0EntryFast, VMMR0EntryInt)); 549 LogRel(("SUP: VMMR0EntryEx located at %RTptr and VMMR0EntryFast at %RTptr\n", VMMR0EntryEx, VMMR0EntryFast)); 549 550 } 550 551 #ifdef RT_OS_WINDOWS … … 556 557 return VINF_SUCCESS; 557 558 } 559 560 /* 561 * Failed, bail out. 562 */ 563 LogRel(("SUP: Loading failed for %s (%s) rc=%Rrc\n", pszModule, pszFilename, rc)); 564 if ( pLoadReq->u.Out.uErrorMagic == SUPLDRLOAD_ERROR_MAGIC 565 && pLoadReq->u.Out.szError[0] != '\0') 566 { 567 LogRel(("SUP: %s\n", pLoadReq->u.Out.szError)); 568 RTErrInfoSet(pErrInfo, rc, pLoadReq->u.Out.szError); 569 } 558 570 else 559 LogRel(("SUP: Loading failed for %s (%s) rc=%Rrc\n", pszModule, pszFilename, rc));571 RTErrInfoSet(pErrInfo, rc, "SUP_IOCTL_LDR_LOAD failed"); 560 572 } 561 573 else 574 { 562 575 LogRel(("SUP: RTLdrEnumSymbols failed for %s (%s) rc=%Rrc\n", pszModule, pszFilename, rc)); 576 RTErrInfoSetF(pErrInfo, rc, "RTLdrEnumSymbols #2 failed"); 577 } 563 578 } 564 579 else 565 LogRel(("SUP: Failed to get entry points for %s (%s) rc=%Rrc\n", pszModule, pszFilename, rc)); 580 { 581 LogRel(("SUP: Failed to get entry point '%s' for %s (%s) rc=%Rrc\n", pszEp, pszModule, pszFilename, rc)); 582 RTErrInfoSetF(pErrInfo, rc, "Failed to resolve entry point '%s'", pszEp); 583 } 566 584 } 567 585 else 586 { 568 587 LogRel(("SUP: RTLdrGetBits failed for %s (%s). rc=%Rrc\n", pszModule, pszFilename, rc)); 588 if (!RTErrInfoIsSet(pErrInfo)) 589 RTErrInfoSetF(pErrInfo, rc, "RTLdrGetBits failed"); 590 } 569 591 RTMemTmpFree(pLoadReq); 570 592 } … … 573 595 AssertMsgFailed(("failed to allocated %u bytes for SUPLDRLOAD_IN structure!\n", SUP_IOCTL_LDR_LOAD_SIZE(cbImageWithTabs))); 574 596 rc = VERR_NO_TMP_MEMORY; 597 RTErrInfoSetF(pErrInfo, rc, "Failed to allocate %u bytes for the load request", SUP_IOCTL_LDR_LOAD_SIZE(cbImageWithTabs)); 575 598 } 576 599 } 600 /* 601 * Already loaded? 602 */ 577 603 else if (RT_SUCCESS(rc)) 578 604 { … … 585 611 #endif 586 612 } 587 } 613 /* 614 * No, failed. 615 */ 616 else 617 RTErrInfoSet(pErrInfo, rc, "SUP_IOCTL_LDR_OPEN failed"); 618 } 619 else 620 RTErrInfoSetF(pErrInfo, rc, "RTLdrEnumSymbols #1 failed"); 588 621 RTLdrClose(hLdrMod); 589 622 return rc; -
trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
r57358 r57378 1843 1843 1844 1844 /** 1845 * memcmp + log.1845 * memcmp + errormsg + log. 1846 1846 * 1847 1847 * @returns Same as memcmp. … … 1850 1850 * @param uRva The RVA to start comparing at. 1851 1851 * @param cb The number of bytes to compare. 1852 */ 1853 static int supdrvNtCompare(PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, uint32_t uRva, uint32_t cb) 1852 * @param pReq The load request. 1853 */ 1854 static int supdrvNtCompare(PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, uint32_t uRva, uint32_t cb, PSUPLDRLOAD pReq) 1854 1855 { 1855 1856 int iDiff = memcmp((uint8_t const *)pImage->pvImage + uRva, pbImageBits + uRva, cb); … … 1861 1862 if (pbNativeBits[off] != pbImageBits[off]) 1862 1863 { 1863 char szBytes[128]; 1864 RTStrPrintf(szBytes, sizeof(szBytes), "native: %.*Rhxs our: %.*Rhxs", 1865 RT_MIN(12, cbLeft), &pbNativeBits[off], 1866 RT_MIN(12, cbLeft), &pbImageBits[off]); 1867 SUPR0Printf("VBoxDrv: Mismatch at %#x of %s: %s\n", off, pImage->szName, szBytes); 1864 /* Note! We need to copy image bits into a temporary stack buffer here as we'd 1865 otherwise risk overwriting them while formatting the error message. */ 1866 uint8_t abBytes[64]; 1867 memcpy(abBytes, &pbImageBits[off], RT_MIN(64, cbLeft)); 1868 supdrvLdrLoadError(VERR_LDR_MISMATCH_NATIVE, pReq, 1869 "Mismatch at %#x of %s:\n" 1870 "ntld: %.*Rhxs\n" 1871 "iprt: %.*Rhxs", 1872 off, pImage->szName, 1873 RT_MIN(64, cbLeft), &pbNativeBits[off], 1874 RT_MIN(64, cbLeft), &abBytes[0]); 1875 SUPR0Printf("VBoxDrv: %s", pReq->u.Out.szError); 1868 1876 break; 1869 1877 } … … 1872 1880 } 1873 1881 1882 1874 1883 int VBOXCALL supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, PSUPLDRLOAD pReq) 1875 1884 { 1876 NOREF(pDevExt); NOREF(pReq);1885 NOREF(pDevExt); 1877 1886 if (pImage->pvNtSectionObj) 1878 1887 { … … 1955 1964 { 1956 1965 if (uRvaNext < aExcludeRgns[i].uRva) 1957 iDiff = supdrvNtCompare(pImage, pbImageBits, uRvaNext, aExcludeRgns[i].uRva - uRvaNext );1966 iDiff = supdrvNtCompare(pImage, pbImageBits, uRvaNext, aExcludeRgns[i].uRva - uRvaNext, pReq); 1958 1967 uRvaNext = aExcludeRgns[i].uRva + aExcludeRgns[i].cb; 1959 1968 } 1960 1969 if (!iDiff && uRvaNext < pImage->cbImageBits) 1961 iDiff = supdrvNtCompare(pImage, pbImageBits, uRvaNext, pImage->cbImageBits - uRvaNext );1970 iDiff = supdrvNtCompare(pImage, pbImageBits, uRvaNext, pImage->cbImageBits - uRvaNext, pReq); 1962 1971 if (!iDiff) 1963 1972 return VINF_SUCCESS; 1964 1973 } 1965 1974 else 1966 supdrvNtCompare(pImage, pbImageBits, 0, pImage->cbImageBits );1975 supdrvNtCompare(pImage, pbImageBits, 0, pImage->cbImageBits, pReq); 1967 1976 return VERR_LDR_MISMATCH_NATIVE; 1968 1977 } 1969 return VERR_INTERNAL_ERROR_4;1978 return supdrvLdrLoadError(VERR_INTERNAL_ERROR_4, pReq, "No NT section object! Impossible!"); 1970 1979 } 1971 1980
Note:
See TracChangeset
for help on using the changeset viewer.