Skip to content

Commit

Permalink
[kext] Fix dev build documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vlabo committed Jan 28, 2025
1 parent 0f28af6 commit 32d6e1c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
26 changes: 10 additions & 16 deletions windows_kext/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Portmaster Windows kext
Implementation of Safing's Portmaster Windows kernel extension in Rust.

### Documentation
### Documentation

- [Driver](driver/README.md) -> entry point.
- [WDK](wdk/README.md) -> Windows Driver Kit interface.
- [Packet Path](PacketFlow.md) -> Detailed documentation of what happens to a packet when it enters the kernel extension.
- [Release](release/README.md) -> Guide how to do a release build.
- [Windows Filtering Platform - MS](https://learn.microsoft.com/en-us/windows-hardware/drivers/network/roadmap-for-developing-wfp-callout-drivers) -> The driver is build on top of WFP.


### Building
### Building (For testing and development)

The Windows Portmaster Kernel Extension is currently only developed and tested for the amd64 (64-bit) architecture.

Expand Down Expand Up @@ -53,23 +52,18 @@ __Build driver:__

```sh
cd driver
cargo build
cargo build --release
```
> Build also works on linux
__Link and sign:__
On a windows machine copy `driver.lib` form the project target directory (`driver/target/x86_64-pc-windows-msvc/debug/driver.lib`) in the same folder as `link.bat`.
Run `link.bat`.

`driver.sys` should appear in the folder. Load and use the driver.
On a windows machine copy `driver.lib` from the project target directory (`driver/target/x86_64-pc-windows-msvc/release/driver.lib`) in the same folder as `link-dev.ps1`.
Run `link-dev.ps1`.

### Test
- Install go
- https://go.dev/dl/
`driver.sys` should appear in the folder.

```sh
cd kext_tester
go run .
Sign the driver with the test certificate:
```

> make sure the hardcoded path in main.go is pointing to the correct `.sys` file
SignTool sign /v /s TestCertStoreName /n TestCertName driver.sys
```
Load and use the driver.
21 changes: 21 additions & 0 deletions windows_kext/link-dev.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Example script for creating debug builds. Libraries may change depending on the version of the WDK that is installed.

$SDK_Version = "10.0.26100.0"

link.exe /OUT:driver.sys `
/MANIFEST:NO /PROFILE /Driver `
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\wdmsec.lib" `
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\ndis.lib" `
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\fwpkclnt.lib" `
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\BufferOverflowK.lib" `
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\ntoskrnl.lib" `
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\hal.lib" `
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\wmilib.lib" `
"C:\Program Files (x86)\Windows Kits\10\lib\wdf\kmdf\x64\1.15\WdfLdr.lib" `
"C:\Program Files (x86)\Windows Kits\10\lib\wdf\kmdf\x64\1.15\WdfDriverEntry.lib" `
"driver.lib" `
/RELEASE /VERSION:"10.0" /DEBUG /MACHINE:X64 /ENTRY:"FxDriverEntry" /OPT:REF /INCREMENTAL:NO /SUBSYSTEM:NATIVE",6.01" /OPT:ICF /ERRORREPORT:PROMPT /MERGE:"_TEXT=.text;_PAGE=PAGE" /NOLOGO /NODEFAULTLIB /SECTION:"INIT,d"

if(!$?) {
Exit $LASTEXITCODE
}

0 comments on commit 32d6e1c

Please sign in to comment.