GithubHelp home page GithubHelp logo

go-umdf-example's Introduction

Go UMDF Prototype

Go言語を用いて Windows ユーザーモードドライバー (User-mode Driver Framework) を書く例。実用性はない

How to build

まず "C:\Program Files (x86)\Windows Kits\10\Lib\wdf\umdf\x64\2.15\WdfDriverStubUm.lib"golangs/thirdparty に複製する。このファイルは再配布不可

次に helper script をビルドする。これは Go言語で Control Flow Guard 問題を回避するためのもの

gcc -c helper.c -o helper.o -Wall -Wextra

次に go build を実行

go build -buildmode=c-shared -o goumdf.dll -ldflags="-v -extldflags '-Wl,--export-all-symbols,-Lthirdparty,-lucrt,-lntdll,-lWdfDriverStubUm,-lntdll -Xlinker --exclude-symbols=_guard_rf_checks_enforced,_guard_icall_checks_enforced,__castguard_slow_path_check_os_handled,__castguard_slow_path_check_nop,__castguard_slow_path_check_fastfail,__castguard_slow_path_check_debugbreak,__castguard_check_failure_os_handled,__castguard_check_failure_nop,__castguard_check_failure_fastfail,__castguard_check_failure_debugbreak,ReadNoFence64,ReadPointerNoFence,_guard_check_icall_nop -Xlinker --script=(このディレクトリのフルパスをエスケープしたもの)\\\\golangs\\\\script.ld  -Xlinker (このディレクトリのフルパスをエスケープしたもの)\\\\golangs\\\\helper.o'"

そして これを inf ファイルと同じディレクトリに複製。 cp golangs/goumdf.dll TrueGoUmdf.dll

次に、 Visual Studio などを使い署名用の鍵を作成し、そのsha1を控える

infファイルとdllへの署名を行う。

signtool.exe sign /ph /fd "sha256" /sha1 "(当該sha1)" .\TrueGoUmdf.dll
stampinf -d "*" -a "amd64" -u "2.15.0" -v "*" -f .\TrueGoUmdf.inf
inf2cat.exe /os:10_x64 /driver:C:(このディレクトリへのフルパス)\ /uselocaltime
signtool.exe sign /ph /fd "sha256" /sha1 "(当該sha1)" .\truegoumdf.cat

ターゲットマシンの C:\DriverTest\Drivers\TrueGoUmdf.{cat,cer,inf,dll} をコピーし、証明書をターゲットマシンに読み込ませる

ターゲットマシンで以下を実行するとインストールされる、動作する

C:\DriverTest\devcon install C:\DriverTest\Drivers\TrueGoUmdf.inf ROOT\TrueGoUmdf

クラッシュする場合のデバッグ

Target Machine で以下を設定

  • WdfVerifier.exe (Windows Driver Kit + Windows SDK) -> Driverの読み込み時に20秒以上待機するように
  • Application Verifier (Windows SDK) から WUDFHost.exe を有効化
  • devcon install したときに WinDbg Preview (Microsoft Store) で WUDFHost.exe にアタッチ

go-umdf-example's People

Contributors

hiromi-mi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.