Skip to content

Instantly share code, notes, and snippets.

@CraigStuntz
Forked from mgroves/PEVerify output
Created March 29, 2012 14:07
Show Gist options
  • Save CraigStuntz/2237777 to your computer and use it in GitHub Desktop.
Save CraigStuntz/2237777 to your computer and use it in GitHub Desktop.
fireweaver IL
.class private auto ansi beforefieldinit FireWeaverExample.Program
extends [mscorlib]System.Object
{
.method public hidebysig specialname rtspecialname
instance void .ctor () cil managed
{
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
}
.method private hidebysig static
void Main (
string[] args
) cil managed
{ // My rough C# translation
.entrypoint
.locals init (
[0] class FireWeaverExample.Dog cat // Dog cat;
)
IL_0000: nop
IL_0001: newobj instance void [FireWeaverExample]FireWeaverExample.Cat::.ctor() // new Cat()
IL_0006: stloc.0 // cat = ;
IL_0007: ldloc.0 //
IL_0008: isinst [FireWeaverExample]FireWeaverExample.Cat // (cat as Cat)
IL_000d: ldnull // null
IL_000e: cgt.un // if ( <= ) { <- This is nonsense, but cgt.un returns 0 for nonsense, see
http://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.cgt_un.aspx
so:
IL_0010: ldc.i4.0
IL_0011: ceq
IL_0013: brtrue.s IL_0021 Nonsense result means true is on the stack, execution jumps to IL_0021
IL_0015: nop
IL_0016: ldloc.0
IL_0017: callvirt instance void [FireWeaverExample]FireWeaverExample.Cat::Bark()
IL_001c: br IL_0027 // } else {
IL_0021: ldloc.0
IL_0022: callvirt instance void FireWeaverExample.Dog::Bark() // cat.Bark(); }
IL_0027: nop
IL_0028: ret
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment