Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Mono.Cecil
- Imports Mono.Cecil.Cil
- Imports System.Reflection
- Public Class Patcher
- Public Shared Function PatchNetSeal(ByVal asm As AssemblyDefinition) As Boolean
- Try
- Dim enumerator As IEnumerator(Of TypeDefinition)
- Try
- enumerator = asm.MainModule.Types.GetEnumerator
- Do While enumerator.MoveNext
- Dim current As TypeDefinition = enumerator.Current
- Try
- Dim enumerator2 As IEnumerator(Of MethodDefinition)
- Try
- enumerator2 = current.Methods.GetEnumerator
- Do While enumerator2.MoveNext
- Dim definition2 As MethodDefinition = enumerator2.Current
- Try
- If definition2.HasBody Then
- Dim enumerator3 As IEnumerator(Of Instruction)
- Dim iLProcessor As ILProcessor = definition2.Body.GetILProcessor
- Try
- enumerator3 = iLProcessor.Body.Instructions.GetEnumerator
- Do While enumerator3.MoveNext
- Dim instruction As Instruction = enumerator3.Current
- If ((instruction.OpCode = OpCodes.Ldstr) AndAlso instruction.Operand.ToString.Contains("Unable to initialize due to missing Net Seal ID.")) Then
- Console.WriteLine(("NetSeal Initialize Path Found: " & current.Name & "." & definition2.Name))
- iLProcessor.Replace(iLProcessor.Body.Instructions.Item(0), iLProcessor.Create(OpCodes.Ret))
- Return True
- End If
- Loop
- Finally
- enumerator3.Dispose()
- End Try
- End If
- Catch exception1 As Exception
- Console.WriteLine("Error :" & vbNewLine)
- Console.WriteLine(exception1)
- End Try
- Loop
- Finally
- enumerator2.Dispose()
- End Try
- Catch exception2 As Exception
- Console.WriteLine("Error :" & vbNewLine)
- Console.WriteLine(exception2)
- End Try
- Loop
- Finally
- enumerator.Dispose()
- End Try
- Catch exception3 As Exception
- Console.WriteLine("Error :" & vbNewLine)
- Console.WriteLine(exception3)
- End Try
- Return False
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment