{"id":27312242,"url":"https://github.com/soratenshi/zig-bait","last_synced_at":"2025-06-28T11:33:23.575Z","repository":{"id":168026152,"uuid":"639161493","full_name":"SoraTenshi/zig-bait","owner":"SoraTenshi","description":"A Zig Hooking Library","archived":false,"fork":false,"pushed_at":"2025-03-09T00:41:02.000Z","size":180,"stargazers_count":19,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-25T06:47:18.158Z","etag":null,"topics":["hooking-library","vmt-hooking"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SoraTenshi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"zenodo":null}},"created_at":"2023-05-10T22:27:34.000Z","updated_at":"2025-06-18T20:36:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"a25207f5-8e12-4d78-8df5-865a9639c7b9","html_url":"https://github.com/SoraTenshi/zig-bait","commit_stats":null,"previous_names":["soratenshi/zig-bait"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SoraTenshi/zig-bait","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoraTenshi%2Fzig-bait","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoraTenshi%2Fzig-bait/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoraTenshi%2Fzig-bait/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoraTenshi%2Fzig-bait/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SoraTenshi","download_url":"https://codeload.github.com/SoraTenshi/zig-bait/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoraTenshi%2Fzig-bait/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262422008,"owners_count":23308565,"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":["hooking-library","vmt-hooking"],"created_at":"2025-04-12T06:39:29.221Z","updated_at":"2025-06-28T11:33:23.534Z","avatar_url":"https://github.com/SoraTenshi.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"![logo](https://github.com/SoraTenshi/zig-bait/blob/main/zig-bait.png?raw=true)\n\nA native Hooking library with support for all common hooking mechanisms.\nDetour \u0026 IAT hooks are not yet supported, but VMT are fully implemented.\n\nIf you have any ideas for how to automatically test this library, please let me know, considering\nASLR and the difference in possible multiple Compilers, i am not really sure how to effectively assure\nthis.\n\n## Usage:\n### Install:\nIn your project just add the dependency to your Zig dependencies: `zig fetch --save https://github.com/SoraTenshi/zig-bait/archive/main.tar.gz`\n\nAnd then in your `build.zig`: \n```zig\nconst bait = b.dependency(\"zig_bait\", .{});\n\nyour_project.root_module.addImport(\"bait\", bait.module(\"zig-bait\"));\n```\n\n### Using in your Project:\n1. Make sure that your target uses the C calling convention. Implicitly `fastcall`, `stdcall` and all the ones\ndefined within Zig are supported.\n\n```zig\n// ...\nconst bait = @import(\"bait\");\nconst HookManager = @import(\"bait\").HookManager;\n\nvar hook_manager: HookManager = undefined;\n\nfn hooked(abc: usize) callconv(.C) void {\n  const original = hook_manager.getOriginalFunction(\u0026hooked).?;\n\n  std.debug.print(\"I am hooked {s}\\n\", .{ \"on you ;)\" });\n  original(abc);\n}\n\npub fn main() !void {\n  const alloc = std.heap.page_allocator;\n  hook_manager = HookManager.init(alloc);\n  defer hook_manager.deinit();\n\n  const victim_vtable: usize = @intFromPtr(getSymbolByName(\"your_target_func\"));\n  try hook_manager.append(\n    bait.Method{\n      .vmt = .{\n        .object_address = victim_table,\n        .positions = \u0026.{ 1 },\n        .targets = \u0026.{ @intFromPtr(\u0026hooked) },\n      }\n    }\n  );\n  try hook_manager.hookAll()\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoratenshi%2Fzig-bait","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoratenshi%2Fzig-bait","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoratenshi%2Fzig-bait/lists"}