mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
Merge pull request #1168 from oguzhanozfe/fix/decoder-moffs-length
fix(relinker): decode the 64-bit address of MOV moffs instructions
This commit is contained in:
@@ -110,6 +110,8 @@ inline constexpr std::uint8_t OneByteInt = 0xCD;
|
||||
inline constexpr std::uint8_t OneByteRetImm16 = 0xC2;
|
||||
inline constexpr std::uint8_t OneByteRetFarImm16 = 0xCA;
|
||||
inline constexpr std::uint8_t OneByteEnter = 0xC8;
|
||||
inline constexpr std::uint8_t OneByteMovMoffsMin = 0xA0;
|
||||
inline constexpr std::uint8_t OneByteMovMoffsMax = 0xA3;
|
||||
|
||||
inline constexpr std::uint8_t TwoByteJccRel32Min = 0x80;
|
||||
inline constexpr std::uint8_t TwoByteJccRel32Max = 0x8F;
|
||||
|
||||
@@ -12,6 +12,7 @@ std::size_t X64InstructionDecoder::Decode(const std::uint8_t* data, std::size_t
|
||||
bool rexPresent = false;
|
||||
std::uint8_t rex = 0;
|
||||
bool operandSizeOverride = false;
|
||||
bool addressSizeOverride = false;
|
||||
bool repnePrefix = false;
|
||||
|
||||
while (pos < available) {
|
||||
@@ -28,7 +29,9 @@ std::size_t X64InstructionDecoder::Decode(const std::uint8_t* data, std::size_t
|
||||
repnePrefix = true;
|
||||
} else if (b == PrefixOperandSize) {
|
||||
operandSizeOverride = true;
|
||||
} else if (b != PrefixLock && b != PrefixRep && b != PrefixAddressSize &&
|
||||
} else if (b == PrefixAddressSize) {
|
||||
addressSizeOverride = true;
|
||||
} else if (b != PrefixLock && b != PrefixRep &&
|
||||
b != PrefixSegCs && b != PrefixSegSs && b != PrefixSegDs &&
|
||||
b != PrefixSegEs && b != PrefixSegFs && b != PrefixSegGs) {
|
||||
break;
|
||||
@@ -205,6 +208,10 @@ std::size_t X64InstructionDecoder::Decode(const std::uint8_t* data, std::size_t
|
||||
if (opcode == OneByteEnter) {
|
||||
immediateSize = ImmSizeEnter;
|
||||
}
|
||||
|
||||
if (opcode >= OneByteMovMoffsMin && opcode <= OneByteMovMoffsMax) {
|
||||
immediateSize = addressSizeOverride ? ImmSize32 : ImmSize64;
|
||||
}
|
||||
} else {
|
||||
if (opcode == TwoByteExtrqInsertqImm8Imm8) {
|
||||
if (!operandSizeOverride && !repnePrefix) {
|
||||
|
||||
@@ -124,6 +124,8 @@ void decoderLengths() {
|
||||
{0x66, 0x0F, 0xC4, 0xC0, 0x01}, {0xC2, 0x08, 0x00}, {0xC8, 0x10, 0x00, 0x00}, {0xF3, 0x0F, 0x2B, 0x07},
|
||||
{0xF2, 0x44, 0x0F, 0x2B, 0x4C, 0x24, 0x10}, {0x0F, 0x01, 0xFA}, {0x0F, 0xB9, 0x00},
|
||||
{0x41, 0x0F, 0xBB, 0xF7}, {0x0F, 0xBB, 0x47, 0x08},
|
||||
{0xA0, 1, 2, 3, 4, 5, 6, 7, 8}, {0x48, 0xA1, 1, 2, 3, 4, 5, 6, 7, 8}, {0xA2, 1, 2, 3, 4, 5, 6, 7, 8},
|
||||
{0x64, 0x48, 0xA3, 1, 2, 3, 4, 5, 6, 7, 8}, {0x67, 0xA1, 1, 2, 3, 4}, {0x48, 0x67, 0xA3, 1, 2, 3, 4},
|
||||
{0x0F, 0x38, 0xCB, 0xCA}, {0x45, 0x0F, 0x38, 0xCC, 0xE1}, {0x0F, 0x38, 0xCD, 0x08}, {0x0F, 0x38, 0xCB, 0x0D, 0x10, 0x00, 0x00, 0x00},
|
||||
{0x0F, 0x3A, 0xCC, 0xD5, 0x03}, {0x45, 0x0F, 0x3A, 0xCC, 0xE1, 0x00}, {0x0F, 0x3A, 0xCC, 0x08, 0x01}, {0x0F, 0x38, 0xC8, 0xCA}, {0x0F, 0x38, 0xC9, 0xCA}, {0x0F, 0x38, 0xCA, 0x08},
|
||||
{0x48, 0x66, 0xB8, 0x34, 0x12}, {0x66, 0x48, 0xB8, 1, 2, 3, 4, 5, 6, 7, 8}, {0x41, 0x48, 0xB8, 1, 2, 3, 4, 5, 6, 7, 8},
|
||||
|
||||
Reference in New Issue
Block a user