mirror of
https://dev.lirent.ru/Vatrog/vm-introspection-engine.git
synced 2026-07-09 00:46:36 +03:00
Scope gva_code_xref by an explicit prot_any argument
It hard-coded VR_X, so a target whose page tables expose no executable region silently yielded zero xrefs. Callers now pass the scope (VR_X to restrict to code, VR_R when the X bit is unavailable); the decoder and exact target match remain the correctness gate. Mirrors the prot_any parameter gva_imm_xref already carries.
This commit is contained in:
+12
-9
@@ -70,18 +70,21 @@ int gva_sig_scan_multi(vmie_mem* m, uintptr_t cr3, uint64_t lo, uint64_t hi,
|
||||
uint32_t prot_any, const sigset* s,
|
||||
sig_multi_hit* out, int max);
|
||||
|
||||
/* code-xref: every instruction in the X-regions of [lo,hi] whose near rel
|
||||
* branch or RIP-relative memory operand resolves to `target_va`. Brute-scans
|
||||
* each byte offset with the light x86-64 decoder (x86dec.h, NOT a full
|
||||
* disassembler): an E8/E9/EB/Jcc rel branch matches when next_rip + rel ==
|
||||
/* code-xref: every instruction in the regions of [lo,hi] kept by `prot_any`
|
||||
* whose near rel branch or RIP-relative memory operand resolves to `target_va`.
|
||||
* Brute-scans each byte offset with the light x86-64 decoder (x86dec.h, NOT a
|
||||
* full disassembler): an E8/E9/EB/Jcc rel branch matches when next_rip + rel ==
|
||||
* target_va, and any RIP-relative operand (ModRM mod=00, rm=101) matches when
|
||||
* next_rip + disp32 == target_va (this covers lea/mov and any other rip-rel
|
||||
* form). Records each matching instruction-start VA. The sweep forces VR_X and
|
||||
* carries a >=15-byte overlap (max x86 instruction length) so no instruction is
|
||||
* cut at a window seam. Writes up to `max` VAs to `out` (NULL to count only) and
|
||||
* returns the TOTAL number of matches, or -1 on bad input. */
|
||||
* form). Records each matching instruction-start VA. The sweep is scoped by
|
||||
* `prot_any` (pass VR_X to restrict to code; pass VR_R when the target's
|
||||
* page-table X bit is unavailable - the decoder and exact target match keep the
|
||||
* result correct, only more bytes are decoded) and carries a >=15-byte overlap
|
||||
* (max x86 instruction length) so no instruction is cut at a window seam. Writes
|
||||
* up to `max` VAs to `out` (NULL to count only) and returns the TOTAL number of
|
||||
* matches, or -1 on bad input. */
|
||||
int gva_code_xref(vmie_mem* m, uintptr_t cr3, uint64_t lo, uint64_t hi,
|
||||
uint64_t target_va, uint64_t* out, int max);
|
||||
uint32_t prot_any, uint64_t target_va, uint64_t* out, int max);
|
||||
|
||||
/* immediate / constant xref: every instruction in [lo,hi] (kept by the
|
||||
* protection filter `prot_any`; pass VR_X to restrict to code) whose IMMEDIATE
|
||||
|
||||
Reference in New Issue
Block a user