The Windows 7 Windows Driver Kit

The Windows 7 Windows Driver Kit PowerPoint PPT Presentation


  • 548 Views
  • Uploaded on
  • Presentation posted in: General

Agenda. InstallationHow build worksTechniques for investigating build issuesBuild Environment Changes in Win7New Tools and SamplesSample Quality ImprovementsDocumentation ImprovementsQ

Download Presentation

The Windows 7 Windows Driver Kit

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


1. The Windows 7 Windows Driver Kit Eliyas Yakub Dev Lead - Windows Driver Framework Dev Manager – Windows Driver Kit

2. Agenda Installation How build works Techniques for investigating build issues Build Environment Changes in Win7 New Tools and Samples Sample Quality Improvements Documentation Improvements Q&A

3. WDK Installation Using Kitsetup Single UI for all kit components Single EULA for all kit components Documentation installation is part of complete kit installation Supports servicing Updates to WDK will be made available on Microsoft Connect as needed Support for Windows 2000 build environment is removed

4. KitSetup

5. How Build Works

6. The WDK Build Tools The WDK Build environment includes: Build utilities: build.exe and nmake.exe Files used to control the build environment: setenv.bat Files to identify what is to be built: dirs files, sources files, makefiles. Compiler cl.exe and linker link.exe Supporting tools: midl.exe, rc.exe, binplace.exe, stampinf.exe, etc. New in WDK for Win7: oacrcl.exe and oacrlink.exe stampinf can update inf and inx files using build.exe and makefile.inc The Microsoft® Interface Definition Language (MIDL) defines interfaces between client and server programs. Microsoft includes the MIDL compiler with the Platform SDK to enable developers to create the interface definition language (IDL) files and application configuration files (ACF) required for remote procedure call (RPC) interfaces and COM/DCOM interfaces. MIDL also supports the generation of type libraries for OLE Automation stampinf can update inf and inx files using build.exe and makefile.inc The Microsoft® Interface Definition Language (MIDL) defines interfaces between client and server programs. Microsoft includes the MIDL compiler with the Platform SDK to enable developers to create the interface definition language (IDL) files and application configuration files (ACF) required for remote procedure call (RPC) interfaces and COM/DCOM interfaces. MIDL also supports the generation of type libraries for OLE Automation

7. Setting Up the Build Environment Open the build environment window by using use the Start menu path Start | All Programs | Windows Driver Kits | WDK_Version | Build Environment | Operating System | Build Environment. Command Prompt window appears The setenv.bat executes in this window, setting the values of numerous environment variables. The setenv.bat command line options include: Type of the build: checked or free Processor architecture: x86, amd64 or IA64 Operating system: WinXP, WinNET, WinLH, Win7 New for Win7: setenv.bat has more command line parameters no_oacr flag and no_separate_object_root flags

8. How the WDK Build Process Works Build.exe scans the dirs files for DIRS and OPTIONAL_DIRS macros Build.exe recurces the tree looking for leaf nodes (sources file) to process 3. Once build.exe found sources file it look for the macros: TARGETNAME, TARGETPATH, SOURCES, INCLUDES Build.exe builds objects.mac for this directory Build.exe calls nmake in each dir as necessary based on what macros are listed in the sources file. If the sources file has a NTTARGETFILEx macro, this causes Bar makefile.def to include makefile.inc 7. Nmake is called per a leaf dir per build pass. DIRS and SOURCES files in the same directory causes build.exe to log an error. Example    DIRS=dir1 dir2 dir3    OPTIONAL_DIRS=dir4 dir5 The <currentdir>\dir1, <currentdir>\dir2, and <currentdir>\dir3 directories will be built in this order every time. The <currentdir>\dir4 and <currentdir>\dir5 directories will only be built if you so specify on the Build utility command-line or by using the BUILD_OPTIONS environment variable. The Build utility supports a "not" switch (~) that removes a directory from the default build. Using the preceding example,    build -cZg ~dir1 ~dir3 dir4 would build only dir2 and dir4. DIRS and SOURCES files in the same directory causes build.exe to log an error. Example    DIRS=dir1 dir2 dir3    OPTIONAL_DIRS=dir4 dir5 The <currentdir>\dir1, <currentdir>\dir2, and <currentdir>\dir3 directories will be built in this order every time. The <currentdir>\dir4 and <currentdir>\dir5 directories will only be built if you so specify on the Build utility command-line or by using the BUILD_OPTIONS environment variable. The Build utility supports a "not" switch (~) that removes a directory from the default build. Using the preceding example,    build -cZg ~dir1 ~dir3 dir4 would build only dir2 and dir4.

9. How the Build Process Works

10. Build Passes Build.exe uses a multi-pass process: Pass0 produces source code: runs midl.exe (.idl ->.h/.c/.tlb) or other tools to produce source code. Pass1 compiles source code to objects/libs (runs cl.exe) Pass2 links objects/libs into final images: - .exe, .sys, .dll (runs link.exe)

11. Build Passes - Example

12. Multiprocessor Build No need to do anything in the WDK build environment to run on a multiprocessor machine! WDK sets the environment variable BUILD_MULTIPROCESSOR = 1 Enables build.exe to run 1 thread per processor. Same as –M option of build.exe No synchronization required between different build passes For example: No synchronization is needed between a LIB produced in Pass1 and a sys file consuming LIB in Pass2. All tasks of a pass complete before next pass starts

13. Multiprocessor Build (Contd.) PRODUCES/CONSUMES macros for synchronization within the same pass Different macros for different build passes: BUILD_PASS0_PRODUCES/ BUILD_PASS0_CONSUMES //for Pass0 BUILD_PRODUCES/BUILD_CONSUMES //for Pass1 BUILD_PASS2_PRODUCES/BUILD_PASS2_CONSUMES //for Pass2 Order in DIRS is still important If consumes is seen without any prior matching produces, it is ignored One producer – many consumers Producer and consumer match by a string

14. Synchonization Example

15. Incorporating Custom Build Steps To run a custom build step at any pass of the build use a combination of NTTARGETFILE# = Target and makefile.inc. Use NTTARGETFILE0, NTTARGETFILE1, NTTARGETFILE2 macros Don’t use NTTARGETFILES NTTARGETFILE# causes makefile.def to include makefile.inc makefile.inc steps are executed after the corresponding pass steps are done Makefile.inc in the same directory as the sources file. The rules in makefile.inc should specify the correct paths for targets so that it builds properly. The rules in makefile.inc should specify the correct paths for targets so that it builds properly.

16. Running Custom Steps at Different Build Passes C:\WinDDK\6939.0.fbl_wdk_build.081031-1900\src\general\echo\kmdf\AutoSync to see .inf generation in action.C:\WinDDK\6939.0.fbl_wdk_build.081031-1900\src\general\echo\kmdf\AutoSync to see .inf generation in action.

17. Code Optimization By default WDK code optimization is turned on the free build Use checked build when you want to step into the code and avoid all optimizations To turn off the optimization on free build, use MSC_OPTIMIZATION macro in your sources file MSC_OPTIMIZATION =/Od /Oi Use platform specific optimization macros 386_OPTIMIZATION, IA64_OPTIMIZATION or AMD64_OPTIMIZATION to override WDK build environment setting for MSC_OPTIMIZATION (Ex. 386_OPTIMIZATION = /Od)

18. Investigating Compilation Issues Generating a preprocessor file - .pp file Where does some type/function prototype/header file come from? Nmake toaster.pp Generating assembly code – cod file Nmake toaster.cod Find out all the macros are defined by the build environment Nmake /P Option #2 for intermediate files…set CL=/P * build * Read the file xxx.i file * set CL= Pipe #3 into a text file.Option #2 for intermediate files…set CL=/P * build * Read the file xxx.i file * set CL= Pipe #3 into a text file.

19. Investigating Link Issues To get verbose information from linker set LINKER_FLAGS=$(LINKER_FLAGS) /VERBOSE How functions get resolved by the linker? What libs are searched to produce this image? Which object files or libraries used? Which linker options are used to product the image? Build log has detailed information Option #2 for intermediate files…set CL=/P * build * Read the file xxx.i file * set CL= Pipe #3 into a text file.Option #2 for intermediate files…set CL=/P * build * Read the file xxx.i file * set CL= Pipe #3 into a text file.

20. Separate Object and Binplace Roots – New to Win7 All objects and binaries that are built are stored separately in an object folder Source code could be immutable (stored on an external disk, read only) Easy to clean up the results of the build of object and binaries folders and start fresh. Example: \WinDDK\6801.0 – the WDK installation folder \WinDDK\6801.0.obj.x86fre – the object root \WinDDK\6801.0.binaries.x86fre – the binaries root Having the source code, objects and binaries under the same WDK root has been a problem for a long time. The source tree could not be made read only. The objects and binaries are stored in folders relative to the source folder. We have to manually navigate and pick up the files we want to move in a common folder. Imagine the Toaster bus, filter and function driver binaries, their INFs and co-installer. How do we solve these issues? separate object root separate binaries root Example: \WinDDK\6801.0 – the WDK installation folder \WinDDK\6801.0.obj.x86fre – the object root \WinDDK\6801.0.binaries.x86fre – the binaries rootHaving the source code, objects and binaries under the same WDK root has been a problem for a long time. The source tree could not be made read only. The objects and binaries are stored in folders relative to the source folder. We have to manually navigate and pick up the files we want to move in a common folder. Imagine the Toaster bus, filter and function driver binaries, their INFs and co-installer. How do we solve these issues? separate object root separate binaries root Example: \WinDDK\6801.0 – the WDK installation folder \WinDDK\6801.0.obj.x86fre – the object root \WinDDK\6801.0.binaries.x86fre – the binaries root

21. Macros for Binplacing Files – New Binplace.exe utility has been provided in WDK for stripping symbol files, splitting and moving files Win7 introduces two new macros for binplacing files as part of build TARGET_DESTINATION PASS2_BINPLACE Can be used to copy additional files that are not produced by build such as INF, CAT file DEST switch (multiple -:DEST possible) Source folder relative to the object root Example: \WinDDK\6801.0.obj.x86fre\src\... Destination folder is relative to the binaries root Example: \WinDDK\6801.0.obj.x86fre\src\...

22. OACR – Automated Code Review Runs PreFast for Drivers (PFD) asynchronously as part of build Reports status via icon in taskbar Highly configurable via .ini files Snooze option available in taskbar (preferred method). Pass No_OACR flag to setenv.bat to disable

23. Introducing OACR

24. New Device Technologies Biometrics XPS Print Hypervisor Sensor/PC3 Windows Vista Display Driver Model (WDDM) updates Wave Real-Time (WaveRT) Wireless Wide Area Network (WWAN) updates Windows Driver Foundation (WDF) 1.9 And more…

25. New Tools in the WDK ComputerModelID OACR IRP Concurrency Coverage (proposed) Service Discovery Profile (SDP) Verifier (proposed) CTRPP (proposed)

26. Sample Changes in the WDK

27. Kit Content Quality Improvement

28. WDK Content Quality Efforts Add header annotations to WDK headers Run PREfast for Drivers (PFD) on samples Run Static Driver Verifier (SDV) on sample Compile with MSC_WARNING_LEVEL=/W4 /WX in sources Run Application Verifier against UMDF samples and driver tools Run Driver Verifier against samples Remove obsolete and poor samples

29. Static Analysis Tools Run Against WDK Samples PREfast for Drivers 112 bug fixes 3110 PFD defects removed from samples Header annotations added to reduce false positives Static Driver Verifier 14 bug fixes Role type annotations added to samples

30. W4 Compiler Warnings Found by setting MSC_WARNING_LEVEL=/W4 /WX in sources files 159 bug fixes 3934 warnings removed from samples Typical errors include uninitialized variables, unreferenced parameters MS08-014 – Security vulnerability could have been prevented by /W4 compilation Many Windows 7 samples will default to /W4 in the sample sources file

31. Windows Driver Kit Documentation

32. WDK Documentation Windows 7 docs coming at Beta Over two thousand new topics Biometrics, XPS, Hypervisor, WDDM, WaveRT, WWAN, WDF Complete technical review of all 802 topics in the Kernel-Mode Driver Architecture Reference Expanded requirements block for new DDIs OS version IRQL requirements Header/lib “Roadmaps” with basic steps to create drivers WDK documentation monthly update on MSDN and WHDC ~1,000,000 million page views per month on MSDN ~10,000 downloads per month on WHDC Increased visibility WDK Doc Blog (http://blogs.msdn.com/wdkdocs)

33. Side-by-Side Translation English to Simplified Chinese on http://translator.live.com

34. Translation Results and Plans Machine Translation Beta participation totaled 502,730 visits Pilot ran Oct. 1st, 2007 through Feb. 28th, 2008 Windows Driver Kit 3rd most viewed of 10 in pilot Majority of our customers non-native English speakers Used survey data to prioritize target languages for side-by-side translation Content in some top languages targeted by end of FY09 Japanese, Chinese (Simplified), Chinese (Traditional), Russian, Korean, Portuguese, French, Spanish

35. Call To Action Send feedback on Docs, Build Environment, etc. Try Microsoft Automated Code Review – tell us what you think Use the new binplace macros

36. Contact the WDK Team: [email protected] (WDK PM team) [email protected] (WDK Test team) [email protected] (WDK Docs team) Available online: WHDC website: http://www.microsoft.com/wdk Read the WDK Doc blog at http://blogs.msdn.com/wdkdocs/default.aspx Download monthly WDK doc refresh from http://www.microsoft.com/whdc/DevTools/WDK/WDKdocs.mspx Driver Development Newsgroup: http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.development.device.drivers&lang=en&cr=US Additional Resources

37. Questions?

  • Login