Advanced Game Hacking Library (C/C++/Rust/Python) (Windows/Linux/FreeBSD)
Made by rdbo
Discord Server
https://discord.com/invite/Qw8jsPD99X
License
This project is licensed under the GNU AGPLv3.0
(no later versions)
Read LICENSE
for more information
NOTE: Submodules and external dependencies might have their own licenses! Check for other LICENSE
files as well.
Features
- Cross Platform (Windows/Linux/FreeBSD)
- Cross Architecture (x86/x64/ARM/ARM64)
libmem
can:
- Find Processes
- Find Modules
- Find Symbols
- Read/Write/Set Memory
- Allocate/Protect Memory
- Scan Memory by Pattern/Signature
- Hook/Unhook Functions
- Assemble/Dissassemble Code (JIT)
- Do VMT Hooking/Unhooking
- Load/Unload Modules
- Get Page Information
- Enumerate Process Threads
And much more!
Examples
For more examples and API manual, access the documentation
C/C++
int
Rust
use *;
unsafe
Python
# Assemble/Disassemble code
=
=
CMake Usage (without installing)
Add the following commands to your CMakeLists.txt
.
They will fetch libmem-config.cmake
from the root of this repository, which will download libmem binaries for your system and include libmem in your CMake project.
include(FetchContent)
# Download and set up libmem
FetchContent_Declare(libmem-config URL "https://raw.githubusercontent.com/rdbo/libmem/config-v1/libmem-config.cmake" DOWNLOAD_NO_EXTRACT TRUE)
FetchContent_MakeAvailable(libmem-config)
set(CMAKE_PREFIX_PATH "${libmem-config_SOURCE_DIR}" "${CMAKE_PREFIX_PATH}")
set(LIBMEM_DOWNLOAD_VERSION "4.4.0")
# Find libmem package
find_package(libmem CONFIG REQUIRED)
Use the following to link against libmem (NOTE: it might be necessary to link against other dependencies - go to the Dependencies
section for more information):
# Link against libmem
target_link_libraries(<YOUR_TARGET_NAME> PRIVATE libmem::libmem)
Installing
Windows
Note: If you download a binary version of libmem in the GitHub releases, you only need to install the Windows SDK. Building is not necessary, just add libmem/include
to your project's include directories and link it against the binary you downloaded.
-
Install the Windows SDK: Windows 7 - Windows 10/11
-
Install Python 3 (Check the option to add Python to PATH) (Use Python 3.8.9 for Windows 7)
-
Install Visual Studio 2022 or newer (with C++ support and CMake) (older versions might work, but they were not tested). NOTE: You can install only the Visual Studio Build Tools if you don't want the whole IDE.
-
Install Git Bash
-
Run a Visual Studio
Developer Command Prompt
(orx64 Native Tools Command Prompt for VS 2022
for 64 bits) as Administrator -
Run the following command to append libmem's destination directory to your
%PATH%
user variable (WARNING - watch for your%PATH%
size limit!):setx PATH "%PATH%;%ProgramFiles%\libmem\include;%ProgramFiles%\libmem\lib"
-
Continue reading at
Build and Install
Linux
Note: The following commands are for Debian/Ubuntu based distributions. Make sure to find the appropriate commands for your Linux distribution.
-
Open a terminal
-
Install GCC, G++, Git, CMake, Make, Python 3, and the Linux headers:
sudo apt install gcc g++ git cmake make python3 linux-headers
-
Continue reading at
Build and Install
FreeBSD
-
Add a mountpoint for the
procfs
filesystem in your/etc/fstab
by appending the following line:proc /proc procfs rw 0 0
-
Manually mount the
procfs
. This will only be necessary if you don't reboot. If you reboot, it will be automatically mounted because of the line at/etc/fstab
. Run the following command (as root):mount -t procfs proc /proc
-
Install Git, CMake and Python3 (run as root) (clang, clang++ and make should already be installed):
pkg install git cmake python3
-
Continue reading at
Build and Install
Build and Install
Note: Run the following commands on Git Bash (Windows) or a terminal (Linux/FreeBSD).
Clone the repository:
git clone --recursive --depth 1 https://github.com/rdbo/libmem
Generate the CMake cache:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
Compile libmem:
Windows: nmake
Unix-like: make -j 4
Install libmem (run as root or as Administrator):
Windows: nmake install
Unix-like: make install
After installing, follow the the proper Usage
section for your programming language
Usage (C/C++)
Add #include <libmem/libmem.h>
(C/C++) or #include <libmem/libmem.hpp>
(C++) to your source code.
Link the generated libmem library against your binary (liblibmem.so
for Unix-like or libmem.dll
for Windows).
For GCC-like compilers: add the flag -llibmem
to your compiler and it should link it.
Usage (Rust)
Add the following line to your Cargo.toml
under [dependencies]
:
= "4"
Import libmem in your Rust source code:
use *;
Usage (Python)
Make sure to have Python >= 3.6 active
Either install the libmem
package from PyPi by running the following command:
pip install --upgrade libmem
Or build and install it yourself by running the following commands:
cd libmem-py
python configure.py
python setup.py install
Now to import libmem, just do the following in your Python code:
Dependencies
All:
- capstone (included in root project)
- keystone (included in root project)
- LIEF (included in root project)
- libstdc++ (used in keystone, LIEF and LLVM)
- libmath (used in keystone)
Windows:
- Windows SDK (-luser32, -lpsapi, -lntdll)
Linux/Android:
- libdl (-ldl)
BSD:
- libdl (-ldl)
- libkvm (-lkvm)
- libprocstat (-lprocstat)
- libelf (-lelf)
API Overview
LM_EnumProcesses
LM_GetProcess
LM_GetProcessEx
LM_FindProcess
LM_IsProcessAlive
LM_GetSystemBits
LM_EnumThreads
LM_EnumThreadsEx
LM_GetThread
LM_GetThreadEx
LM_GetThreadProcess
LM_EnumModules
LM_EnumModulesEx
LM_FindModule
LM_FindModuleEx
LM_LoadModule
LM_LoadModuleEx
LM_UnloadModule
LM_UnloadModuleEx
LM_EnumSymbols
LM_FindSymbolAddress
LM_DemangleSymbol
LM_FreeDemangleSymbol
LM_EnumSymbolsDemangled
LM_FindSymbolAddressDemangled
LM_EnumPages
LM_EnumPagesEx
LM_GetPage
LM_GetPageEx
LM_ReadMemory
LM_ReadMemoryEx
LM_WriteMemory
LM_WriteMemoryEx
LM_SetMemory
LM_SetMemoryEx
LM_ProtMemory
LM_ProtMemoryEx
LM_AllocMemory
LM_AllocMemoryEx
LM_FreeMemory
LM_FreeMemoryEx
LM_DataScan
LM_DataScanEx
LM_PatternScan
LM_PatternScanEx
LM_SigScan
LM_SigScanEx
LM_HookCode
LM_HookCodeEx
LM_UnhookCode
LM_UnhookCodeEx
LM_Assemble
LM_AssembleEx
LM_FreeCodeBuffer
LM_Disassemble
LM_DisassembleEx
LM_FreeInstructions
LM_CodeLength
LM_CodeLengthEx
LM_VmtNew
LM_VmtHook
LM_VmtUnhook
LM_VmtGetOriginal
LM_VmtReset
LM_VmtFree
Projects
Made with libmem: