Skip to content

Commit

Permalink
initial implementation; UWP does not work yet
Browse files Browse the repository at this point in the history
  • Loading branch information
lostmsu committed Apr 14, 2023
1 parent 1d59e65 commit 5625540
Show file tree
Hide file tree
Showing 31 changed files with 688 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
<PathToXAMLWinRTImplementations>AppContainerTest\</PathToXAMLWinRTImplementations>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
<PropertyGroup>
<ProjectGuid>ace7c503-878e-4c66-8b62-33ed3830f31a</ProjectGuid>
<TargetPlatformVersion>10.0.22621.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<AssetTargetFallback>net6.0-windows$(TargetPlatformVersion);$(AssetTargetFallback)</AssetTargetFallback>
<DefaultLanguage>en-US</DefaultLanguage>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
<EntryPointProjectUniqueName>..\AppContainerTest\AppContainerTest.csproj</EntryPointProjectUniqueName>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Content Include="Images\SplashScreen.scale-200.png" />
<Content Include="Images\LockScreenLogo.scale-200.png" />
<Content Include="Images\Square150x150Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Images\StoreLogo.png" />
<Content Include="Images\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AppContainerTest\AppContainerTest.csproj">
<SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
<PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
<TrustLevel>Partial</TrustLevel>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="[1.2.221109.1]">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="[10.0.22621.755]">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions AppContainerTest/AppContainerTest (Package)/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">

<Identity
Name="fc793027-d487-40c0-899e-66562fd62f8c"
Publisher="CN=lost"
Version="1.0.0.0" />

<mp:PhoneIdentity
PhoneProductId="fc793027-d487-40c0-899e-66562fd62f8c"
PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
<DisplayName>AppContainerTest (Package)</DisplayName>
<PublisherDisplayName>lost</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>

<Resources>
<Resource Language="x-generate"/>
</Resources>

<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="AppContainerTest (Package)"
Description="AppContainerTest (Package)"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>

<Capabilities>
</Capabilities>
</Package>
17 changes: 17 additions & 0 deletions AppContainerTest/AppContainerTest/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. -->

<Application
x:Class="AppContainerTest.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
</ResourceDictionary>
</Application.Resources>
</Application>
27 changes: 27 additions & 0 deletions AppContainerTest/AppContainerTest/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace AppContainerTest;

using Microsoft.UI.Xaml;

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App: Application {
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App() {
this.InitializeComponent();
}

/// <summary>
/// Invoked when the application is launched.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs args) {
this.mainWindow = new MainWindow();
this.mainWindow.Activate();
}

Window mainWindow;
}
22 changes: 22 additions & 0 deletions AppContainerTest/AppContainerTest/AppContainerTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>AppContainerTest</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;ARM64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<UseWinUI>true</UseWinUI>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.221109.1" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\PrivateNamespaces.csproj" />
</ItemGroup>
</Project>
19 changes: 19 additions & 0 deletions AppContainerTest/AppContainerTest/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. -->

<Window
x:Class="AppContainerTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBox x:Name="Family" IsReadOnly="True"/>
<TextBox x:Name="BoundaryName" />
<TextBox x:Name="Path" />
<Button Click="Button_Click">Click Me</Button>
<TextBlock x:Name="Error" Foreground="Red" />
</StackPanel>
</Window>
44 changes: 44 additions & 0 deletions AppContainerTest/AppContainerTest/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
namespace AppContainerTest;

using System;
using System.Diagnostics;
using System.Security.Principal;
using System.Threading;

using LostTech.Win32.PrivateNamespaces;

using Microsoft.UI.Xaml;

using Windows.ApplicationModel;

public sealed partial class MainWindow: Window {
public MainWindow() {
this.InitializeComponent();

this.Family.Text = Package.Current.Id.FamilyName;
}

void Button_Click(object sender, RoutedEventArgs e) {
try {
string[] parts = this.Path.Text.Split('\\', StringSplitOptions.RemoveEmptyEntries);
Debug.Assert(parts.Length == 2);

using var boundary = new BoundaryDescriptor(
this.BoundaryName.Text,
BoundaryDescriptor.CreateFlags.AddAppContainerSID);
boundary.Add(WellKnownSidType.WorldSid);
boundary.Add(WellKnownSidType.WinLowLabelSid);

using var ns = PrivateNamespace.Open(boundary, parts[0]);
try {
using var semaphore = Semaphore.OpenExisting(this.Path.Text);
semaphore.Release();
this.Error.Text = "";
} catch (Exception ex) {
this.Error.Text = $"unable to operate semaphore: {ex}";
}
} catch (Exception ex) {
this.Error.Text = $"unable to open private namespace: {ex}";
}
}
}
27 changes: 27 additions & 0 deletions AppContainerTest/AppContainerTest/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="AppContainerTest.app"/>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below informs the system that this application is compatible with OS features first introduced in Windows 8.
For more info see https://docs.microsoft.com/windows/win32/sysinfo/targeting-your-application-at-windows-8-1
It is also necessary to support features in unpackaged applications, for example the custom titlebar implementation.-->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>

<application xmlns="urn:schemas-microsoft-com:asm.v3"
xmlns:settings2005="http://schemas.microsoft.com/SMI/2005/WindowsSettings"
xmlns:settings="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<windowsSettings>
<!-- The combination of below two tags have the following effect:
1) Per-Monitor for >= Windows 10 Anniversary Update
2) System < Windows 10 Anniversary Update
-->
<settings2005:dpiAware>true/PM</settings2005:dpiAware>
<settings:dpiAwareness>PerMonitorV2, PerMonitor</settings:dpiAwareness>
</windowsSettings>
</application>
</assembly>
Loading

0 comments on commit 5625540

Please sign in to comment.