fix(entry): replace jmpt start with call start + ud2 in relinker
This commit is contained in:
parent
baa8a8d9d3
commit
12fb2e928b
|
|
@ -121,8 +121,9 @@ inline constexpr std::uint8_t kStubOpMovDwordPtrRsp[] = {0x89, 0x04, 0x24};
|
|||
inline constexpr std::uint8_t kStubOpMovQwordPtrRsp8Rbx[] = {0x48, 0x89, 0x5c, 0x24, 0x08};
|
||||
inline constexpr std::uint8_t kStubOpMovRdiRsp[] = {0x48, 0x89, 0xe7};
|
||||
inline constexpr std::uint8_t kStubOpXorRsiRsi[] = {0x48, 0x31, 0xf6};
|
||||
inline constexpr std::uint8_t kStubOpJmpRel32 = 0xe9;
|
||||
inline constexpr std::size_t kStubJmpInstructionSize = 5;
|
||||
inline constexpr std::uint8_t kStubOpCallRel32 = 0xe8;
|
||||
inline constexpr std::size_t kStubCallInstructionSize = 5;
|
||||
inline constexpr std::uint8_t kStubOpUd2[] = {0x0f, 0x0b};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,14 +23,15 @@ std::vector<std::uint8_t> EntryStubBuilder::BuildEntryStub(
|
|||
_appendBytes(s, kStubOpMovQwordPtrRsp8Rbx, sizeof(kStubOpMovQwordPtrRsp8Rbx));
|
||||
_appendBytes(s, kStubOpMovRdiRsp, sizeof(kStubOpMovRdiRsp));
|
||||
_appendBytes(s, kStubOpXorRsiRsi, sizeof(kStubOpXorRsiRsi));
|
||||
const std::uint64_t jmpInsnVaddr = stubVaddr + s.size();
|
||||
const std::uint64_t jmpNextVaddr = jmpInsnVaddr + kStubJmpInstructionSize;
|
||||
const auto rel32 = static_cast<std::int32_t>(realEntryVaddr - jmpNextVaddr);
|
||||
s.push_back(kStubOpJmpRel32);
|
||||
const std::uint64_t callInsnVaddr = stubVaddr + s.size();
|
||||
const std::uint64_t callNextVaddr = callInsnVaddr + kStubCallInstructionSize;
|
||||
const auto rel32 = static_cast<std::int32_t>(realEntryVaddr - callNextVaddr);
|
||||
s.push_back(kStubOpCallRel32);
|
||||
s.push_back(static_cast<std::uint8_t>(rel32 & 0xff));
|
||||
s.push_back(static_cast<std::uint8_t>((rel32 >> 8) & 0xff));
|
||||
s.push_back(static_cast<std::uint8_t>((rel32 >> 16) & 0xff));
|
||||
s.push_back(static_cast<std::uint8_t>((rel32 >> 24) & 0xff));
|
||||
_appendBytes(s, kStubOpUd2, sizeof(kStubOpUd2));
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue