Skip to content

Add a way to hide launched application through leakless #6

@lexuzieel

Description

@lexuzieel

Currently on windows, even if you launch a console application using leakless you get console window flashing.
On further research I found that it is caused by -H=windowsgui flag here.

Problem is, since it is a build-time flag, there is no way to control this programmatically.

After tinkering with the code for a bit it looks like it is possible to adjust this behavior dynamically by removing -H=windowsgui flag and instead setting syscall.SysProcAttr.HideWindow in osSetupCmd for windows here.

Then it is possible to set this through leakless launcher options (I have put up a draft in my fork). This essentially makes it possible to configure leakless launcher like this:

https://github.com/avixFF/leakless/blob/99b97b5/leakless_windows_test.go#L13-L22

This in turn launches modified leakless binary like so:

leakless.exe --hide-window <uid> <tcp-addr> <cmd>

which triggers command setup snippet for windows:

https://github.com/avixFF/leakless/blob/99b97b5/cmd/leakless/os_windows.go#L14-L17

The current issue with this is that it looks like it doesn't completely solve this problem.
While I was successfully was able to show and hide notepad.exe on windows (by replacing path to the binary here), it looks like this approach doesn't work for binaries compiled with -H=windowsgui flag.

In fact when launching a binary compiled with -H=windowsgui flag (i.e. test_windows.exe), leakless.exe is always shown even if HideWindow is true.

Here is the final test that isn't working as expected if you run it manually on windows

What are your thoughts on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions