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 support for 22449 & correct naming #1

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

NyaMisty
Copy link

  • 22449 introduced a new method GetAllCurrentDesktops, and I fixed it. Tested on 22454
  • Actually, all name of interface can be retrived from twinui.pcshell.dll's PDB symbol:
    image

Also, Grabacr07's repo haven't been active for over a year, and Windows 11 is moving blazing fast, would you like to maintain a new VirtualDesktop package, so that users can benefit from newest Windows virtual features.

@sliddington
Copy link

Thanks @NyaMisty
Since you seem to have the process well covered would you mind documenting the process for these updates - or is that already somewhere else - not sure where we should put it of course!

@anaisbetts
Copy link

anaisbetts commented Sep 18, 2021

@NyaMisty Good find! This is great, thanks for updating this

@NyaMisty
Copy link
Author

Document here comes:
For Interface Definition changing cases (i.e. Interface GUID & CLSID didn't change):

  1. Retriving Interface Definition: Download and open the OleViewDotNet, and go to Registry -> Interface By Name, then lookup IVirtualDesktopManager and IVirtualDesktopManager, right click "View Proxy Definition"
  2. Use IDA Pro to open twinui.pcshell.dll, find CVirtualDesktopManager, and then you'll find functions with [thunk] prefix, corresponds then with interface definition
    image

For CLSID changing cases: (much harder, not for non-professional)

  • Search whole System32 for Interface GUID's first part like "b2f925b9" using hex editor (note the little endian, you'll have to search "b9 25 f9 b2" in the editor), check them in IDA one by one

@sliddington
Copy link

sliddington commented Sep 18, 2021 via email

@anaisbetts
Copy link

This mostly works, but it seems that VirtualDesktopNotificationListener (exposed in the library as VirtualDesktop.CurrentChanged and friends) don't fire events anymore

@sliddington
Copy link

@anaisbetts I checked that and it turns out the 21359 version was correct. So on my fork I have merged NyaMisty's 22449 version (since it has correct naming) with the 21359 interface. It works for me on 22463.
My fork is https://github.com/sliddington/VirtualDesktop

@sliddington
Copy link

Looks like the official Win 11 and Insider versions since don't have the IDs in the registry at all - does this mean we can't access via COM any more? I did a "go back" to the previous version I had (22463) to get the IDs saved and am about to go forward again to see if it works if we know them already instead of fetching from the registry - I imagine not since I guess the registry is what links that ID to the binaries.

I suspect the new way to access this stuff is via Windows.Internal.Shell.Multitasking... I see some likely stuff in Interfaces By Name and Runtime Classes in OleViewDotNet.

Any ideas @NyaMisty @mntone ?

@sliddington
Copy link

It does work with the ids from 22463 - they are in the registry but the interface names have been replaced by the ids so the function that searches by name fails.

Ids are .. i'll be updating my fork in next few days
//return new Dictionary<string, Guid> {
// { "IVirtualDesktopNotificationService", new Guid("0cd45e71-d927-4f15-8b0a-8fef525337bf") },
// { "IApplicationViewCollection", new Guid("1841c6d7-4f9d-42c0-af41-8747538f10e5") },
// { "IApplicationView", new Guid("372e1d3b-38d3-42e4-a15b-8ab2b178f513") },
// { "IVirtualDesktopPinnedApps", new Guid("4ce81583-1e4c-4632-a621-07a53543148f") },
// { "IVirtualDesktop", new Guid("536d3495-b208-4cc9-ae26-de8111275bf8") },
// { "IVirtualDesktopManagerInternal", new Guid("b2f925b9-5a0f-4d2e-9f4d-2b1507593c10") },
// { "IVirtualDesktopNotification", new Guid("cd403e52-deed-4c13-b437-b98380f2b1e8") }
//};

@anaisbetts
Copy link

@sliddington Which registry settings are missing? They seem to be there on upgraded Windows installs, but not on fresh Win11 installs

@sliddington
Copy link

@sliddington Which registry settings are missing? They seem to be there on upgraded Windows installs, but not on fresh Win11 installs

All of them seemed to be there, just without their names. I made a build that worked for me (an upgraded install) but then didn't on the offical 22000 build.

The master branch has recently been updated to apparently work for 22000. I haven't check it out yet.

@mzomparelli
Copy link

mzomparelli commented Aug 27, 2023

It appears that IVirtualDesktopManagerInternal in Win 11 build 22621 has new members. It also appears that IObjectArray GetAllCurrentDesktops(); was removed. Anyone know anything about these remote virtual desktops?

GetCount(uint *)
MoveViewToDesktop(IApplicationView *,IVirtualDesktop *)
CanViewMoveDesktops(IApplicationView *,int *)
GetCurrentDesktop(IVirtualDesktop * *)
GetDesktops(IObjectArray * *)
GetAdjacentDesktop(IVirtualDesktop *,uint,IVirtualDesktop * *)
SwitchDesktop(IVirtualDesktop *)
CreateDesktopW(IVirtualDesktop * *)
MoveDesktop(IVirtualDesktop *,uint)
RemoveDesktop(IVirtualDesktop *,IVirtualDesktop *)
FindDesktop(_GUID const &,IVirtualDesktop * *)
GetDesktopSwitchIncludeExcludeViews(IVirtualDesktop *,IObjectArray * *,IObjectArray * *)
SetDesktopName(IVirtualDesktop *,HSTRING__ *)
SetDesktopWallpaper(IVirtualDesktop *,HSTRING__ *)
UpdateWallpaperPathForAllDesktops(HSTRING__ *)
CopyDesktopState(IApplicationView *,IApplicationView *)
CreateRemoteDesktop(HSTRING__ *,IVirtualDesktop * *)
SwitchRemoteDesktop(IVirtualDesktop *)
SwitchDesktopWithAnimation(IVirtualDesktop *)
GetLastActiveDesktop(IVirtualDesktop * *)
WaitForAnimationToComplete(void)
OnViewAddedInternal(IApplicationView *,IVirtualDesktop *)
OnViewAddedInternal(IApplicationView *)
OnPinnedViewAddedInternal(IApplicationView *)
OnViewRemovedFromSwitchersInternal(IApplicationView *)
OnViewRemovedInternal(IApplicationView *)
SetViewCollectionInternal(IApplicationViewCollection *)
CreateRecoveredDesktopInternal(_GUID const &,IVirtualDesktop * *)
RemoveDesktopForRecoveryInternal(IVirtualDesktop *,IVirtualDesktop *)
SwitchDesktopForRecoveryInternal(IVirtualDesktop *)
ViewVisibilityUpdatedInternal(IApplicationView *)
MoveViewToDesktopNoGroupPropagateInternal(IApplicationView *,IVirtualDesktop *)
SubscribeToWindowMessageService(IImmersiveWindowMessageService *)
SubscribeToVDSoftLandingService(wil::com_ptr_t<IApplicationViewVisibilityDebouncedNotificationService,wil::err_returncode_policy>)
UnsubscribeToVDSoftLandingService(void)
SetRemoteSessionWindowManager(wil::com_ptr_t<Windows::Internal::Shell::IRemoteSessionWindowManager,wil::err_exception_policy> const &)
DelayInitialize(ISwitchThumbnailDeviceManager *,IVirtualDesktopSwitchAnimator *,IImmersiveSettingsCache *,IMultitaskingViewServiceProvider *)
DismissTaskViewInRemote(IVirtualDesktop *)

@mzomparelli
Copy link

Looks like some changes to IApplicationView as well

SetFocus(void)
SwitchTo(void)
TryInvokeBack(IAsyncCallback *)
GetThumbnailWindow(HWND__ * *)
GetMonitor(IImmersiveMonitor * *)
GetVisibility(int *)
SetCloak(APPLICATION_VIEW_CLOAK_TYPE,int)
GetPosition(_GUID const &,void * *)
SetPosition(IApplicationViewPosition *)
InsertAfterWindow(HWND__ *)
GetExtendedFramePosition(tagRECT *)
GetAppUserModelId(ushort * *)
SetAppUserModelId(ushort const *)
IsEqualByAppUserModelId(ushort const *,int *)
GetViewState(uint *)
SetViewState(uint)
GetNeediness(int *)
GetLastActivationTimestamp(unsigned __int64 *)
SetLastActivationTimestamp(unsigned __int64)
GetVirtualDesktopId(_GUID *)
SetVirtualDesktopId(_GUID const &)
GetShowInSwitchers(int *)
SetShowInSwitchers(int)
GetScaleFactor(uint *)
CanReceiveInput(int *)
GetCompatibilityPolicyType(APPLICATION_VIEW_COMPATIBILITY_POLICY *)
SetCompatibilityPolicyType(APPLICATION_VIEW_COMPATIBILITY_POLICY)
GetPositionerPriority(IShellPositionerPriority * *)
SetPositionerPriority(IShellPositionerPriority *)
GetSizeConstraints(IImmersiveMonitor *,tagSIZE *,tagSIZE *)
GetSizeConstraintsForDpi(uint,tagSIZE *,tagSIZE *)
SetSizeConstraintsForDpi(uint const *,tagSIZE const *,tagSIZE const *)
QuerySizeConstraintsFromApp(void)
OnMinSizePreferencesUpdated(HWND__ *)
ApplyOperation(IApplicationViewOperation *)
IsTray(int *)
IsInHighZOrderBand(int *)
IsSplashScreenPresented(int *)
Flash(void)
GetRootSwitchableOwner(IApplicationView * *)
EnumerateOwnershipTree(IObjectArray * *)
GetEnterpriseId(ushort * *)
GetEnterpriseChromePreference(int *)
IsMirrored(int *)
GetFrameworkViewType(FRAMEWORK_VIEW_TYPE *)
GetCanTab(int *)
SetCanTab(int)
GetIsTabbed(int *)
SetIsTabbed(int)
RefreshCanTab(void)
GetIsOccluded(int *)
SetIsOccluded(int)
UpdateEngagementFlags(VIEW_ENGAGEMENT_FLAGS,VIEW_ENGAGEMENT_FLAGS)
SetForceActiveWindowAppearance(int)
GetLastActivationFILETIME(_FILETIME *)
GetPersistingStateName(ushort * *)
v_SetCloak(APPLICATION_VIEW_CLOAK_TYPE,int)
v_GetNativeWindow(HWND__ * *)
v_RefreshEnterpriseIdIfNeeded(void)
v_GetProcessId(ulong *)

@mzomparelli
Copy link

The ordering of IVirtualDesktop has changed.

You have them all except your unknown's name is IsRemote and it was moved to the end:

IsViewVisible(IApplicationView *,int *)
GetID(_GUID *)
GetName(HSTRING__ * *)
GetWallpaper(HSTRING__ * *)
IsRemote(int *)

@mzomparelli
Copy link

mzomparelli commented Aug 28, 2023

So those are not the working interfaces either, but that new stuff is still interesting.

Here are some updated interfaces that do work - Note the GUID changes as well
I'm still having issues with the VirtualDesktopNotifications. I'll report back once I figure it out.

[ComImport]
[Guid("A3175F2D-239C-4BD2-8AA0-EEBA8B0B138E")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IVirtualDesktopManagerInternal
{
	int GetCount();

	void MoveViewToDesktop(IApplicationView pView, IVirtualDesktop desktop);

	bool CanViewMoveDesktops(IApplicationView pView);

	IVirtualDesktop GetCurrentDesktop();

	//IObjectArray GetAllCurrentDesktops();

	IObjectArray GetDesktops();

	IVirtualDesktop GetAdjacentDesktop(IVirtualDesktop pDesktopReference, int uDirection);

	void SwitchDesktop(IVirtualDesktop desktop);

	IVirtualDesktop CreateDesktopW();

	void MoveDesktop(IVirtualDesktop desktop, int nIndex);

	void RemoveDesktop(IVirtualDesktop pRemove, IVirtualDesktop pFallbackDesktop);

	IVirtualDesktop FindDesktop(in Guid desktopId);

	void GetDesktopSwitchIncludeExcludeViews(IVirtualDesktop desktop, out IObjectArray o1, out IObjectArray o2);

	void SetDesktopName(IVirtualDesktop desktop, [MarshalAs(UnmanagedType.HString)] string name);

	void SetDesktopWallpaper(IVirtualDesktop desktop, [MarshalAs(UnmanagedType.HString)] string path);

	void UpdateWallpaperPathForAllDesktops([MarshalAs(UnmanagedType.HString)] string path);

	void CopyDesktopState(IApplicationView pView0, IApplicationView pView1);

}
[ComImport]
[Guid("372e1d3b-38d3-42e4-a15b-8ab2b178f513")]
[InterfaceType(ComInterfaceType.InterfaceIsIInspectable)]
public interface IApplicationView
{

	void GetIids(out ulong iidCount, out IntPtr iids);

	void GetRuntimeClassName([MarshalAs(UnmanagedType.HString)] out string className);

	void GetTrustLevel(out IntPtr trustLevel);

	void SetFocus();

	void SwitchTo();

    void TryInvokeBack(ref IntPtr /* IAsyncCallback* */ callback);

    void GetThumbnailWindow(out IntPtr hwnd);

    void GetMonitor(out IntPtr /* IImmersiveMonitor */ immersiveMonitor);

    void GetVisibility(out int visibility);

	void SetCloak(APPLICATION_VIEW_CLOAK_TYPE cloakType, int unknown);

	void GetPosition(ref Guid guid /* GUID for IApplicationViewPosition */, out IntPtr /* IApplicationViewPosition** */ position);

	void SetPosition(ref IntPtr /* IApplicationViewPosition* */ position);

	void InsertAfterWindow(IntPtr hwnd);

	void GetExtendedFramePosition(out Rect rect);

    void GetAppUserModelId([MarshalAs(UnmanagedType.LPWStr)] out string id);

    void SetAppUserModelId(string id);

    void IsEqualByAppUserModelId(string id, out int result);

    void GetViewState(out int state);

    void SetViewState(int state);

    void GetNeediness(out int neediness);

    void GetLastActivationTimestamp(out long timestamp);

    void SetLastActivationTimestamp(long timestamp);

    void GetVirtualDesktopId(out Guid guid);

    void SetVirtualDesktopId(ref Guid guid);

    void GetShowInSwitchers(out int flag);

    void SetShowInSwitchers(int flag);

    void GetScaleFactor(out int factor);

    void CanReceiveInput(out bool canReceiveInput);

    void GetCompatibilityPolicyType(out APPLICATION_VIEW_COMPATIBILITY_POLICY flags);

    void SetCompatibilityPolicyType(APPLICATION_VIEW_COMPATIBILITY_POLICY flags);


    void GetSizeConstraints(IntPtr /* IImmersiveMonitor* */ monitor, out Size size1, out Size size2);

    void GetSizeConstraintsForDpi(int uint1, out Size size1, out Size size2);

    void SetSizeConstraintsForDpi(ref int uint1, ref Size size1, ref Size size2);


    void OnMinSizePreferencesUpdated(IntPtr hwnd);

    void ApplyOperation(ref IntPtr /* IApplicationViewOperation* */ operation);

    void IsTray(out bool isTray);

    void IsInHighZOrderBand(out bool isInHighZOrderBand);

    void IsSplashScreenPresented(out bool isSplashScreenPresented);

    void Flash();

    void GetRootSwitchableOwner(out IApplicationView rootSwitchableOwner);

    void EnumerateOwnershipTree(out IObjectArray ownershipTree);

    void GetEnterpriseId([MarshalAs(UnmanagedType.LPWStr)] out string enterpriseId);

    void IsMirrored(out bool isMirrored);

	void Unknown1(out int unknown); //22621
    void Unknown2(out int unknown); //22621
    void Unknown3(out int unknown); //22621
    void Unknown4(int unknown); //22621
    void Unknown5(out int unknown); //22621
    void Unknown6(int unknown); //22621
    void Unknown7(); //22621
    void Unknown8(out int unknown); //22621
    void Unknown9(int unknown); //22621
    void Unknown10(int unknown, int int2); //22621
    void Unknown11(int unknown); //22621
    void Unknown12(out Size unknown); //22621

}
[ComImport]
[Guid("3F07F4BE-B107-441A-AF0F-39D82529072C")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IVirtualDesktop
{
    bool IsViewVisible(IApplicationView view);

    Guid GetID();

    void GetName([MarshalAs(UnmanagedType.HString)] out string name);

    void GetWallpaperPath([MarshalAs(UnmanagedType.HString)] out string name);

}
[ComImport]
[Guid("B287FA1C-7771-471A-A2DF-9B6B21F0D675")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IVirtualDesktopNotification
{
    void VirtualDesktopCreated(IObjectArray p1, IVirtualDesktop pDesktop);

    void VirtualDesktopDestroyBegin(IObjectArray p1, IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback);

    void VirtualDesktopDestroyFailed(IObjectArray p1, IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback);

    void VirtualDesktopDestroyed(IObjectArray p1, IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback);

   // void Unknown2(int i);

    void VirtualDesktopMoved(IObjectArray p1, IVirtualDesktop pDesktop, int nIndexFrom, int nIndexTo);

    void VirtualDesktopRenamed(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string name);

    void ViewVirtualDesktopChanged(IntPtr pView);

    void CurrentVirtualDesktopChanged(IObjectArray p1, IVirtualDesktop pDesktopOld, IVirtualDesktop pDesktopNew);

    void VirtualDesktopWallpaperChanged(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string path);
}

@mzomparelli
Copy link

I'm pretty sure IVirtualDesktopNotification has two new members as I see them in the dll when I view in IDA. However, I still cannot get the notifications to work. Let me know if you guys figure it out.

[ComImport]
[Guid("B287FA1C-7771-471A-A2DF-9B6B21F0D675")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IVirtualDesktopNotification
{
    void VirtualDesktopCreated(IObjectArray p1, IVirtualDesktop pDesktop);

    void VirtualDesktopDestroyBegin(IObjectArray p1, IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback);

    void VirtualDesktopDestroyFailed(IObjectArray p1, IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback);

    void VirtualDesktopDestroyed(IObjectArray p1, IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback);

    //void Unknown2(int i);

    void VirtualDesktopMoved(IObjectArray p1, IVirtualDesktop pDesktop, int nIndexFrom, int nIndexTo);

    void VirtualDesktopRenamed(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string name);

    void ViewVirtualDesktopChanged(IntPtr pView);

    void CurrentVirtualDesktopChanged(IObjectArray p1, IVirtualDesktop pDesktopOld, IVirtualDesktop pDesktopNew);

    void VirtualDesktopWallpaperChanged(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string path);

    IVirtualDesktop VirtualDesktopSwitched();

    IVirtualDesktop RemoteVirtualDesktopConnected();

}

@mzomparelli
Copy link

I'm so dumb. I forgot to remove the monitor stuff from the notification interface. Thise object arrays are gone now. Here is the updated interface:

[ComImport]
[Guid("B287FA1C-7771-471A-A2DF-9B6B21F0D675")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IVirtualDesktopNotification
{
    void VirtualDesktopCreated(IVirtualDesktop pDesktop);

    void VirtualDesktopDestroyBegin(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback);

    void VirtualDesktopDestroyFailed(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback);

    void VirtualDesktopDestroyed(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback);

    //void Unknown2(int i);

    void VirtualDesktopMoved(IVirtualDesktop pDesktop, int nIndexFrom, int nIndexTo);

    void VirtualDesktopRenamed(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string name);

    void ViewVirtualDesktopChanged(IntPtr pView);

    void CurrentVirtualDesktopChanged(IVirtualDesktop pDesktopOld, IVirtualDesktop pDesktopNew);

    void VirtualDesktopWallpaperChanged(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string path);

    IVirtualDesktop VirtualDesktopSwitched();

    IVirtualDesktop RemoteVirtualDesktopConnected();

}

@mzomparelli
Copy link

mzomparelli commented Aug 28, 2023

I took the liberty to match the interface to what I see in the DLL twinui.pcshell.dll. This fills in all those unknowns we had as well as adds more. I have not tested that these names are the correct names, only that they match up to the DLL and that it compiles and runs on build 22621. It would be nice if someone would test these news ones to see what they do. Specifically the ones that mention remote.

[ComImport]
[Guid("372e1d3b-38d3-42e4-a15b-8ab2b178f513")]
[InterfaceType(ComInterfaceType.InterfaceIsIInspectable)]
public interface IApplicationView
{
	void SetFocus();
	void SwitchTo();
    void TryInvokeBack(ref IntPtr /* IAsyncCallback* */ callback);
    void GetThumbnailWindow(out IntPtr hwnd);
    void GetMonitor(out IntPtr /* IImmersiveMonitor */ immersiveMonitor);
    void GetVisibility(out int visibility);
	void SetCloak(APPLICATION_VIEW_CLOAK_TYPE cloakType, int unknown);
	void GetPosition(ref Guid guid /* GUID for IApplicationViewPosition */, out IntPtr /* IApplicationViewPosition** */ position);
	void SetPosition(ref IntPtr /* IApplicationViewPosition* */ position);
	void InsertAfterWindow(IntPtr hwnd);
	void GetExtendedFramePosition(out Rect rect);
    void GetAppUserModelId([MarshalAs(UnmanagedType.LPWStr)] out string id);
    void SetAppUserModelId(string id);
    void IsEqualByAppUserModelId(string id, out int result);
    void GetViewState(out int state);
    void SetViewState(int state);
    void GetNeediness(out int neediness);
    void GetLastActivationTimestamp(out long timestamp);
    void SetLastActivationTimestamp(long timestamp);
    void GetVirtualDesktopId(out Guid guid);
    void SetVirtualDesktopId(ref Guid guid);
    void GetShowInSwitchers(out int flag);
    void SetShowInSwitchers(int flag);
    void GetScaleFactor(out int factor);
    void CanReceiveInput(out bool canReceiveInput);
    void GetCompatibilityPolicyType(out APPLICATION_VIEW_COMPATIBILITY_POLICY flags);
    void SetCompatibilityPolicyType(APPLICATION_VIEW_COMPATIBILITY_POLICY flags);
    void GetSizeConstraints(IntPtr /* IImmersiveMonitor* */ monitor, out Size size1, out Size size2);
    void GetSizeConstraintsForDpi(int uint1, out Size size1, out Size size2);
    void SetSizeConstraintsForDpi(ref int uint1, ref Size size1, ref Size size2);
    void OnMinSizePreferencesUpdated(IntPtr hwnd);
    void ApplyOperation(ref IntPtr /* IApplicationViewOperation* */ operation);
    void IsTray(out bool isTray);
    void IsInHighZOrderBand(out bool isInHighZOrderBand);
    void IsSplashScreenPresented(out bool isSplashScreenPresented);
    void Flash();
    void GetRootSwitchableOwner(out IApplicationView rootSwitchableOwner);
    void EnumerateOwnershipTree(out IObjectArray ownershipTree);
    void GetEnterpriseId([MarshalAs(UnmanagedType.LPWStr)] out string enterpriseId);
    void GetEnterpriseChromePreference(out int unknown);
    void IsMirrored(out bool isMirrored);
    void GetFrameworkViewType(out int /*FRAMEWORK_VIEW_TYPE*/ unknown);
    void GetCanTab(out int unknown);
    void SetCanTab(int unknown);
    void GetIsTabbed(out int unknown);
    void SetIsTabbed(int unknown);
    void RefreshCanTab();
    void GetIsOccluded(out int unknown);
    void SetIsOccluded(int unknown);
    void UpdateEngagementFlags(int /*VIEW_ENGAGEMENT_FLAGS*/ unknown, int /*VIEW_ENGAGEMENT_FLAGS*/ int2);
    void SetForceActiveWindowAppearance(int unknown);
    void GetLastActivationFILETIME(FILETIME timestamp);
    void GetPersistingStateName([MarshalAs(UnmanagedType.LPWStr)] out string name);
    void v_SetCloak(APPLICATION_VIEW_CLOAK_TYPE cloakType, int unknown);
    void v_RefreshEnterpriseIdIfNeeded();
    void v_GetProcessId(out ulong processId);
	
}

[ComImport]
[Guid("3F07F4BE-B107-441A-AF0F-39D82529072C")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IVirtualDesktop
{
    bool IsViewVisible(IApplicationView view);
    Guid GetID();
    void GetName([MarshalAs(UnmanagedType.HString)] out string name);
    void GetWallpaperPath([MarshalAs(UnmanagedType.HString)] out string name);
    void IsRemote(out bool isRemote);
}


[ComImport]
[Guid("A3175F2D-239C-4BD2-8AA0-EEBA8B0B138E")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IVirtualDesktopManagerInternal
{
	int GetCount();
	void MoveViewToDesktop(IApplicationView pView, IVirtualDesktop desktop);
	bool CanViewMoveDesktops(IApplicationView pView);
	IVirtualDesktop GetCurrentDesktop();
	//IObjectArray GetAllCurrentDesktops();
	IObjectArray GetDesktops();
	IVirtualDesktop GetAdjacentDesktop(IVirtualDesktop pDesktopReference, int uDirection);
	void SwitchDesktop(IVirtualDesktop desktop);
	IVirtualDesktop CreateDesktopW();
	void MoveDesktop(IVirtualDesktop desktop, int nIndex);
	void RemoveDesktop(IVirtualDesktop pRemove, IVirtualDesktop pFallbackDesktop);
	IVirtualDesktop FindDesktop(in Guid desktopId);
	void GetDesktopSwitchIncludeExcludeViews(IVirtualDesktop desktop, out IObjectArray o1, out IObjectArray o2);
	void SetDesktopName(IVirtualDesktop desktop, [MarshalAs(UnmanagedType.HString)] string name);
	void SetDesktopWallpaper(IVirtualDesktop desktop, [MarshalAs(UnmanagedType.HString)] string path);
	void UpdateWallpaperPathForAllDesktops([MarshalAs(UnmanagedType.HString)] string path);
	void CopyDesktopState(IApplicationView pView0, IApplicationView pView1);
    IVirtualDesktop CreateRemoteDesktop([MarshalAs(UnmanagedType.HString)] string name);
    void SwitchRemoteDesktop(IVirtualDesktop desktop);
    void SwitchDesktopWithAnimation(IVirtualDesktop desktop);
    IVirtualDesktop GetLastActiveDesktop();
    void WaitForAnimationToComplete();
}

[ComImport]
[Guid("B287FA1C-7771-471A-A2DF-9B6B21F0D675")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IVirtualDesktopNotification
{
    void VirtualDesktopCreated(IVirtualDesktop pDesktop);
    void VirtualDesktopDestroyBegin(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback);
    void VirtualDesktopDestroyFailed(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback);
    void VirtualDesktopDestroyed(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback);
    void VirtualDesktopMoved(IVirtualDesktop pDesktop, int nIndexFrom, int nIndexTo);
    void VirtualDesktopRenamed(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string name);
    void ViewVirtualDesktopChanged(IntPtr pView);
    void CurrentVirtualDesktopChanged(IVirtualDesktop pDesktopOld, IVirtualDesktop pDesktopNew);
    void VirtualDesktopWallpaperChanged(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string path);
    IVirtualDesktop VirtualDesktopSwitched();
    IVirtualDesktop RemoteVirtualDesktopConnected();
}

@mzomparelli
Copy link

This handy python script will mean we are never in this predicament again

https://github.com/t1m0thyj/GetVirtualDesktopAPI_DIA

@Slion
Copy link

Slion commented Aug 28, 2023

This handy python script will mean we are never in this predicament again

https://github.com/t1m0thyj/GetVirtualDesktopAPI_DIA

@mzomparelli
That looks most interresting. Feel free to contribute to: https://github.com/Slion/VirtualDesktop.
I just started publishing NuGet packages off that branch since @Grabacr07 as been MIA for a while.
What does DIA stands for? Would be great if we could thoroughly document the whole reverse engineering process.

Related to Grabacr07#76

@sliddington
Copy link

Re: #1 (comment)
My guess ... either related to "Azure Virtual Desktop" but I think that is effectively just a fancy name for a virtual machine.
Or something like you can connect an RDP session to a virtual desktop on an already running machine?

@mzomparelli
Copy link

This handy python script will mean we are never in this predicament again
https://github.com/t1m0thyj/GetVirtualDesktopAPI_DIA

What does DIA stands for?

Debug Interface Access, the dll is part of the 2005 C++ Redistributable.

The method the python used is basically the same I did with IDA Free. I wish I would have found the script first.

@mzomparelli
Copy link

If you are interested you can check out my application for virtual desktops and hotkeys. One thing I really like is he DesktopView which is a replacement for TaskView. - https://zvirtualdesktop.com/

I really need to get started on a v2 that uses a more modern forms like WPF.

@mzomparelli
Copy link

Re: #1 (comment) My guess ... either related to "Azure Virtual Desktop" but I think that is effectively just a fancy name for a virtual machine. Or something like you can connect an RDP session to a virtual desktop on an already running machine?

Sounds like something I could use if it works with remote desktop.

@mzomparelli
Copy link

If anyone wants, I have the interfaces for Windows Server 2022.

@Dexterously
Copy link

If you are interested you can check out my application for virtual desktops and hotkeys. One thing I really like is he DesktopView which is a replacement for TaskView. - https://zvirtualdesktop.com/

I really need to get started on a v2 that uses a more modern forms like WPF.

Which library are you using to support Windows 11 Insider?

@mzomparelli
Copy link

I think Win11 insider is the same as Win11 22H2 but I don't have insider to test. I'll work on setting up a VM to test it.

@mzomparelli
Copy link

There are three insider channels. The beta channel appears to be the same build as 22H2.
I guess I'll try the other two.

image

@Dexterously
Copy link

Dexterously commented Aug 29, 2023

There are three insider channels. The beta channel appears to be the same build as 22H2. I guess I'll try the other two.

image

My machine installed KB5029351 update and this codebase no longer works. Any thoughts?

@mzomparelli
Copy link

Run WinVer and tell me what build you have

@Dexterously
Copy link

Run WinVer and tell me what build you have

22621.2215

@mzomparelli
Copy link

that is not an insider build anymore, it's 22H2. You can use the interfaces I provided above for that build. zVirtualDesktop will work with your build.

@Slion
Copy link

Slion commented Aug 30, 2023

@Dexterously Try my fork:
https://github.com/Slion/VirtualDesktop

It's not working on Insider builds but does work with the latest official Win11.

@Slion
Copy link

Slion commented Aug 30, 2023

If anyone wants, I have the interfaces for Windows Server 2022.

It would be fantastic if you could contribute them to: https://github.com/Slion/VirtualDesktop

@Dexterously
Copy link

@Dexterously Try my fork: https://github.com/Slion/VirtualDesktop

It's not working on Insider builds but does work with the latest official Win11.

The problem I have is that it starting throwing this error today.

I just assumed that it was no longer supported:
image

image

I get these errors running this branch as of right now: https://github.com/Slion/VirtualDesktop

@Slion
Copy link

Slion commented Aug 30, 2023

I'm on 22621.2134 and it seems to be working there. Can you confirm yours is an insider build?

Just did the August update. I'm now on 22621.2215 and it is indeed broken again.

@mzomparelli
Copy link

22621.2215 is not an insider build and the interface I posted in this thread work for it. I'm running 22H2 22621.2215 and I'm not running an insider build. I'm just on the normal user build.

@mzomparelli
Copy link

If anyone wants, I have the interfaces for Windows Server 2022.

It would be fantastic if you could contribute them to: https://github.com/Slion/VirtualDesktop

Let me get my crap together and I'll go check out your repo and see if I can add to it.

@mzomparelli
Copy link

@Dexterously Try my fork: https://github.com/Slion/VirtualDesktop
It's not working on Insider builds but does work with the latest official Win11.

The problem I have is that it starting throwing this error today.

I just assumed that it was no longer supported: image

image

I get these errors running this branch as of right now: https://github.com/Slion/VirtualDesktop

Get more info on this. Which one is throwing the error? It only takes one of the interfaces to be wrong.

@mzomparelli
Copy link

Seems there might be something different between the 22621.2215 builds for insider versus non-insider. A build should be a build though, right?

@mzomparelli
Copy link

can someone send me the twinui.pcshell.dll from that insider build. If you can't attach here then send to [email protected]

@mzomparelli
Copy link

can someone send me the twinui.pcshell.dll from that insider build. If you can't attach here then send to [email protected]

No need for that. I'm installing in Hyper-V. I'll test the other insider builds too.

@Slion
Copy link

Slion commented Aug 30, 2023

Get more info on this. Which one is throwing the error? It only takes one of the interfaces to be wrong.

VirtualDesktopManagerInternal

@Slion
Copy link

Slion commented Aug 30, 2023

Seems there might be something different between the 22621.2215 builds for insider versus non-insider. A build should be a build though, right?

22621.2215 is no insider build. It's just 22H2 August 2023 update.

@Dexterously
Copy link

I'll get more information today. However, I am NOT running an insider build. This just started yesterday.

@Slion
Copy link

Slion commented Aug 30, 2023

I've opened the following ticket to track progress on that 22621.2215 issue:
Slion#1

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.

6 participants