diff --git a/service/firewall/interception/windowskext2/kext.go b/service/firewall/interception/windowskext2/kext.go index aaedac89..fa5a8f0d 100644 --- a/service/firewall/interception/windowskext2/kext.go +++ b/service/firewall/interception/windowskext2/kext.go @@ -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) diff --git a/windows_kext/kextinterface/kext.go b/windows_kext/kextinterface/kext.go index 2707a791..8322ead8 100644 --- a/windows_kext/kextinterface/kext.go +++ b/windows_kext/kextinterface/kext.go @@ -11,6 +11,7 @@ import ( "syscall" "time" + "github.com/safing/portmaster/base/log" "golang.org/x/sys/windows" ) @@ -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() @@ -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) diff --git a/windows_kext/kextinterface/protocol_test.go b/windows_kext/kextinterface/protocol_test.go index c09cf286..35a5264d 100644 --- a/windows_kext/kextinterface/protocol_test.go +++ b/windows_kext/kextinterface/protocol_test.go @@ -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) diff --git a/windows_kext/protocol/src/info.rs b/windows_kext/protocol/src/info.rs index fc50d589..cb0e7664 100644 --- a/windows_kext/protocol/src/info.rs +++ b/windows_kext/protocol/src/info.rs @@ -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,