Git Product home page Git Product logo

jvm-hook's Introduction

JVM-Hook

JVM-Hook is a helper library for creating native applications that interact with the JVM. It aims to ease up the process and make the process more user friendly.


Features

  • Hooking: You can easily hook JVM functions with the help of MinHook. It's also easy to edit if you want to implement your own hooking library.
  • Easy integration: Provides a powerful wrapper for the JNI functionality.
  • Coverage: Works both for internal as well as external projects.

Getting started

Prerequisites

  • Have Java Development Kit (JDK) installed.
  • C++ compiler that supports C++11 or later.
  • Minhook (assuming you do not use your own library)

Installation

To use JVM-Hook in your project, simply download jvmhook.h and jvmhook.cpp and include the header.

Usage

To use JVM-Hook in your project, you first need to initialize the library by calling the JVMHook::Init() function. This function initializes the JVM and sets up the JNI environment. You can specify a handle to the JVM if you're not injecting your binary into the JVM.

JVMHook MyJVM;
MyJVM.Init();

It's important that you call the JVMHook::Exit() before exiting your process or else the JVM might crash.

MyJVM.Exit();

Obtaining function pointers

To obtain a pointer to a Java function in memory you call the JVMHook::GetFunctionPointer() function. There are multiple function overrides to suite different scenarios but the one shown below takes the function name, class, JNI signature as well as whether the function is static or not.

void* myFunctionPtr = MyJVM.GetFunctionPointer("TestClass", "TestFunction", "()V", true);

Hooking functions

To hook Java functions with JVMHook you call the JVMHook::HookFunction() function. This is also the function you want to edit if you would like to change out the MinHook hooking method for your own solution.

using f_myFunction = void(__stdcall*)(void**, void**);
inline f_myFunction testFunctionOriginal;
void __stdcall testFunctionHook(void** p1, void** p2)
{
    // Place le code in here

    return testFunctionOriginal(p1, p2);
}

// ...

void* myFunctionPtr = MyJVM.GetFunctionPointer("TestClass", "TestFunction", "()V", true);

if (MyJVM.HookFunction(myFunctionPtr, &testFunctionHook, &testFunctionOriginal))
    // Passed
else
    // Failed

Contribute

JVM-Hook is an open-source library, and we welcome contributions from the community. If you'd like to contribute to JVM-Hook, here are some ways you can help:

  • Submit bug reports: If you encounter any bugs or issues while using JVM-Hook, please let me know! You can submit bug reports and issues through the project's GitHub issue tracker.
  • Submit pull requests: If you've made changes or improvements to JVM-Hook, we encourage you to submit a pull request. Please make sure that your changes are well-tested and that they adhere to the project's coding standards.

When contributing to JVM-Hook, please be respectful and professional in all communications, all contributions are appreciated!

jvm-hook's People

Contributors

opcode86 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

66hh

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.