Changeset 34241 in vbox for trunk/src/VBox/HostDrivers/Support
- Timestamp:
- Nov 22, 2010 2:26:53 PM (14 years ago)
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
r33878 r34241 1556 1556 1557 1557 1558 SUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule, void **ppvImageBase) 1559 { 1560 int rc = VINF_SUCCESS; 1561 #ifdef VBOX_WITH_HARDENING 1558 SUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule, void **ppvImageBase, char *pszErr, size_t cbErr) 1559 { 1562 1560 /* 1563 1561 * Check that the module can be trusted. 1564 1562 */ 1565 rc = supR3HardenedVerifyFixedFile(pszFilename, false /* fFatal */); 1566 #endif 1563 int rc = SUPR3HardenedVerifyPlugIn(pszFilename, pszErr, cbErr); 1567 1564 if (RT_SUCCESS(rc)) 1565 { 1568 1566 rc = supLoadModule(pszFilename, pszModule, NULL, ppvImageBase); 1569 else 1570 LogRel(("SUPR3LoadModule: Verification of \"%s\" failed, rc=%Rrc\n", rc)); 1567 if (RT_FAILURE(rc)) 1568 RTStrPrintf(pszErr, cbErr, "supLoadModule returned %Rrc", rc); 1569 } 1571 1570 return rc; 1572 1571 } … … 2056 2055 { 2057 2056 void *pvImageBase; 2058 return SUPR3LoadModule(pszFilename, "VMMR0.r0", &pvImageBase );2057 return SUPR3LoadModule(pszFilename, "VMMR0.r0", &pvImageBase, NULL, 0); 2059 2058 } 2060 2059 … … 2189 2188 2190 2189 LogFlow(("SUPR3HardenedLdrLoadAppPriv: returns %Rrc\n", rc)); 2190 return rc; 2191 } 2192 2193 2194 SUPR3DECL(int) SUPR3HardenedLdrLoadPlugIn(const char *pszFilename, PRTLDRMOD phLdrMod, char *pszErr, size_t cbErr) 2195 { 2196 int rc; 2197 2198 /* 2199 * Validate input. 2200 */ 2201 AssertPtr(pszErr); 2202 Assert(cbErr > 32); 2203 AssertPtrReturn(phLdrMod, VERR_INVALID_PARAMETER); 2204 *phLdrMod = NIL_RTLDRMOD; 2205 AssertPtrReturn(pszFilename, VERR_INVALID_PARAMETER); 2206 AssertReturn(RTPathStartsWithRoot(pszFilename), VERR_INVALID_PARAMETER); 2207 2208 #ifdef VBOX_WITH_HARDENING 2209 /* 2210 * Verify the image file. 2211 */ 2212 rc = supR3HardenedVerifyFile(pszFilename, RTHCUINTPTR_MAX, pszErr, cbErr); 2213 if (RT_FAILURE(rc)) 2214 { 2215 if (!pszErr || !cbErr) 2216 LogRel(("supR3HardenedVerifyFile: Verification of \"%s\" failed, rc=%Rrc\n", pszFilename, rc)); 2217 return rc; 2218 } 2219 #endif 2220 2221 /* 2222 * Try load it. 2223 */ 2224 rc = RTLdrLoad(pszFilename, phLdrMod); 2225 if (RT_FAILURE(rc)) 2226 RTStrPrintf(pszErr, cbErr, "RTLdrLoad returned %Rrc", rc); 2191 2227 return rc; 2192 2228 } -
trunk/src/VBox/HostDrivers/Support/testcase/tstSupLoadModule.cpp
r28800 r34241 70 70 case VINF_GETOPT_NOT_OPTION: 71 71 { 72 char szErr[4096+1024]; 72 73 void *pvImageBase; 73 rc = SUPR3LoadModule(ValueUnion.psz, RTPathFilename(ValueUnion.psz), &pvImageBase );74 rc = SUPR3LoadModule(ValueUnion.psz, RTPathFilename(ValueUnion.psz), &pvImageBase, szErr, sizeof(szErr)); 74 75 if (RT_FAILURE(rc)) 75 76 { 76 RTMsgError("%Rrc when attempting to load '%s' \n", rc, ValueUnion.psz);77 RTMsgError("%Rrc when attempting to load '%s': %s\n", rc, ValueUnion.psz, szErr); 77 78 return 1; 78 79 }
Note:
See TracChangeset
for help on using the changeset viewer.