Skip to content

Commit

Permalink
[windows_kext] Fix minor problems
Browse files Browse the repository at this point in the history
  • Loading branch information
vlabo committed Jul 1, 2024
1 parent 8965712 commit 2e33048
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion service/firewall/interception/windowskext2/kext.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ func Start() error {
}

// Start service and open file
service.Start(true)
err = service.Start(true)
if err != nil {
log.Errorf("failed to start service: %s", err)
}

kextFile, err = service.OpenFile(1024)
if err != nil {
return fmt.Errorf("failed to open driver: %w", err)
Expand Down
5 changes: 3 additions & 2 deletions windows_kext/kextinterface/kext.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"syscall"
"time"

"github.com/safing/portmaster/base/log"
"golang.org/x/sys/windows"
)

Expand Down Expand Up @@ -221,7 +222,7 @@ func CreateKextService(driverName string, driverPath string) (*KextService, erro
// Check if there is an old service.
service, err := windows.OpenService(manager, &driverNameU16[0], windows.SERVICE_ALL_ACCESS)
if err == nil {
fmt.Println("kext: old driver service was found")
log.Warning("kext: old driver service was found")
oldService := &KextService{handle: service, driverName: driverName}
oldService.Stop(true)
err = oldService.Delete()
Expand All @@ -234,7 +235,7 @@ func CreateKextService(driverName string, driverPath string) (*KextService, erro
}

service = winInvalidHandleValue
fmt.Println("kext: old driver service was deleted successfully")
log.Warning("kext: old driver service was deleted successfully")
}

driverPathU16, err := syscall.UTF16FromString(driverPath)
Expand Down
1 change: 1 addition & 0 deletions windows_kext/kextinterface/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestRustInfoFile(t *testing.T) {
for {
info, err := RecvInfo(file)
// First info should be with invalid size.
// This tests if invalid info data is handled properly.
if first {
if !errors.Is(err, ErrUnexpectedInfoSize) {
t.Errorf("unexpected error: %s\n", err)
Expand Down
2 changes: 1 addition & 1 deletion windows_kext/protocol/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ fn generate_test_info_file() -> Result<(), std::io::Error> {
for _ in 0..selected.capacity() {
selected.push(enums.choose(&mut rng).unwrap().clone());
}
// Write wrong size data.
// Write wrong size data. To make sure that mismatches between kext and portmaster are handled properly.
let mut info = connection_info_v6(
1,
2,
Expand Down

0 comments on commit 2e33048

Please sign in to comment.