{"id":13607009,"url":"https://github.com/rdbo/libmem","last_synced_at":"2026-01-24T00:33:37.952Z","repository":{"id":41386667,"uuid":"285150189","full_name":"rdbo/libmem","owner":"rdbo","description":"Advanced Game Hacking Library for C, Modern C++, Rust and Python (Windows/Linux/FreeBSD) (Process/Memory Hacking) (Hooking/Detouring) (Cross Platform) (x86/x64) (DLL/SO Injection) (Internal/External) (Assembler/Disassembler)","archived":false,"fork":false,"pushed_at":"2025-04-14T21:40:53.000Z","size":2462,"stargazers_count":953,"open_issues_count":52,"forks_count":112,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-05-14T03:21:50.482Z","etag":null,"topics":["assembler","c","c-plus-plus","code-injection","detour-hook","disassembler","function-call","game-hacking","hook","library-injection","memory","process","python","rust","syscall"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rdbo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-08-05T01:55:27.000Z","updated_at":"2025-05-14T01:48:58.000Z","dependencies_parsed_at":"2023-10-17T06:29:09.972Z","dependency_job_id":"b810620a-dafe-4487-b0b5-2eb16fdb9f30","html_url":"https://github.com/rdbo/libmem","commit_stats":{"total_commits":1162,"total_committers":4,"mean_commits":290.5,"dds":0.2117039586919105,"last_synced_commit":"bfa45c57580a6ee7671b78f1028394a325357714"},"previous_names":[],"tags_count":160,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdbo%2Flibmem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdbo%2Flibmem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdbo%2Flibmem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdbo%2Flibmem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rdbo","download_url":"https://codeload.github.com/rdbo/libmem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254076850,"owners_count":22010611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembler","c","c-plus-plus","code-injection","detour-hook","disassembler","function-call","game-hacking","hook","library-injection","memory","process","python","rust","syscall"],"created_at":"2024-08-01T19:01:14.718Z","updated_at":"2026-01-24T00:33:37.946Z","avatar_url":"https://github.com/rdbo.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"![libmem-logo](https://raw.githubusercontent.com/rdbo/libmem/master/LOGO.png)  \n### Advanced Game Hacking Library (C/C++/Rust/Python) (Windows/Linux/FreeBSD)\n### Made by rdbo\n#  \n\n## Discord Server\nhttps://discord.com/invite/Qw8jsPD99X\n\n## License\nThis project is licensed under the `GNU AGPLv3.0` (no later versions)\n\nRead `LICENSE` for more information\n\n**NOTE:** Submodules and external dependencies might have their own licenses! Check for their licenses as well.\n\n## Platforms\n|OS|x86|x64|ARM|Aarch64|\n|:--:|:---:|:---:|:---:|:-------:|\n|Windows|:white_check_mark:|:white_check_mark:|:warning:|:warning:|\n|Linux|:white_check_mark:|:white_check_mark:|:warning:|:warning:|\n|FreeBSD|:heavy_check_mark:|:heavy_check_mark:|:warning:|:warning:|\n\n|Status|Description|\n|:------:|:-----------:|\n|:white_check_mark:|100% working|\n|:heavy_check_mark:|Mostly working|\n|:warning:|Untested|\n\n## Features\n- [x] Internal and External\n- [x] Find and Enumerate Processes, Modules, Symbols, Threads and Segments\n- [x] Read/Write Memory\n- [x] Allocate/Protect Memory\n- [x] Scan Memory by Pattern/Signature\n- [x] Resolve Pointer Scans/Pointer Maps\n- [x] Hook/Unhook Functions\n- [x] Assemble/Disassemble Code (JIT)\n- [x] VMT Hooking/Unhooking\n- [x] Load/Unload Modules\n- [x] Enumerate Process Threads\n\n***And much more!***\n\n## Examples\n### Modern C++\n```cpp\n/* C++20 or higher */\n#include \u003clibmem/libmem.hpp\u003e\n#include \u003ciostream\u003e\n\nusing namespace libmem;\n\nint main()\n{\n\tAddress disas_addr = reinterpret_cast\u003cAddress\u003e(main);\n\n\t// Disassemble function 'main' until a 'ret' is found\n\tfor (;;) {\n\t\tauto inst = Disassemble(disas_addr).value();\n\t\tstd::cout \u003c\u003c inst.to_string() \u003c\u003c std::endl;\n\t\tif (inst.mnemonic == \"ret\")\n\t\t\tbreak;\n\t\tdisas_addr += inst.bytes.size();\n\t}\n\n\treturn 0;\n}\n\n/*\nOutput:\n0x55b1a3259275: push rbp -\u003e [ 55 ]\n0x55b1a3259276: mov rbp, rsp -\u003e [ 48 89 e5 ]\n...\n0x55b1a325941a: leave  -\u003e [ c9 ]\n0x55b1a325941b: ret  -\u003e [ c3 ]\n*/\n```\n\n### C/C++\n```c\n#include \u003clibmem/libmem.h\u003e\n\nvoid hk_take_damage(int amount)\n{\n  printf(\"hooked take_damage! no damage will be taken\\n\");\n  return;\n}\n\nint main()\n{\n\tlm_module_t game_mod;\n\tlm_address_t fn_take_damage;\n\n\tLM_FindModule(\"game.dll\", \u0026game_mod);\n\tprintf(\"[*] Base address of 'game.dll': %p\\n\", game_mod.base);\n\n\tfn_take_damage = LM_FindSymbolAddress(\u0026game_mod, \"take_damage\");\n\tprintf(\"[*] Found 'take_damage' function: %p\\n\", fn_take_damage);\n\n\tLM_HookCode(fn_take_damage, hk_take_damage, LM_NULLPTR);\n\tprintf(\"[*] 'take_damage' hooked, player will no longer receive damage\\n\");\n\n\treturn 0;\n}\n```\n\n### Rust\n```rust\nuse libmem::*;\n\nfn godmode() -\u003e Option\u003c()\u003e {\n    let game_process = find_process(\"game_linux64\")?;\n    let client_module = find_module_ex(\u0026game_process, \"libclient.so\")?;\n\n    let fn_update_health = sig_scan_ex(\n        \u0026game_process,\n        \"55 48 89 E5 66 B8 ?? ?? 48 8B 5D FC\",\n        client_module.base,\n        client_module.size,\n    )?;\n    println!(\n        \"[*] Signature scan result for 'update_health' function: {}\",\n        fn_update_health\n    );\n\n    let shellcode = assemble_ex(\"mov rbx, 1337; mov [rdi], rbx; ret\", Arch::X64, 0)?;\n    write_memory_ex(\u0026game_process, fn_update_health + 8, \u0026shellcode.as_slice())?;\n    println!(\"[*] Patched 'update_health' function to always set health to 1337!\");\n\n    Some(())\n}\n\nfn main() {\n    godmode();\n}\n```\n\n### Python\n```py\nfrom libmem import *\nimport time\n\nprocess = find_process(\"game.exe\")\ngame_mod = find_module_ex(process, process.name)\n\n# Resolve a Cheat Engine pointer scan\nhealth_pointer = deep_pointer_ex(process, game_mod.base + 0xdeadbeef, [0xA0, 0x04, 0x10, 0xF0, 0x0])\n\n# Set player health to 1337 forever\nwhile True:\n    write_memory_ex(process, health_pointer, bytearray(int(1337).to_bytes(4)))\n    time.sleep(0.2)\n```\n\n## Documentation\nThe main documentation for libmem can be found in `include/libmem.h`.\nAll APIs are documented and contain very descriptive information about each function, their parameters and return value.\nThey are located in nearby comments, so you should be able to see them by hovering on your text editor/IDE.\n\nSimilarly, the bindings documentation is embedded with their packages, so your text editor/IDE should be able to access the documentation for each API.\n\n## Unofficial Bindings\nThese bindings are done by the community/third-parties and are not affiliated with the libmem project or its author.\n\nTheir code can have their own licenses as well, diverging from libmem's.\n\n- [Nim_Libmem](https://github.com/Hypnootika/python_nim_libmem)\n- [Crazymem (NodeJS)](https://github.com/karliky/Crazymem)\n\n## CMake Usage (without installing)\nAdd the following commands to your `CMakeLists.txt`.\n\nThey 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.\n\n```cmake\ninclude(FetchContent)\n\n# Download and set up libmem\nFetchContent_Declare(libmem-config URL \"https://raw.githubusercontent.com/rdbo/libmem/config-v1/libmem-config.cmake\" DOWNLOAD_NO_EXTRACT TRUE)\nFetchContent_MakeAvailable(libmem-config)\nset(CMAKE_PREFIX_PATH \"${libmem-config_SOURCE_DIR}\" \"${CMAKE_PREFIX_PATH}\")\nset(LIBMEM_DOWNLOAD_VERSION \"5.1.4\")\n\n# Find libmem package\nfind_package(libmem CONFIG REQUIRED)\n```\n\nUse the following to link against libmem (NOTE: it might be necessary to link against other dependencies - go to the `Dependencies` section for more information):\n\n```cmake\n# Link against libmem\ntarget_link_libraries(\u003cYOUR_TARGET_NAME\u003e PRIVATE libmem::libmem)\n```\n\n## Installing\n\n### vcpkg\n\n[![vcpkg](https://img.shields.io/vcpkg/v/libmem)](https://vcpkg.io/en/package/libmem)\n\n**Note**: Support vcpkg for package management\n\n1. Install vcpkg (https://github.com/microsoft/vcpkg)\n\n2. Run the following command to install the libmem package:\n\n```\nvcpkg install libmem\n```\n\nFor detailed commands on installing different versions and more information, please refer to Microsoft's official instructions (https://learn.microsoft.com/en-us/vcpkg/get_started/overview)\n\n### Windows\n**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.\n\n1. Install the Windows SDK: [Windows 7](https://www.microsoft.com/en-us/download/details.aspx?id=8279) - [Windows 10/11](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/)\n\n2. Install [Python 3](https://python.org/downloads) (Check the option to add Python to PATH) (Use [Python 3.8.9](https://python.org/downloads/release/python-389) for Windows 7)\n\n3. Install [Visual Studio](https://visualstudio.microsoft.com/) 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.\n\n4. Install [Git Bash](https://git-scm.com/downloads)\n\n5. Run a Visual Studio `Developer Command Prompt` (or `x64 Native Tools Command Prompt for VS 2022` for 64 bits) as Administrator\n\n6. Run the following command to append libmem's destination directory to your `%PATH%` user variable (**WARNING** - watch for your `%PATH%` size limit!):\n\n        setx PATH \"%PATH%;%ProgramFiles%\\libmem\\include;%ProgramFiles%\\libmem\\lib\"\n\n7. Continue reading at `Build and Install`\n\n### Linux\n**Note**: The following commands are for Debian/Ubuntu based distributions. Make sure to find the appropriate commands for your Linux distribution.\n\n1. Open a terminal\n\n2. Install GCC, G++, Git, CMake, Make, Python 3, and the Linux headers:\n\n        sudo apt install gcc g++ git cmake make python3 linux-headers\n\n3. Continue reading at `Build and Install`\n\n### FreeBSD\n\n1. Add a mountpoint for the `procfs` filesystem in your `/etc/fstab` by appending the following line:\n\n        proc\t\t/proc\t\tprocfs\trw\t0\t0\n\n2. 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):\n\n        mount -t procfs proc /proc\n\n3. Install Git, CMake and Python3 (run as root) (clang, clang++ and make should already be installed):\n\n        pkg install git cmake python3\n\n4. Continue reading at `Build and Install`\n\n### Build and Install\n**Note**: Run the following commands on Git Bash (Windows) or a terminal (Linux/FreeBSD).\n\nClone the repository:\n```\ngit clone --recursive --depth 1 https://github.com/rdbo/libmem\n```\nGenerate the CMake cache:\n```\nmkdir build\ncd build\ncmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-fpermissive -DCMAKE_EXPORT_COMPILE_COMMANDS=1\n```\n\nCompile libmem:\n\n*Windows*: `nmake`\n\n*Unix-like*: `make -j 4`\n\nInstall libmem (run as root or as Administrator):\n\n*Windows*: `nmake install`\n\n*Unix-like*: `make install`\n\nAfter installing, follow the the proper `Usage` section for your programming language\n\n## Usage (C/C++)\n\nAdd `#include \u003clibmem/libmem.h\u003e` (C/C++) or `#include \u003clibmem/libmem.hpp\u003e` (C++) to your source code.\nLink the generated libmem library against your binary (`liblibmem.so` for Unix-like or `libmem.dll` for Windows).\n*For GCC-like compilers*: add the flag `-llibmem` to your compiler and it should link it.\n```c\n#include \u003clibmem/libmem.h\u003e /* C/C++ */\n#include \u003clibmem/libmem.hpp\u003e /* Force C++ */\n```\n\n## Usage (Rust)\n**NOTE**: You no longer have to install libmem to use with Rust, as long as the `fetch` feature is enabled on the libmem crate (default). If you disable that feature, it will look for libmem in your system, and you can make the libmem path explicit by using the environment var `LIBMEM_DIR=\u003cpath to libmem's directory\u003e`.\n\nAdd the following line to your `Cargo.toml` under `[dependencies]`:\n```toml\nlibmem = \"5\"\n```\nImport libmem in your Rust source code:\n```rust\nuse libmem::*;\n```\n\n## Usage (Python)\n**NOTE**: You no longer have to install libmem to use with Python. If no installation is found, the package will fetch and link libmem for you seamlessly. You can use the `LIBDIR=\u003cpath to libmem's directory\u003e` environment variable to tell the libmem package where to look for your installation (if you installed it).\n\nMake sure to have Python \u003e= 3.6 active  \nEither install the `libmem` package from PyPi by running the following command:  \n```\npip install --upgrade libmem\n```\nOr build and install it yourself by running the following commands:\n```\ncd libmem-py\npython configure.py\npython setup.py install\n```\nNow to import libmem, just do the following in your Python code:\n```py\nfrom libmem import *\n```\n\n## Dependencies\nAll:\n- capstone (included in root project)\n- keystone (included in root project)\n- LIEF (included in root project)\n- libstdc++ (used in keystone, LIEF and LLVM)\n- libmath (used in keystone)\n\nWindows:  \n- Windows SDK (user32.lib, psapi.lib, ntdll.lib, shell32.lib)\n\nLinux/Android:  \n- libdl (-ldl)\n\nBSD:  \n- libdl (-ldl)  \n- libkvm (-lkvm)\n- libprocstat (-lprocstat)    \n- libelf (-lelf)\n  \n## API Overview\n```\n** Process APIs **\nLM_EnumProcesses\nLM_GetProcess\nLM_GetProcessEx\nLM_GetCommandLine\nLM_FreeCommandLine\nLM_FindProcess\nLM_IsProcessAlive\nLM_GetBits\nLM_GetSystemBits\n\n** Thread APIs **\nLM_EnumThreads\nLM_EnumThreadsEx\nLM_GetThread\nLM_GetThreadEx\nLM_GetThreadProcess\n\n** Module APIs **\nLM_EnumModules\nLM_EnumModulesEx\nLM_FindModule\nLM_FindModuleEx\nLM_LoadModule\nLM_LoadModuleEx\nLM_UnloadModule\nLM_UnloadModuleEx\n\n** Symbol APIs **\nLM_EnumSymbols\nLM_FindSymbolAddress\nLM_DemangleSymbol\nLM_FreeDemangledSymbol\nLM_EnumSymbolsDemangled\nLM_FindSymbolAddressDemangled\n\n** Memory Segment APIs **\nLM_EnumSegments\nLM_EnumSegmentsEx\nLM_FindSegment\nLM_FindSegmentEx\n\n** Memory APIs **\nLM_ReadMemory\nLM_ReadMemoryEx\nLM_WriteMemory\nLM_WriteMemoryEx\nLM_SetMemory\nLM_SetMemoryEx\nLM_ProtMemory\nLM_ProtMemoryEx\nLM_AllocMemory\nLM_AllocMemoryEx\nLM_FreeMemory\nLM_FreeMemoryEx\n\n** Scanning APIs **\nLM_DeepPointer\nLM_DeepPointerEx\nLM_DataScan\nLM_DataScanEx\nLM_PatternScan\nLM_PatternScanEx\nLM_SigScan\nLM_SigScanEx\n\n** Assembler APIs **\nLM_GetArchitecture\nLM_Assemble\nLM_AssembleEx\nLM_FreePayload\nLM_Disassemble\nLM_DisassembleEx\nLM_FreeInstructions\nLM_CodeLength\nLM_CodeLengthEx\n\n** Hooking APIs **\nLM_HookCode\nLM_HookCodeEx\nLM_UnhookCode\nLM_UnhookCodeEx\nLM_VmtNew\nLM_VmtHook\nLM_VmtUnhook\nLM_VmtGetOriginal\nLM_VmtReset\nLM_VmtFree\n```\n\n## Contributing\nRead the file `CONTRIBUTING.md` in the root directory of this repository\n\n## Projects\nMade with libmem:  \n- [AssaultCube Multihack](https://github.com/rdbo/AssaultCube-Multihack)  \n- [X-Inject](https://github.com/rdbo/x-inject)  \n- [DirectX9 BaseHook](https://github.com/rdbo/DX9-BaseHook)  \n- [DirectX11 BaseHook](https://github.com/rdbo/DX11-BaseHook)  \n- [OpenGL BaseHook](https://github.com/rdbo/GL-BaseHook)  \n- [Counter-Strike 1.6 BaseHook](https://github.com/rdbo/cstrike-basehook)  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdbo%2Flibmem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frdbo%2Flibmem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdbo%2Flibmem/lists"}