Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manipulating a Variable from a .foreach loop in Windbg

Tags:

windbg

I am trying to enumerate in a Windbg script a list of objects and perform an operation on.

So i get the Directory objects then i do a foreach on each object in that directory.

.foreach /pS 19 /ps 1 (Address {!object @$t7}) {!object Address}

The problem is that "Address" is not always an address token. I need to skip non-numeric tokens. I can't do that using /ps , without skipping some valid addresses and screwing up the tokens.

I tries something like .if ($spat(Address, "-")) != 1 { }

but that did not work.

Can i not perform operations on the Variable "Address" before actually passing it to the OutCommand ?

Thanks.

like image 778
pengwinsurf Avatar asked Mar 28 '26 14:03

pengwinsurf


1 Answers

I tries something like .if ($spat(Address, "-")) != 1 { }

This should work, but your syntax is slightly incorrect. You will need something like this:

.if ( $spat( "Address","[0-f][0-f][0-f][0-f][0-f][0-f][0-f][0-f]" ) )
{
    some code;
};

This will match addresses. See the String Wildcard Syntax page in windbg help for more details on matching.

like image 82
ben_re Avatar answered Mar 30 '26 03:03

ben_re



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!