#ifndef SERVICE_PROBE_H
#define SERVICE_PROBE_H

#include "../Common/ExploitCore.h"

#ifdef __cplusplus
extern "C" {
#endif

// ============================================================================
// Read-only IOKit service probe.
//
// This performs NO memory corruption. It only:
//   - enumerates candidate kernel services by class name,
//   - checks whether a sandboxed (sideloaded) app can open a user client,
//   - reads a few public registry properties.
//
// The result tells us which CVE components are reachable from app context.
// ============================================================================

typedef struct {
    const char *class_name;
    bool found;
    kern_return_t open_kr;   // KERN_SUCCESS means the user client is openable
    io_connect_t connect;    // valid only if open_kr == KERN_SUCCESS (closed again)
    int obj_count;
} service_probe_result_t;

// Probe a single service class. Fills `out`. Returns true if the service existed.
bool service_probe_one(const char *class_name, service_probe_result_t *out);

// Enumerate ALL published IOService objects, and for any whose class/name
// matches an "interesting" token, attempt IOServiceOpen type 0. Logs every
// openable user client. Read-only; no memory corruption.
void service_probe_enumerate(void);

// Probe the built-in candidate list and log everything via exploit_log().
void service_probe_run(void);

#ifdef __cplusplus
}
#endif

#endif // SERVICE_PROBE_H
