GithubHelp home page GithubHelp logo

inline_hook's Introduction

Inline Hook

Head only, User mode inline hook support x86 x64

Example

hook LoadLibraryW

#include <stdio.h>
#include <Windows.h>
#include "inline_hook.hpp"


HMODULE WINAPI MyLoadLibraryW(LPCWSTR lpLibFileName);


//LoadLibraryW的函数指针
typedef HMODULE(WINAPI* LoadLibraryWType)(LPCWSTR lpLibFileName);


auto inline_hook = InlineHook<LoadLibraryWType>(reinterpret_cast<ULONG_PTR>(LoadLibraryW), MyLoadLibraryW);


//自己的LoadLibraryW
HMODULE WINAPI MyLoadLibraryW(LPCWSTR lpLibFileName)
{
	printf("MyLoadLibraryW:%ws\n", lpLibFileName);
	
	//拒绝ntdll.dll
	if (wcsstr(lpLibFileName, L"ntdll.dll"))
	{
		return reinterpret_cast<HMODULE>(0x114514);
	}
	
	
	//调用原始函数
	auto original_func_result = inline_hook.CallOriginalFunc(lpLibFileName);

	printf("original func result:%p\n", original_func_result);

	return original_func_result;
}



int main() {
	
	inline_hook.Motify();
	auto ntdll_module = LoadLibraryW(L"ntdll.dll");
	auto user32_module = LoadLibraryW(L"user32.dll");
	
	printf("ntdll module:%p\n", ntdll_module);    //ntdll module:0000000000114514
	printf("user32 module:%p\n", user32_module);  //user32 module:00007FFF8B080000

	
	return 0;
}

inline_hook's People

Contributors

git-xiaocao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

crackercat

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.