WinDbg从模块获取名称空间

问题描述 投票:0回答:1

我想用!mbm中的命令sosex.dll将断点放在CustomSpace名称空间的每个方法上。但是该怎么做?

[PlayWithReference-项目名称。

我试图用命令!lm观察哪些模块被加载

0:000> lm
start    end        module name
00f60000 00f68000   PlayWithReference   (deferred)             
72480000 724d4000   MSCOREE    (deferred)             
73fc0000 74090000   KERNEL32   (deferred)             
760f0000 762c8000   KERNELBASE   (deferred)             
76f00000 7708c000   ntdll      (export symbols)       C:\windows\SYSTEM32\ntdll.dll

然后使用命令x,我观察到模块的功能

0:000> x PlayWithReference!*
*** WARNING: Unable to verify checksum for PlayWithReference.exe
<MSIL:00f60059         > PlayWithReference!Foo2 (void)
<MSIL:00f60071         > PlayWithReference!Main (void)
<MSIL:00f60026         > PlayWithReference!Foo1 (void)
<MSIL:00f6012f         > PlayWithReference!<Foo1>b__1_0 (void)
<MSIL:00f6000f         > PlayWithReference!get_Address (void)
<MSIL:00f60016         > PlayWithReference!set_Address (void)
<MSIL:00f60007         > PlayWithReference!set_Name (void)
<MSIL:00f60000         > PlayWithReference!get_Name (void)
<MSIL:00f6001e         > PlayWithReference!Foo (void)

x-命令从模块返回功能名称,但没有有关名称空间的信息。

如果我使用!mbm CustomSpace.Program.Foo,它将放置断点并正常工作。但是如果没有命名空间,在这种情况下,我只能执行!mbm *Foo之类的操作,它将在具有该名称的所有函数上放置断点。怎么做?

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace NotWorkingName
{
    public class Employee
    {
        public string Name { get; set; }

        public string Address { get; set; }
    }

    class Program
    {
        public static void Foo()
        {
            Employee employee = new Employee();
        }
        public static void Foo1()
        {
            var t = Task.Factory.StartNew(() =>
            {
                for (int i = 0; i < 3; i++)
                {
                    Foo2();
                }
            });
            t.Wait();
        }

        public static void Foo2()
        {
            Thread.Sleep(1000);
            Console.WriteLine("Foo2");
        }

        static void Main(string[] args)
        {
            List<string> TestReferences = new List<string>();
            for (int i = 0; i < 100000; i++)
            {
                TestReferences.Add(i.ToString());
            }
            Employee employee = new Employee();
            employee.Name = "Test";
            employee.Name = "Test1";
            Console.WriteLine(employee.Name);
            Foo1();
            Employee employee1 = new Employee();
            Employee employee2 = new Employee();
            Employee employee3 = new Employee();
            Employee employee4 = new Employee();
            Employee employee5 = new Employee();
            Employee employee6 = new Employee();
            Employee employee7 = new Employee();
            Employee employee8 = new Employee();
            Employee employee9 = new Employee();
            Employee employee10 = new Employee();
            Employee employee11 = new Employee();
            Foo();
            Console.Write("The end");
        }
    }
}
c# windbg
1个回答
0
投票

尝试一下(使用旧的SOS):

'a'仅要求具有第二个参数

!name2ee PlayWithReference a
Module:      00007ff8d5be2838
Assembly:    PlayWithReference.exe

0:099> !dumpmodule -mt 0007ff8d5be2838
(...)


Types defined in this module

              MT    TypeDef Name
------------------------------------------------------------------------------
00007ff8d5be3250 0x02000024 NotWorkingName.Employee
00007ff8d5be34a0 0x02000029 NotWorkingName.Program

Types referenced in this module

              MT    TypeRef Name
------------------------------------------------------------------------------
00007ff93324a260 0x02000010 System.Collections.IEnumerable

(...)

要获取所有类的方法,请执行以下操作:

!dumpmt -md 00007ff8d5be3250
(...)

MethodDesc Table
           Entry       MethodDesc    JIT Name
00007ff8d53044a8 00007ff8d5be2fc0   NONE NotWorkingName.Employee.set_Name()
00007ff8d53044b8 00007ff8d5be2fd0   NONE NotWorkingName.Employee.get_Name()
(...)

不漂亮,但是有效

© www.soinside.com 2019 - 2024. All rights reserved.