Skip to content

Latest commit

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

JavaHook – Java Method Hooking Library

A simple, small library for hooking Java methods from C++ without using JVMTI.

⚠️ Correct code execution is guaranteed only on the official Java 8 Update 191 build. For other Java versions, you may need to modify the JDK classes in the JvmStructures.hpp file to match your target version.

Library can:

  • Intercept method calls
  • Get arguments of the intercepted method at runtime
  • Change arguments of the intercepted method at runtime

Examples

Hook for the setFlySpeed method in Minecraft 1.8.8

imageimage

Hook for the sendChatMessage method in Minecraft 1.8.8

imageimage

Dependencies

JDK 8 update 191

udis86

Step 1: install JDK and include these folders in your project:

  • java_folder\jdk1.8.0_191\include
  • java_folder\jdk1.8.0_191\include\win32
  • java_folder\jdk1.8.0_191\include\win32\bridge

Also, link the jvm.lib from: java_folder\jdk1.8.0_191\lib.

P.S: Java folder is usually located in C:\Program Files\Java

Step 2: Build udis86 and include it in your project:

Include udis_folder\BuildVS2010\Build\Include

And link libudis86.lib from udis_folder\BuildVS2010\Build\Lib\x64

P.S: Build is usually located in udis_folder\BuildVS2010\Build.

Including the library in a Visual Studio project

Visual Studio 2022 will be used as an example

  1. Clone the repository to a directory you are comfortable with
  2. Open your project in Visual Studio, right-click on the project in the Solution Explorer and select "Properties"
  3. In the "Configuration Properties" section, go to "VC++ Directories", select "Include Directories" and click on the dropdown menu. Click "Edit" and add cloned_repository/include there.
  4. Done!

Requirements

x64 Windows 7, 8, 8.1, 10, 11

About

Simple two-header library for Java methods hooking from C++ without using JVMTI. Allows intercepting method calls and accessing or modifying their arguments at runtime.

Topics

Resources

Stars

15 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages