mach-detours/include/mach_detours.h

49 lines
1.8 KiB
C
Raw Normal View History

2025-09-28 00:37:03 +02:00
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Lysann Tranvouez. All rights reserved.
2025-09-27 23:12:16 +02:00
#pragma once
2025-09-28 00:37:03 +02:00
#ifndef MACH_DETOURS_H
#define MACH_DETOURS_H
2025-09-30 00:09:10 +02:00
#ifdef __cplusplus
extern "C" {
#endif
2025-09-28 00:37:03 +02:00
#include <mach/error.h>
#include <mach/mach_types.h>
typedef void* detour_func_t;
#define detour_err_in_progress (err_local | 1)
2025-09-29 00:08:13 +02:00
#define detour_err_wrong_thread (err_local | 2)
#define detour_err_too_small (err_local | 3)
#define detour_err_too_large (err_local | 4)
2025-09-28 00:37:03 +02:00
mach_error_t detour_transaction_begin();
2025-10-03 00:04:52 +02:00
mach_error_t detour_transaction_begin_managed();
2025-09-28 00:37:03 +02:00
mach_error_t detour_transaction_abort();
mach_error_t detour_transaction_commit();
mach_error_t detour_transaction_commit_ex(detour_func_t** out_failed_target);
mach_error_t detour_manage_thread(thread_t thread);
2025-10-03 00:04:52 +02:00
mach_error_t detour_manage_all_threads();
2025-09-28 00:37:03 +02:00
mach_error_t detour_attach(detour_func_t* inout_pointer, detour_func_t detour);
mach_error_t detour_attach_ex(detour_func_t* inout_pointer, detour_func_t detour, detour_func_t* out_real_trampoline, detour_func_t* out_real_target, detour_func_t* out_real_detour);
mach_error_t detour_detach(detour_func_t* inout_pointer, detour_func_t detour);
2025-09-27 23:12:16 +02:00
2025-10-01 23:55:17 +02:00
mach_error_t detour_attach_and_commit(detour_func_t* inout_pointer, detour_func_t detour);
mach_error_t detour_attach_and_commit_ex(detour_func_t* inout_pointer, detour_func_t detour, detour_func_t* out_real_trampoline, detour_func_t* out_real_target, detour_func_t* out_real_detour);
mach_error_t detour_detach_and_commit(detour_func_t* inout_pointer, detour_func_t detour);
2025-09-29 23:53:05 +02:00
bool detour_set_ignore_too_small(bool value);
bool detour_set_retain_regions(bool value);
void* detour_set_system_region_lower_bound(void* value);
void* detour_set_system_region_upper_bound(void* value);
2025-09-30 00:09:10 +02:00
#ifdef __cplusplus
}
#endif
2025-09-28 00:37:03 +02:00
#endif // MACH_DETOURS_H