├── .gitignore ├── LICENSE.md ├── README.md ├── Unity-Injector.sln ├── Unity-Injector ├── Main.cpp ├── Main.h ├── Main.resx ├── ProcessHelper.cpp ├── ProcessHelper.h ├── Unity-Injector.vcxproj ├── Unity-Injector.vcxproj.filters ├── Utility.cpp └── Utility.h └── proxy ├── MinHook.h ├── PropertySheet.props ├── ReadMe.txt ├── dllmain.cpp ├── mono.cpp ├── mono.h ├── proxy.cpp ├── proxy.h ├── proxy.vcxproj ├── proxy.vcxproj.filters ├── stdafx.cpp ├── stdafx.h └── targetver.h /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | *.opendb 10 | 11 | # User-specific files (MonoDevelop/Xamarin Studio) 12 | *.userprefs 13 | 14 | # Build results 15 | [Dd]ebug/ 16 | [Dd]ebugPublic/ 17 | [Rr]elease/ 18 | [Rr]eleases/ 19 | x64/ 20 | x86/ 21 | build/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | 26 | # Visual Studio 2015 cache/options directory 27 | .vs/ 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | # NUNIT 34 | *.VisualState.xml 35 | TestResult.xml 36 | 37 | # Build Results of an ATL Project 38 | [Dd]ebugPS/ 39 | [Rr]eleasePS/ 40 | dlldata.c 41 | 42 | # DNX 43 | project.lock.json 44 | artifacts/ 45 | 46 | *_i.c 47 | *_p.c 48 | *_i.h 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.tmp_proj 63 | *.log 64 | *.vspscc 65 | *.vssscc 66 | .builds 67 | *.pidb 68 | *.svclog 69 | *.scc 70 | 71 | # Chutzpah Test files 72 | _Chutzpah* 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opensdf 79 | *.sdf 80 | *.cachefile 81 | 82 | # Visual Studio profiler 83 | *.psess 84 | *.vsp 85 | *.vspx 86 | 87 | # TFS 2012 Local Workspace 88 | $tf/ 89 | 90 | # Guidance Automation Toolkit 91 | *.gpState 92 | 93 | # ReSharper is a .NET coding add-in 94 | _ReSharper*/ 95 | *.[Rr]e[Ss]harper 96 | *.DotSettings.user 97 | 98 | # JustCode is a .NET coding add-in 99 | .JustCode 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | _NCrunch_* 109 | .*crunch*.local.xml 110 | 111 | # MightyMoose 112 | *.mm.* 113 | AutoTest.Net/ 114 | 115 | # Web workbench (sass) 116 | .sass-cache/ 117 | 118 | # Installshield output folder 119 | [Ee]xpress/ 120 | 121 | # DocProject is a documentation generator add-in 122 | DocProject/buildhelp/ 123 | DocProject/Help/*.HxT 124 | DocProject/Help/*.HxC 125 | DocProject/Help/*.hhc 126 | DocProject/Help/*.hhk 127 | DocProject/Help/*.hhp 128 | DocProject/Help/Html2 129 | DocProject/Help/html 130 | 131 | # Click-Once directory 132 | publish/ 133 | 134 | # Publish Web Output 135 | *.[Pp]ublish.xml 136 | *.azurePubxml 137 | ## TODO: Comment the next line if you want to checkin your 138 | ## web deploy settings but do note that will include unencrypted 139 | ## passwords 140 | #*.pubxml 141 | 142 | *.publishproj 143 | 144 | # NuGet Packages 145 | *.nupkg 146 | # The packages folder can be ignored because of Package Restore 147 | **/packages/* 148 | # except build/, which is used as an MSBuild target. 149 | !**/packages/build/ 150 | # Uncomment if necessary however generally it will be regenerated when needed 151 | #!**/packages/repositories.config 152 | 153 | # Windows Azure Build Output 154 | csx/ 155 | *.build.csdef 156 | 157 | # Windows Store app package directory 158 | AppPackages/ 159 | 160 | # Visual Studio cache files 161 | # files ending in .cache can be ignored 162 | *.[Cc]ache 163 | # but keep track of directories ending in .cache 164 | !*.[Cc]ache/ 165 | 166 | # Others 167 | ClientBin/ 168 | [Ss]tyle[Cc]op.* 169 | ~$* 170 | *~ 171 | *.dbmdl 172 | *.dbproj.schemaview 173 | *.pfx 174 | *.publishsettings 175 | node_modules/ 176 | orleans.codegen.cs 177 | 178 | # RIA/Silverlight projects 179 | Generated_Code/ 180 | 181 | # Backup & report files from converting an old project file 182 | # to a newer Visual Studio version. Backup files are not needed, 183 | # because we have git ;-) 184 | _UpgradeReport_Files/ 185 | Backup*/ 186 | UpgradeLog*.XML 187 | UpgradeLog*.htm 188 | 189 | # SQL Server files 190 | *.mdf 191 | *.ldf 192 | 193 | # Business Intelligence projects 194 | *.rdl.data 195 | *.bim.layout 196 | *.bim_*.settings 197 | 198 | # Microsoft Fakes 199 | FakesAssemblies/ 200 | 201 | # Node.js Tools for Visual Studio 202 | .ntvs_analysis.dat 203 | 204 | # Visual Studio 6 build log 205 | *.plg 206 | 207 | # Visual Studio 6 workspace options file 208 | *.opt 209 | 210 | # LightSwitch generated files 211 | GeneratedArtifacts/ 212 | _Pvt_Extensions/ 213 | ModelManifest.xml 214 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 aw-3 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity-Injector 2 | 3 | ![img](http://i.imgur.com/ZaB815W.png "Screenshot") 4 | -------------------------------------------------------------------------------- /Unity-Injector.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Unity-Injector", "Unity-Injector\Unity-Injector.vcxproj", "{C40CDEE1-2910-4591-81D7-78841FEB9BDF}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {D700FC3D-0A9D-4933-AA46-38E178622E22} = {D700FC3D-0A9D-4933-AA46-38E178622E22} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proxy", "proxy\proxy.vcxproj", "{D700FC3D-0A9D-4933-AA46-38E178622E22}" 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|x64 = Debug|x64 16 | Debug|x86 = Debug|x86 17 | Release|x64 = Release|x64 18 | Release|x86 = Release|x86 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {C40CDEE1-2910-4591-81D7-78841FEB9BDF}.Debug|x64.ActiveCfg = Debug|x64 22 | {C40CDEE1-2910-4591-81D7-78841FEB9BDF}.Debug|x64.Build.0 = Debug|x64 23 | {C40CDEE1-2910-4591-81D7-78841FEB9BDF}.Debug|x86.ActiveCfg = Debug|Win32 24 | {C40CDEE1-2910-4591-81D7-78841FEB9BDF}.Debug|x86.Build.0 = Debug|Win32 25 | {C40CDEE1-2910-4591-81D7-78841FEB9BDF}.Release|x64.ActiveCfg = Release|x64 26 | {C40CDEE1-2910-4591-81D7-78841FEB9BDF}.Release|x64.Build.0 = Release|x64 27 | {C40CDEE1-2910-4591-81D7-78841FEB9BDF}.Release|x86.ActiveCfg = Release|Win32 28 | {C40CDEE1-2910-4591-81D7-78841FEB9BDF}.Release|x86.Build.0 = Release|Win32 29 | {D700FC3D-0A9D-4933-AA46-38E178622E22}.Debug|x64.ActiveCfg = Debug|x64 30 | {D700FC3D-0A9D-4933-AA46-38E178622E22}.Debug|x64.Build.0 = Debug|x64 31 | {D700FC3D-0A9D-4933-AA46-38E178622E22}.Debug|x86.ActiveCfg = Debug|Win32 32 | {D700FC3D-0A9D-4933-AA46-38E178622E22}.Debug|x86.Build.0 = Debug|Win32 33 | {D700FC3D-0A9D-4933-AA46-38E178622E22}.Release|x64.ActiveCfg = Release|x64 34 | {D700FC3D-0A9D-4933-AA46-38E178622E22}.Release|x64.Build.0 = Release|x64 35 | {D700FC3D-0A9D-4933-AA46-38E178622E22}.Release|x86.ActiveCfg = Release|Win32 36 | {D700FC3D-0A9D-4933-AA46-38E178622E22}.Release|x86.Build.0 = Release|Win32 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /Unity-Injector/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "Main.h" 2 | 3 | #define WIN32_LEAN_AND_MEAN 4 | #include 5 | 6 | using namespace UnityInjector; 7 | 8 | [System::STAThreadAttribute] 9 | int WinMain(HINSTANCE, HINSTANCE, LPSTR, int) 10 | { 11 | Application::EnableVisualStyles(); 12 | Main mainFrm; 13 | 14 | Application::Run(%mainFrm); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /Unity-Injector/Main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 3 | 4 | #include "Utility.h" 5 | #include "ProcessHelper.h" 6 | 7 | #include 8 | #include 9 | 10 | namespace UnityInjector { 11 | 12 | using namespace System; 13 | using namespace System::ComponentModel; 14 | using namespace System::Collections; 15 | using namespace System::Windows::Forms; 16 | using namespace System::Data; 17 | using namespace System::Drawing; 18 | using namespace System::Reflection; 19 | 20 | /// 21 | /// Summary for Main 22 | /// 23 | public ref class Main : public System::Windows::Forms::Form 24 | { 25 | public: 26 | Main(void) 27 | { 28 | InitializeComponent(); 29 | // 30 | //TODO: Add the constructor code here 31 | // 32 | } 33 | 34 | protected: 35 | /// 36 | /// Clean up any resources being used. 37 | /// 38 | ~Main() 39 | { 40 | if (components) 41 | { 42 | delete components; 43 | } 44 | } 45 | private: System::Windows::Forms::MenuStrip^ menuStrip1; 46 | protected: 47 | private: System::Windows::Forms::ToolStripMenuItem^ profilesToolStripMenuItem; 48 | private: System::Windows::Forms::ToolStripMenuItem^ loadToolStripMenuItem; 49 | private: System::Windows::Forms::ToolStripMenuItem^ saveAsToolStripMenuItem; 50 | private: System::Windows::Forms::ToolStripMenuItem^ recentToolStripMenuItem; 51 | private: System::Windows::Forms::ToolStripMenuItem^ toolsToolStripMenuItem; 52 | private: System::Windows::Forms::ToolStripMenuItem^ helpToolStripMenuItem; 53 | private: System::Windows::Forms::ToolStripMenuItem^ aboutToolStripMenuItem; 54 | private: System::Windows::Forms::GroupBox^ groupProcess; 55 | private: System::Windows::Forms::ComboBox^ comboProcesses; 56 | 57 | private: System::Windows::Forms::GroupBox^ groupDLLs; 58 | private: System::Windows::Forms::ListBox^ listDLLs; 59 | private: System::Windows::Forms::ContextMenuStrip^ ctxListDLLs; 60 | private: System::Windows::Forms::ToolStripMenuItem^ addToolStripMenuItem; 61 | private: System::Windows::Forms::ToolStripMenuItem^ removeToolStripMenuItem; 62 | private: System::Windows::Forms::OpenFileDialog^ dlgSelectDLLs; 63 | private: System::Windows::Forms::Button^ btnInject; 64 | 65 | private: System::Windows::Forms::ToolStripMenuItem^ patchMonoFunctionsToolStripMenuItem; 66 | private: System::Windows::Forms::ToolStripMenuItem^ entrypointDefinitionToolStripMenuItem; 67 | private: System::ComponentModel::IContainer^ components; 68 | 69 | 70 | 71 | 72 | 73 | private: 74 | /// 75 | /// Required designer variable. 76 | /// 77 | 78 | 79 | #pragma region Windows Form Designer generated code 80 | /// 81 | /// Required method for Designer support - do not modify 82 | /// the contents of this method with the code editor. 83 | /// 84 | void InitializeComponent(void) 85 | { 86 | this->components = (gcnew System::ComponentModel::Container()); 87 | this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip()); 88 | this->profilesToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); 89 | this->loadToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); 90 | this->saveAsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); 91 | this->recentToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); 92 | this->toolsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); 93 | this->patchMonoFunctionsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); 94 | this->helpToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); 95 | this->aboutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); 96 | this->groupProcess = (gcnew System::Windows::Forms::GroupBox()); 97 | this->btnInject = (gcnew System::Windows::Forms::Button()); 98 | this->comboProcesses = (gcnew System::Windows::Forms::ComboBox()); 99 | this->groupDLLs = (gcnew System::Windows::Forms::GroupBox()); 100 | this->listDLLs = (gcnew System::Windows::Forms::ListBox()); 101 | this->ctxListDLLs = (gcnew System::Windows::Forms::ContextMenuStrip(this->components)); 102 | this->addToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); 103 | this->removeToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); 104 | this->dlgSelectDLLs = (gcnew System::Windows::Forms::OpenFileDialog()); 105 | this->entrypointDefinitionToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); 106 | this->menuStrip1->SuspendLayout(); 107 | this->groupProcess->SuspendLayout(); 108 | this->groupDLLs->SuspendLayout(); 109 | this->ctxListDLLs->SuspendLayout(); 110 | this->SuspendLayout(); 111 | // 112 | // menuStrip1 113 | // 114 | this->menuStrip1->BackColor = System::Drawing::SystemColors::Control; 115 | this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) { 116 | this->profilesToolStripMenuItem, 117 | this->toolsToolStripMenuItem, this->helpToolStripMenuItem 118 | }); 119 | this->menuStrip1->Location = System::Drawing::Point(0, 0); 120 | this->menuStrip1->Name = L"menuStrip1"; 121 | this->menuStrip1->Size = System::Drawing::Size(284, 24); 122 | this->menuStrip1->TabIndex = 0; 123 | this->menuStrip1->Text = L"menuStrip1"; 124 | // 125 | // profilesToolStripMenuItem 126 | // 127 | this->profilesToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) { 128 | this->loadToolStripMenuItem, 129 | this->saveAsToolStripMenuItem, this->recentToolStripMenuItem 130 | }); 131 | this->profilesToolStripMenuItem->Name = L"profilesToolStripMenuItem"; 132 | this->profilesToolStripMenuItem->Size = System::Drawing::Size(58, 20); 133 | this->profilesToolStripMenuItem->Text = L"Profiles"; 134 | // 135 | // loadToolStripMenuItem 136 | // 137 | this->loadToolStripMenuItem->Name = L"loadToolStripMenuItem"; 138 | this->loadToolStripMenuItem->Size = System::Drawing::Size(114, 22); 139 | this->loadToolStripMenuItem->Text = L"Load"; 140 | // 141 | // saveAsToolStripMenuItem 142 | // 143 | this->saveAsToolStripMenuItem->Name = L"saveAsToolStripMenuItem"; 144 | this->saveAsToolStripMenuItem->Size = System::Drawing::Size(114, 22); 145 | this->saveAsToolStripMenuItem->Text = L"Save As"; 146 | // 147 | // recentToolStripMenuItem 148 | // 149 | this->recentToolStripMenuItem->Name = L"recentToolStripMenuItem"; 150 | this->recentToolStripMenuItem->Size = System::Drawing::Size(114, 22); 151 | this->recentToolStripMenuItem->Text = L"Recent"; 152 | // 153 | // toolsToolStripMenuItem 154 | // 155 | this->toolsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) { this->patchMonoFunctionsToolStripMenuItem }); 156 | this->toolsToolStripMenuItem->Name = L"toolsToolStripMenuItem"; 157 | this->toolsToolStripMenuItem->Size = System::Drawing::Size(48, 20); 158 | this->toolsToolStripMenuItem->Text = L"Tools"; 159 | // 160 | // patchMonoFunctionsToolStripMenuItem 161 | // 162 | this->patchMonoFunctionsToolStripMenuItem->CheckOnClick = true; 163 | this->patchMonoFunctionsToolStripMenuItem->Name = L"patchMonoFunctionsToolStripMenuItem"; 164 | this->patchMonoFunctionsToolStripMenuItem->Size = System::Drawing::Size(194, 22); 165 | this->patchMonoFunctionsToolStripMenuItem->Text = L"Patch Mono Functions"; 166 | // 167 | // helpToolStripMenuItem 168 | // 169 | this->helpToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) { 170 | this->entrypointDefinitionToolStripMenuItem, 171 | this->aboutToolStripMenuItem 172 | }); 173 | this->helpToolStripMenuItem->Name = L"helpToolStripMenuItem"; 174 | this->helpToolStripMenuItem->Size = System::Drawing::Size(44, 20); 175 | this->helpToolStripMenuItem->Text = L"Help"; 176 | // 177 | // aboutToolStripMenuItem 178 | // 179 | this->aboutToolStripMenuItem->Name = L"aboutToolStripMenuItem"; 180 | this->aboutToolStripMenuItem->Size = System::Drawing::Size(183, 22); 181 | this->aboutToolStripMenuItem->Text = L"About"; 182 | // 183 | // groupProcess 184 | // 185 | this->groupProcess->Controls->Add(this->btnInject); 186 | this->groupProcess->Controls->Add(this->comboProcesses); 187 | this->groupProcess->Location = System::Drawing::Point(12, 27); 188 | this->groupProcess->Name = L"groupProcess"; 189 | this->groupProcess->Size = System::Drawing::Size(260, 67); 190 | this->groupProcess->TabIndex = 1; 191 | this->groupProcess->TabStop = false; 192 | this->groupProcess->Text = L"Process"; 193 | // 194 | // btnInject 195 | // 196 | this->btnInject->Enabled = false; 197 | this->btnInject->Location = System::Drawing::Point(179, 19); 198 | this->btnInject->Name = L"btnInject"; 199 | this->btnInject->Size = System::Drawing::Size(75, 23); 200 | this->btnInject->TabIndex = 1; 201 | this->btnInject->Text = L"Inject"; 202 | this->btnInject->UseVisualStyleBackColor = true; 203 | this->btnInject->Click += gcnew System::EventHandler(this, &Main::btnInject_Click); 204 | // 205 | // comboProcesses 206 | // 207 | this->comboProcesses->FormattingEnabled = true; 208 | this->comboProcesses->Location = System::Drawing::Point(6, 19); 209 | this->comboProcesses->Name = L"comboProcesses"; 210 | this->comboProcesses->Size = System::Drawing::Size(167, 21); 211 | this->comboProcesses->TabIndex = 0; 212 | this->comboProcesses->SelectedIndexChanged += gcnew System::EventHandler(this, &Main::comboProcesses_SelectedIndexChanged); 213 | this->comboProcesses->Enter += gcnew System::EventHandler(this, &Main::listProcesses_Enter); 214 | this->comboProcesses->Layout += gcnew System::Windows::Forms::LayoutEventHandler(this, &Main::listProcesses_Layout); 215 | // 216 | // groupDLLs 217 | // 218 | this->groupDLLs->Controls->Add(this->listDLLs); 219 | this->groupDLLs->Location = System::Drawing::Point(12, 100); 220 | this->groupDLLs->Name = L"groupDLLs"; 221 | this->groupDLLs->Size = System::Drawing::Size(260, 150); 222 | this->groupDLLs->TabIndex = 2; 223 | this->groupDLLs->TabStop = false; 224 | this->groupDLLs->Text = L"DLLs"; 225 | // 226 | // listDLLs 227 | // 228 | this->listDLLs->ContextMenuStrip = this->ctxListDLLs; 229 | this->listDLLs->FormattingEnabled = true; 230 | this->listDLLs->HorizontalScrollbar = true; 231 | this->listDLLs->Location = System::Drawing::Point(7, 22); 232 | this->listDLLs->Name = L"listDLLs"; 233 | this->listDLLs->Size = System::Drawing::Size(247, 121); 234 | this->listDLLs->TabIndex = 0; 235 | // 236 | // ctxListDLLs 237 | // 238 | this->ctxListDLLs->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) { 239 | this->addToolStripMenuItem, 240 | this->removeToolStripMenuItem 241 | }); 242 | this->ctxListDLLs->Name = L"ctxListDLLs"; 243 | this->ctxListDLLs->Size = System::Drawing::Size(118, 48); 244 | // 245 | // addToolStripMenuItem 246 | // 247 | this->addToolStripMenuItem->Name = L"addToolStripMenuItem"; 248 | this->addToolStripMenuItem->Size = System::Drawing::Size(117, 22); 249 | this->addToolStripMenuItem->Text = L"Add"; 250 | this->addToolStripMenuItem->Click += gcnew System::EventHandler(this, &Main::addToolStripMenuItem_Click); 251 | // 252 | // removeToolStripMenuItem 253 | // 254 | this->removeToolStripMenuItem->Name = L"removeToolStripMenuItem"; 255 | this->removeToolStripMenuItem->Size = System::Drawing::Size(117, 22); 256 | this->removeToolStripMenuItem->Text = L"Remove"; 257 | // 258 | // dlgSelectDLLs 259 | // 260 | this->dlgSelectDLLs->Filter = L"Dynamic Link Library | *.DLL"; 261 | // 262 | // entrypointDefinitionToolStripMenuItem 263 | // 264 | this->entrypointDefinitionToolStripMenuItem->Name = L"entrypointDefinitionToolStripMenuItem"; 265 | this->entrypointDefinitionToolStripMenuItem->Size = System::Drawing::Size(183, 22); 266 | this->entrypointDefinitionToolStripMenuItem->Text = L"Entrypoint definition"; 267 | this->entrypointDefinitionToolStripMenuItem->Click += gcnew System::EventHandler(this, &Main::entrypointDefinitionToolStripMenuItem_Click); 268 | // 269 | // Main 270 | // 271 | this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); 272 | this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; 273 | this->ClientSize = System::Drawing::Size(284, 262); 274 | this->Controls->Add(this->groupDLLs); 275 | this->Controls->Add(this->groupProcess); 276 | this->Controls->Add(this->menuStrip1); 277 | this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D; 278 | this->MainMenuStrip = this->menuStrip1; 279 | this->MaximizeBox = false; 280 | this->Name = L"Main"; 281 | this->ShowIcon = false; 282 | this->Text = L"Unity Injector"; 283 | this->Load += gcnew System::EventHandler(this, &Main::Main_Load); 284 | this->menuStrip1->ResumeLayout(false); 285 | this->menuStrip1->PerformLayout(); 286 | this->groupProcess->ResumeLayout(false); 287 | this->groupDLLs->ResumeLayout(false); 288 | this->ctxListDLLs->ResumeLayout(false); 289 | this->ResumeLayout(false); 290 | this->PerformLayout(); 291 | 292 | } 293 | #pragma endregion 294 | private: System::Void Main_Load(System::Object^ sender, System::EventArgs^ e) 295 | { 296 | // Set architecture 297 | #ifdef _WIN64 298 | this->Text = "Unity Injector x64"; 299 | #else 300 | this->Text = "Unity Injector x86"; 301 | #endif 302 | } 303 | 304 | void UpdateListProcesses() 305 | { 306 | ProcessHelper::UpdateProcessInfo(); 307 | auto processes = ProcessHelper::g_Processes; 308 | 309 | // Amazing race condition 10/10 310 | comboProcesses->Items->Clear(); 311 | 312 | for (auto it = processes.begin(); it != processes.end(); it++) { 313 | auto pi = *it; 314 | 315 | // Can't inject DLLs into different architectures 316 | if (!pi->SameArchitecture()) 317 | continue; 318 | 319 | // Mono required for injection 320 | if(pi->HasModule("mono.dll")) 321 | comboProcesses->Items->Add(gcnew String(pi->ProcessName.data())); 322 | } 323 | } 324 | 325 | System::String^ GetAssemblyName(System::String^ dll) 326 | { 327 | System::String^ assemblyName = ""; 328 | 329 | try 330 | { 331 | assemblyName = AssemblyName::GetAssemblyName(dll)->Name; 332 | assemblyName = assemblyName->Replace("-", "_"); 333 | } 334 | catch (...) 335 | { 336 | 337 | } 338 | 339 | return assemblyName; 340 | } 341 | 342 | private: System::Void listProcesses_Enter(System::Object^ sender, System::EventArgs^ e) { 343 | UpdateListProcesses(); 344 | } 345 | private: System::Void listProcesses_Layout(System::Object^ sender, System::Windows::Forms::LayoutEventArgs^ e) { 346 | //UpdateListProcesses(); 347 | } 348 | private: System::Void addToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { 349 | System::Windows::Forms::DialogResult res = dlgSelectDLLs->ShowDialog(); 350 | 351 | if (res != System::Windows::Forms::DialogResult::OK) 352 | { 353 | return; 354 | } 355 | 356 | for each (System::String^ dll in dlgSelectDLLs->FileNames) 357 | { 358 | if (GetAssemblyName(dll) != "") 359 | listDLLs->Items->Add(dll); 360 | else 361 | MessageBox::Show("Not a valid assembly!"); 362 | } 363 | } 364 | private: System::Void btnInject_Click(System::Object^ sender, System::EventArgs^ e) { 365 | if (comboProcesses->SelectedIndex == -1) 366 | return; 367 | 368 | auto selProcess = comboProcesses->Items[comboProcesses->SelectedIndex]; 369 | 370 | for (auto it = ProcessHelper::g_Processes.begin(); it != ProcessHelper::g_Processes.end(); it++) { 371 | ProcessHelper::ProcessInfo* pi = *it; 372 | 373 | if ((gcnew System::String(pi->ProcessName.data()))->Equals(selProcess)) 374 | { 375 | for each (System::String^ dll in listDLLs->Items) 376 | { 377 | ProcessHelper::InjectDLL(Utility::ToString(dll), Utility::ToString(GetAssemblyName(dll)), pi); 378 | } 379 | } 380 | } 381 | 382 | UpdateListProcesses(); 383 | } 384 | private: System::Void comboProcesses_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { 385 | btnInject->Enabled = comboProcesses->SelectedIndex != -1; 386 | } 387 | private: System::Void entrypointDefinitionToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { 388 | MessageBox::Show("Class Loader { static void Load(); }"); 389 | } 390 | }; 391 | } 392 | -------------------------------------------------------------------------------- /Unity-Injector/Main.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 132, 17 125 | 126 | 127 | 243, 17 128 | 129 | -------------------------------------------------------------------------------- /Unity-Injector/ProcessHelper.cpp: -------------------------------------------------------------------------------- 1 | #include "ProcessHelper.h" 2 | #include "Utility.h" 3 | 4 | #include 5 | #include 6 | 7 | using namespace ProcessHelper; 8 | 9 | #define PROXY_FILE "proxy.dll" 10 | 11 | std::vector ProcessHelper::g_Processes; 12 | 13 | bool ProcessInfo::HasModule(std::string moduleName) 14 | { 15 | for (auto it = Modules.begin(); it != Modules.end(); it++) 16 | if (*it == moduleName) 17 | return true; 18 | return false; 19 | } 20 | 21 | void* ProcessHelper::ProcessInfo::GetModuleBase(std::string moduleName) 22 | { 23 | void* ret = nullptr; 24 | 25 | HANDLE snapModule = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessId); 26 | MODULEENTRY32 me = { 0 }; 27 | 28 | me.dwSize = sizeof(MODULEENTRY32); 29 | 30 | if (Module32First(snapModule, &me)) 31 | { 32 | do 33 | { 34 | if (Utility::ToString(me.szModule) == moduleName) 35 | { 36 | ret = (void*)me.modBaseAddr; 37 | } 38 | } while (Module32Next(snapModule, &me)); 39 | } 40 | 41 | CloseHandle(snapModule); 42 | 43 | return ret; 44 | } 45 | 46 | void ProcessInfo::UpdateModules() 47 | { 48 | Modules.clear(); 49 | 50 | HANDLE snapModule = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessId); 51 | MODULEENTRY32 me = { 0 }; 52 | 53 | me.dwSize = sizeof(MODULEENTRY32); 54 | 55 | if (Module32First(snapModule, &me)) 56 | { 57 | do 58 | { 59 | Modules.push_back(Utility::ToString(me.szModule)); 60 | } while (Module32Next(snapModule, &me)); 61 | } 62 | 63 | CloseHandle(snapModule); 64 | } 65 | 66 | std::string ProcessInfo::GetExePath() 67 | { 68 | HANDLE handle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ProcessId); 69 | DWORD tempSize = MAX_PATH; 70 | char temp[MAX_PATH]; 71 | 72 | if (handle == ERROR || handle == INVALID_HANDLE_VALUE) 73 | { 74 | return ""; 75 | } 76 | 77 | QueryFullProcessImageNameA(handle, NULL, temp, &tempSize); 78 | 79 | CloseHandle(handle); 80 | 81 | return std::string(temp); 82 | } 83 | 84 | bool ProcessInfo::SameArchitecture() 85 | { 86 | short arch = GetArchitecture(); 87 | 88 | #ifdef _WIN64 89 | return arch == (short)0x8664; 90 | 91 | #else 92 | return arch != (short)0x8664; 93 | #endif 94 | } 95 | 96 | short ProcessInfo::GetArchitecture() 97 | { 98 | short arch = 0; 99 | short peOffset = 0; 100 | char temp[2] = { 0 }; 101 | 102 | std::ifstream input(GetExePath(), std::ios::binary); 103 | 104 | if (!input.is_open()) { 105 | return 0x14C; // Assume 32bit 106 | } 107 | 108 | 109 | input.seekg(0x3C); 110 | input.read(temp, sizeof(short)); 111 | 112 | memcpy(&peOffset, temp, sizeof(short)); 113 | 114 | input.seekg(peOffset + 4); 115 | input.read(temp, sizeof(short)); 116 | 117 | memcpy(&arch, temp, sizeof(short)); 118 | 119 | input.close(); 120 | 121 | return arch; 122 | } 123 | 124 | void ProcessHelper::UpdateProcessInfo() 125 | { 126 | // Clear list 127 | for (auto it = ProcessHelper::g_Processes.begin(); it != ProcessHelper::g_Processes.end(); it++) { 128 | delete *it; 129 | } 130 | 131 | ProcessHelper::g_Processes.clear(); 132 | 133 | HANDLE snapProcess = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); 134 | PROCESSENTRY32 pe = { 0 }; 135 | 136 | pe.dwSize = sizeof(PROCESSENTRY32); 137 | 138 | if(Process32First(snapProcess, &pe)) 139 | do 140 | { 141 | ProcessInfo* pi = new ProcessInfo; 142 | 143 | pi->ProcessName = Utility::ToString(pe.szExeFile); 144 | pi->ProcessId = pe.th32ProcessID; 145 | 146 | pi->UpdateModules(); 147 | 148 | g_Processes.push_back(pi); 149 | } while (Process32Next(snapProcess, &pe)); 150 | 151 | CloseHandle(snapProcess); 152 | } 153 | 154 | bool ProcessHelper::IsProxyLoaded(ProcessInfo *pi) 155 | { 156 | pi->UpdateModules(); 157 | 158 | for (auto it = pi->Modules.begin(); it != pi->Modules.end(); it++) 159 | if (*it == PROXY_FILE) 160 | return true; 161 | return false; 162 | } 163 | 164 | void* ProcessHelper::LoadProxy(std::string proxyPath, ProcessInfo *pi) 165 | { 166 | if (IsProxyLoaded(pi)) 167 | return pi->GetModuleBase(PROXY_FILE); 168 | 169 | // Load via LoadLibrary + CreateRemoteThread 170 | // TODO: add more injection methods 171 | 172 | HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pi->ProcessId); 173 | 174 | if (handle == INVALID_HANDLE_VALUE) 175 | { 176 | return false; 177 | } 178 | 179 | FARPROC fpLoadLibrary = GetProcAddress(GetModuleHandleA("kernel32.dll"), "LoadLibraryA"); 180 | 181 | if (fpLoadLibrary == NULL) 182 | { 183 | CloseHandle(handle); 184 | return false; 185 | } 186 | 187 | LPVOID pDllPath = VirtualAllocEx(handle, NULL, proxyPath.length(), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); 188 | 189 | if (pDllPath == NULL) 190 | { 191 | CloseHandle(handle); 192 | return false; 193 | } 194 | 195 | if (WriteProcessMemory(handle, pDllPath, proxyPath.data(), proxyPath.length(), NULL) == ERROR) 196 | { 197 | CloseHandle(handle); 198 | return false; 199 | } 200 | 201 | if (CreateRemoteThread(handle, NULL, NULL, (LPTHREAD_START_ROUTINE)fpLoadLibrary, pDllPath, NULL, NULL) == ERROR) 202 | { 203 | CloseHandle(handle); 204 | return false; 205 | } 206 | 207 | CloseHandle(handle); 208 | 209 | Sleep(1000); 210 | 211 | return pi->GetModuleBase(PROXY_FILE); 212 | } 213 | 214 | // Injects proxy dll and loads DLL via mono 215 | bool ProcessHelper::InjectDLL(std::string dllPath, std::string dllNamespace, ProcessInfo *pi) 216 | { 217 | std::string proxyPath = Utility::CurrentPath() + "\\" + PROXY_FILE; 218 | 219 | void* proxyBase = LoadProxy(proxyPath, pi); 220 | if (proxyBase == nullptr) 221 | return false; 222 | 223 | std::vector proxyFile = Utility::FileReadAllBytes(Utility::ToWString(proxyPath)); 224 | 225 | typedef void(__cdecl *LoadAssembly_t)(const char* assemblyPath); 226 | LoadAssembly_t loadAssembly = (LoadAssembly_t)((intptr)proxyBase + (intptr)Utility::GetProcAddressEx(&proxyFile[0], "LoadAssembly")); 227 | 228 | // Call the LoadAssembly function via CRT 229 | 230 | HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pi->ProcessId); 231 | 232 | if (handle == INVALID_HANDLE_VALUE) 233 | { 234 | return false; 235 | } 236 | 237 | LPVOID pDllStruct = VirtualAllocEx(handle, NULL, sizeof(LPVOID) * 2, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); 238 | LPVOID pDllPath = VirtualAllocEx(handle, NULL, dllPath.length(), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); 239 | LPVOID pDllNamespace = VirtualAllocEx(handle, NULL, dllNamespace.length(), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); 240 | 241 | if (pDllStruct == NULL || pDllPath == NULL || pDllNamespace == NULL) 242 | { 243 | CloseHandle(handle); 244 | return false; 245 | } 246 | 247 | if (WriteProcessMemory(handle, pDllStruct, &pDllPath, sizeof(LPVOID), NULL) == ERROR) 248 | { 249 | CloseHandle(handle); 250 | return false; 251 | } 252 | 253 | if (WriteProcessMemory(handle, (LPVOID)((intptr)pDllStruct + sizeof(LPVOID)), &pDllNamespace, sizeof(LPVOID), NULL) == ERROR) 254 | { 255 | CloseHandle(handle); 256 | return false; 257 | } 258 | 259 | if (WriteProcessMemory(handle, pDllPath, dllPath.data(), dllPath.length(), NULL) == ERROR) 260 | { 261 | CloseHandle(handle); 262 | return false; 263 | } 264 | 265 | if (WriteProcessMemory(handle, pDllNamespace, dllNamespace.data(), dllNamespace.length(), NULL) == ERROR) 266 | { 267 | CloseHandle(handle); 268 | return false; 269 | } 270 | 271 | if (CreateRemoteThread(handle, NULL, NULL, (LPTHREAD_START_ROUTINE)loadAssembly, pDllStruct, NULL, NULL) == ERROR) 272 | { 273 | CloseHandle(handle); 274 | return false; 275 | } 276 | 277 | CloseHandle(handle); 278 | 279 | return true; 280 | } 281 | 282 | -------------------------------------------------------------------------------- /Unity-Injector/ProcessHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace ProcessHelper { 10 | class ProcessInfo { 11 | public: 12 | std::string ProcessName; 13 | int ProcessId; 14 | std::vector Modules; 15 | 16 | // Checks if process has module loaded 17 | bool HasModule(std::string moduleName); 18 | 19 | void* GetModuleBase(std::string moduleName); 20 | 21 | // Refreshes modules list 22 | void UpdateModules(); 23 | 24 | // Returns full process file path 25 | std::string GetExePath(); 26 | 27 | // true if same arch as injector 28 | bool SameArchitecture(); 29 | 30 | private: 31 | short GetArchitecture(); 32 | }; 33 | 34 | extern std::vector g_Processes; 35 | 36 | void UpdateProcessInfo(); 37 | 38 | bool IsProxyLoaded(ProcessInfo *pi); 39 | 40 | /// Proxy module base 41 | void* LoadProxy(std::string proxyPath, ProcessInfo *pi); 42 | 43 | bool InjectDLL(std::string dllPath, std::string dllNamespace, ProcessInfo *pi); 44 | 45 | } -------------------------------------------------------------------------------- /Unity-Injector/Unity-Injector.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {C40CDEE1-2910-4591-81D7-78841FEB9BDF} 23 | v4.5.2 24 | ManagedCProj 25 | UnityInjector 26 | 8.1 27 | 28 | 29 | 30 | Application 31 | true 32 | v140 33 | true 34 | Unicode 35 | 36 | 37 | Application 38 | false 39 | v140 40 | true 41 | Unicode 42 | 43 | 44 | Application 45 | true 46 | v140 47 | true 48 | Unicode 49 | 50 | 51 | Application 52 | false 53 | v140 54 | true 55 | Unicode 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | true 77 | 78 | 79 | true 80 | 81 | 82 | false 83 | 84 | 85 | false 86 | 87 | 88 | 89 | Level3 90 | Disabled 91 | WIN32;_DEBUG;%(PreprocessorDefinitions) 92 | 93 | 94 | psapi.lib 95 | 96 | 97 | 98 | 99 | Level3 100 | Disabled 101 | _DEBUG;%(PreprocessorDefinitions) 102 | 103 | 104 | psapi.lib 105 | 106 | 107 | 108 | 109 | Level3 110 | WIN32;NDEBUG;%(PreprocessorDefinitions) 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | Level3 119 | NDEBUG;%(PreprocessorDefinitions) 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | CppForm 140 | 141 | 142 | 143 | 144 | 145 | 146 | Main.h 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /Unity-Injector/Unity-Injector.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /Unity-Injector/Utility.cpp: -------------------------------------------------------------------------------- 1 | #include "Utility.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace Utility; 11 | 12 | std::string Utility::ToString(std::wstring wstr) { 13 | using ccvt = std::codecvt_utf8; 14 | std::wstring_convert converter; 15 | 16 | return converter.to_bytes(wstr); 17 | } 18 | 19 | std::string Utility::ToString(System::String^ str) { 20 | msclr::interop::marshal_context context; 21 | return context.marshal_as(str); 22 | } 23 | 24 | std::wstring Utility::ToWString(std::string str) { 25 | using ccvt = std::codecvt_utf8; 26 | std::wstring_convert converter; 27 | 28 | return converter.from_bytes(str); 29 | } 30 | 31 | std::string Utility::CurrentPath() 32 | { 33 | char pBuf[MAX_PATH] = { 0 }; 34 | 35 | int bytes = GetModuleFileNameA(NULL, pBuf, MAX_PATH); 36 | 37 | if (bytes > 0) 38 | { 39 | std::string ret = std::string(pBuf); 40 | 41 | ret = ret.substr(0, ret.size() - 19); // UGLY - HACK 42 | 43 | return ret; 44 | } 45 | 46 | return ""; 47 | } 48 | 49 | template 50 | LPVOID GetPtrFromRVA( 51 | DWORD rva, T* pNTHeader, PBYTE imageBase) // 'T' = PIMAGE_NT_HEADERS 52 | { 53 | PIMAGE_SECTION_HEADER pSectionHdr; 54 | INT delta; 55 | 56 | pSectionHdr = GetEnclosingSectionHeader(rva, pNTHeader); 57 | if (!pSectionHdr) 58 | return 0; 59 | 60 | delta = (INT)(pSectionHdr->VirtualAddress - pSectionHdr->PointerToRawData); 61 | return (PVOID)(imageBase + rva - delta); 62 | } 63 | 64 | template 65 | PIMAGE_SECTION_HEADER GetEnclosingSectionHeader( 66 | DWORD rva, 67 | T* pNTHeader) // 'T' == PIMAGE_NT_HEADERS 68 | { 69 | PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(pNTHeader); 70 | unsigned i; 71 | 72 | for (i = 0; i < pNTHeader->FileHeader.NumberOfSections; i++, section++) 73 | { 74 | // This 3 line idiocy is because Watcom's linker actually sets the 75 | // Misc.VirtualSize field to 0. (!!! - Retards....!!!) 76 | DWORD size = section->Misc.VirtualSize; 77 | if (0 == size) 78 | size = section->SizeOfRawData; 79 | 80 | // Is the RVA within this section? 81 | if ((rva >= section->VirtualAddress) && 82 | (rva < (section->VirtualAddress + size))) 83 | return section; 84 | } 85 | 86 | return 0; 87 | } 88 | 89 | void* Utility::GetProcAddressEx(void* pModuleBase, std::string procName) 90 | { 91 | PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)pModuleBase; 92 | 93 | if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) 94 | return nullptr; 95 | 96 | PIMAGE_NT_HEADERS32 pNtHdrs32 = (PIMAGE_NT_HEADERS32)((PUCHAR)pModuleBase + pDosHeader->e_lfanew); 97 | PIMAGE_NT_HEADERS64 pNtHdrs64 = (PIMAGE_NT_HEADERS64)((PUCHAR)pModuleBase + pDosHeader->e_lfanew); 98 | 99 | PIMAGE_EXPORT_DIRECTORY pExportDir = NULL; 100 | 101 | PULONG pAddressOfFunctions; 102 | PULONG pAddressOfNames; 103 | PUSHORT pAddressOfOrdinals; 104 | ULONG numberOfNames; 105 | 106 | if (pNtHdrs32->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) 107 | { 108 | pExportDir = (PIMAGE_EXPORT_DIRECTORY)GetPtrFromRVA(pNtHdrs32->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress, pNtHdrs32, (PBYTE)pModuleBase); 109 | 110 | pAddressOfFunctions = (PULONG)GetPtrFromRVA(pExportDir->AddressOfFunctions, pNtHdrs32, (PBYTE)pModuleBase); 111 | pAddressOfNames = (PULONG)GetPtrFromRVA(pExportDir->AddressOfNames, pNtHdrs32, (PBYTE)pModuleBase); 112 | pAddressOfOrdinals = (PUSHORT)GetPtrFromRVA(pExportDir->AddressOfNameOrdinals, pNtHdrs32, (PBYTE)pModuleBase); 113 | numberOfNames = pExportDir->NumberOfNames; 114 | 115 | for (ULONG i = 0; i < numberOfNames; i++) { 116 | 117 | PCSTR pszName = (PCSTR)(GetPtrFromRVA(pAddressOfNames[i], pNtHdrs32, (PBYTE)pModuleBase)); 118 | SHORT ordinal = pAddressOfOrdinals[i]; 119 | if (/*procName == pszName*/ std::string(pszName).find(procName) != std::string::npos) { // HACK 120 | return (void*)pAddressOfFunctions[ordinal]; 121 | } 122 | } 123 | } 124 | else if (pNtHdrs64->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) 125 | { 126 | pExportDir = (PIMAGE_EXPORT_DIRECTORY)GetPtrFromRVA(pNtHdrs64->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress, pNtHdrs64, (PBYTE)pModuleBase); 127 | 128 | pAddressOfFunctions = (PULONG)GetPtrFromRVA(pExportDir->AddressOfFunctions, pNtHdrs64, (PBYTE)pModuleBase); 129 | pAddressOfNames = (PULONG)GetPtrFromRVA(pExportDir->AddressOfNames, pNtHdrs64, (PBYTE)pModuleBase); 130 | pAddressOfOrdinals = (PUSHORT)GetPtrFromRVA(pExportDir->AddressOfNameOrdinals, pNtHdrs64, (PBYTE)pModuleBase); 131 | numberOfNames = pExportDir->NumberOfNames; 132 | 133 | for (ULONG i = 0; i < numberOfNames; i++) { 134 | 135 | PCSTR pszName = (PCSTR)(GetPtrFromRVA(pAddressOfNames[i], pNtHdrs64, (PBYTE)pModuleBase)); 136 | SHORT ordinal = pAddressOfOrdinals[i]; 137 | if (/*procName == pszName*/ std::string(pszName).find(procName) != std::string::npos) { // HACK 138 | return (void*)pAddressOfFunctions[ordinal]; 139 | } 140 | } 141 | } 142 | 143 | 144 | 145 | 146 | 147 | return nullptr; 148 | } 149 | 150 | std::vector Utility::FileReadAllBytes(const std::wstring& name) { 151 | std::ifstream input(name, std::ios::binary); 152 | if (input.is_open()) { 153 | 154 | std::vector buffer(( 155 | std::istreambuf_iterator(input)), 156 | (std::istreambuf_iterator())); 157 | 158 | return buffer; 159 | } 160 | return std::vector(); 161 | } -------------------------------------------------------------------------------- /Unity-Injector/Utility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #ifdef _WIN64 7 | typedef uint64_t intptr; 8 | #else 9 | typedef uint32_t intptr; 10 | #endif 11 | 12 | namespace Utility { 13 | std::string ToString(std::wstring); 14 | std::string ToString(System::String^); 15 | 16 | std::wstring ToWString(std::string); 17 | 18 | std::string CurrentPath(); 19 | 20 | void* GetProcAddressEx(void* pModuleBase, std::string procName); 21 | 22 | std::vector FileReadAllBytes(const std::wstring& name); 23 | } -------------------------------------------------------------------------------- /proxy/MinHook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2015 Tsuda Kageyu. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #if !(defined _M_IX86) && !(defined _M_X64) 32 | #error MinHook supports only x86 and x64 systems. 33 | #endif 34 | 35 | #include 36 | 37 | // MinHook Error Codes. 38 | typedef enum MH_STATUS 39 | { 40 | // Unknown error. Should not be returned. 41 | MH_UNKNOWN = -1, 42 | 43 | // Successful. 44 | MH_OK = 0, 45 | 46 | // MinHook is already initialized. 47 | MH_ERROR_ALREADY_INITIALIZED, 48 | 49 | // MinHook is not initialized yet, or already uninitialized. 50 | MH_ERROR_NOT_INITIALIZED, 51 | 52 | // The hook for the specified target function is already created. 53 | MH_ERROR_ALREADY_CREATED, 54 | 55 | // The hook for the specified target function is not created yet. 56 | MH_ERROR_NOT_CREATED, 57 | 58 | // The hook for the specified target function is already enabled. 59 | MH_ERROR_ENABLED, 60 | 61 | // The hook for the specified target function is not enabled yet, or already 62 | // disabled. 63 | MH_ERROR_DISABLED, 64 | 65 | // The specified pointer is invalid. It points the address of non-allocated 66 | // and/or non-executable region. 67 | MH_ERROR_NOT_EXECUTABLE, 68 | 69 | // The specified target function cannot be hooked. 70 | MH_ERROR_UNSUPPORTED_FUNCTION, 71 | 72 | // Failed to allocate memory. 73 | MH_ERROR_MEMORY_ALLOC, 74 | 75 | // Failed to change the memory protection. 76 | MH_ERROR_MEMORY_PROTECT, 77 | 78 | // The specified module is not loaded. 79 | MH_ERROR_MODULE_NOT_FOUND, 80 | 81 | // The specified function is not found. 82 | MH_ERROR_FUNCTION_NOT_FOUND 83 | } 84 | MH_STATUS; 85 | 86 | // Can be passed as a parameter to MH_EnableHook, MH_DisableHook, 87 | // MH_QueueEnableHook or MH_QueueDisableHook. 88 | #define MH_ALL_HOOKS NULL 89 | 90 | #ifdef __cplusplus 91 | extern "C" { 92 | #endif 93 | 94 | // Initialize the MinHook library. You must call this function EXACTLY ONCE 95 | // at the beginning of your program. 96 | MH_STATUS WINAPI MH_Initialize(VOID); 97 | 98 | // Uninitialize the MinHook library. You must call this function EXACTLY 99 | // ONCE at the end of your program. 100 | MH_STATUS WINAPI MH_Uninitialize(VOID); 101 | 102 | // Creates a Hook for the specified target function, in disabled state. 103 | // Parameters: 104 | // pTarget [in] A pointer to the target function, which will be 105 | // overridden by the detour function. 106 | // pDetour [in] A pointer to the detour function, which will override 107 | // the target function. 108 | // ppOriginal [out] A pointer to the trampoline function, which will be 109 | // used to call the original target function. 110 | // This parameter can be NULL. 111 | MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal); 112 | 113 | // Creates a Hook for the specified API function, in disabled state. 114 | // Parameters: 115 | // pszModule [in] A pointer to the loaded module name which contains the 116 | // target function. 117 | // pszTarget [in] A pointer to the target function name, which will be 118 | // overridden by the detour function. 119 | // pDetour [in] A pointer to the detour function, which will override 120 | // the target function. 121 | // ppOriginal [out] A pointer to the trampoline function, which will be 122 | // used to call the original target function. 123 | // This parameter can be NULL. 124 | MH_STATUS WINAPI MH_CreateHookApi( 125 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal); 126 | 127 | // Removes an already created hook. 128 | // Parameters: 129 | // pTarget [in] A pointer to the target function. 130 | MH_STATUS WINAPI MH_RemoveHook(LPVOID pTarget); 131 | 132 | // Enables an already created hook. 133 | // Parameters: 134 | // pTarget [in] A pointer to the target function. 135 | // If this parameter is MH_ALL_HOOKS, all created hooks are 136 | // enabled in one go. 137 | MH_STATUS WINAPI MH_EnableHook(LPVOID pTarget); 138 | 139 | // Disables an already created hook. 140 | // Parameters: 141 | // pTarget [in] A pointer to the target function. 142 | // If this parameter is MH_ALL_HOOKS, all created hooks are 143 | // disabled in one go. 144 | MH_STATUS WINAPI MH_DisableHook(LPVOID pTarget); 145 | 146 | // Queues to enable an already created hook. 147 | // Parameters: 148 | // pTarget [in] A pointer to the target function. 149 | // If this parameter is MH_ALL_HOOKS, all created hooks are 150 | // queued to be enabled. 151 | MH_STATUS WINAPI MH_QueueEnableHook(LPVOID pTarget); 152 | 153 | // Queues to disable an already created hook. 154 | // Parameters: 155 | // pTarget [in] A pointer to the target function. 156 | // If this parameter is MH_ALL_HOOKS, all created hooks are 157 | // queued to be disabled. 158 | MH_STATUS WINAPI MH_QueueDisableHook(LPVOID pTarget); 159 | 160 | // Applies all queued changes in one go. 161 | MH_STATUS WINAPI MH_ApplyQueued(VOID); 162 | 163 | // Translates the MH_STATUS to its name as a string. 164 | const char * WINAPI MH_StatusToString(MH_STATUS status); 165 | 166 | #ifdef __cplusplus 167 | } 168 | #endif 169 | 170 | -------------------------------------------------------------------------------- /proxy/PropertySheet.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /proxy/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | DYNAMIC LINK LIBRARY : proxy Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this proxy DLL for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your proxy application. 9 | 10 | 11 | proxy.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | proxy.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | proxy.cpp 25 | This is the main DLL source file. 26 | 27 | When created, this DLL does not export any symbols. As a result, it 28 | will not produce a .lib file when it is built. If you wish this project 29 | to be a project dependency of some other project, you will either need to 30 | add code to export some symbols from the DLL so that an export library 31 | will be produced, or you can set the Ignore Input Library property to Yes 32 | on the General propert page of the Linker folder in the project's Property 33 | Pages dialog box. 34 | 35 | ///////////////////////////////////////////////////////////////////////////// 36 | Other standard files: 37 | 38 | StdAfx.h, StdAfx.cpp 39 | These files are used to build a precompiled header (PCH) file 40 | named proxy.pch and a precompiled types file named StdAfx.obj. 41 | 42 | ///////////////////////////////////////////////////////////////////////////// 43 | Other notes: 44 | 45 | AppWizard uses "TODO:" comments to indicate parts of the source code you 46 | should add to or customize. 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | -------------------------------------------------------------------------------- /proxy/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | DisableThreadLibraryCalls(hModule); 13 | CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)Entrypoint, (LPVOID)hModule, NULL, NULL); 14 | break; 15 | case DLL_THREAD_ATTACH: 16 | case DLL_THREAD_DETACH: 17 | case DLL_PROCESS_DETACH: 18 | break; 19 | } 20 | return TRUE; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /proxy/mono.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | mClassFromName_t mono_class_from_name = MONO_FUNC("mono_class_from_name"); 4 | mClassGetMethodFromName_t mono_class_get_method_from_name = MONO_FUNC("mono_class_get_method_from_name"); 5 | mRuntimeInvoke_t mono_runtime_invoke = MONO_FUNC("mono_runtime_invoke"); 6 | mClassGetPropertyFromName_t mono_class_get_property_from_name = MONO_FUNC("mono_class_get_property_from_name"); 7 | mPropertyGetSetMethod_t mono_property_get_set_method = MONO_FUNC("mono_property_get_set_method"); 8 | mPropertyGetGetMethod_t mono_property_get_get_method = MONO_FUNC("mono_property_get_get_method"); 9 | mAssemblyOpen_t mono_assembly_open = MONO_FUNC("mono_assembly_open"); 10 | mAssemblyGetImage_t mono_assembly_get_image = MONO_FUNC("mono_assembly_get_image"); 11 | mDomainGet_t mono_domain_get = MONO_FUNC("mono_domain_get"); 12 | mImageOpenFromData_t mono_image_open_from_data = MONO_FUNC("mono_image_open_from_data"); 13 | mAssemblyLoadFromFull_t mono_assembly_load_from_full = MONO_FUNC("mono_assembly_load_from_full"); 14 | 15 | mDomainGet_t origDomainGet = nullptr; 16 | bool injected = false; 17 | 18 | std::vector FileReadAllBytes(const std::wstring& name) { 19 | std::ifstream input(name, std::ios::binary); 20 | if (input.is_open()) { 21 | 22 | std::vector buffer(( 23 | std::istreambuf_iterator(input)), 24 | (std::istreambuf_iterator())); 25 | 26 | return buffer; 27 | } 28 | return std::vector(); 29 | } 30 | 31 | template 32 | T MONO_FUNC(const char *funcName) { 33 | static HMODULE hMono = GetModuleHandleA("mono.dll"); 34 | return (T)GetProcAddress(hMono, funcName); 35 | } 36 | 37 | void* __cdecl hkMonoDomainGet() 38 | { 39 | void* ret = origDomainGet(); 40 | 41 | if (!g_AssemblyQueue.empty()) 42 | { 43 | auto assembly = g_AssemblyQueue.front(); 44 | g_AssemblyQueue.pop(); 45 | 46 | LoadMonoDll(assembly.first, assembly.second); 47 | } 48 | 49 | return ret; 50 | } 51 | 52 | void LoadHook() 53 | { 54 | MH_Initialize(); 55 | MH_CreateHook(mono_domain_get, &hkMonoDomainGet, (LPVOID*)&origDomainGet); 56 | MH_EnableHook(mono_domain_get); 57 | } 58 | 59 | void RemoveHook() 60 | { 61 | MH_DisableHook(mono_domain_get); 62 | MH_Uninitialize(); 63 | } 64 | 65 | 66 | void LoadMonoDll(std::string dllPath, std::string dllNamespace) 67 | { 68 | MonoImageOpenStatus status; 69 | 70 | using ccvt = std::codecvt_utf8; 71 | std::wstring_convert converter; 72 | std::vector data = FileReadAllBytes(converter.from_bytes(dllPath)); 73 | 74 | MonoImage* raw_img = mono_image_open_from_data(reinterpret_cast(data.data()), data.size(), 1, &status, 0); 75 | 76 | MonoAssembly* assembly = mono_assembly_load_from_full(raw_img, "ok", &status, 0); 77 | 78 | MonoImage* img = mono_assembly_get_image(assembly); 79 | 80 | MonoClass* mainClass = mono_class_from_name(img, dllNamespace.data(), "Loader"); 81 | 82 | MonoMethod* method = mono_class_get_method_from_name(mainClass, "Load", 0); 83 | 84 | mono_runtime_invoke(method, NULL, NULL, NULL); 85 | } 86 | -------------------------------------------------------------------------------- /proxy/mono.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // returned.cpp : Defines the exported functions for the DLL application. 4 | // 5 | 6 | #include "stdafx.h" 7 | #include 8 | 9 | #define MonoDomain void 10 | #define MonoAssembly void 11 | #define MonoClass void 12 | #define MonoMethod void 13 | #define MonoObject void 14 | #define MonoImage void 15 | #define MonoProperty void 16 | 17 | typedef enum { 18 | MONO_IMAGE_OK, 19 | MONO_IMAGE_ERROR_ERRNO, 20 | MONO_IMAGE_MISSING_ASSEMBLYREF, 21 | MONO_IMAGE_IMAGE_INVALID 22 | } MonoImageOpenStatus; 23 | 24 | 25 | 26 | std::vector FileReadAllBytes(const std::wstring& name); 27 | 28 | template 29 | T MONO_FUNC(const char *funcName); 30 | 31 | //Class 32 | typedef MonoClass* (__cdecl* mClassFromName_t)(MonoImage* image, const char* name_space, const char* name); 33 | typedef MonoMethod* (__cdecl* mClassGetMethodFromName_t)(MonoClass* mclass, const char* name, int param_count); 34 | typedef MonoObject* (__cdecl* mRuntimeInvoke_t)(MonoMethod* method, void* obj, void** params, MonoObject** exc); 35 | typedef MonoProperty* (__cdecl* mClassGetPropertyFromName_t)(MonoClass* mclass, const char* name); 36 | typedef MonoMethod* (__cdecl* mPropertyGetSetMethod_t)(MonoProperty* prop); 37 | typedef MonoMethod* (__cdecl* mPropertyGetGetMethod_t)(MonoProperty* prop); 38 | typedef MonoAssembly* (__cdecl* mAssemblyOpen_t)(const char *filename, MonoImageOpenStatus *status); 39 | typedef MonoImage* (__cdecl* mAssemblyGetImage_t)(MonoAssembly *assembly); 40 | typedef MonoDomain* (__cdecl* mDomainGet_t)(); 41 | typedef MonoImage* (__cdecl* mImageOpenFromData_t)(char* data, uint32_t len, int32_t nCopy, MonoImageOpenStatus *status, int32_t refonly); 42 | typedef MonoAssembly* (__cdecl* mAssemblyLoadFromFull_t)(MonoImage* image, void *fname, MonoImageOpenStatus *status, bool refonly); 43 | 44 | 45 | void LoadHook(); 46 | void RemoveHook(); 47 | 48 | void LoadMonoDll(std::string dllPath, std::string dllNamespace); -------------------------------------------------------------------------------- /proxy/proxy.cpp: -------------------------------------------------------------------------------- 1 | // proxy.cpp : Defines the exported functions for the DLL application. 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | std::queue> g_AssemblyQueue; 7 | 8 | void Entrypoint(HMODULE hModule) 9 | { 10 | LoadHook(); 11 | 12 | // RemoveHook(); 13 | } 14 | 15 | void LoadAssembly(assembly_params* assembly) 16 | { 17 | std::string dllPath = assembly->szPath; 18 | std::string dllNamespace = assembly->szNamespace; 19 | 20 | std::pair dllInfo(dllPath, dllNamespace); 21 | 22 | g_AssemblyQueue.push(dllInfo); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /proxy/proxy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern std::queue> g_AssemblyQueue; 4 | 5 | struct assembly_params { 6 | const char* szPath; 7 | const char* szNamespace; 8 | }; 9 | 10 | void Entrypoint(HMODULE hModule); 11 | 12 | __declspec(dllexport) void LoadAssembly(assembly_params* assembly); -------------------------------------------------------------------------------- /proxy/proxy.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {D700FC3D-0A9D-4933-AA46-38E178622E22} 23 | Win32Proj 24 | proxy 25 | 8.1 26 | 27 | 28 | 29 | DynamicLibrary 30 | true 31 | v140 32 | Unicode 33 | 34 | 35 | DynamicLibrary 36 | false 37 | v140 38 | true 39 | Unicode 40 | 41 | 42 | DynamicLibrary 43 | true 44 | v140 45 | Unicode 46 | 47 | 48 | DynamicLibrary 49 | false 50 | v140 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | true 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | false 87 | 88 | 89 | 90 | Use 91 | Level3 92 | Disabled 93 | WIN32;_DEBUG;_WINDOWS;_USRDLL;PROXY_EXPORTS;%(PreprocessorDefinitions) 94 | 95 | 96 | Windows 97 | true 98 | 99 | 100 | 101 | 102 | Use 103 | Level3 104 | Disabled 105 | _DEBUG;_WINDOWS;_USRDLL;PROXY_EXPORTS;%(PreprocessorDefinitions) 106 | 107 | 108 | Windows 109 | true 110 | 111 | 112 | 113 | 114 | Level3 115 | Use 116 | MaxSpeed 117 | true 118 | true 119 | WIN32;NDEBUG;_WINDOWS;_USRDLL;PROXY_EXPORTS;%(PreprocessorDefinitions) 120 | 121 | 122 | Windows 123 | true 124 | true 125 | true 126 | 127 | 128 | 129 | 130 | Level3 131 | Use 132 | MaxSpeed 133 | true 134 | true 135 | NDEBUG;_WINDOWS;_USRDLL;PROXY_EXPORTS;%(PreprocessorDefinitions) 136 | 137 | 138 | Windows 139 | true 140 | true 141 | true 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | false 156 | 157 | 158 | false 159 | 160 | 161 | false 162 | 163 | 164 | false 165 | 166 | 167 | 168 | 169 | 170 | 171 | Create 172 | Create 173 | Create 174 | Create 175 | 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /proxy/proxy.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | -------------------------------------------------------------------------------- /proxy/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // proxy.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /proxy/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #if defined _M_X64 25 | #if defined _DEBUG 26 | #pragma comment(lib, "libMinHook-x64-v140-mtd.lib") 27 | #else 28 | #pragma comment(lib, "libMinHook-x64-v140-mt.lib") 29 | #endif 30 | #elif defined _M_IX86 31 | #if defined _DEBUG 32 | #pragma comment(lib, "libMinHook-x86-v140-mtd.lib") 33 | #else 34 | #pragma comment(lib, "libMinHook-x86-v140-mt.lib") 35 | #endif 36 | #endif 37 | 38 | #include "MinHook.h" 39 | 40 | #include "mono.h" 41 | #include "proxy.h" -------------------------------------------------------------------------------- /proxy/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | --------------------------------------------------------------------------------