#ifndef IG_DISPATCH_H #define IG_DISPATCH_H #include #include #include "../include/IGDefender.h" #ifdef __cplusplus extern "C" { #endif /* 线程安全解析并缓存目标;每次调用前校验,失败不调用目标。 * 检查依赖 pthread/dlsym/Mach,不可用于异步信号处理器或 fork 后的子进程。 * 仅供逐调用点接入,不能作为全局 libc interpose 实现。 */ ssize_t IG_dispatch_write(int fd, const void *buffer, size_t count); int IG_dispatch_close(int fd); /* Only redirect reviewed ordinary call sites, never signal handlers or post-fork * child paths. getpid returns -1 with errno if validation fails (unlike libc). * These declarations do not automatically redirect existing IPA imports. */ ssize_t IG_dispatch_read(int fd, void *buffer, size_t count); int IG_dispatch_open(const char *path, int flags, ...); int IG_dispatch_unlink(const char *path); pid_t IG_dispatch_getpid(void); FILE *IG_dispatch_fopen(const char *path, const char *mode); __attribute__((noreturn)) void IG_dispatch_exit(int status); pid_t IG_dispatch_fork(void); void *IG_dispatch_dlopen(const char *path, int mode); void *IG_dispatch_dlsym(void *handle, const char *symbol); int ig_dispatch_check(IGFindingSink sink, void *ctx); #ifdef IG_OBSERVATION /* 保留原 write/close 试点计数 ABI;新增入口不计入这四个字段。 * 仅观察构建导出只读计数,不提供地址覆盖或关闭校验的接口。 */ typedef struct { uint64_t write_attempted, write_dispatched; uint64_t close_attempted, close_dispatched; } IGDispatchObservation; IGDispatchObservation ig_dispatch_observation(void); #endif #ifdef IG_DISPATCH_TESTING /* 只编入宿主测试,不允许在 App 发布包定义此宏。 */ void ig_dispatch_test_override(unsigned index, void *address); void ig_dispatch_test_reentry(int enabled); #endif #ifdef __cplusplus } #endif #endif