Is there any way I can see the contents of the string table in a running .NET application?
I want to compare a console application with vanilla string concatinations and one using the string builder.
Is there any way I can see the contents of the string table in a running .NET application?
I want to compare a console application with vanilla string concatinations and one using the string builder.
You can use ClrMD to attach to a process and retrieve information from it. Something along the lines of the following should work:
var proc = Process.GetProcessesByName("myapp.exe").FirstOrDefault();
using (var target = DataTarget.AttachToProcess(proc.Id, 1000))
{
var runtime = target.ClrVersions[0].CreateRuntime();
var heap = runtime.GetHeap();
foreach (var obj in heap.EnumerateObjectAddresses())
{
var type = heap.GetObjectType(obj);
if (type.Name == "System.String")
{
var value = (string)type.GetValue(obj);
// Write value to disk or something.
}
}
}