// Helper tool interface for privileged operations

#include <mach/std_types.defs>
#include <mach/mach_types.defs>

import "FortunateSonIPCTypes.h";
import "fileport.h";
import "Security/Authorization.h";

subsystem HexFiendHelper 1500;

userprefix _GratefulFather;
serverprefix _FortunateSon;

type FilePath = c_string[*:256];
type bool = int8_t;
type VMRegionAttributes = uint32_t;

type FileOffset_t = uint64_t;

type VarData_t = ^ array [] of uint8_t;
type fileport_t = MACH_MSG_TYPE_MOVE_SEND;
type AuthorizationExternalForm = struct [32] of uint8_t;

routine SayHey(
    server: mach_port_t;
    in path : FilePath;
    out result : int);

routine OpenFile(
	server: mach_port_t;
	in path: FilePath;
	in writable: int;
	out fd: fileport_t;
	out err: int);

routine ProcessInfo(
    server: mach_port_t;
    in pid: int;
    out bitSize: uint8_t);

routine ReadProcess(
    server: mach_port_t;
    in pid: int;
    in offset: mach_vm_address_t;
    in requestedLength: mach_vm_size_t;
    out result: VarData_t
);

routine AttributesForAddress(
    server: mach_port_t;
    in pid: int;
    in offset: mach_vm_address_t;
    out result: VMRegionAttributes;
    out applicableLength: mach_vm_size_t
);

routine SetAuthorization(
	server: mach_port_t;
	in auth: AuthorizationExternalForm
);
