Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions internal/ingress/block_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ func showBlockedModal(event BlockEvent, ingressAddress string) {
"--package-id", event.Artifact.PackageName,
"--package-version", event.Artifact.PackageVersion,
"--package-human-name", event.Artifact.DisplayName,
// Encapsulate title as an argument: It can contain spaces causing the argument parsing to fail for windows.
"--title", fmt.Sprintf("\"%s\"", title),
"--subtitle", fmt.Sprintf("\"%s\"", subtitle),
"--title", title,
"--subtitle", subtitle,
"--ingress", ingressAddress,
"--bypass-enabled=true",
}
Expand Down
15 changes: 8 additions & 7 deletions internal/platform/platform_windows_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"fmt"
"log"
"syscall"
"strings"
"unsafe"

Expand Down Expand Up @@ -69,12 +70,13 @@ func getLoggedInUserSIDs(ctx context.Context) ([]string, error) {
}

func buildCommandLineForWindowsProcess(binaryPath string, args []string) *uint16 {
cmdLine := binaryPath
if len(args) > 0 {
cmdLine = fmt.Sprintf(`"%s" %s`, binaryPath, strings.Join(args, " "))
} else {
cmdLine = fmt.Sprintf(`"%s"`, binaryPath)
escapedArgs := make([]string, 0, len(args)+1)
escapedArgs = append(escapedArgs, syscall.EscapeArg(binaryPath))
for _, arg := range args {
escapedArgs = append(escapedArgs, syscall.EscapeArg(arg))
}

cmdLine := strings.Join(escapedArgs, " ")
cmdLinePtr, err := windows.UTF16PtrFromString(cmdLine)
if err != nil {
return nil
Expand Down Expand Up @@ -106,8 +108,7 @@ func runProcessAsUser(duplicatedToken windows.Token, cmdLinePtr *uint16, envBloc
var si windows.StartupInfo
si.Cb = uint32(unsafe.Sizeof(si))
si.Desktop, _ = windows.UTF16PtrFromString("winsta0\\default")
si.Flags = windows.STARTF_USESTDHANDLES | windows.STARTF_USESHOWWINDOW
si.ShowWindow = uint16(windows.SW_HIDE)
si.Flags = windows.STARTF_USESTDHANDLES
si.StdOutput = stdoutWrite
si.StdErr = stdoutWrite

Expand Down
Loading