I have a C# dll with a member similar to the following:
public void DoStuff(int i) {
try {
something.InnerDoStuff(i);
}
catch (Exception ex) {
throw ex;
}
}
I figured out how to get the throw opcode:
Add-Type -Path 'c:\Program Files\ILSpy2\Mono.Cecil.dll'
Add-Type -Path 'c:\Program Files\ILSpy2\Mono.Cecil.pdb.dll'
$dll = 'c:\Program Files\ZippySoft\Something\foo.dll'
$assemblyDefinition = [Mono.Cecil.AssemblyDefinition]::ReadAssembly($dll);
$doThingsIlAsm = (
(
$assemblyDefinition.MainModule.Types `
| where { $_.Name -eq 'DoerOfThings' } `
| select -first 1 *
).Methods | where { $_.Name -eq 'DoStuff' }
).Body.Instructions
$throwOp = ($doThingsIlAsm | where {
$_.OpCode.Name -eq 'throw'
})
My question is how do I replace throw opcode with a rethrow opcode?