I am trying to debug managed code. .exe
file is build for x64
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DebugTutorial
{
class Program
{
public static void Foo2()
{
Console.WriteLine("Foo2");
}
public static void Foo1()
{
Console.WriteLine("Foo1");
}
public static void Parent()
{
Foo1();
Console.WriteLine("Parent");
}
static void Main(string[] args)
{
Foo1();
Foo2();
Parent();
}
}
}
I am doing next commands:
0:000> .load C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
0:000> .load C:\Users\Anton\Downloads\sosex_64\sosex.dll
0:000> .symfix
0:000> .reload /f
Reloading current modules
.*** WARNING: Unable to verify checksum for DebugTutorial.exe
....
0:000> lm
start end module name
00000252`916b0000 00000252`916b6000 DebugTutorial C (pdb symbols) C:\ProgramData\dbg\sym\DebugTutorial.pdb\B430DC1915A0462AB2D21E18458D70E71\DebugTutorial.pdb
00007ffb`233a0000 00007ffb`23404000 MSCOREE (pdb symbols) C:\ProgramData\dbg\sym\mscoree.pdb\02E66277C518120A967A3BFBC1850C941\mscoree.pdb
00007ffb`30280000 00007ffb`304f3000 KERNELBASE (pdb symbols) C:\ProgramData\dbg\sym\kernelbase.pdb\CD6C76E6120253287103CD7E22CC0A5D1\kernelbase.pdb
00007ffb`32900000 00007ffb`329b1000 KERNEL32 (pdb symbols) C:\ProgramData\dbg\sym\kernel32.pdb\CA130BEBF44E36EAC20C5E95752843F61\kernel32.pdb
00007ffb`33ca0000 00007ffb`33e81000 ntdll (pdb symbols) C:\ProgramData\dbg\sym\ntdll.pdb\95927C40B68E505CD22742795247114C1\ntdll.pdb
0:000> !mbp DebugTutorial Foo1
The CLR has not yet been initialized in the process.
Breakpoint resolution will be attempted when the CLR is initialized.
0:000> .load C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
0:000> .reload /f
Reloading current modules
.*** WARNING: Unable to verify checksum for DebugTutorial.exe
....
0:000> !mbp DebugTutorial Foo1
The breakpoint could not be set because a breakpoint has already been specified for this source location.
If I place breakpoin with F9 hotkey I see next
0:000> g
Unable to insert breakpoint 0 at 00000252`916b002e, Win32 error 0n998
"Invalid access to memory location."
bp0 at 00000252`916b002e failed
WaitForEvent failed
ntdll!LdrpDoDebuggerBreak+0x31:
00007ffb`33d6c93d eb00 jmp ntdll!LdrpDoDebuggerBreak+0x33 (00007ffb`33d6c93f)
Win32 error 0n998
Why? What is happening? How to debug .net with windbg?