[windows_kext] Fix minor problems

This commit is contained in:
Vladimir Stoilov
2024-07-01 15:06:54 +03:00
parent 89657123ec
commit 2e3304809f
4 changed files with 10 additions and 4 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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,