I love clang-format

This commit is contained in:
offtkp 2025-05-08 17:52:17 +03:00
parent 4a4563a89b
commit 7228072a5f

View File

@ -511,7 +511,9 @@ static std::pair<bool, u64> TryPatch(u8* code, PatchModule* module) {
#if defined(ARCH_X86_64)
static bool TryExecuteIllegalInstruction(void* ctx, void* code_address, ZydisDecodedInstruction& instruction, ZydisDecodedOperand* operands) {
static bool TryExecuteIllegalInstruction(void* ctx, void* code_address,
ZydisDecodedInstruction& instruction,
ZydisDecodedOperand* operands) {
switch (instruction.mnemonic) {
case ZYDIS_MNEMONIC_EXTRQ: {
bool immediateForm = operands[1].type == ZYDIS_OPERAND_TYPE_IMMEDIATE &&
@ -644,7 +646,8 @@ static bool TryExecuteIllegalInstruction(void* ctx, void* code_address, ZydisDec
#elif defined(ARCH_ARM64)
// These functions shouldn't be needed for ARM as it will use a JIT so there's no need to patch
// instructions.
static bool TryExecuteIllegalInstruction(void*, void*, ZydisDecodedInstruction&, ZydisDecodedOperand*) {
static bool TryExecuteIllegalInstruction(void*, void*, ZydisDecodedInstruction&,
ZydisDecodedOperand*) {
return false;
}
#else
@ -691,20 +694,23 @@ static bool PatchesIllegalInstructionHandler(void* context) {
void* code_address = Common::GetRip(context);
ZydisDecodedInstruction instruction;
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
const auto status = Common::Decoder::Instance()->decodeInstruction(instruction, operands, code_address);
const auto status =
Common::Decoder::Instance()->decodeInstruction(instruction, operands, code_address);
if (!ZYAN_SUCCESS(status)) {
return false;
}
if (instruction.length < 5) {
// The instruction is not big enough for a relative jump, don't try to patch it and pass it to
// our illegal instruction interpreter directly
// The instruction is not big enough for a relative jump, don't try to patch it and pass it
// to our illegal instruction interpreter directly
return TryExecuteIllegalInstruction(context, code_address, instruction, operands);
} else {
if (!TryPatchJit(code_address)) {
// Any instructions >= 5 bytes should get successfully patched and the above will return true
// Returning false would be an error as we previously check that the instruction is >= 5 to get here
LOG_ERROR(Core, "Failed to patch address %lx -- mnemonic: %d", (u64)code_address, (int)instruction.mnemonic);
// Any instructions >= 5 bytes should get successfully patched and the above will return
// true Returning false would be an error as we previously check that the instruction is
// >= 5 to get here
LOG_ERROR(Core, "Failed to patch address %lx -- mnemonic: %d", (u64)code_address,
(int)instruction.mnemonic);
}
}