Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Overlay WindowsStore-Apps (UWP) without code-signing
Peter Repukat
Peter Repukat

Posted on

     

Overlay WindowsStore-Apps (UWP) without code-signing

Disclaimer: This post was originally posted onmy own blog

Introduction

I came to discover that, you cannot simply overlay Metro/UWP/Windows-Store Apps (or whatever they are called these days) using always on top windows.

I learned while it is possible, for that to work the program has to have theuiAccess=True-flag set in the manifest, and it must be signed.
That, of course, isn't good news for any hobby or small open-source project, as code-signing certificates cost money.
There is another way, however...

But first, let's see what happens if you try to focus any old “always on top”-window while running a fullscreen store app.
If that happens, it causes the Windows Store app in “fullscreen”-mode to instantly minimize.
Even though store apps never really run in exclusive fullscreen!

Store app minimizing when always on top Terminal gets focused

Some programs however are perfectly capable of doing this, like the Windows Taskbar itself or DisplayFusions intermediate loading window...

DisplayFusion loading window perfectly overlaying store app

I asked the developers of DisplayFusion how they are doing it, and they shared the secret with me: The aforementioneduiAccess=True-flag along with a signed executable.

Formy endless quest in gettingSteam Input to work with stuff it normally doesn't, an overlay for Windows Store apps would be a real boon.
But spending ~100 bucks per year for a free project, that I have way too little time to properly maintain and support, doesn't seem all too appealing.

Luckily, with a bit of hacking, using undocumented Windows APIs, I managed to get it to work.
I think the whole process is rather interesting, and so I wanted to share it with you.

Window z-order

Z-ordering in Windows 10 (up from Win8) works in so-called“WindowBands”
The order of (some) bands, from lowest to highest, is as follows:

  • ZBID_DESKTOP
  • ZBID_IMMERSIVE_BACKGROUND
  • ZBID_IMMERSIVE_APPCHROME
  • ZBID_IMMERSIVE_MOGO
  • ZBID_IMMERSIVE_INACTIVEMOBODY
  • ZBID_IMMERSIVE_NOTIFICATION
  • ZBID_IMMERSIVE_EDGY
  • ZBID_SYSTEM_TOOLS
  • ZBID_LOCK (Win10)
  • ZBID_ABOVELOCK_UX (Win10)
  • ZBID_IMMERSIVE_IHM
  • ZBID_GENUINE_WINDOWS
  • ZBID_UIACCESS

Multiple windows, annotated with WindowBands

If you're wondering why you never heard of “WindowBands” before, it is because you normally won't get to use them (explicitly).
All the APIs are undocumented and not made publicly available by Microsoft.
But we will get to that.

Any regular old window gets created withZBID_DESKTOP and will remain there.
Setting a window to be always-on-top usingSetWindowPos(...) will just change the ordering inside theZBID_DESKTOP-band.
An expectation to that is, for example, the previously mentioneduiAccess=True-flag
with a signed executable. Then the window will get created in theZBID_UIACCESS
-band.

If anyZBID_DESKTOP-window gets “touched” while running a store app in “fullscreen”-mode, the store app gets minimized.
Other bands don't necessarily cause that behavior.

Using other WindowBands

Code

Enum

enumZBID{ZBID_DEFAULT=0,ZBID_DESKTOP=1,ZBID_UIACCESS=2,ZBID_IMMERSIVE_IHM=3,ZBID_IMMERSIVE_NOTIFICATION=4,ZBID_IMMERSIVE_APPCHROME=5,ZBID_IMMERSIVE_MOGO=6,ZBID_IMMERSIVE_EDGY=7,ZBID_IMMERSIVE_INACTIVEMOBODY=8,ZBID_IMMERSIVE_INACTIVEDOCK=9,ZBID_IMMERSIVE_ACTIVEMOBODY=10,ZBID_IMMERSIVE_ACTIVEDOCK=11,ZBID_IMMERSIVE_BACKGROUND=12,ZBID_IMMERSIVE_SEARCH=13,ZBID_GENUINE_WINDOWS=14,ZBID_IMMERSIVE_RESTRICTED=15,ZBID_SYSTEM_TOOLS=16,// Win10ZBID_LOCK=17,ZBID_ABOVELOCK_UX=18,};
Enter fullscreen modeExit fullscreen mode

CreateWindowInBand

Same asCreateWindowEx except with 1 more parameterdwBand where you specify the band the window should stay.

HWNDWINAPICreateWindowInBand(DWORDdwExStyle,LPCWSTRlpClassName,LPCWSTRlpWindowName,DWORDdwStyle,intx,inty,intnWidth,intnHeight,HWNDhWndParent,HMENUhMenu,HINSTANCEhInstance,LPVOIDlpParam,DWORDdwBand);
Enter fullscreen modeExit fullscreen mode

SetWindowBand

Same asSetWindowPos except with 1 more parameterdwBand

BOOLWINAPISetWindowBand(HWNDhWnd,HWNDhwndInsertAfter,DWORDdwBand);
Enter fullscreen modeExit fullscreen mode

GetWindowBand

BOOLWINAPIGetWindowBand(HWNDhWnd,PDWORDpdwBand);
Enter fullscreen modeExit fullscreen mode

Calling the APIs?

All those functions are private APIs found inuser32.dll, so you have to useGetProcAdress to get to them.
But Microsoft implemented some checks to prevent their usage.

  • GetWindowBand always works.
  • CreateWindowInBand/Ex only works if you passZBID_DEFAULT orZBID_DESKTOPZBID_UIACCESS works only with theuiAccess=True-flag set and code-signing.
  • SetWindowBand will never work.

Calling them anyway...

CreateWindowInBand

To useCreateWindowInBand with any ZBID, you need to inject a .dll into an immersive process (bright blue inProcessExplorer) and call it from there.

SetWindowInBand

SetWindowBand gets a little more interesting. In order to use that, you have to inject a .dll intoexplorer.exe and hookSetWindowBand with a trampoline.
As soon as the StartMenu opens, or a new window gets created, the function will be called.
Now you can call the original function twice.
Once with a different HWND and ZBID and then with the original parameters.
A full example of this can be foundhere

Conclusion

With the introduction of Windows Store apps, Microsoft also introduced the concept of WindowBands, to more offer more granular control over window z-ordering.
Many Bands are available, but they don't allow you to use them explicitly.

With a bit of hacking, however, it's completely possible to freely take advantage of any WindowBand.

And soGloSC/GlosSI (My cobbled together tool for SteamInput) users can enjoy stuff like this:

GlosSI enabling Steam Overlay with Minecraft UWP edition


Credits/Sources:adltax

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Swiss-Army-Knife Developer, interested in all things technical: Programming, hacking, 3D-printing, cars, gaming and also a photography and Photoshop nut.
  • Location
    Germany
  • Education
    Computer Science @ OTH-Regensburg
  • Work
    Specialized Software Developer @ CmdScale
  • Joined

More fromPeter Repukat

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp