Windbg syntax - combining two commands (MASM and C++) into one

Viewed 211

My apologies if I should know this, but I know that someone else will know straight away if it's possible (and I'd assume it is) and then I can know for the future. But is it possible to combine these two commands into one?

0:006> ? @@(this->m_pSession->m_SessionContext._Mypair._Myval2._Bx._Buf)
Evaluate expression: 1628841015336 = 0000017b`3e7d7828
0:006> ?? (char *) 0x0000017b3e7d7828
char * 0x0000017b`3e7d7828
 "BlahBlahBlah"

I have no problem, per se, running them sequentially, but I figured that I must be able to use something really clever, like parentheses or something?, to wrap the first in the second... however, no matter what I try I only get Windbg moaning about a syntax error... that's fair enough... mea culpa.

The first command returns what I want, which is the address of a char *, but does it actually return everything you see echoed to the console, and that's why I cannot simply do something like this?

?? (char *) (? @@(this->m_pSession->m_SessionContext._Mypair._Myval2._Bx._Buf))

And get my "BlahBlahBlah" echoed? Or am I simply missing some obtuse Windbg syntax requirement?

I thought that I'd be clever and try to use a pseudo-register, but I don't think I'm clever enough as I now can't seem to combine these two commands into one:

0:006> r? @$t2 = @@masm(@@c++(this->m_pSession->m_SessionContext._Mypair._Myval2._Bx._Buf))
0:006> .printf "%ma\n", @$t2
BlahBlahBlah

Well, that's actually a lie - I can get it in one command if I do this:

r? @$t2 = @@masm(@@c++(this->m_pSession->m_SessionContext._Mypair._Myval2._Bx._Buf));.printf "%ma\n", @$t2

But that's not really what I was aiming for... that's a finagle, any pointers greatly appreciated.

1 Answers

i don't know why use convouluted strategies
I hope you understand the implementation of std::string and sso (short string optimization)
I hope you understand any string that crosses a threshold cannot be printed with _Buf
but need to be printed via its _Ptr

why not use just c++ or use the convenience functions

try some of the below expressions and see if it satisfies the needs

0:000> ?? testA._Mypair._Myval2._Bx._Buf
char [16] 0x00000016`32b6f958

105 'i'
0:000> ?? (char *)testA._Mypair._Myval2._Bx._Buf
char * 0x00000016`32b6f958
 "i'll be ssoed"

0:000> da @@c++(testA._Mypair._Myval2._Bx._Buf)
00000016`32b6f958  "i'll be ssoed"

0:000> da @@c++(testW._Mypair._Myval2._Bx._Buf)
00000016`32b6f938  "p.Wj&."

0:000> da @@c++(testW._Mypair._Myval2._Bx._Ptr)
00000126`6a579470  "H"

0:000> du @@c++(testW._Mypair._Myval2._Bx._Ptr)
00000126`6a579470  "Hello My Dear World Do You Recog"
00000126`6a5794b0  "nize my wide string ?"

also you can alias them if you like

0:000> as /ma mystr @@(testA._Mypair._Myval2._Bx._Buf)
0:000> al
  Alias            Value  
 -------          ------- 
 mystr            i'll be ssoed 
0:000> .echo ${mystr}
i'll be ssoed
0:000> as /mu mystr @@(testW._Mypair._Myval2._Bx._Ptr)
0:000> al
  Alias            Value  
 -------          ------- 
 mystr            Hello My Dear World Do You Recognize my wide string ? 
0:000> .echo ${mystr}
Hello My Dear World Do You Recognize my wide string ?
Related