Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tool feature: hide console window at the runtime #126

Closed
wants to merge 1 commit into from

Conversation

ilopX
Copy link
Contributor

@ilopX ilopX commented Jan 2, 2021

Hide console window

When you run a GUI application written and compiled with dart, a console appears that can be hidden with this tutorial.

How to

  1. First build your program
cd win32
dart compile exe .\example\hello.dart -o .\example\bin\your_app.exe
  1. Then run the patch
dart .\tool\hide_console\switch_subsystem.dart GUI .\example\bin\your_app.exe
  1. Run your application and enjoy
call .\example\bin\your_app.exe

Return the console back

dart .\tool\hide_console\switch_subsystem.dart CONSOLE .\example\bin\your_app.exe

How it works

The dart script switch_subsystem.dart replaces bytes in the PE header (your_app.exe). This changes the system flag from WINDOWS:CONSOLE to WINDOWS:GUI.

final IMAGE_SUBSYSTEM_WINDOWS_GUI = [98, 52, 68, 0, 2];
final file = File('your_app.exe').openSync(mode: FileMode.append);
file.setPositionSync(START_PE + SUBSYSTEM_PE);
file.writeFromSync(IMAGE_SUBSYSTEM_WINDOWS_GUI);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant