├── .gitignore ├── Jomtek's Proxy Remover.sln ├── Jomtek's Proxy Remover ├── App.config ├── Jomtek's Proxy Remover.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── ProxyRemover.cs └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.vspscc 94 | *.vssscc 95 | .builds 96 | *.pidb 97 | *.svclog 98 | *.scc 99 | 100 | # Chutzpah Test files 101 | _Chutzpah* 102 | 103 | # Visual C++ cache files 104 | ipch/ 105 | *.aps 106 | *.ncb 107 | *.opendb 108 | *.opensdf 109 | *.sdf 110 | *.cachefile 111 | *.VC.db 112 | *.VC.VC.opendb 113 | 114 | # Visual Studio profiler 115 | *.psess 116 | *.vsp 117 | *.vspx 118 | *.sap 119 | 120 | # Visual Studio Trace Files 121 | *.e2e 122 | 123 | # TFS 2012 Local Workspace 124 | $tf/ 125 | 126 | # Guidance Automation Toolkit 127 | *.gpState 128 | 129 | # ReSharper is a .NET coding add-in 130 | _ReSharper*/ 131 | *.[Rr]e[Ss]harper 132 | *.DotSettings.user 133 | 134 | # TeamCity is a build add-in 135 | _TeamCity* 136 | 137 | # DotCover is a Code Coverage Tool 138 | *.dotCover 139 | 140 | # AxoCover is a Code Coverage Tool 141 | .axoCover/* 142 | !.axoCover/settings.json 143 | 144 | # Coverlet is a free, cross platform Code Coverage Tool 145 | coverage*[.json, .xml, .info] 146 | 147 | # Visual Studio code coverage results 148 | *.coverage 149 | *.coveragexml 150 | 151 | # NCrunch 152 | _NCrunch_* 153 | .*crunch*.local.xml 154 | nCrunchTemp_* 155 | 156 | # MightyMoose 157 | *.mm.* 158 | AutoTest.Net/ 159 | 160 | # Web workbench (sass) 161 | .sass-cache/ 162 | 163 | # Installshield output folder 164 | [Ee]xpress/ 165 | 166 | # DocProject is a documentation generator add-in 167 | DocProject/buildhelp/ 168 | DocProject/Help/*.HxT 169 | DocProject/Help/*.HxC 170 | DocProject/Help/*.hhc 171 | DocProject/Help/*.hhk 172 | DocProject/Help/*.hhp 173 | DocProject/Help/Html2 174 | DocProject/Help/html 175 | 176 | # Click-Once directory 177 | publish/ 178 | 179 | # Publish Web Output 180 | *.[Pp]ublish.xml 181 | *.azurePubxml 182 | # Note: Comment the next line if you want to checkin your web deploy settings, 183 | # but database connection strings (with potential passwords) will be unencrypted 184 | *.pubxml 185 | *.publishproj 186 | 187 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 188 | # checkin your Azure Web App publish settings, but sensitive information contained 189 | # in these scripts will be unencrypted 190 | PublishScripts/ 191 | 192 | # NuGet Packages 193 | *.nupkg 194 | # NuGet Symbol Packages 195 | *.snupkg 196 | # The packages folder can be ignored because of Package Restore 197 | **/[Pp]ackages/* 198 | # except build/, which is used as an MSBuild target. 199 | !**/[Pp]ackages/build/ 200 | # Uncomment if necessary however generally it will be regenerated when needed 201 | #!**/[Pp]ackages/repositories.config 202 | # NuGet v3's project.json files produces more ignorable files 203 | *.nuget.props 204 | *.nuget.targets 205 | 206 | # Microsoft Azure Build Output 207 | csx/ 208 | *.build.csdef 209 | 210 | # Microsoft Azure Emulator 211 | ecf/ 212 | rcf/ 213 | 214 | # Windows Store app package directories and files 215 | AppPackages/ 216 | BundleArtifacts/ 217 | Package.StoreAssociation.xml 218 | _pkginfo.txt 219 | *.appx 220 | *.appxbundle 221 | *.appxupload 222 | 223 | # Visual Studio cache files 224 | # files ending in .cache can be ignored 225 | *.[Cc]ache 226 | # but keep track of directories ending in .cache 227 | !?*.[Cc]ache/ 228 | 229 | # Others 230 | ClientBin/ 231 | ~$* 232 | *~ 233 | *.dbmdl 234 | *.dbproj.schemaview 235 | *.jfm 236 | *.pfx 237 | *.publishsettings 238 | orleans.codegen.cs 239 | 240 | # Including strong name files can present a security risk 241 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 242 | #*.snk 243 | 244 | # Since there are multiple workflows, uncomment next line to ignore bower_components 245 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 246 | #bower_components/ 247 | 248 | # RIA/Silverlight projects 249 | Generated_Code/ 250 | 251 | # Backup & report files from converting an old project file 252 | # to a newer Visual Studio version. Backup files are not needed, 253 | # because we have git ;-) 254 | _UpgradeReport_Files/ 255 | Backup*/ 256 | UpgradeLog*.XML 257 | UpgradeLog*.htm 258 | ServiceFabricBackup/ 259 | *.rptproj.bak 260 | 261 | # SQL Server files 262 | *.mdf 263 | *.ldf 264 | *.ndf 265 | 266 | # Business Intelligence projects 267 | *.rdl.data 268 | *.bim.layout 269 | *.bim_*.settings 270 | *.rptproj.rsuser 271 | *- [Bb]ackup.rdl 272 | *- [Bb]ackup ([0-9]).rdl 273 | *- [Bb]ackup ([0-9][0-9]).rdl 274 | 275 | # Microsoft Fakes 276 | FakesAssemblies/ 277 | 278 | # GhostDoc plugin setting file 279 | *.GhostDoc.xml 280 | 281 | # Node.js Tools for Visual Studio 282 | .ntvs_analysis.dat 283 | node_modules/ 284 | 285 | # Visual Studio 6 build log 286 | *.plg 287 | 288 | # Visual Studio 6 workspace options file 289 | *.opt 290 | 291 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 292 | *.vbw 293 | 294 | # Visual Studio LightSwitch build output 295 | **/*.HTMLClient/GeneratedArtifacts 296 | **/*.DesktopClient/GeneratedArtifacts 297 | **/*.DesktopClient/ModelManifest.xml 298 | **/*.Server/GeneratedArtifacts 299 | **/*.Server/ModelManifest.xml 300 | _Pvt_Extensions 301 | 302 | # Paket dependency manager 303 | .paket/paket.exe 304 | paket-files/ 305 | 306 | # FAKE - F# Make 307 | .fake/ 308 | 309 | # CodeRush personal settings 310 | .cr/personal 311 | 312 | # Python Tools for Visual Studio (PTVS) 313 | __pycache__/ 314 | *.pyc 315 | 316 | # Cake - Uncomment if you are using it 317 | # tools/** 318 | # !tools/packages.config 319 | 320 | # Tabs Studio 321 | *.tss 322 | 323 | # Telerik's JustMock configuration file 324 | *.jmconfig 325 | 326 | # BizTalk build output 327 | *.btp.cs 328 | *.btm.cs 329 | *.odx.cs 330 | *.xsd.cs 331 | 332 | # OpenCover UI analysis results 333 | OpenCover/ 334 | 335 | # Azure Stream Analytics local run output 336 | ASALocalRun/ 337 | 338 | # MSBuild Binary and Structured Log 339 | *.binlog 340 | 341 | # NVidia Nsight GPU debugger configuration file 342 | *.nvuser 343 | 344 | # MFractors (Xamarin productivity tool) working folder 345 | .mfractor/ 346 | 347 | # Local History for Visual Studio 348 | .localhistory/ 349 | 350 | # BeatPulse healthcheck temp database 351 | healthchecksdb 352 | 353 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 354 | MigrationBackup/ 355 | 356 | # Ionide (cross platform F# VS Code tools) working folder 357 | .ionide/ 358 | 359 | # Fody - auto-generated XML schema 360 | FodyWeavers.xsd -------------------------------------------------------------------------------- /Jomtek's Proxy Remover.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30128.74 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jomtek's Proxy Remover", "Jomtek's Proxy Remover\Jomtek's Proxy Remover.csproj", "{66FA1749-D522-4CF6-9D36-D4418F950D4B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {66FA1749-D522-4CF6-9D36-D4418F950D4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {66FA1749-D522-4CF6-9D36-D4418F950D4B}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {66FA1749-D522-4CF6-9D36-D4418F950D4B}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {66FA1749-D522-4CF6-9D36-D4418F950D4B}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {96C3FCE8-2F79-41C3-B6D5-601F62713E69} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Jomtek's Proxy Remover/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Jomtek's Proxy Remover/Jomtek's Proxy Remover.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {66FA1749-D522-4CF6-9D36-D4418F950D4B} 8 | Exe 9 | Jomtek_s_Proxy_Remover 10 | Jomtek%27s Proxy Remover 11 | v4.8 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | ..\..\..\..\Documents\Software cracking\Development\dnlib\dnlib.dll 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Jomtek's Proxy Remover/Program.cs: -------------------------------------------------------------------------------- 1 | using dnlib.DotNet; 2 | using dnlib.DotNet.Emit; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Reflection; 7 | using System.Text; 8 | using System.Threading; 9 | using System.Threading.Tasks; 10 | 11 | namespace Jomtek_s_Proxy_Remover 12 | { 13 | class Program 14 | { 15 | static void Main(string[] args) 16 | { 17 | while (true) 18 | { 19 | Console.Clear(); 20 | 21 | string modulePath = ""; 22 | int proxyDepth = 0; 23 | 24 | try 25 | { 26 | modulePath = args[0]; 27 | } 28 | catch (IndexOutOfRangeException) 29 | { 30 | Console.WriteLine("Error : no module selected... press ENTER to exit."); 31 | Console.ReadLine(); 32 | Environment.Exit(0); 33 | } 34 | 35 | Console.Write("Proxy depth : "); 36 | int.TryParse(Console.ReadLine(), out proxyDepth); 37 | 38 | if (proxyDepth < 1) 39 | { 40 | Console.WriteLine("Invalid proxy depth (should be greater than 1)"); 41 | Thread.Sleep(700); 42 | continue; 43 | } 44 | 45 | Console.Clear(); 46 | 47 | ModuleContext modCtx = ModuleDef.CreateModuleContext(); 48 | ModuleDefMD module = ModuleDefMD.Load(modulePath, modCtx); 49 | 50 | var myProxyRemover = new ProxyRemover(module, modulePath); 51 | int removedProxies = myProxyRemover.RemoveProxiesFromTypes(module.Types, proxyDepth); 52 | 53 | if (removedProxies > 0) Console.WriteLine(); 54 | Console.WriteLine(removedProxies + " proxies removed"); 55 | Console.WriteLine(); 56 | 57 | if (removedProxies > 0) 58 | { 59 | Console.WriteLine("Saving module..."); 60 | myProxyRemover.SaveModule(); 61 | } 62 | 63 | 64 | Console.WriteLine("Done."); 65 | Console.ReadLine(); 66 | break; 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Jomtek's Proxy Remover/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Jomtek's Proxy Remover")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Jomtek's Proxy Remover")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("66fa1749-d522-4cf6-9d36-d4418f950d4b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Jomtek's Proxy Remover/ProxyRemover.cs: -------------------------------------------------------------------------------- 1 | using dnlib.DotNet; 2 | using dnlib.DotNet.Emit; 3 | using dnlib.DotNet.Writer; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Reflection; 9 | using System.Runtime.InteropServices; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | 13 | namespace Jomtek_s_Proxy_Remover 14 | { 15 | class ProxyRemover 16 | { 17 | private ModuleDef module; 18 | private string modulePath; 19 | private Dictionary opcodesDict; 20 | 21 | public ProxyRemover(ModuleDef module, string modulePath) 22 | { 23 | this.module = module; 24 | this.modulePath = modulePath; 25 | 26 | opcodesDict = new Dictionary(); 27 | opcodesDict.Add("System.String", OpCodes.Ldstr); 28 | opcodesDict.Add("System.Int32", OpCodes.Ldc_I4); 29 | opcodesDict.Add("System.SByte", OpCodes.Ldc_I4_S); 30 | opcodesDict.Add("System.Boolean", OpCodes.Ldc_I4_1); 31 | } 32 | 33 | private bool IsTypeAnalyzable(TypeDef moduleType) => 34 | moduleType.HasMethods && !moduleType.Namespace.Contains(".My"); 35 | 36 | private bool IsProxyTypeAnalyzable(string proxyType) { 37 | return new string[] { "System.String", "System.Int32", "System.SByte", "System.Boolean" }.Contains(proxyType); 38 | } 39 | 40 | private bool IsMethodProxy(MethodDef method, IList instructions) => 41 | method.HasReturnType && !method.HasParams() && instructions.Count == 2; 42 | 43 | private Dictionary AnalyzeMethods(IList methods) 44 | { 45 | var proxyDict = new Dictionary(); 46 | 47 | foreach (MethodDef method in methods) 48 | { 49 | if (method.Body != null) 50 | { 51 | IList methodInstructions = method.Body.Instructions; 52 | 53 | if (IsMethodProxy(method, methodInstructions) && IsProxyTypeAnalyzable(method.ReturnType.ToString())) 54 | { 55 | object methodReturnValue = methodInstructions[0].Operand; // from the ld instruction, just before the ret 56 | OpCode ldOpcode = methodInstructions[0].OpCode; 57 | 58 | if (method.ReturnType.ToString() == "System.Boolean") 59 | methodReturnValue = ldOpcode == OpCodes.Ldc_I4_1; 60 | 61 | proxyDict[method.MDToken] = methodReturnValue; 62 | } 63 | } 64 | } 65 | 66 | return proxyDict; 67 | } 68 | 69 | private MethodDef[] RemoveProxies(IList methods, Dictionary proxies) 70 | { 71 | var removedMethods = new List(); 72 | 73 | foreach (MethodDef method in methods) 74 | { 75 | if (method.Body != null) 76 | { 77 | int counter = 0; 78 | for (int i = 0; i < method.Body.Instructions.Count - 1; i++) 79 | { 80 | Instruction instruction = method.Body.Instructions[counter]; 81 | 82 | if (instruction.OpCode == OpCodes.Call && counter > 0) 83 | { 84 | try 85 | { 86 | MethodDef calledFunc = (MethodDef)instruction.Operand; 87 | if (proxies.ContainsKey(calledFunc.MDToken)) 88 | { 89 | object resolvedValue = proxies[calledFunc.MDToken]; 90 | string resolvedValueType = resolvedValue.GetType().ToString(); 91 | 92 | if (IsProxyTypeAnalyzable(resolvedValueType)) 93 | { 94 | if (method.Body.Instructions[counter - 1].OpCode == OpCodes.Ldarg_0) 95 | { 96 | method.Body.Instructions.RemoveAt(counter - 1); 97 | counter--; 98 | } 99 | 100 | removedMethods.Add(calledFunc); 101 | proxies.Remove(calledFunc.MDToken); 102 | 103 | instruction.OpCode = opcodesDict[resolvedValueType]; 104 | 105 | if (resolvedValueType == "System.Boolean") 106 | if (!(bool)resolvedValue) instruction.OpCode = OpCodes.Ldc_I4_0; 107 | else 108 | instruction.Operand = resolvedValue; 109 | 110 | Console.WriteLine("Removed proxy " + calledFunc.MDToken.ToString()); 111 | } 112 | } 113 | } catch (InvalidCastException) {} 114 | } 115 | 116 | counter++; 117 | } 118 | } 119 | } 120 | 121 | return removedMethods.ToArray(); 122 | } 123 | 124 | private void RemoveUnusedProxies(TypeDef moduleType, Dictionary globalProxiesList) 125 | { 126 | int counter = 0; 127 | for (int x = 0; x < moduleType.Methods.Count; x++) // Remove unused proxies 128 | { 129 | MethodDef method = moduleType.Methods[counter]; 130 | 131 | if (globalProxiesList.ContainsKey(method.MDToken)) 132 | { 133 | method.Body.Instructions.Clear(); 134 | moduleType.Methods.RemoveAt(counter); 135 | globalProxiesList.Remove(method.MDToken); 136 | counter--; 137 | } 138 | 139 | counter++; 140 | } 141 | } 142 | public int RemoveProxiesFromTypes(IEnumerable moduleTypes, int cycles) 143 | { 144 | var globalProxiesList = new Dictionary(); 145 | int totalRemovedMethods = 0; 146 | 147 | for (int i = 0; i < cycles; i++) 148 | { 149 | int removedMethodsThisCycle = 0; 150 | 151 | // Analyze types 152 | foreach (TypeDef moduleType in moduleTypes) 153 | { 154 | if (IsTypeAnalyzable(moduleType)) 155 | { 156 | if (moduleType.DeclaringType != null && !IsTypeAnalyzable(moduleType.DeclaringType)) continue; 157 | 158 | Dictionary foundProxies = 159 | AnalyzeMethods(moduleType.Methods); 160 | 161 | globalProxiesList = globalProxiesList.Union(foundProxies).ToDictionary(x => x.Key, x => x.Value); 162 | } 163 | } 164 | 165 | // Remove proxies 166 | foreach (TypeDef moduleType in moduleTypes) 167 | { 168 | if (IsTypeAnalyzable(moduleType)) 169 | { 170 | if (moduleType.DeclaringType != null && !IsTypeAnalyzable(moduleType.DeclaringType)) continue; 171 | 172 | MethodDef[] removedMethods = RemoveProxies(moduleType.Methods, globalProxiesList); 173 | removedMethodsThisCycle += removedMethods.Count(); 174 | 175 | foreach (MethodDef method in removedMethods) // Remove used proxies 176 | moduleType.Methods.Remove(method); 177 | } 178 | } 179 | 180 | // Remove unused proxies 181 | foreach (TypeDef moduleType in moduleTypes) 182 | { 183 | RemoveUnusedProxies(moduleType, globalProxiesList); 184 | } 185 | 186 | totalRemovedMethods += removedMethodsThisCycle; 187 | 188 | if (removedMethodsThisCycle == 0) 189 | break; 190 | } 191 | 192 | return totalRemovedMethods; 193 | } 194 | 195 | public void SaveModule() 196 | { 197 | string savePath = Path.ChangeExtension(modulePath, null); 198 | 199 | var moduleOptions = new ModuleWriterOptions(module); 200 | moduleOptions.MetadataOptions.Flags = MetadataFlags.KeepOldMaxStack; 201 | moduleOptions.MetadataLogger = DummyLogger.NoThrowInstance; 202 | 203 | module.Write(savePath + "_fixed" + Path.GetExtension(modulePath), moduleOptions); 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Jomtek's Universal Proxy-Remover 4 | Unfortunately, at the moment, this proxy fixer can only fix proxies which return literal values. 5 | For example, this proxy won't get fixed : 6 | 7 | static int myProxy() { 8 | return 1 + 1; 9 | } 10 | 11 | But I'm doing my best to update it asap :) 12 | 13 | # What is a proxy ? 14 | When we're talking about IL code and .NET reverse engineering, a "proxy" is an intermediate method to a value. 15 | Quick example 16 | 17 | static void main(string[] args) { 18 | Console.WriteLine(myProxy()); 19 | } 20 | 21 | static int myProxy() { 22 | return "hello!; 23 | } 24 | 25 | 26 | As you can see, proxies can make values harder to read. Now imagine this applied to thousands of values, submersed in thousands of lines of code... 27 | 28 | # Proxy depth 29 | Obviously, proxies can call other proxies, which will then call other proxies... That's why I added a "depth" setting on this proxy remover. Quick example of a depth 2 proxified code. 30 | 31 | static void main(string[] args) { 32 | Console.WriteLine(myProxy()); 33 | } 34 | 35 | static int myProxy() { 36 | return anotherProxy(); 37 | } 38 | 39 | static int anotherProxy() { 40 | return "hello!"; 41 | } 42 | 43 |
Result after proxy removal : 44 | 45 | static void main(string[] args) { 46 | Console.WriteLine("hello!"); 47 | } 48 | 49 | # Credits 50 | Special thanks to 51 | - the NetShields Obfuscator community 52 | - [0x4d4](https://github.com/0xd4d) (dnlib's inventor) 53 | - [Mindsystemm](https://github.com/MindSystemm) (a nice friend of mine) 54 | --------------------------------------------------------------------------------