選択したウィンドウPIDに属するすべてのワインウィンドウハンドルを一覧表示するには?

選択したウィンドウPIDに属するすべてのワインウィンドウハンドルを一覧表示するには?

winedbgすべてのウィンドウハンドルのリストを提供する次のコマンドがあります。

$ winedbg --command "info wnd"
Window handle        Class Name        Style    WndProc  Thread   Text
00010020             #32769            96000000 00000000 00000022 -- Empty --
 006c02e4            tooltips_class32  84800000 00000000 00000115 -- Empty --
 00270280            tooltips_class32  84800001 00000000 00000115 -- Empty --
 002101a6            tooltips_class32  84800001 00000000 000000d6 -- Empty --
 001700c4            tooltips_class32  84800000 00000000 000000d6 -- Empty --
 019a02ca            ComboLBox         44808041 00000000 00000115 -- Empty --
 00700040            tooltips_class32  94800000 00000000 000000d6 -- Empty --
 004106c8            tooltips_class32  84800001 00000000 00000115 -- Empty --
 008f0172            tooltips_class32  84800000 00000000 00000115 -- Empty --
 007402a8            ComboLBox         44808041 00000000 00000115 -- Empty --
 003807de            MetaQuotes::MetaT 14cf8000 00000000 00000115 1809640: MetaT
  00230782           msctls_statusbar3 5400014e 00000000 00000115 -- Empty --
  000f0670           AfxControlBar140s 56002800 00000000 00000115 Standard
   003b065a          Static            50000100 00000000 00000115 -- Empty --
   00110678          ToolbarWindow32   5400186e 00000000 00000115 Timeframes
   0050069a          ToolbarWindow32   5400186e 00000000 00000115 Line Studies
   001f06ac          ToolbarWindow32   5400186e 00000000 00000115 Charts
   001706b2          ToolbarWindow32   5400186e 00000000 00000115 Standard
  001d05e2           AfxControlBar140s 56008200 00000000 00000115 Tester
   001a048e          Afx:00400000:b:00 56000000 00000000 00000115 Terminal
      002c0118       Shell Embedding   56010000 00000000 00000115 Shell Embeddin
 00900386            nsAppShell:EventW 04c00000 00000000 00000115 nsAppShell:Eve
 07bf01c4            nsAppShell:EventW 04c00000 00000000 000000d6 nsAppShell:Eve

terminal.exe特定のプロセス(/)に属するウィンドウハンドルのみを含むようにこのリストをフィルタリングしたいのですが、000000ce問題は上記のリストにpidリストがなく(したがって可能ですgrep)、私のプロセスに33の異なるスレッドがあることです。

$ winedbg --command "info proc"
 pid      threads  executable (all id:s are in hex)
 000000ce 33       'terminal.exe'
 0000002b 8        'rpcss.exe'
 00000021 4        'explorer.exe'
 0000000e 5        'services.exe'
 0000001a 3        \_ 'plugplay.exe'
 00000012 4        \_ 'winedevice.exe'

利用可能なステップは次のようにリストできます(読みやすくするためにいくつかのステップが削除されました)。

$ winedbg --command "info thread"
process  tid      prio (all id:s are in hex)
0000000e services.exe
    0000011a    0
    0000001d    0
    00000014    0
    00000010    0
    0000000f    0
000000ce terminal.exe
    000000de    0
    0000013a    0
    0000004f    0
    00000115    0

特定のプロセスに属するウィンドウハンドルのみを含むようにウィンドウハンドルリストをフィルタリングする最も簡単な方法は何ですか?

私が知らない特別なオプションはありますか?それとも、pid->thread->wnd IDを一致させるために何行の解析スクリプトが必要ですかgrep

ベストアンサー1

選択したハンドルを一覧表示するコマンドは次のとおりです(terminal.exeアプリケーション名に置き換えられます)。

$ winedbg --command "info wnd" | grep -wf <(winedbg --command "info threads" | ex +"/terminal.exe\n\zs/;,/^\S/-p" -scq! /dev/stdin | awk '{print $1}' )

デフォルトでは、特定のスレッドリストを介してすべてのウィンドウハンドラgrep()リストを取得します。info wndリストは、ex出力に基づいてエディタで解析され、info threads()によってロードされた特殊ファイル()に保存されます。 awk コマンドは、スレッド ID をリストする最初の列を出力します。/dev/fdgrep-f

使用法構文ガイドラインex:

  • +"cmd"- コマンドを実行
  • /terminal.exe\n\zs/;,/^\S/-p

    • /pattern1/;,/pattern2/- 範囲検索(;最初のパターンの後にカーソルを置きます)
    • /terminal.exe\n\zs/-terminal.exe始点の検索と表示(\zs
    • /^\S/- 空白ではなく最初の行で選択が終了します。
    • -p-上記の選択から1行を引いて印刷します(関連郵便はがき)
    • -scq!-S黙々と強制的に(!)実行キューそれ注文する
    • /dev/stdin- 標準入力から読む

おすすめ記事