Simplify patch

This commit is contained in:
Michiel Hazelhof 2023-01-03 21:36:15 +01:00
parent a9f3cef023
commit bb086b99dd
No known key found for this signature in database
GPG Key ID: EECB9B96355B5EBF
1 changed files with 3 additions and 5 deletions

View File

@ -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
{