diff --git a/src/detours.cpp b/src/detours.cpp index 91d840d1..33591a06 100644 --- a/src/detours.cpp +++ b/src/detours.cpp @@ -1170,6 +1170,26 @@ then unsigned size-unscaled (8) 12-bit offset, then opcode bits 0xF94. } } } + + // Skip over a branch to the import jump if there is one. + if ((Opcode & 0xfc000000) == 0x14000000) { + // B + INT64 branchOffset = (Opcode & 0x03ffffff) << 2; + if ((Opcode & 0x02000000) != 0) { + branchOffset |= (INT64)0xfffffffff0000000ULL; + } + PBYTE const pbBranchTarget = pbCode + branchOffset; + ULONG const BranchOpcode = fetch_opcode(pbBranchTarget); + + if ((BranchOpcode & 0x9f00001f) == 0x90000010) { + PBYTE const pbNew = detour_skip_jmp(pbBranchTarget, ppGlobals); + + if (pbNew != pbBranchTarget) { + DETOUR_TRACE(("%p->%p: skipped over branch to import table.\n", pbCode, pbNew)); + return pbNew; + } + } + } return pbCode; }