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

Bump WinUIEx and Microsoft.WindowsAppSDK #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions About/Rebound.About.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.0-prerelease.240722.1" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240829007" />
<PackageReference Include="System.Management" Version="9.0.0-rc.1.24431.7" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="WinUIEx" Version="2.4.2" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions Cleanup/Rebound.Cleanup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.1" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240829007" />
<PackageReference Include="WinUIEx" Version="2.4.2" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions Defrag/Rebound.Defrag.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.5" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2646-prerelease" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240829007" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Diagnostics.EventLog" Version="9.0.0-preview.6.24327.7" />
<PackageReference Include="System.Management" Version="8.0.0" />
<PackageReference Include="TaskScheduler" Version="2.11.0" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="WinUIEx" Version="2.4.2" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.0-prerelease.240722.1" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240829007" />
<PackageReference Include="System.Drawing.Common" Version="8.0.8" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="WinUIEx" Version="2.4.2" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions Helpers/Rebound.Helpers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2646-prerelease" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240829007" />
<PackageReference Include="WinUIEx" Version="2.4.2" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Rebound/Rebound.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@
<PackageReference Include="Ivirius.UI.Controls" Version="0.2.0-prerelease" />
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.2.1-experimental2" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240829007" />
<PackageReference Include="System.Drawing.Common" Version="8.0.8" />
<PackageReference Include="System.Management" Version="9.0.0-rc.1.24431.7" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="WinUIEx" Version="2.4.2" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions Run/Rebound.Run.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.3" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240829007" />
<PackageReference Include="TaskScheduler" Version="2.11.0" />
<PackageReference Include="WindowsDisplayAPI" Version="1.3.0.13" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="WinUIEx" Version="2.4.2" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions SysInfo/Rebound.SysInfo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<Manifest Include="$(ApplicationManifest)" />
<PackageReference Include="Ivirius.UI.Controls" Version="0.1.1-prerelease" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240829007" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.0" />
<PackageReference Include="System.Management" Version="9.0.0-preview.6.24327.7" />
<PackageReference Include="WinUICommunity.Win2D" Version="6.9.0" />
Expand All @@ -52,7 +52,7 @@
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="WinUIEx" Version="2.4.2" />
</ItemGroup>
<!--
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
Expand Down
2 changes: 1 addition & 1 deletion TrustedPlatform/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
FontWeight="Normal"
Foreground="{Binding Foreground, ElementName=WindowTitle}"
Opacity="0.5"
Text=" v0.0.3"
Text=" v0.0.4"
TextTrimming="CharacterEllipsis" />
</StackPanel>
<StackPanel
Expand Down
109 changes: 69 additions & 40 deletions TrustedPlatform/Models/TpmManager.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Management;
using System.Text;
using Tpm2Lib;
using Windows.Devices.Spi;

public class TpmManager : INotifyPropertyChanged
{
private string _manufacturerName;
private string _manufacturerVersion;
private string _specificationVersion;
private string _status;
private string _tpmSubVersion;
private string _pcClientSpecVersion;
private string _pcrValues;
public string _manufacturerName;
public string _manufacturerVersion;
public string _specificationVersion;
public string _status;
public string _tpmSubVersion;
public string _pcClientSpecVersion;
public string _pcrValues;

public string ManufacturerName
{
Expand Down Expand Up @@ -85,40 +90,33 @@ private set

public TpmManager()
{
GetTpmInfo();
tpmDevice = new TbsDevice(); // or whichever device you are using
tpmDevice.Connect(); // No assignment, just calling the method
tpm = new Tpm2(tpmDevice);
GetTpmInfo(); // No assignment, just calling the method
}

public void RefreshTpmInfo()
{
GetTpmInfo();
GetTpmInfo(); // No assignment, just calling the method
}

public List<string> GetTpmInfo()
private void GetTpmInfo()
{
try
{
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\CIMV2\Security\MicrosoftTpm", "SELECT * FROM Win32_Tpm"))
{
foreach (ManagementObject queryObj in searcher.Get())
{
return new List<string>
{
queryObj["ManufacturerID"] != null ? ConvertManufacturerIdToName((uint)queryObj["ManufacturerID"]) : "Unknown",
queryObj["ManufacturerVersion"]?.ToString() ?? "Unknown",
queryObj["SpecVersion"]?.ToString() ?? "Unknown",
queryObj["ManufacturerVersion"]?.ToString() ?? "Unknown",
queryObj["SpecVersion"]?.ToString() ?? "Unknown",
GetPcrValues(),
queryObj["IsActivated_InitialValue"] != null && (bool)queryObj["IsActivated_InitialValue"] ? "Ready" : "Not Ready"
};
/*ManufacturerName = queryObj["ManufacturerID"] != null ? ConvertManufacturerIdToName((uint)queryObj["ManufacturerID"]) : "Unknown";
ManufacturerName = queryObj["ManufacturerID"] != null ? ConvertManufacturerIdToName((uint)queryObj["ManufacturerID"]) : "Unknown";
ManufacturerVersion = queryObj["ManufacturerVersion"]?.ToString() ?? "Unknown";
SpecificationVersion = queryObj["SpecVersion"]?.ToString() ?? "Unknown";
TpmSubVersion = queryObj["ManufacturerVersion"]?.ToString() ?? "Unknown";
PcClientSpecVersion = queryObj["SpecVersion"]?.ToString() ?? "Unknown";
PcrValues = GetPcrValues();

Status = queryObj["IsActivated_InitialValue"] != null && (bool)queryObj["IsActivated_InitialValue"] ? "Ready" : "Not Ready";*/
Status = queryObj["IsActivated_InitialValue"] != null && (bool)queryObj["IsActivated_InitialValue"] ? "Ready" : "Not Ready";
}
}
}
Expand All @@ -133,21 +131,9 @@ public List<string> GetTpmInfo()
Status = "Error communicating with TPM";
Console.WriteLine($"An error occurred while getting TPM information: {ex.Message}");
}

return new List<string>()
{
ManufacturerName,
ManufacturerVersion,
SpecificationVersion,
TpmSubVersion,
PcClientSpecVersion,
PcrValues,

Status,
};
}

private string ConvertManufacturerIdToName(uint manufacturerId)
public string ConvertManufacturerIdToName(uint manufacturerId)
{
var manufacturerStr = string.Empty;
manufacturerStr += (char)((manufacturerId >> 24) & 0xFF);
Expand All @@ -157,11 +143,54 @@ private string ConvertManufacturerIdToName(uint manufacturerId)
return manufacturerStr;
}

private string GetPcrValues()
public Tpm2Device tpmDevice;
public Tpm2 tpm;
public string GetPcrValues()
{
// Placeholder for PCR retrieval logic. This should query TPM for PCR values.
// Requires advanced access via TBS API or TPM library.
return "PCR values are not directly accessible via WMI. Requires advanced TPM API.";
try
{
// Specify PCR selection for reading (e.g., PCR 0, 1, 2)
PcrSelection[] pcrSelectionIn = { new PcrSelection(TpmAlgId.Sha256, new uint[] { 0, 1, 2 }) };
PcrSelection[] pcrSelectionOut;
Tpm2bDigest[] pcrValues;

// Read PCR values
tpm.PcrRead(pcrSelectionIn, out pcrSelectionOut, out pcrValues);

// Build a string to display PCR values
StringBuilder pcrStringBuilder = new StringBuilder();

// Check if pcrValues has entries
if (pcrValues.Length == 0)
{
return "No PCR values available.";
}

for (int i = 0; i < pcrSelectionOut.Length; i++)
{
pcrStringBuilder.AppendLine($"PCR {i}: {BitConverter.ToString(pcrValues[i].buffer)}");
}

return pcrStringBuilder.ToString();
}
catch (TpmException tpmEx)
{
// Log specific TPM-related errors
Debug.WriteLine($"TPM Error retrieving PCR values: {tpmEx.Message} (Error Code:)");
return $"TPM Error: {tpmEx.Message} (Error Code:)";
}
catch (Exception ex)
{
// Log general errors with stack trace
Debug.WriteLine($"General Error retrieving PCR values: {ex.Message}\n{ex.StackTrace}");
return $"Error retrieving PCR values: {ex.Message}";
}
finally
{
// Ensure resources are cleaned up
tpm?.Dispose();
tpmDevice?.Dispose();
}
}

protected virtual void OnPropertyChanged(string propertyName)
Expand Down
117 changes: 117 additions & 0 deletions TrustedPlatform/Rebound - Backup.TrustedPlatform.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.22621.35-preview</WindowsSdkPackageVersion>
<RootNamespace>Rebound.TrustedPlatform</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x64;x86</Platforms>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &gt;= 8">win-x86;win-x64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &lt; 8">win10-x86;win10-x64</RuntimeIdentifiers>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
<Version>0.0.3</Version>
<ImplicitUsings>true</ImplicitUsings>
<LangVersion>Latest</LangVersion>
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<WindowsPackageType>MSIX</WindowsPackageType>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundle>Never</AppxBundle>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<PackageCertificateKeyFile>Rebound.TrustedPlatform_TemporaryKey.pfx</PackageCertificateKeyFile>
</PropertyGroup>

<ItemGroup>
<None Include="Assets\**\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<Content Remove="Assets\Store\icon.ico" />
<Content Remove="Assets\Store\icon.png" />
</ItemGroup>

<ItemGroup>
<None Remove="Assets\icon.ico" />
<None Remove="MainWindow.xaml" />
</ItemGroup>

<ItemGroup>
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

<!--
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
Tools extension to be activated for this project even if the Windows App SDK Nuget
package has not yet been restored.
-->
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<ProjectCapability Include="Msix" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.WinUI.Controls.Sizers" Version="8.1.240821" />
<PackageReference Include="CommunityToolkit.WinUI.Helpers" Version="8.0.240109" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.2.1-experimental2" />
<PackageReference Include="Microsoft.TSS" Version="2.1.1" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.1" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageReference Include="System.Management" Version="9.0.0-rc.1.24431.7" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
</ItemGroup>
<ItemGroup>
<Page Update="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>

<!--
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
Explorer "Package and Publish" context menu entry to be enabled for this project even if
the Windows App SDK Nuget package has not yet been restored.
-->
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
</PropertyGroup>

<ItemGroup>
<None Include="..\Rebound\Assets\AppIcons\Rebound11Icon.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<None Include="..\.github\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Helpers\Rebound.Helpers.csproj" />
</ItemGroup>

<PropertyGroup>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Authors>Riverside, ErrorTek,TheDevil, Lamparter</Authors>
<PackageProjectUrl>https://ivirius.vercel.app</PackageProjectUrl>
<Title>TPM Management</Title>
<PackageId>Riverside.Rebound.TrustedPlatform</PackageId>
<Copyright>Copyright (c) 2024-present Ivirius Community</Copyright>
<Description>Windows 11 done right.</Description>
<PackageIcon>Rebound11Icon.png</PackageIcon>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<AssemblyName>Rebound TPM Management</AssemblyName>
</PropertyGroup>
</Project>
Loading