add detour_free_unused_regions
This commit is contained in:
parent
7c25e72f15
commit
67a74ef7e1
2 changed files with 20 additions and 1 deletions
|
|
@ -205,11 +205,20 @@ bool detour_set_ignore_too_small(bool value);
|
||||||
/// @brief Toggle whether to free memory allocated for trampoline regions when they are empty.
|
/// @brief Toggle whether to free memory allocated for trampoline regions when they are empty.
|
||||||
///
|
///
|
||||||
/// Default is `true` - free unused regions upon commit.<br/>
|
/// Default is `true` - free unused regions upon commit.<br/>
|
||||||
/// `false` means they are not freed upon commit. Note that there is no way to manually free unused regions.
|
/// `false` means they are not freed upon commit. See also `detour_free_unused_regions`.
|
||||||
///
|
///
|
||||||
/// @returns the previous state of the flag
|
/// @returns the previous state of the flag
|
||||||
bool detour_set_retain_regions(bool value);
|
bool detour_set_retain_regions(bool value);
|
||||||
|
|
||||||
|
/// @brief Frees unused trampoline memory regions
|
||||||
|
///
|
||||||
|
/// @note Must be called from within a transaction to maintain thread saefty.
|
||||||
|
///
|
||||||
|
/// @returns `err_none` on success, else:<br/>
|
||||||
|
/// * `detour_err_wrong_thread` if the calling thread is not the owner of the transaction, or if there is no
|
||||||
|
/// transaction. See `detour_transaction_begin`.
|
||||||
|
mach_error_t detour_free_unused_regions();
|
||||||
|
|
||||||
/// @brief Sets the lower bound of the memory area that will not be used for detours trampoline regions
|
/// @brief Sets the lower bound of the memory area that will not be used for detours trampoline regions
|
||||||
///
|
///
|
||||||
/// Default is `0x70000000`
|
/// Default is `0x70000000`
|
||||||
|
|
|
||||||
|
|
@ -1001,6 +1001,16 @@ bool detour_set_retain_regions(const bool value)
|
||||||
return previous;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mach_error_t detour_free_unused_regions()
|
||||||
|
{
|
||||||
|
if (s_transaction_thread != mach_thread_self()) {
|
||||||
|
return detour_err_wrong_thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal_detour_free_unused_trampoline_regions();
|
||||||
|
return err_none;
|
||||||
|
}
|
||||||
|
|
||||||
void* detour_set_system_region_lower_bound(void* value)
|
void* detour_set_system_region_lower_bound(void* value)
|
||||||
{
|
{
|
||||||
void* previous = s_system_region_lower_bound;
|
void* previous = s_system_region_lower_bound;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue