depends2dotはたぶんいらない – Dependancy Walker使おう

ldd2dotは Unix での話。じゃぁ Windows では?

Dependancy Walker使おう:
Dependancy Walker

ldd2dot相当のものを作るのは結構ダルいよ。

まず、Microsoft Visual C++ Compiler for Python 2.7にも付属する「dumpbin」で、目的の半分ね:

 1 C:\Windows\system32> dumpbin -dependents notepad.exe
 2 Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
 3 Copyright (C) Microsoft Corporation.  All rights reserved.
 4 
 5 
 6 Dump of file notepad.exe
 7 
 8 File Type: EXECUTABLE IMAGE
 9 
10   Image has the following dependencies:
11 
12     ADVAPI32.dll
13     KERNEL32.dll
14     GDI32.dll
15     USER32.dll
16     msvcrt.dll
17     COMDLG32.dll
18     SHELL32.dll
19     WINSPOOL.DRV
20     ole32.dll
21     SHLWAPI.dll
22     COMCTL32.dll
23     OLEAUT32.dll
24     ntdll.dll
25     VERSION.dll
26 
27   Summary
28 
29         3000 .data
30         1000 .pdata
31         4000 .rdata
32         1000 .reloc
33        20000 .rsrc
34         B000 .text

で、これのフルパスを取るところからが暗黒面。

なんでこれが「暗黒面」かというと、Dynamic-Link Library Search Orderが複雑怪奇だから、だね。せいぜい2種類、環境変数と pkg-config、くらいしか制御のない Unix とは大違い。

の2つ(と FreeLibrary)で、まぁ書けるはずだけど、つまりは「システム」(Windows のローダね)に「読み込ませてみる」ことをしない限り、フルパスは取れない。

難しいプログラミングではないけれど、「自力でパス解決」するのは無理があるんです。だいたいDynamic-Link Library Search Orderだって、もう5年前と違ってるしさ。