Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
今回は、ユーザーモードドライバーフレームワーク(User-mode Driver Framework, UMDF) のバージョン 2 について学びたい方向けのサンプル、Toaster Sample (UMDF Version 2) をご紹介します。
皆さん、こんにちは。WDK サポートチームの津田です。今回は、このサンプルをビルドして、ターゲット側 PC の Windows 10 (1607) x86 にインストールし、デバイスマネージャ上で表示されるところまでを確認します。サンプルをビルドする、開発側の PC は Windows 10 (1607) x64 に Visual Studio 2015 と WDK 10 がインストールされています。
1. サンプルの入手
Toaster Sample (UMDF Version 2) サンプルは、以下のサイトの右側の緑色の [Clone or Download] ボタンを押すと表示される [Download ZIP] ボタンで Windows-driver-samples-master.zipをダウンロードすると、Windows-driver-samples-master\general\toaster\umdf2 のフォルダにあります。
https://github.com/Microsoft/Windows-driver-samples
2. サンプルのビルド
このフォルダの umdf2toaster.sln を、Visual Studio 2015 で開きます。
[ソリューション ‘umdf2toaster’] を右クリックして [構成マネージャー] をクリックします。
今回は、[アクティブソリューション構成] を [Debug]、[アクティブ ソリューション プラットフォーム] を[Win32] とします。
[ソリューション ‘umdf2toaster’] を右クリックして [ソリューションのリビルド] をクリックします。\umdf2\Debug\package フォルダに以下の 5 つのファイルができます。
filterum.dll
filterum.inf
wdfsimpleum.dll
wdfsimpleum.inf
wudf.cat
なお、exe フォルダについては、各 exe のフォルダに Debug フォルダができ、そこにビルドされてできたアプリケーションがあります。例えば、umdf2\exe\notify\Debug フォルダに notify.exe があることが確認できます。
3. サンプルのインストール
今回動作確認する OS は、Windows 10 (1607) x86 です。これが入っているターゲット PC に C:\umdf2toaster というフォルダを作り、前述のビルドしてできたファイルのうち、wdfsimpleum.dll, wdfsimpleum.inf, wudf.cat をコピーします。また、開発用 PC の C:\Program Files (x86)\Windows Kits\10\Tools\x86 にある devcon.exe も、ターゲット PC の同じ C:\umdf2toaster フォルダにコピーします。
管理者権限でコマンドプロンプトを起動します。cd コマンドで C:\umdf2toaster フォルダに移動し、以下を実行します。
devcon install wdfsimpleum.inf root\toaster |
ドライバーをインストールするかどうか確認するダイアログが表示されたら、そのままインストールしてください。以下が表示されたら成功です。
Device node created. Install is complete when drivers are installed... Updating drivers for root\toaster from C:\umdf2toaster\wdfsimpleum.inf. Drivers installed successfully. |
4. デバイスマネージャでの確認
[スタート] を右クリックし、[デバイス マネージャー] を起動しますと、以下のように [Toaster] のノードに [Sample UMDF Toaster Driver - simple] と表示されていることが確認できます。
[ 補足] 当該ドライバが動作するプロセス ID の確認
先程のコマンドプロンプトから、以下のように「tasklist.exe -m <ドライバの DLL ファイル名>」 を実行することで、このドライバがどのプロセス ID の WUDFHost.exe で動作しているか確認することができます。
>tasklist -m wdfsimpleum.dll
イメージ名 PID モジュール ========================= ======== ============================================ WUDFHost.exe 4856 wdfsimpleum.dll |
これを確認することで、仮に複数 WUDFHost.exe が動作している環境でも、ご自身のドライバの動作しているプロセスを特定することができます。これが確認できれば、windbg.exe がある環境で、以下のように 「windbg -p <PID>」のコマンドの PID を上記の 4856 に置き換えて実行することで、wdfsimpleum.dll のライブデバッグを始めることができます。
windbg -p 4856 |
参考文献
Toaster Sample (UMDF Version 2)
https://github.com/Microsoft/Windows-driver-samples/tree/master/general/toaster/umdf2
Attaching a User-Mode Debugger
https://msdn.microsoft.com/en-us/windows/hardware/drivers/wdf/attaching-a-user-mode-debugger
以上の内容がお役に立ちましたら幸いです。
Please sign in to use this experience.
Sign in