{"id":13728963,"url":"https://github.com/HearthSim/UnityHook","last_synced_at":"2025-05-08T01:30:29.862Z","repository":{"id":29461598,"uuid":"32998066","full_name":"HearthSim/UnityHook","owner":"HearthSim","description":"Platform to hook into Unity3D assemblies","archived":false,"fork":false,"pushed_at":"2017-12-27T23:29:18.000Z","size":675,"stargazers_count":271,"open_issues_count":1,"forks_count":56,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-04-09T20:10:41.622Z","etag":null,"topics":["c-sharp","unity3d"],"latest_commit_sha":null,"homepage":"https://hearthsim.info","language":"C#","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/HearthSim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-27T16:49:43.000Z","updated_at":"2025-03-05T00:50:26.000Z","dependencies_parsed_at":"2022-08-07T14:16:33.794Z","dependency_job_id":null,"html_url":"https://github.com/HearthSim/UnityHook","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HearthSim%2FUnityHook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HearthSim%2FUnityHook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HearthSim%2FUnityHook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HearthSim%2FUnityHook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HearthSim","download_url":"https://codeload.github.com/HearthSim/UnityHook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252981371,"owners_count":21835416,"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":["c-sharp","unity3d"],"created_at":"2024-08-03T02:00:52.838Z","updated_at":"2025-05-08T01:30:29.140Z","avatar_url":"https://github.com/HearthSim.png","language":"C#","readme":"# UnityHook\n\nUnityHook is a simple platform for hooking managed function calls, targeting\nspecifically assemblies compiled for [Unity3d](http://unity3d.com/) games.\n\nInstalled hooks allow overriding hooked functions' return values, essentially\ngranting complete control over managed code execution in a targeted game.\n\n## Hooker\n\n**Hooker** is the project that actually injects code into original game assemblies/libraries (= .dll files).\nIt can be used to 'hook' and 'restore' assemblies. Run `hooker.exe help` for information about the options to pass.\nTo hook game-assemblies you need to tell it the location of the game folder and the path to a compiled **HookRegistry** binary.\n\n## HookRegistry\n\n**HookRegistry** is the project that contains code to be executed when a hooked method/function has been called\nwhile the game is running. The project compiles to 1 binary file that must be passed to **Hooker**.\nCurrently implemented hooks are following:\n\n- Hearthstone - *with dependancy on HS game libraries*\n    - Disable SSL connection between client/server;\n    - Duplicate packets transferred between client/server to other TCP streams. These streams try to attach to the\n    [HearthStone PacketAnalyzer](https://github.com/HearthSim/Hearthstone-Packet-Dumps/tree/master/HackstoneAnalyzer). \n- General\n    - Hooking into the Unity logger.\n\n\u003e **Hooker** will attempt to copy all referenced (by **HookRegistry**) library files to the library folder of the game. Make sure to validate all necessary library files are copied by inspecting the **Hooker** log output.\n\n## Hooks file\nThe file which declares all methods, located inside the game libraries, to be hooked. See `/Hooker/example_hooks` for more information about it's syntax. The example_hooks file is used in the next section's example.\n\n\u003e **NOTE:** The hooker will always hook all methods entered in the Hooks file, if found. \nHooking a specific method when the **HooksRegistry** binary has no code to inject will have NO side effect on the game! The game will run a bit slower though..\n\n## Build\n\nVisual Studio 2017 has to be installed to build both projects. Required components are C# - and Unity development tools! Visual Studio 2017 Community edition is free to download and capable to perform the build.\n\n1. Clone the repo;\n2. Create a junction link between the solution folder and the game install path. See `/createJunction.bat`;\n2. Open UnityHook solution file with Visual Studio;\n3. Build project **Hooker**;\n4. Build project **HookRegistry**;\n5. All binary files can be found inside the `bin` folder of each project.\n\n## Usage Example\n\u003e The example expects the example_hooks file to be used as of the latest commit, also the latest **HookRegistry** binary.\n\nEffects of the example\n- The game creates a non secure connection to the server (NOT through a TLS tunnel);\n- All transferred network packets are being duplicated to another TCP 'dump'-stream.\n\nWhat you need\n\n- The **PATH** to **Hooker** compiled binaries. Refered to as {HOOKERPATH};\n- The compiled binary **FILE** from **HookRegistry**. Referred to as {REGISTRY};\n- The **PATH** to the game installation folder. Referred to as {GAMEDIR};\n- The path to a hooks **FILE**, example_hooks as mentioned above. Referred to as {HOOKS}.\n    \nSteps\n\n1. Call Hooker.exe;\n```\n{HOOKERPATH}\\Hooker.exe hook -d \"{GAMEDIR}\" -h \"{HOOKS}\" -l \"{REGISTRY}\"\n```\n2. Verify that that Hooker did not encounter a problem;\n    - Check the log output;\n    - Requested methods are hooked;\n    - Game assemblies are duplicated next to the original as {name}.original.dll -\u003e Backup;\n    - Patched assemblies are written to the game directory as {name}.out.dll;\n    - Patched assemblies replaced the original assemblies as {name}.dll;\n    - **HookRegistry** assembly, **and referenced assemblies**, are copied next to the game assemblies;\n3. Run the game -\u003e Watch the game log for lines starting with [HOOKER].\n\n\u003e To restore, run the command ```{HOOKERPATH}\\Hooker.exe restore -d \"{GAMEDIR}\"```\n\n## Remarks\n\n* This project is intended to run within the context of the Unity Engine. If Unity Engine is *not* initialised when **HookRegistry** is initialised, then no hooks will run. Each method will perform as if unhooked when outside of the Unity Engine context.","funding_links":[],"categories":["C#","Tool"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHearthSim%2FUnityHook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHearthSim%2FUnityHook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHearthSim%2FUnityHook/lists"}