//
//  kutils.h
//  Cyanide
//
//  Created by seo on 3/25/26.
//

#ifndef kutils_h
#define kutils_h

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <mach/mach.h>

uint64_t proc_self(void);
uint64_t task_self(void);
void kutils_reset_self_cache(void);
bool kutils_recover_self_proc_from(uint64_t anchor_proc);
char* proc_get_p_name(uint64_t proc);
uint64_t proc_task(uint64_t proc);
uint64_t proc_find(pid_t pid);
uint64_t proc_find_by_name(const char* name);
const char* get_bootManifestHash(void);
uint64_t task_get_ipc_port_kobject(uint64_t task, mach_port_t port);
uint64_t task_get_vm_map(uint64_t task_ptr);
int disable_excguard_kill(uint64_t task);
int disable_excguard_kill_save(uint64_t task, uint32_t *origOut);
int restore_excguard_kill(uint64_t task, uint32_t origFlags);
uint64_t thread_get_t_tro(uint64_t thread);
uint64_t thread_get_task(uint64_t thread);
uint16_t thread_get_options(uint64_t thread);
void thread_set_options(uint64_t thread, uint16_t options);
void thread_set_mutex(uint64_t thread, uint32_t ctid);
uint32_t thread_get_mutex(uint64_t thread);
uint64_t thread_get_kstackptr(uint64_t thread);
uint64_t thread_get_jop_pid(uint64_t thread);
uint64_t thread_get_rop_pid(uint64_t thread);
uint64_t proc_get_cred_label(uint64_t proc);
uint64_t amfi_cslot_get(uint64_t label);
uint64_t label_get_sandbox(uint64_t label);
uint64_t kalloc_array_decode(uint64_t ptr);

#endif /* kutils_h */
