Skip to content

Add SlimDetoursDetachEx to allow to free the trampoline manually#19

Open
m417z wants to merge 2 commits intoKNSoft:mainfrom
m417z:free-trampoline-manually
Open

Add SlimDetoursDetachEx to allow to free the trampoline manually#19
m417z wants to merge 2 commits intoKNSoft:mainfrom
m417z:free-trampoline-manually

Conversation

@m417z
Copy link
Copy Markdown

@m417z m417z commented Apr 10, 2025

Usage example:

// Detach but don't free trampoline.
SlimDetoursTransactionBegin();
PVOID pTrampoline = NULL;
DETOUR_DETACH_OPTIONS Options;
Options.ppTrampolineToFreeManually = &pTrampoline;
SlimDetoursDetachEx(pPointer, pDetour, &Options);
SlimDetoursTransactionCommit();

// Make sure the trampoline can be safely freed.
Sleep(1000);

// Free trampoline.
SlimDetoursFreeTrampoline(pTrampoline);

I don't find it very elegant, but it can help address #12.

Depends on #17 (will be rebased once it's merged).

@m417z m417z force-pushed the free-trampoline-manually branch from 6e5792c to 21fb49a Compare April 10, 2025 19:50
@m417z m417z marked this pull request as draft April 10, 2025 21:09
@m417z m417z force-pushed the free-trampoline-manually branch 3 times, most recently from 942a4f7 to d425fa4 Compare April 11, 2025 15:16
@m417z m417z force-pushed the free-trampoline-manually branch from d425fa4 to 266cb49 Compare June 21, 2025 17:36
@m417z m417z marked this pull request as ready for review June 21, 2025 17:38
@m417z m417z force-pushed the free-trampoline-manually branch from 266cb49 to f48ed71 Compare June 21, 2025 17:59
@RatinCN RatinCN force-pushed the main branch 2 times, most recently from 8937581 to 30ff0bc Compare September 4, 2025 08:45
Usage example:

SlimDetoursTransactionBegin();
PVOID pTrampoline = NULL;
DETOUR_DETACH_OPTIONS Options;
Options.ppTrampolineToFreeManually = &pTrampoline;
SlimDetoursDetachEx(pPointer, pDetour, &Options);
SlimDetoursTransactionCommit();
Sleep(1000);
SlimDetoursFreeTrampoline(pTrampoline);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant