Some small pieces of code related to @Hexacorn's tweet
- ListDescribedThreads.c - C code, going through all threads you can open and displaying all non-empty descriptions.
- AbuseThreadDescription.c - (so obvious in my case) try to to abuse descriptions. Let's set it to something long and try to set for each thread. I have realized it must be below 32K wchars, and it is an effect of the limit set in the undocumented
RtlInitUnicodeStringEx()
being called withinSetThreadDescription()
. - WinDBGListDescribedThreads.txt - Looking for described threads in WinDBG (kernel debug, dump, livekd).
- If you want to see the memory used by descriptions:
poolmon.exe -iThNm
See also PoolMon documentation.
Microsoft official documentation:
Legacy approach to thread naming: https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2008/xcb2z8hs(v=vs.90) (Thanks @PELock for reminding this)