Changeset 97024 in vbox for trunk/src/VBox/Main
- Timestamp:
- Oct 6, 2022 8:26:17 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/initterm.cpp
r96407 r97024 245 245 246 246 /** 247 * Replacement function for the InvokeStub method for the IDLLHost stub. 248 */ 249 static HRESULT STDMETHODCALLTYPE 250 DLLHost_InvokeStub(IRpcStubBuffer *pThis, RPCOLEMESSAGE *pMsg, IRpcChannelBuffer *pBuf) RT_NOTHROW_DEF 251 { 252 /* 253 * Our mission here is to prevent remote calls to this interface as method #3 254 * contain a raw pointer an DllGetClassObject function. There are only that 255 * method in addition to the IUnknown stuff, and it's ASSUMED that it's 256 * process internal only (cross apartment stuff). 257 */ 258 uint32_t const iMethod = pMsg->iMethod & 0xffff; /* Uncertain, but there are hints that the upper bits are flags. */ 259 HRESULT hrc; 260 if (pMsg->rpcFlags & RPCFLG_LOCAL_CALL) 261 hrc = CStdStubBuffer_Invoke(pThis, pMsg, pBuf); 262 else 263 { 264 LogRel(("DLLHost_InvokeStub: Rejected call to CDLLHost::%s: rpcFlags=%#x cbBuffer=%#x dataRepresentation=%d buffer=%p:{%.*Rhxs} reserved1=%p reserved2={%p,%p,%p,%p,%p}\n", 265 pMsg->iMethod == 0 ? "QueryInterface" : 266 pMsg->iMethod == 1 ? "AddRef" : 267 pMsg->iMethod == 2 ? "ReleaseRef" : 268 pMsg->iMethod == 3 ? "DllGetClassObject" : "Unknown", pMsg->rpcFlags, pMsg->cbBuffer, 269 pMsg->dataRepresentation, pMsg->Buffer, RT_VALID_PTR(pMsg->Buffer) ? pMsg->cbBuffer : 0, pMsg->Buffer, 270 pMsg->reserved1, pMsg->reserved2[0], pMsg->reserved2[1], pMsg->reserved2[2], pMsg->reserved2[3], pMsg->reserved2[4])); 271 hrc = E_ACCESSDENIED; 272 } 273 return hrc; 274 } 275 276 /** 247 277 * Replaces the IRundown InvokeStub method with Rundown_InvokeStub so we can 248 278 * reject remote calls to a couple of misdesigned methods. 279 * 280 * Also replaces the IDLLHost for the same reasons. 249 281 */ 250 282 void PatchComBugs(void) … … 283 315 */ 284 316 static const IID s_IID_Rundown = {0x00000134,0x0000,0x0000,{0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}}; 317 static const IID s_IID_DLLHost = {0x00000141,0x0000,0x0000,{0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}}; 285 318 decltype(CStdStubBuffer_Invoke) *pfnInvoke = (decltype(pfnInvoke))GetProcAddress(hmod, "CStdStubBuffer_Invoke"); 286 319 if (!pfnInvoke) … … 319 352 cAlreadyPatched++; 320 353 } 354 else if (IsEqualIID(*piid, s_IID_DLLHost)) 355 { 356 if (pCurStub->Vtbl.Invoke == pfnInvoke) 357 { 358 DWORD fOld = 0; 359 if (VirtualProtect(&pCurStub->Vtbl.Invoke, sizeof(pCurStub->Vtbl.Invoke), PAGE_READWRITE, &fOld)) 360 { 361 pCurStub->Vtbl.Invoke = DLLHost_InvokeStub; 362 VirtualProtect(&pCurStub->Vtbl.Invoke, sizeof(pCurStub->Vtbl.Invoke), fOld, &fOld); 363 cPatched++; 364 } 365 else 366 AssertMsgFailed(("%d\n", GetLastError())); 367 } 368 else 369 cAlreadyPatched++; 370 } 321 371 } 322 372 } … … 338 388 ("last error: %u; Rundown_InvokeStub=%p\n", GetLastError(), Rundown_InvokeStub)); 339 389 } 340 else341 AssertLogRelMsg(cAlreadyPatched > 0, ("COM patching of IRundown failed!\n"));390 AssertLogRelMsg(cAlreadyPatched + cPatched >= 2, 391 ("COM patching of IRundown/IDLLHost failed! (%d+%d)\n", cAlreadyPatched, cPatched)); 342 392 } 343 393
Note:
See TracChangeset
for help on using the changeset viewer.