Skip to content

MarkEcza/Lazy-Detour

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Lazy Detour

Whats this?

Lazy Detour is a single header file to easily manage and create hooks using the open source MinHook library which can be found below.

Usage

Detour Function

	int function_somewhere(int a1, bool sum)
	{
		int result = a1;
		
		if (sum) {
			result + 10;
		}

		return result;
	}
	// This could be anywhere in any binary aslong as you have the pointer to the function you are okay.

	int my_detour(int a1, bool sum)
	{
		sum = false;
		//We detour and modify the original arg.

		return get_original<decltype(&my_detour)>("my_detour")(a1, sum); //We use this if you want the original function to execute.
	}
	// This is your own function which is going to get called inside the original once the original is called.	

Create Detour

MH_Initialize();

//Name, pointer to original, your function.
create_and_enable_hook("my_detour", reinterpret_cast<void*>(&function_somewhere), reinterpret_cast<void*>(&my_detour));

//Once you want to remove do
remove_all_hooks(); 
//Or
remove_hook("my_detour");

MinHook: https://github.com/TsudaKageyu/minhook

About

Simple way of making and destroying hooks using MinHook.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages