Skip to content

Instantly share code, notes, and snippets.

@idvorkin
Created December 9, 2012 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idvorkin/4245198 to your computer and use it in GitHub Desktop.
Save idvorkin/4245198 to your computer and use it in GitHub Desktop.
dumpMDForAction
$$ Call DumpMD on the target of a System.Action(aka delgate).
$$ Tested on x64 only
$$ From: http://geekswithblogs.net/akraus1/archive/2012/05/20/149699.aspx
.echo usage - $$>a< ".\dumpMDForAction.dbg" addressOfObject
.loadby sos clr
$$ Sorry World, I did not find a simpler way. I'll explain the parts
$$ for the next time I'm feeling like doing this.
$$ DESIRE: t0 = (Action._methodPtrAux !=0) ? Action._methodPtrAux : Action._methodPtr
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$ Some commands (.shell, $$<) need to be wrapped in block statements.
$$ [in windbg] .block {...}
$$ Launch command with input of !do (see do.txt) passed in on stdin, and stdout sent to out.dbg
$$ [in windbg] .shell -i- -o .\out.dbg -ci "!do ${$arg1}"
$$ Launch powershell and process the command at -command. From here on in, we're in powershell.
$$ (Note | must be spelt ^|)
$$ [in cmd] powershell -command
$$ Get all lines that have _methodPtr on them, where the Value column != 0
$$ $input ^| ? {$_ -match '\b(\w+)\b _methodPtr'} ^| ? {$matches[1] -ne 0 }
$$ Get the last one - and re-write the output to be r $t0 = value.
.block { .shell -i- -o .\out.dbg -ci "!do ${$arg1}" powershell -command $input ^| ? {$_ -match '\b(\w+)\b _methodPtr'} ^| ? {$matches[1] -ne 0 } ^| ForEach-Object {$matches[1]} ^| Select-Object -last 1 ^| ForEach-Object {'r $t0='+$_} }
.block { $$<out.dbg }
r $t1 = $t0+5
.echo $arg1
r $t2 = @$t1 + 8*by(@$t1+2) + 3
r $t3 = 8*by(@$t1+1)
r $t4 = poi(@$t2) + @$t3
.echo Dumping
!DumpMD @$t4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment