Advertisement
IAmXeClutch

[Project] TSS Patcher

Jun 15th, 2014
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Mono.Cecil;
  7. using Mono.Cecil.Cil;
  8.  
  9. namespace TSS_Patcher
  10. {
  11.     class Program
  12.     {
  13.         static string path;
  14.  
  15.         static void Main(string[] args)
  16.         {
  17.             path = args[0];
  18.             Console.Title = "TSS Patcher";
  19.             Console.ForegroundColor = ConsoleColor.White;
  20.             Console.Write("TSS Patcher - Anon Xero\n\nFile: " + path);
  21.             Magic(AssemblyDefinition.ReadAssembly(path));
  22.         }
  23.  
  24.         static void Magic(AssemblyDefinition asdef)
  25.         {
  26.             Console.Write("\n\nStarting Patcher...\n\n");
  27.  
  28.             // Set to Standard Edition
  29.             asdef.EntryPoint.Body.Instructions[1] = Instruction.Create(OpCodes.Ldc_I4_1);
  30.             Console.Write("P1: Set to standard edition\n");
  31.  
  32.             // Find & edit the location of Registration #
  33.             foreach (ModuleDefinition moduledef in asdef.Modules)
  34.                 foreach (TypeDefinition typedef in moduledef.Types)
  35.                     if (typedef.HasMethods)
  36.                         foreach (MethodDefinition methoddef in typedef.Methods)
  37.                             if (methoddef.HasBody)
  38.                                 if (methoddef.Body.Instructions.Count > 0x61)
  39.                                     if (methoddef.Body.Instructions[0x61].OpCode == OpCodes.Ldarg_3)
  40.                                         if (methoddef.Body.Instructions[0x61].Offset == 0x10A)
  41.                                             methoddef.Body.Instructions[0x61] = Instruction.Create(OpCodes.Ldstr, "CrackedByXeClutch");
  42.             Console.Write("P2: Registration # stamped\n");
  43.  
  44.             // Save patched assembly
  45.             asdef.Write(path.TrimEnd(".exe".ToCharArray()) + " - TSS Patcher.exe");
  46.             Console.Write("P3: Patched assembly saved\n");
  47.            
  48.             Console.ForegroundColor = ConsoleColor.Green;
  49.             Console.Write("Done !\n");
  50.             Console.ForegroundColor = ConsoleColor.White;
  51.             Console.Write("Press any key to exit...");
  52.             Console.ReadKey();
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement