kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

mem.c (845B)


      1 /* Guarded read/write of guest memory plus bp-byte fixup. The actual
      2  * SIGSEGV catch lives in the host's KitDbgOs.guarded_copy; this TU
      3  * just delegates and then overlays original bytes from the bp table
      4  * over any patched ranges in read results. */
      5 
      6 #include <string.h>
      7 
      8 #include "dbg/dbg.h"
      9 
     10 KitStatus dbg_mem_read(KitJitSession* s, uint64_t addr, void* dst, size_t n) {
     11   KitStatus st;
     12   if (!s || !dst || n == 0) return KIT_INVALID;
     13   st = s->os->guarded_copy(s->os->user, dst, (const void*)(uintptr_t)addr, n);
     14   if (st != KIT_OK) return st;
     15   dbg_bp_unpatch_read(s, addr, dst, n);
     16   return KIT_OK;
     17 }
     18 
     19 KitStatus dbg_mem_write(KitJitSession* s, uint64_t addr, const void* src,
     20                         size_t n) {
     21   if (!s || !src || n == 0) return KIT_INVALID;
     22   return s->os->guarded_copy(s->os->user, (void*)(uintptr_t)addr, src, n);
     23 }