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

[Proposal] On Windows 11+, try out the new consoleAllocationPolicy manifest entry #1543

Closed
DHowett opened this issue Feb 11, 2024 · 2 comments

Comments

@DHowett
Copy link

DHowett commented Feb 11, 2024

Hey! 👋

I'm the maintainer for the Windows Console subsystem, and a big ImHex fan. I remember the discussion we had over in microsoft/terminal#16174 about imhex-gui and imhex being allocated a console due to being compiled with /SUBSYSTEM:CONSOLE.

In the recent insider builds for Windows 11, we finally added support for CONSOLE subsystem applications to opt-out of automatic console allocation.

The spec is here, though it's a bit dense.

In short, you add this to your win32 manifest:

<!-- You probably already have these lines
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <application>
    <windowsSettings>
-->
      <consoleAllocationPolicy xmlns="http://schemas.microsoft.com/SMI/2024/WindowsSettings">detached</consoleAllocationPolicy>
<!-- (and these)
    </windowsSettings>
  </application>
</assembly>
-->

With that entry, your EXE will only get a console if it inherits one. It won't automatically make one -- ever1 -- unless you call AllocConsole or this new AllocConsoleWithOptions API.

Feel free to close this out, or follow up with any questions! I'd be happy to test out any builds if you can't get at a Windows Insider machine/VM. 🙂

Footnotes

  1. I'm hoping to get this backported to Windows 10 and the current in-market versions of Windows 11 as well. That will take some time. But since we didn't want to break all existing console applications . . . on Windows <=11 2023 it actually will automatically get a console. Ugh.

@WerWolv
Copy link
Owner

WerWolv commented Feb 11, 2024

Hey, thanks a lot! That's some fantastic news and a huge step in the right direction!

I'm happy to add this to ImHex, however if this only applies to very new versions of Windows 11, I'll probably still have to keep the current forwarder application around for the time being.

We currently don't have a manifest like this yet and I honestly also don't know much about them. ImHex is built using MinGW on Windows and I'm not sure if that supports embedding those easily. I'll definitely look into it though.

@DHowett
Copy link
Author

DHowett commented Dec 29, 2024

I just tried out 6a5473f (portable), and I love it. It works exactly like I'd expect an application on e.g. Linux to work 🙂.

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

No branches or pull requests

2 participants