Code Monkey home page Code Monkey logo

functionhooks's Introduction

FunctionHooks

Header-only C++ library for hooking functions on Windows x64. Supports inline and virtual table hooks.

Getting Started

Include "function_hooks.h" in your project.

Inlike hook example:

#include <function_hooks.h>

// Function that is called when hooked function is called
void Hook(fn_hooks::Registers regs) {

}

int main() {

  // To hook
  const size_t byte_count = 13; // How many bytes to copy to end of the hook from start of the function
  fn_hooks::InlineHook(function_ptr, Hook, byte_count);

  // To unhook
  fn_hooks::Unhook(function_ptr);
}

Running the tests

Tests are located in FunctionHooksTest. Tests can be run with Visual Studio. See Run unit tests with Test Explorer

License

This project is licensed under the MIT License - see the LICENSE.md file for details

functionhooks's People

Contributors

jarijaas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

functionhooks's Issues

Does it still work in 2024 ?

I tried what was in the unit test (because I can't run that one in VS2022):

void Hook( fn_hooks::Registers regs )
{
	OutputDebugStringA( "Hook" );
}

void HookedFunction( )
{
	OutputDebugStringA( "GlobalFunction" );
}

int main()
{
	// To hook
	const size_t byte_count = 0x1A; // How many bytes to copy to end of the hook from start of the function
	const uint64_t fn_ptr = fn_hooks::ReadJump( reinterpret_cast<uint64_t>( HookedFunction ) );
	fn_hooks::InlineHook( fn_ptr, Hook, byte_count );

	HookedFunction( );
}

and it crashes after it exits Hook()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.