{"id":19293502,"url":"https://github.com/reloaded-project/reloaded.hooks-rs","last_synced_at":"2025-10-24T10:02:18.475Z","repository":{"id":186440361,"uuid":"672675322","full_name":"Reloaded-Project/Reloaded.Hooks-rs","owner":"Reloaded-Project","description":"[WIP, NOT YET USABLE] Next Gen no_std Rust rewrite the Reloaded.Hooks library.","archived":false,"fork":false,"pushed_at":"2024-09-06T18:27:17.000Z","size":3210,"stargazers_count":4,"open_issues_count":10,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T07:46:28.275Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Reloaded-Project.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,"publiccode":null,"codemeta":null}},"created_at":"2023-07-30T22:02:52.000Z","updated_at":"2025-03-14T16:57:53.000Z","dependencies_parsed_at":"2023-09-24T03:32:06.062Z","dependency_job_id":"c6a1378c-a337-4d82-9afc-51f979c5ef5b","html_url":"https://github.com/Reloaded-Project/Reloaded.Hooks-rs","commit_stats":null,"previous_names":["reloaded-project/reloaded.hooks-rs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Reloaded-Project/Reloaded.Hooks-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reloaded-Project%2FReloaded.Hooks-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reloaded-Project%2FReloaded.Hooks-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reloaded-Project%2FReloaded.Hooks-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reloaded-Project%2FReloaded.Hooks-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Reloaded-Project","download_url":"https://codeload.github.com/Reloaded-Project/Reloaded.Hooks-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reloaded-Project%2FReloaded.Hooks-rs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269390980,"owners_count":24409531,"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","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-09T22:35:14.159Z","updated_at":"2025-10-24T10:02:18.350Z","avatar_url":"https://github.com/Reloaded-Project.png","language":"Rust","readme":"# reloaded-hooks\n\n[![Crates.io](https://img.shields.io/crates/v/reloaded-hooks.svg)](https://crates.io/crates/reloaded-hooks)\n[![Docs.rs](https://docs.rs/reloaded-hooks/badge.svg)](https://docs.rs/reloaded-hooks)\n[![CI](https://github.com/Reloaded-Project/Reloaded.Hooks-rs/workflows/CI/badge.svg)](https://github.com/Reloaded-Project/Reloaded.Hooks-rs/actions)\n\n## About\n\nAdvanced native function hooks for x86, x64. Now in Rust, and cross platform too!\nYou can learn more about this project in the [dedicated documentation page][docs].\n\n## Development\n\nHow to develop this project.\n\n***Clone this Repository:***\n```bash\n# When cloning, make sure symlinks are enabled\ngit clone -c core.symlinks=true https://github.com/Reloaded-Project/Reloaded.Hooks-rs.git\n```\n\n***Install Rust:***\n- Install the [Rust Toolchain.][rust-toolchain]  \n\n***Setup IDE***\n- This repository is fully with VSCode. [Guidance below](#visual-studio-code-integration).\n\n### Visual Studio Code Integration\n\n`Code`/`VSCode` is the de-facto Rust development environment.  \n\nThe following extensions are required:  \n- [rust-analyzer][rust-analyzer] for Rust support.  \n- [coverage-gutters][coverage-gutters] for Coverage support.  \n- [CodeLLDB][codelldb] for debugging.  \n- [crates](https://marketplace.visualstudio.com/items?itemName=serayuzgur.crates) easier dependency management.  \n\nThe VSCode configuration in Reloaded projects (`.vscode`) contain the following:  \n- Run Rust linter `clippy` on Save.  \n- Run code format `rustfmt` on Save.  \n- Tasks for common operations (generate documentation, active CI/CD etc.).  \n\nThese configurations are in the `.vscode` folder; and the tasks can be ran via `Ctrl+Shift+P -\u003e Run Task`.  \n\n#### Test Coverage\n\nFirst install or update `tarpaulin`:\n\n```bash\ncargo install cargo-tarpaulin\n```\n\nTo run Coverage, run task (`Ctrl+Shift+P -\u003e Run Task`), you should see something similar to: \n\n| Task                   | Description                                                                |\n| ---------------------- | -------------------------------------------------------------------------- |\n| Cargo Watch Tarpaulin  | Automatically runs tests and updates coverage on save.                     |\n| Generate Code Coverage | Manually generate code coverage (`cobertura.xml`, `tarpaulin-report.html`) |\n\nThe `tarpaulin-report.html` file can be opened in VSCode (`Show Preview`) for a live view.\n\nFor GUI integration, run action `Coverage Gutter: Watch` (in `Ctrl+Shift+P` actions menu).\n\n## Debugging Benchmarks\n\nIf you wish to debug benchmarks in VSCode, go to `Run and Debug` Menu and generate the launch \nprofiles, you should get one for debugging benchmarks.\n\n## Benchmarks with Side Effects\n\nSome benchmarks have side effects, such as `assembly_hook_creation` in x86 package; which make subsequent runs slower. \n\nIn those scenarios, you can run them as such:\n\n```\ncargo bench --bench my_benchmark -- assembly_hook_creation --warm-up-time 0.000000001 --measurement-time 5 --verbose\n```\n\nYou will get a printout such as:\n\n```\nBenchmarking assembly_hook_creation: Warming up for 1.0000 ns\nBenchmarking assembly_hook_creation: Collecting 100 samples in estimated 52.981 s (80800 iterations)\nBenchmarking assembly_hook_creation: Analyzing\nassembly_hook_creation  time:   [10.355 µs 10.613 µs 10.833 µs]\n                        change: [-5.0994% -1.8940% +1.5054%] (p = 0.28 \u003e 0.05)\n                        No change in performance detected.\n```\n\nWith this info, you'll find out that for 80800 iterations it takes, 10.613 µs on average, per iteration, or\n857ms for all 80800 iterations, if extrapolated.\n\nThese benches are disabled by default, re-enable them in source code to run them if desired.\n\n## Profiling Benchmarks\n\n### Linux/OSX\n\nExecute the following:\n\n```\ncargo bench --bench my_benchmark --profile profile -- --profile-time 10\n```\n\nThis should give you a flamegraph in `target/criterion/\u003cmethod_name\u003e/profile`. You can open that flamegraph in a web browser.\n\n### Windows\n\nExecute the following:\n\n```\ncargo bench --bench my_benchmark --no-run --profile profile\n```\n\nNavigate to the executable listed in the commandline:\n\n```\ntarget/profile/deps/my_benchmark-eced832ac8f31257.exe\n```\n\nAnd run with command `my_benchmark-eced832ac8f31257.exe --bench --profile-time 10` under an external profiler, such as Visual Studio.  \n\n![example](./assets/profile_example.png)\n\n## Optimizing for Size when Creating C Libraries\n\n1. Add `\"cdylib\"` crate type to `Cargo.toml` (if not already present)\n\n```\n[lib]\ncrate-type = [\"cdylib\"]\n```\n\nInstall `cargo-bloat`, `nightly toolchain` and `build-std`:\n\n```\ncargo install cargo-bloat\nrustup toolchain install nightly\nrustup component add rust-src --toolchain nightly\n```\n\nRun `cargo-bloat` the following command to calculate package size:\n\n```\nRUSTFLAGS=\"-C panic=abort -C lto=fat -C embed-bitcode=yes\" cargo +nightly bloat -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-pc-windows-gnu --profile profile --crate-type cdylib -n 100\n```\n\nChange `--target` if needed for your platform.  \nThis should produce binaries more appropriate for dynamic linking from C.  \n\n## File Layout\n\nIndividual projects are under the `projects` folder; they contain the following:  \n\n- `reloaded-hooks-portable`: Core engine of `Reloaded.Hooks`, platform \u0026 architecture agnostic.  \n- `reloaded-hooks-x86-sys`: Implements support for x86 \u0026 AMD64 architecture.  \n- `reloaded-hooks-aarch64-sys`: Implements support for ARM64 (aarch64) architecture.  \n- `reloaded-hooks-buffers-common`: Improves support on Linux/macOS/Windows by adding targeted memory allocation capabilities. Using [reloaded-memory-buffers][reloaded-memory-buffers].  \n- `reloaded-hooks`: High level API for the `Reloaded.Hooks` packages.  \n\nThe following is the expected file layout for the repository:\n\n```\n.vscode/\ndocs/\nmkdocs.yml\n```\n\nThe `docs` folder, and `mkdocs.yml` contain [MkDocs Material documentation][mkdocs-material] for your project.  \n\n## Cross Platform Targeting\n\nSome templates allow for cross platform development.  \n\nTo work with cross-platform code, where you need to access OS specific APIs, some helper scripts are provided.  \n\n### Including All Code Paths\n\nTo include all code paths for local builds, consider editing `.cargo/config.toml`.\n\n```toml\n[build]\n# Note: This breaks IntelliJ Rust. Remove this line temporarily if working from that IDE.\ntarget = ['x86_64-unknown-linux-gnu','x86_64-apple-darwin','x86_64-pc-windows-gnu']\n```\n\nYou might need to install the targets first:\n\n```bash\nrustup target add x86_64-unknown-linux-gnu\nrustup target add x86_64-apple-darwin\nrustup target add x86_64-pc-windows-gnu\n```\n\nNow when you run `cargo build`, it will build code for all platforms; and you'll get your compiler errors, warnings etc.\n\n### Cross Testing on Local Machine\n\n#### Prerequisites (Windows)\n\n- Install [Docker Desktop](https://www.docker.com/products/docker-desktop/).  \n- Disable WSL 2 (Docker Desktop -\u003e Settings -\u003e General -\u003e Use the WSL 2 based engine).  \n\n#### Prerequisites (Linux)\n\n- Install [Podman](https://podman.io) from your package manager.  \n\n#### Prerequisites (Common)\n\nInstall cross\n\n```\ncargo install cross\n```\n\n#### Running Cross-Platform Tests\n\nUse the provided `pwsh` scripts in `scripts` folder.\n\n- `./test-wine-x64.ps1`: Tests your code in Wine on x86_64.  \n- `./test-linux-x64.ps1`: Tests your code in Linux on x86_64.  \n- `./test-linux-x86.ps1`: Tests your code in Linux on x86.  \n\nThese scripts can be used on any platform given the prerequisites are met.  \nIf you need to test Apple stuff without an Apple machine, you're generally out of luck outside of using CI/CD for testing.  \n\n## Contributing\n\nSee [CONTRIBUTING](CONTRIBUTING.MD) for guidance on how to contribute to this project.  \n\n## License\n\nLicensed under [GPL V3 w/ Reloaded FAQ](./LICENSE), the default for Reloaded project.  \n[Learn more about Reloaded's choice of licensing.][reloaded-license].  \n\n[codecov]: https://about.codecov.io/\n[codelldb]: https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb\n[coverage-gutters]: https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters \n[crates-io-key]: https://crates.io/settings/tokens\n[docs]: https://reloaded-project.github.io/Reloaded.Hooks-rs\n[mkdocs-material]: https://squidfunk.github.io/mkdocs-material/\n[reloaded-license]: https://reloaded-project.github.io/Reloaded.MkDocsMaterial.Themes.R2/Pages/license/\n[reloaded-memory-buffers]: https://crates.io/crates/reloaded_memory_buffers\n[rust-analyzer]: https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer\n[rust-toolchain]: https://www.rust-lang.org/tools/install\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freloaded-project%2Freloaded.hooks-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freloaded-project%2Freloaded.hooks-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freloaded-project%2Freloaded.hooks-rs/lists"}