zoukankan      html  css  js  c++  java
  • Windbg Script---从.NET应用程序检索查询/存储过程

    好的,假如正在调试一个.NET应用程序。您需要找出从访问数据库的线程执行的查询和存储过程,但是您不知道如何。好消息!这已经不是问题了!此脚本显示与SQLCommand或OracleCommand对象关联的所有查询或存储过程。此外,您可以单击它以获取更多详细信息和使用它的线程。。
    以下是截图:

     Source code for GET_SQLCOMMAND.TXT:

    $
    
    $$
    
    $$ =============================================================================
    
    $$ It shows the SQL commands from a .NET application. It gives you detailed information
    
    $$ and the threads using the query/stored procedure you selected.
    
    $$ Useful for Oracle and SQL Server.
    
    $$
    
    $$ Compatibility: Win32.
    
    $$
    
    $$ Usage: Use $$>< to run the program.
    
    $$
    
    $$ Requirements: Public symbols.
    
    $$
    
    $$ If necessary change the filename below to include your path and filename.
    
    $$ By default it uses the WinDbg path and the default file name is GET_SQLCOMMAND.TXT
    
    $$
    
    $$ Roberto Alexis Farah
    
    $$ Blog: http://blogs.msdn.com/debuggingtoolbox/
    
    $$
    
    $$ All my scripts are provided "AS IS" with no warranties, and confer no rights.
    
    $$ =============================================================================
    
    $$
    
    ad /q *
    
    r @$t0 = 0
    
    r @$t1 = 0
    
    .printf /D "<b>
    Click on the queries/stored procedures below to get more details and to find out the threads using it.
    
    </b>"
    
    .block
    
    {
    
        .block
    
        {
    
            as ${/v:ScriptName} MYSCRIPTS\GET_SQLCOMMAND.TXT
    
        }
    
        .block
    
        {
    
            as SQLCommand .block
    
            {
    
                !DumpObj poi(@$t0+0x10)
    
                !DumpObj @$t0
    
                !GCRoot @$t0
    
            }
    
        }
    
        .block
    
        {
    
            as OracleCommand .block
    
            {
    
                !DumpObj poi(@$t0+0x14)
    
                !DumpObj @$t0
    
                !GCRoot @$t0
    
            }
    
        }
    
    }
    
    .foreach(obj {!dumpheap -short -type System.Data.SqlClient.SqlCommand } )
    
    {
    
        r @$t1 = 1
    
        .printf /D "<link cmd="r @$t0 = ${obj}; ${SQLCommand} ;ad ${/v:ScriptName}; $$><${ScriptName}"><b>%mu</b></link>
    
    ", poi(${obj}+0x10)+0xc
    
    }
    
    .foreach(obj {!dumpheap -short -type System.Data.OracleClient.OracleCommand } )
    
    {
    
        r @$t1 = 1
    
        .printf /D "<link cmd="r @$t0 = ${obj}; ${OracleCommand} ;ad ${/v:ScriptName}; $$><${ScriptName}"><b>%mu</b></link>
    
    ", poi(${obj}+0x14)+0xc
    
    }
    
    .if(0 = @$t1)
    
    {
    
        .printf /D "<b>
    No SQL commands found.
    </b>"
    
    }
    
  • 相关阅读:
    定点数的表示
    [收集]XMPP使用tls 和sasl登录
    socket函数
    [收集] SendMessage、PostMessage原理
    DLL中用malloc分配了一块内存,但是在exe程序中释放引发的错误:其原因可能是堆被损坏,这也说明 **.exe 中或它所加载的任何 DLL 中有 bug。
    关于在IWebBrowser中无法响应Ctrl+C等快捷键的解决方法
    Enum 操作
    程序员面对分歧和难题应当具备的态度【转】
    NDIS学习笔记一
    NDIS学习笔记二——(模拟丢包)
  • 原文地址:https://www.cnblogs.com/yilang/p/13457587.html
Copyright © 2011-2022 走看看