Changeset 84 for binary-improvements/assembly-patcher
- Timestamp:
- Jul 19, 2014, 12:47:32 PM (10 years ago)
- Location:
- binary-improvements/assembly-patcher
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/assembly-patcher/Assembly-Patcher.userprefs
r83 r84 3 3 <MonoDevelop.Ide.Workbench ActiveDocument="Main.cs"> 4 4 <Files> 5 <File FileName="Main.cs" Line=" 48" Column="3" />5 <File FileName="Main.cs" Line="29" Column="54" /> 6 6 <File FileName="AssemblyInfo.cs" Line="21" Column="1" /> 7 7 </Files> 8 <Pads> 9 <Pad Id="ProjectPad"> 10 <State expanded="True"> 11 <Node name="Assembly-Patcher" expanded="True"> 12 <Node name="References" expanded="True"> 13 <Node name="/home/ci/Schreibtisch/7dtd-svn/binary-improvements/7dtd-server-fixes/bin/Release/7dtd-server-fixes.dll" selected="True" /> 14 </Node> 15 </Node> 16 </State> 17 </Pad> 18 </Pads> 8 19 </MonoDevelop.Ide.Workbench> 9 20 <MonoDevelop.Ide.DebuggingService.Breakpoints> -
binary-improvements/assembly-patcher/Main.cs
r83 r84 14 14 connectLogPatch (module); 15 15 executionLogPatch( module); 16 publicCommandPermissionsPatch (module); 16 17 module.Write ("Assembly-CSharp.dll"); 17 18 Console.WriteLine ("Done"); 19 } 20 21 private static void publicCommandPermissionsPatch (ModuleDefinition module) 22 { 23 TypeDefinition type = module.GetType ("AdminTools"); 24 25 if (isPatched (type)) { 26 return; 27 } 28 29 markTypePatched (module, type); 30 replaceMethod (type, "GetAllowedCommandsList", true, 1, typeof(AdminToolsStuff).GetMethod ("GetAllowedCommandsList")); 18 31 } 19 32 … … 51 64 52 65 markTypePatched (module, type); 53 replaceMethod (type, ".ctor", 1, typeof(AllocsNetTelnetServer).GetMethod ("init"));54 replaceMethod (type, "Disconnect", 0, typeof(AllocsNetTelnetServer).GetMethod ("Disconnect"));55 replaceMethod (type, "SetConsole", 1, typeof(AllocsNetTelnetServer).GetMethod ("SetConsole"));56 replaceMethod (type, "WriteToClient", 1, typeof(AllocsNetTelnetServer).GetMethod ("WriteToClient"));66 replaceMethod (type, ".ctor", false, 1, typeof(AllocsNetTelnetServer).GetMethod ("init")); 67 replaceMethod (type, "Disconnect", false, 0, typeof(AllocsNetTelnetServer).GetMethod ("Disconnect")); 68 replaceMethod (type, "SetConsole", false, 1, typeof(AllocsNetTelnetServer).GetMethod ("SetConsole")); 69 replaceMethod (type, "WriteToClient", false, 1, typeof(AllocsNetTelnetServer).GetMethod ("WriteToClient")); 57 70 } 58 71 … … 92 105 } 93 106 94 private static void replaceMethod (TypeDefinition type, string methodName, int opCount, MethodBase targetMethod)107 private static void replaceMethod (TypeDefinition type, string methodName, bool addThisRef, int opCount, MethodBase targetMethod) 95 108 { 96 109 foreach (MethodDefinition method in type.Methods) { … … 100 113 var call = il.Create (OpCodes.Call, method.Module.Import (targetMethod)); 101 114 var i = 0; 115 if (addThisRef) 116 il.InsertBefore (method.Body.Instructions [i++], il.Create (OpCodes.Ldarg, 0)); 102 117 for (int op = 0; op < opCount; op++) { 103 118 il.InsertBefore (method.Body.Instructions [i++], il.Create (OpCodes.Ldarg, op + 1));
Note:
See TracChangeset
for help on using the changeset viewer.