Giter Club home page Giter Club logo

kernelhook's Introduction

Inline hooking in Windows kernel. This is simple tool to show how to properly create inline hooks in kernel. It requires disabling PatchGuard which is relatively simple via patching kernel image (ntoskrnl.exe).

Most of tools like this one in order to write to read-only code disable write-protect bit in CR0. The problem with that method is that control registers are per-processor, not per-thread registers. After disabling CR0.WP context switch changing processor on which the thread is executing can happen. Because of this we will write over read-only with CR0.WP disabled which will cause bluescreen. The simple solution to this would be raising IRQL to DPC level to make sure context switch won't happen. This however creates problem of accessing paged memory with interrupts disabled, which will cause bluescreen when memory have been paged out to disk. Solution used here is creating read-write mapping of the code using memory descriptors list.

The hooks need at least 14 bytes available at the beginning of function. It doesn't trash any registers. Usage example (hooking NtClose) is in example.c.

Current limitations:

  • RIP-relative addressing is not handled.
  • Relative CALLs, JMPs, Jccs are not handled.

kernelhook's People

Contributors

adrianyy avatar

Watchers

 avatar

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.