AI prompts
base on Rust port of the official Windows Driver Samples on Github. Leverages windows-drivers-rs # Rust Driver Samples
This is a Rust port of the driver samples from the original [Windows Driver Samples on Github.](https://github.com/microsoft/Windows-driver-samples)
The repository provides examples and best practices for Windows driver development in Rust using crates from [windows-drivers-rs.](https://github.com/microsoft/windows-drivers-rs)
## Getting Started
### Pre-requisites
#### Required
* Set up [EWDK Build Environment](https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/using-the-enterprise-wdk)
* Easy install option:
* Install the latest version from link
* <https://learn.microsoft.com/en-us/legal/windows/hardware/enterprise-wdk-license-2022>
* Expand the ISO image to c:\ewdk
* Start Environment by running in command prompt:
* ```c:\ewdk\LaunchBuildEnv.cmd```
* Install [Clang](https://clang.llvm.org/get_started.html)
* Easy install option:
* `winget install LLVM.LLVM`
* Install [Rust](https://www.rust-lang.org/tools/install)
* Easy install option for x64 systems:
```pwsh
Invoke-RestMethod -Uri "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe" -OutFile "$env:USERPROFILE\Downloads\rustup-init.exe"
& "$env:USERPROFILE\Downloads\rustup-init.exe" -y
```
#### Rust Setup
Run the following commands after setting up Rust.
`cargo install cargo-make --no-default-features --features tls-native`
__Note on arm64: ARM64 support for ring is [not released yet](https://github.com/briansmith/ring/issues/1167), so TLS features must be disabled until arm64 is officially supported by ring (probably in 0.17.0 release)__
##### Optional
These are not-required, but may make it easier to work in a rust environment:
`cargo install cargo-expand cargo-edit cargo-workspaces`
## Documentation
`cargo doc --document-private-items --open`
## Build and Test
### Build
From an EWDK development command prompt, run:
`cargo make`
If build is successful, this will stamp the INF and create a CAT file placed with driver binary and INF in `Package` folder.
### Install
#### One Time PC Setup
1. If Bitlocker is enabled, suspend Bitlocker
Example: `manage-bde -protectors -disable C:`
1. Turn off Secure Boot via your UEFI/BIOS Settings
Example: `shutdown -r -o -t 0` then pick Advanced -> UEFI Settings
1. If Bitlocker is enabled, suspend Bitlocker again
Example: `manage-bde -protectors -disable C:`
1. Turn on test signing
`bcdedit /set testsigning on`
1. Reboot
`shutdown -r -t 0`
1. Copy the following to the DUT (Device Under Test: the computer you want to test the driver on):
1. The driver `package` folder located in the [Cargo Output Directory](https://doc.rust-lang.org/cargo/guide/build-cache.html). The Cargo Output Directory changes based off of build profile, target architecture, etc.
* Ex. `<REPO_ROOT>\target\x86_64-pc-windows-msvc\debug\package`, `<REPO_ROOT>\target\x86_64-pc-windows-msvc\release\package`, `<REPO_ROOT>\target\aarch64-pc-windows-msvc\debug\package`, `<REPO_ROOT>\target\aarch64-pc-windows-msvc\release\package`,
`<REPO_ROOT>\target\debug\package`,
`<REPO_ROOT>\target\release\package`
1. The version of `devgen.exe` from the WDK Developer Tools that matches the archtecture of your DUT
* Ex. `C:\ewdk\Program Files\Windows Kits\10\Tools\10.0.22621.0\x64\devgen.exe`
1. Install the Certificate on the DUT:
1. Double click the certificate
1. Click Install Certificate
1. Store Location: Local Machine -> Next
1. Place all certificates in the following Store -> Browse -> Trusted Root Certification Authorities -> Ok -> Next
1. Repeat 2-4 for Store -> Browse -> Trusted Publishers -> Ok -> Next
1. Finish
1. Install the driver from Admin Command Prompt:
1. In the package directory, run: `pnputil.exe /add-driver echo_2.inf /install`
1. Create a software device from Admin Command Prompt:
1. In the directory that `devgen.exe` was copied to, run: `devgen.exe /add /hardwareid "root\ECHO_2"`
### Test
* To capture prints:
* Start [DebugView](https://learn.microsoft.com/en-us/sysinternals/downloads/debugview)
1. Enable `Capture Kernel`
2. Enable `Enable Verbose Kernel Output`
* Alternatively, you can see prints in an active Windbg session.
1. Attach WinDBG
2. `ed nt!Kd_DEFAULT_Mask 0xFFFFFFFF`
### Usage
The echo driver can be tested by using the [included sample app](./general/echo/kmdf/exe).
* cargo run --bin echoapp
* Send single write and read request synchronously
* cargo run --bin echoapp -- -Async
* Send 100 reads and writes asynchronously
Exit the app anytime by pressing Ctrl-C
## Windows driver development
### Windows Driver Kit (WDK)
Take a look at the compilation of the new and changed driver-related content for Windows 11. Areas of improvement include camera, print, display, Near Field Communication (NFC), WLAN, Bluetooth, and more.
[Find out what's new in the WDK](https://docs.microsoft.com/windows-hardware/drivers/what-s-new-in-driver-development)
### Windows Driver Frameworks
The Windows Driver Frameworks (WDF) are a set of libraries that make it simple to write high-quality device drivers.
[WDF driver development guide](https://docs.microsoft.com/windows-hardware/drivers/wdf/)
### Samples
Use the samples in this repo to guide your Windows driver development. Whether you're just getting started or porting an older driver to the newest version of Windows, code samples are valuable guides on how to write drivers.
For information about important changes that need to be made to the WDK sample drivers before releasing device drivers based on the sample code, see the following topic:
[From Sample Code to Production Driver - What to Change in the Samples](https://docs.microsoft.com/en-us/windows-hardware/drivers/gettingstarted/from-sample-code-to-production-driver)
## Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.
", Assign "at most 3 tags" to the expected json: {"id":"2526","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"