Created
February 29, 2024 19:32
-
-
Save guillaC/faaf5d7172229301552b4aad94f5f542 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static string SelfDecompile() | |
{ | |
string result = string.Empty; | |
string assemblyFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location; | |
AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(assemblyFilePath); | |
// Trouver la classe Program | |
TypeDefinition programType = null; | |
foreach (TypeDefinition type in assembly.MainModule.Types) | |
{ | |
if (type.Name == "Program") | |
{ | |
programType = type; | |
break; | |
} | |
} | |
if (programType != null) | |
{ | |
foreach (MethodDefinition method in programType.Methods) | |
{ | |
result = $"{result}Method: {method.Name}{Environment.NewLine}"; | |
foreach (Instruction instruction in method.Body.Instructions) | |
{ | |
result = $"{result}{instruction.OpCode} {instruction.Operand}{Environment.NewLine}"; | |
} | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment