{"id":22902599,"url":"https://github.com/notnite/nativeproxy","last_synced_at":"2025-05-08T05:44:09.241Z","repository":{"id":264968040,"uuid":"859642966","full_name":"NotNite/NativeProxy","owner":"NotNite","description":"Proxy DLL modding with C# Native AOT","archived":false,"fork":false,"pushed_at":"2024-09-19T19:34:19.000Z","size":8,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T21:18:12.495Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NotNite.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}},"created_at":"2024-09-19T03:03:24.000Z","updated_at":"2025-03-11T15:53:07.000Z","dependencies_parsed_at":"2024-11-27T02:19:40.339Z","dependency_job_id":null,"html_url":"https://github.com/NotNite/NativeProxy","commit_stats":null,"previous_names":["notnite/nativeproxy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotNite%2FNativeProxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotNite%2FNativeProxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotNite%2FNativeProxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotNite%2FNativeProxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NotNite","download_url":"https://codeload.github.com/NotNite/NativeProxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253009534,"owners_count":21839712,"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":[],"created_at":"2024-12-14T02:16:22.361Z","updated_at":"2025-05-08T05:44:09.207Z","avatar_url":"https://github.com/NotNite.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NativeProxy\n\nProxy DLL modding with C# Native AOT.\n\n---\n\nC# is a good language for native modding with its native interop, but there is only two ways to run it in another executable:\n\n- Initialize the [Common Language Runtime](https://learn.microsoft.com/en-us/dotnet/standard/clr)\n  - Initializing the CLR has to be done from native code, so you will need to write a C/C++/Rust loader or use a project that contains one (like [Reloaded II](https://github.com/Reloaded-Project/Reloaded-II))\n- Compile your program to a [Native AOT](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot) library\n  - Native AOT libraries still need to be loaded into the executable somehow, usually through DLL injection or a proxy DLL\n\nEvery option, minus a proxy DLL, requires another component to function. So let's use proxy DLLs!\n\nThis is a source generator that can take a list of DLL exports and generate magical proxy exports for it. It does this by resolving the real export at runtime and then editing the assembly of the source generated export.\n\n## Usage\n\nAdd this to your .csproj:\n\n```xml\n\u003cItemGroup\u003e\n    \u003cNone Remove=\"NativeProxy.d3d11.txt\"/\u003e\n    \u003cAdditionalFiles Include=\"NativeProxy.d3d11.txt\"/\u003e\n    \u003cCompilerVisibleProperty Include=\"NativeProxy_OriginalPath\" /\u003e\n\u003c/ItemGroup\u003e\n\n\u003cPropertyGroup\u003e\n    \u003cNativeProxy_OriginalPath\u003eC:/Windows/System32/d3d11.dll\u003c/NativeProxy_OriginalPath\u003e\n\u003c/PropertyGroup\u003e\n```\n\nThen make an entrypoint:\n\n```cs\npublic static class Proxy {\n    [ProxyEntrypoint]\n    public static void Main() {\n        // Have fun!\n    }\n}\n```\n\nNote: This Main method is called from DllMain. Be careful about deadlocks - you might need another thread.\n\n## Why modifying the function assembly?\n\nLooking at the decompilation of the stub exports:\n\n```text\n180071c40  int64_t D3D11CreateDevice()\n\n180071c47      int64_t pFrame = 0\n180071c4c      int64_t var_10 = 0\n180071c56      RhpReversePInvoke(\u0026pFrame)\n180071c56\n180071c6f      for (int32_t i = 0; i s\u003c 0x3e8; i += 1)\n180071c62          S_P_CoreLib_System_Threading_Thread__Sleep(0x3e8)\n180071c62\n180071c81      return RhpReversePInvokeReturn(\u0026pFrame)\n```\n\nThe `RhpReversePInvoke`/`RhpReversePInvokeReturn` create problems, modifying registers and the stack when we don't want that to happen. There is no way to avoid this and just insert our own `jmp RealCode` - so we just write some assembly into memory! How fun.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotnite%2Fnativeproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotnite%2Fnativeproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotnite%2Fnativeproxy/lists"}