New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wdk compilation environment support #159

Closed
ranwei1025 opened this Issue Feb 26, 2018 · 14 comments

Comments

Projects
None yet
2 participants
@ranwei1025

ranwei1025 commented Feb 26, 2018

References

Tests

Please download xmake-v2.2.1-dev and try it.

Online Docs

https://xmake.io/#/home?id=wdk-driver-program

Roadmap

  • detect.sdks.find_wdk
    • wdk 10.0
  • target rules (need be applied to target in xmake.lua)
    • rule("wdk.driver")
    • rule("wdk.binary")
    • rule("wdk.static")
    • rule("wdk.shared")
    • rule("wdk.env.kmdf")
    • rule("wdk.env.umdf")
    • rule("wdk.env.wdm")
  • config values
    • set_values("wdk.umdf.sdkver", "1.9")
    • set_values("wdk.kmdf.sdkver", "2.15")
    • set_values("wdk.inf2cat.os", ...)
    • set_values("wdk.env.winver", "8.1" or "8" or "7")
      • default: "10"
  • wdk-tasks-for-msbuild
    • rule("wdk.inf")
      • add_values("wdk.inf.flags", ...)
    • rule("wdk.tracewpp")
      • add_values("wdk.tracewpp.flags", ...)
    • rule("wdk.man")
      • add_values("wdk.man.flags", ...)
      • add_values("wdk.man.prefix", ...)
      • add_values("wdk.man.header", ...)
      • add_values("wdk.man.counter_header", ...)
      • add_values("wdk.man.resource", ...)
    • rule("wdk.mc")
      • add_values("wdk.mc.flags", ...)
      • add_values("wdk.mc.header", ...)
    • rule("wdk.mof")
      • add_values("wdk.mof.flags", ...)
      • add_values("wdk.mof.header", ...)
    • rule("wdk.sign")
      • set_values("wdk.sign.mode", "test" or "release")
        • default: no signing
      • set_values("wdk.sign.store", ...)
      • set_values("wdk.sign.thumbprint", "032122545DCAA6167B1ADBE5F7FDF07AE2234AAA")
      • set_values("wdk.sign.company", ...)
      • set_values("wdk.sign.certfile", "signcert.cer")
      • set_values("wdk.sign.timestamp", "http://timestamp.verisign.com/scripts/timstamp.dll")
        • optional
    • rule("wdk.package.cab")
      • xmake package

@waruqi waruqi added this to the 2.1.10 milestone Feb 26, 2018

@waruqi waruqi added in review in progress and removed in review labels May 3, 2018

@waruqi

This comment has been minimized.

Member

waruqi commented May 5, 2018

umdf example echo:

-- add modes: debug and release 
add_rules("mode.debug", "mode.release")

-- enable unicode
add_defines("_UNICODE", "UNICODE")

-- add target
target("echo")

    -- add rules
    add_rules("wdk.env.umdf", "wdk.driver")

    -- add files
    add_files("driver/*.c") 
    add_files("driver/*.inx")

    -- add includedirs
    add_includedirs("exe")

-- add target
target("app")

    -- add rules
    add_rules("wdk.env.umdf", "wdk.binary")

    -- add files
    add_files("exe/*.cpp") 
@waruqi

This comment has been minimized.

Member

waruqi commented May 5, 2018

kmdf example ioctl:

-- add modes: debug and release 
add_rules("mode.debug", "mode.release")

-- add target
target("nonpnp")

    -- add rules
    add_rules("wdk.env.kmdf", "wdk.driver")

    -- add flags for rule: wdk.tracewpp
    add_values("wdk.tracewpp.flags", "-func:TraceEvents(LEVEL,FLAGS,MSG,...)", "-func:Hexdump((LEVEL,FLAGS,MSG,...))")

    -- add files
    add_files("driver/*.c", {rule = "wdk.tracewpp"}) 
    add_files("driver/*.rc")

-- add target
target("app")

    -- add rules
    add_rules("wdk.env.kmdf", "wdk.binary")

    -- add files
    add_files("exe/*.c") 
    add_files("exe/*.inf")
@waruqi

This comment has been minimized.

Member

waruqi commented May 11, 2018

wdm example with *.man perfcounters:

-- add modes: debug and release 
add_rules("mode.debug", "mode.release")

-- add target
target("kcs")

    -- add rules
    add_rules("wdk.env.wdm", "wdk.driver")

    -- add flags for rule: wdk.man
    add_values("wdk.man.flags", "-prefix Kcs")
    add_values("wdk.man.resource", "kcsCounters.rc")
    add_values("wdk.man.header", "kcsCounters.h")
    add_values("wdk.man.counter_header", "kcsCounters_counters.h")
    
    -- add files
    add_files("*.c", "*.rc", "*.man") 
@waruqi

This comment has been minimized.

Member

waruqi commented May 13, 2018

kmdf example with *.mc serial:

-- add modes: debug and release 
add_rules("mode.debug", "mode.release")

-- add target
target("serial")

    -- add rules
    add_rules("wdk.env.kmdf", "wdk.driver")

    -- add flags for rule: wdk.tracewpp
    add_values("wdk.tracewpp.flags", "-func:SerialDbgPrintEx(LEVEL,FLAGS,MSG,...)")

    -- add header file name for rule: wdk.mc
    add_values("wdk.mc.header", "serlog.h")

    -- add files
    add_files("*.c", {rule = "wdk.tracewpp"}) 
    add_files("*.mc", "*.rc", "*.inx")
@waruqi

This comment has been minimized.

Member

waruqi commented May 14, 2018

wdm example with *.mof msdsm:

-- add modes: debug and release 
add_rules("mode.debug", "mode.release")

-- add target
target("msdsm")

    -- add rules
    add_rules("wdk.env.wdm", "wdk.driver")

    -- add flags for rule: wdk.tracewpp
    add_values("wdk.tracewpp.flags", "-func:TracePrint((LEVEL,FLAGS,MSG,...))")

    -- add files
    add_files("*.c", {rule = "wdk.tracewpp"}) 
    add_files("*.rc", "*.inf")
    add_files("*.mof|msdsm.mof")

    -- add file msdsm.mof and modify default wdk.mof.header for this file
    add_files("msdsm.mof", {values = {wdk_mof_header = "msdsmwmi.h"}}) 

    -- set precompiled header
    set_pcheader("precomp.h")

    -- add links
    add_links("mpio")
@ranwei1025

This comment has been minimized.

ranwei1025 commented May 16, 2018

  • 需要增加指定wdk安装路径 对于当前cmd已经存在wdk环境变量的情况 直接使用
  • 需要增加wdk.wdm.driver规则 比如测试例子的 perfcounters 就是wdm程序 就不应该按照kmdf规则处理
  • 需要增加编译应用程序规则 比如 wdk例子下usbview 编译支持, see #173
@ranwei1025

This comment has been minimized.

ranwei1025 commented May 16, 2018

usbview 是个图形界面应用程序 但不依赖于umdf
应该增加 如wdk的 winxp win7 win2003 等编译环境设置 这个对驱动编译是比较有用的

@waruqi

This comment has been minimized.

Member

waruqi commented May 16, 2018

Ok, I will modify wdk rules.

Thanks!

@waruqi

This comment has been minimized.

Member

waruqi commented May 19, 2018

@ranwei1025 I add win.sdk.application and win.sdk.dotnet rules to compile usbview example, you can see #173

@waruqi

This comment has been minimized.

Member

waruqi commented May 22, 2018

Uses the other given wdk directory (mount EWDK_rs3_release_svc_16299_171024-1647.iso to G:):

$ xmake f --wdk="G:\Program Files\Windows Kits\10" -c
$ xmake
@waruqi

This comment has been minimized.

Member

waruqi commented May 24, 2018

Package driver and make *.cab file to build or the given output directory:

$ xmake [p|package]
$ xmake [p|package] -o outputdir
build directory
  - drivers
    - sampledsm
       - debug/x86/sampledsm.cab
       - release/x64/sampledsm.cab
       - debug/x86/sampledsm.cab
       - release/x64/sampledsm.cab
@waruqi

This comment has been minimized.

Member

waruqi commented May 25, 2018

Disable signing by default

target("msdsm")
    add_rules("wdk.wdm.driver")

Test signing using builtin test certificate

Please run $xmake l utils.wdk.testcert install as admin to install a test certificate first (only once)!

target("msdsm")
    add_rules("wdk.env.wdm", "wdk.driver")
    set_values("wdk.sign.mode", "test")

Test signing using installed certificate in machine

target("msdsm")
    add_rules("wdk.env.wdm", "wdk.driver")
    set_values("wdk.sign.mode", "test")
    set_values("wdk.sign.thumbprint", "032122545DCAA6167B1ADBE5F7FDF07AE2234AAA")
target("msdsm")
    add_rules("wdk.env.wdm", "wdk.driver")
    set_values("wdk.sign.mode", "test")
    set_values("wdk.sign.store", "PrivateCertStore")
    set_values("wdk.sign.company", "tboox.org(test)")

Release signing

target("msdsm")
    add_rules("wdk.env.wdm", "wdk.driver")
    set_values("wdk.sign.mode", "release")
    set_values("wdk.sign.company", "xxxx")
    set_values("wdk.sign.certfile", path.join(os.projectdir(), "xxxx.cer"))
@waruqi

This comment has been minimized.

Member

waruqi commented May 28, 2018

Compile driver target for low version windows (default: win10):

set_values("wdk.env.winver", "win10")
set_values("wdk.env.winver", "win10_rs3")
set_values("wdk.env.winver", "win81")
set_values("wdk.env.winver", "win8")
set_values("wdk.env.winver", "win7")
set_values("wdk.env.winver", "win7_sp1")
set_values("wdk.env.winver", "win7_sp2")
set_values("wdk.env.winver", "win7_sp3")

Format:

nt4, win2k, winxp, ws03, win6, vista, ws08, longhorn, win7, win8, win81, winblue, win10 + '_' + sp1, sp2, sp3, th2, rs1, rs2, rs3

Or we can configure winver via command line:

$ xmake f --wdk_winver=win10_rs3

Add some builtin values for windows sdk version, for examples:

target("test")
    
    on_load(function (target)
        local winnt_version = target:values("wdk.env.winnt_version")
        if winnt_version > "0x0A000000" then
            target:add("defines", "TEST")
        end
    end)
  • target:values("wdk.env.winver")
  • target:values("wdk.env.winnt_version")
  • target:values("wdk.env.ntddi_version")
  • target:values("wdk.env.winver_version")

@waruqi waruqi added done and removed in progress labels Jun 7, 2018

@waruqi

This comment has been minimized.

Member

waruqi commented Jun 7, 2018

@waruqi waruqi closed this Jun 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment