Skip to content

Repository files navigation

build build build build license code-quality Bugs


Logo

libhack

A modern and easy to use memory hacking library.
Explore docs »

Examples · Report Bug · Request Feature

Table of Contents

About The Project

This is a simple and easy to use memory hacking library. It was created to make my work on the project easier but can be used for many other purposes.

Built With

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

This is an example of how to list things you need to use the software and how to install them.

Building


  1. Clone the libhack
git clone https://github.com/lucas-engen/libhack.git
  1. Go to project folder
cd libhack
  1. Configure the project
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
  1. Build the library
cmake --build build --parallel
  1. Run the tests
cmake --build build --target test

To install the library and headers locally, run:

cmake --install build --prefix "$HOME/.local"

Building examples


  1. Configure the project with examples enabled
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DLIBHACK_BUILD_EXAMPLES=ON
  1. Build the examples
cmake --build build --parallel

Usage

To use this library, simply copy the development files to your project source code folder. Example:

We have a project called foo and it has the following files: foo.c and main.c localized inside the foo folder. The project tree will be something like this:

foo
|  foo.c
|  main.c

If you want to use libhack library, just put the libhack header files and libhack import library inside the foo folder. The source code tree will be:

foo
|   foo.c
|   main.c
|   hack.h
|   process.h
|   ...
|   ...
|   ...
|   libhack.a

In order to build the project foo, you just need to run

gcc foo.c main.c -L. -lhack

At this point the foo program will be dynamically linked to libhack, and will need libhack.dll or libhack.so to be opened correctly.

For more examples, please refer to examples below

Cross-platform memory API

The unified API works on both Windows and Linux and uses native-width process addresses:

uint32_t value;
libhack_status_t status = libhack_read_memory(
    handle, address, &value, sizeof(value));

Use libhack_init_by_pid when the target PID is already known. Existing type-specific functions remain available for compatibility.

Pointer chains

libhack_resolve_pointer_chain, libhack_read_pointer_chain and libhack_write_pointer_chain accept the base address and offsets copied from Cheat Engine. For offsets = {0x10, 0x20, 0x8}, libhack resolves *(*(base_address + 0x10) + 0x20) + 0x8 and performs the operation at the resulting address. Offsets are signed, so negative offsets are supported.

const libhack_offset_t offsets[] = {0x10, 0x20, 0x8};
uint32_t value;

libhack_status_t status = libhack_read_pointer_chain(
    handle, base_address, offsets, arraySize(offsets), &value, sizeof(value));

The target process must have the same pointer width as the libhack process.

Módulos, regiões e assinaturas

libhack_get_modules and libhack_get_memory_regions expose module bases, sizes, paths and normalized rwx protections. Release their allocated data with the corresponding libhack_free_* function. libhack_scan_memory and libhack_scan_module support byte signatures using an x/? mask and return all matches through struct libhack_match_list.

As operações retornam libhack_status_t; libhack_get_last_error() fornece o último status e libhack_get_last_native_error() o código nativo de Windows ou Linux. Nenhuma dessas APIs encerra o processo em caso de erro.

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/new_feature)
  3. Commit your Changes (git commit -m 'Add new feature')
  4. Push to the Branch (git push origin feature/new_feature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Lucas Vieira - Instagram - Gmail

Project Link: https://github.com/lucas-engen/libhack

Acknowledgements

  • To God for life
  • To my father Jenner Silva who introduced me to the world of computing

About

A simple, modern and easy to use memory hacking library

Topics

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages