vbox的更動 66794 路徑 trunk/src/VBox/HostDrivers
- 時間撮記:
- 2017-5-4 下午01:09:36 (8 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/HostDrivers/Support/posix/SUPR3HardenedMain-posix.cpp
r66632 r66794 342 342 */ 343 343 uint32_t cRipRelMovs = 0; 344 uint32_t cRelCalls = 0; 344 345 345 346 /* Just use the disassembler to skip 12 bytes or more, we might need to … … 350 351 int rc = DISInstr(pbTarget + offJmpBack, DISCPUMODE_64BIT, &Dis, &cbInstr); 351 352 if ( RT_FAILURE(rc) 352 || (Dis.pCurInstr->fOpType & DISOPTYPE_CONTROLFLOW) 353 || ( Dis.pCurInstr->fOpType & DISOPTYPE_CONTROLFLOW 354 && Dis.pCurInstr->uOpcode != OP_CALL) 353 355 || ( Dis.ModRM.Bits.Mod == 0 354 356 && Dis.ModRM.Bits.Rm == 5 /* wrt RIP */ … … 358 360 if (Dis.ModRM.Bits.Mod == 0 && Dis.ModRM.Bits.Rm == 5 /* wrt RIP */) 359 361 cRipRelMovs++; 362 if ( Dis.pCurInstr->uOpcode == OP_CALL 363 && (Dis.pCurInstr->fOpType & DISOPTYPE_RELATIVE_CONTROLFLOW)) 364 cRelCalls++; 360 365 361 366 offJmpBack += cbInstr; … … 363 368 } 364 369 370 /* 371 * Each relative call requires 7 extra bytes as it is converted to an absolute one 372 * using two instructions (mov raw, qword + call rax). */ 373 cbPatchMem += cRelCalls * 7; 365 374 cbPatchMem += 14; /* jmp qword [$+8 wrt RIP] + 8 byte address to jump to. */ 366 375 cbPatchMem = RT_ALIGN_32(cbPatchMem, 8); 367 376 368 /* Allocate suitable exec tuable memory available. */377 /* Allocate suitable executable memory available. */ 369 378 bool fConvRipRelMovs = false; 370 379 uint8_t *pbPatchMem = supR3HardenedMainPosixExecMemAlloc(cbPatchMem, pbTarget, cRipRelMovs > 0); … … 397 406 int rc = DISInstr(pbTarget + offInsn, DISCPUMODE_64BIT, &Dis, &cbInstr); 398 407 if ( RT_FAILURE(rc) 399 || (Dis.pCurInstr->fOpType & DISOPTYPE_CONTROLFLOW)) 408 || ( Dis.pCurInstr->fOpType & DISOPTYPE_CONTROLFLOW 409 && Dis.pCurInstr->uOpcode != OP_CALL)) 400 410 return VERR_SUPLIB_UNEXPECTED_INSTRUCTION; 401 411 … … 439 449 pbPatchMem += sizeof(int32_t); 440 450 } 451 } 452 else if ( Dis.pCurInstr->uOpcode == OP_CALL 453 && (Dis.pCurInstr->fOpType & DISOPTYPE_RELATIVE_CONTROLFLOW)) 454 { 455 /* Convert to absolute call. */ 456 uintptr_t uAddr = (uintptr_t)&pbTarget[offInsn + cbInstr] + (intptr_t)Dis.Param1.uValue; 457 458 *pbPatchMem++ = 0x48; 459 *pbPatchMem++ = 0xb8; 460 *(uint64_t *)pbPatchMem = uAddr; 461 pbPatchMem += sizeof(uint64_t); 462 463 *pbPatchMem++ = 0xff; /* call rax */ 464 *pbPatchMem++ = 0xd0; 441 465 } 442 466 else
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器