何がしたいのか?→DLLの検索パスを変えたい(レジストリを弄らずに!)
具体的には?→System32ではなく実行ファイルのあるディレクトリから同名のDLLを呼び出したい
.local [ex)sample.exe.local]
DLL リダイレクト(非常に強力)
Windows 98 SE,Windows 2000,Windows XP,Windows Vista等で利用可能(Windows 7は未確認) ただしKnownDLL以外に限る
Windows Vistaユーザーはレジストリの書き換え必須。色々と危険なので常時有効にすべきではない。
プログラムのリダイレクトを有効にすると、そのプログラムが DLL を読み込もうとするたびに、まずプログラムが格納されているディレクトリ、次に通常の検索場所、の順に検索が行われます。
引用元:Windows 秘話: DLL Hell からの脱却
Known DLLs cannot be redirected. For a list of known DLLs, see the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs.
引用元:Dynamic-Link Library Redirection (Windows)
Realizing the value of DotLocal(.local) dll redirection in private testing, a change is made in Windows Vista, that when the registry HKLM\Software\Microsoft\WindowsNT\CurrentVersion\Image File Execution Options!DevOverrideEnable:REG_DWORD is set to 1, DotLocal(.local) dll redirection will be enabled, even if the application has a manifest.
引用元:Junfeng Zhang’s Windows Programming Notes : DotLocal (.local) Dll Redirection
少し影響力が大きすぎるので今回はこの方法を使えない。.manifestか.configか・・・どうすんのよこれ・・・。
.manifest [ex)sample.exe.manifest]
SxS
Windows XP,Windows Vista等で利用可能(Windows 7は未確認)
~.manifestの一例
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <dependency> <dependentassembly> <assemblyidentity type="win32" name="sample.dll" version="1.0.0.0" processorArchitecture="x86"></assemblyidentity> </dependentassembly> </dependency> </assembly>
さっぱり分からん
間違っている可能性有り そもそも想定していた通りに動作しなかった件
二流プログラマの三流な日常: .manifest?.local?.config?には.configを利用した方法が書かれていたが同じくさっぱり分からん ![]()
いっそのことDLLのファイル名を書き換えて本体をコンパイルし直した方がが早いんじゃないかと・・・
結果:Dependency Walkerで確認すると一見実行ファイルのあるディレクトリから呼び出しているように見える。しかし実際はSystem32から呼び出されていた…….(´・ω・) カワイソス
色々と不便なのでこの記事は臨時更新中