From bb086b99dd1158b5d400660e00f96172874fb1d6 Mon Sep 17 00:00:00 2001 From: Michiel Hazelhof Date: Tue, 3 Jan 2023 21:36:15 +0100 Subject: [PATCH] Simplify patch --- bitBetter/Program.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bitBetter/Program.cs b/bitBetter/Program.cs index 24a07b6..d17fcbb 100644 --- a/bitBetter/Program.cs +++ b/bitBetter/Program.cs @@ -45,16 +45,14 @@ internal class Program TypeDef type = services.First(t => t.Name == "LicensingService"); MethodDef constructor = type.FindConstructors().First(); - Instruction instToReplace = + Instruction instructionToPatch = constructor.Body.Instructions .FirstOrDefault(i => i.OpCode == OpCodes.Ldstr && String.Equals((String)i.Operand, existingCert.Thumbprint, StringComparison.InvariantCultureIgnoreCase)); - if (instToReplace != null) + if (instructionToPatch != null) { - Int32 index = constructor.Body.Instructions.IndexOf(instToReplace); - constructor.Body.Instructions.Remove(instToReplace); - constructor.Body.Instructions.Insert(index, Instruction.Create(OpCodes.Ldstr, certificate.Thumbprint)); + instructionToPatch.Operand = certificate.Thumbprint; } else {