Reputation: 21
My boolean variable can be referenced using the syntax
MPrime.exe Spirit.MPrimeComServerManager._isComServerReady
I have tried using the syntax
?? MPrime.exe Spirit.MPrimeComServerManager._isComServerReady=1
and I am not sure how to use e*
commands with managed code.
This is the output from !DumpObj
:
00007fff81a6d6e8 4000198 169 System.Boolean 1 static 0 _isComServerReady
Upvotes: 2
Views: 558
Reputation: 59208
Let's write this example program to see how Booleans work in .NET and how to change the value with WinDbg:
using System;
namespace ChangeValueOfBoolean
{
class Program
{
static void Main()
{
var h = new BooleanHolder();
h.BoolValue = true;
Console.WriteLine("Debug now. Boolean member has the value {0}", h.BoolValue);
Console.ReadLine();
Console.WriteLine("After debugging, boolean member has the value {0}", h.BoolValue);
h.BoolValue = true;
Console.ReadLine();
}
}
class BooleanHolder
{
public bool BoolValue { get; set; }
}
}
Steps to debug:
.symfix;.reload
.loadby sos clr
!dumpheap -short -type BooleanHolder
!do <address>
dump the raw value in memory dd <address>+<offset> L1
We'll see that true == 1
ed <address>+<offset> 0
g
Press Enter
It has switched to false
Complete walkthrough in WinDbg:
0:004> .symfix;.reload
Reloading current modules
..........................
0:004> .loadby sos clr
0:004> !dumpheap -short -type BooleanHolder
025330c8
0:004> !do 025330c8
Name: ChangeValueOfBoolean.BooleanHolder
MethodTable: 00144d74
EEClass: 00141804
Size: 12(0xc) bytes
File: E:\Projekte\SVN\HelloWorlds\ChangeValueOfBoolean\bin\Debug\ChangeValueOfBoolean.exe
Fields:
MT Field Offset Type VT Attr Value Name
704bf3d8 4000001 4 System.Boolean 1 instance 1 <BoolValue>k__BackingField
0:004> dd 025330c8+4 L1
025330cc 00000001
0:004> ed 025330c8+4 0
0:004> g
Upvotes: 3