Skip to content

Commit

Permalink
Add VBS attribute and more debugging projects
Browse files Browse the repository at this point in the history
  • Loading branch information
gus33000 committed Feb 22, 2024
1 parent 0abf201 commit b82fc15
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 5 deletions.
46 changes: 46 additions & 0 deletions UUPMediaCreator.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.StoreServices.Dis
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnifiedUpdatePlatform.Services.Temp", "src\TempManager\UnifiedUpdatePlatform.Services.Temp.csproj", "{1AAC4923-A4E5-41D9-87FA-CFB028F802E5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Windows.Internal.Flighting", "src\Windows.Internal.Flighting\Windows.Internal.Flighting.csproj", "{B86CE874-B470-4294-BF98-21BB603E1F46}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Playground", "src\Applications\Playground\Playground.csproj", "{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -373,6 +377,46 @@ Global
{1AAC4923-A4E5-41D9-87FA-CFB028F802E5}.Release|x64.Build.0 = Release|Any CPU
{1AAC4923-A4E5-41D9-87FA-CFB028F802E5}.Release|x86.ActiveCfg = Release|Any CPU
{1AAC4923-A4E5-41D9-87FA-CFB028F802E5}.Release|x86.Build.0 = Release|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Debug|ARM.ActiveCfg = Debug|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Debug|ARM.Build.0 = Debug|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Debug|arm64.ActiveCfg = Debug|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Debug|arm64.Build.0 = Debug|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Debug|x64.ActiveCfg = Debug|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Debug|x64.Build.0 = Debug|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Debug|x86.ActiveCfg = Debug|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Debug|x86.Build.0 = Debug|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Release|Any CPU.Build.0 = Release|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Release|ARM.ActiveCfg = Release|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Release|ARM.Build.0 = Release|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Release|arm64.ActiveCfg = Release|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Release|arm64.Build.0 = Release|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Release|x64.ActiveCfg = Release|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Release|x64.Build.0 = Release|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Release|x86.ActiveCfg = Release|Any CPU
{B86CE874-B470-4294-BF98-21BB603E1F46}.Release|x86.Build.0 = Release|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Debug|ARM.ActiveCfg = Debug|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Debug|ARM.Build.0 = Debug|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Debug|arm64.ActiveCfg = Debug|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Debug|arm64.Build.0 = Debug|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Debug|x64.ActiveCfg = Debug|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Debug|x64.Build.0 = Debug|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Debug|x86.ActiveCfg = Debug|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Debug|x86.Build.0 = Debug|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Release|Any CPU.Build.0 = Release|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Release|ARM.ActiveCfg = Release|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Release|ARM.Build.0 = Release|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Release|arm64.ActiveCfg = Release|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Release|arm64.Build.0 = Release|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Release|x64.ActiveCfg = Release|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Release|x64.Build.0 = Release|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Release|x86.ActiveCfg = Release|Any CPU
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -394,6 +438,8 @@ Global
{C5835DCF-1A20-414B-865A-AA3F8CACE62D} = {162FE1A9-890A-4101-AFF8-54F6B1483882}
{09F6A782-B790-4734-82BD-2685AACC489F} = {162FE1A9-890A-4101-AFF8-54F6B1483882}
{1AAC4923-A4E5-41D9-87FA-CFB028F802E5} = {162FE1A9-890A-4101-AFF8-54F6B1483882}
{B86CE874-B470-4294-BF98-21BB603E1F46} = {162FE1A9-890A-4101-AFF8-54F6B1483882}
{CB4B918C-3DBD-40AA-99F7-83EF033DB8A8} = {C4A7DBD6-6FB5-410A-9252-922C7909C82C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FEE89471-4FE8-4620-991F-4EBAD0F4CFEA}
Expand Down
14 changes: 14 additions & 0 deletions src/Applications/Playground/Playground.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0-windows10.0.22621</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Windows.Internal.Flighting\Windows.Internal.Flighting.csproj" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions src/Applications/Playground/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Playground
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine(new Windows.Internal.Flighting.PlatformCTAC("WU_OS", "10.0.26058.1000").UriQuery);
}
}
}
13 changes: 8 additions & 5 deletions src/UnifiedUpdatePlatform.Services.WindowsUpdate/CTAC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,10 @@ public CTAC(OSSkuId ReportingSku,
string ReleaseType,
bool SyncCurrentVersionOnly,
bool IsStore = false,
string ContentType = "Mainline") : base()
string ContentType = "Mainline",
bool IsVbsEnabled = true) : base()
{
BuildCTAC(ReportingSku, ReportingVersion, MachineType, FlightRing, FlightingBranchName, BranchReadinessLevel, CurrentBranch, ReleaseType, SyncCurrentVersionOnly, IsStore, ContentType);
BuildCTAC(ReportingSku, ReportingVersion, MachineType, FlightRing, FlightingBranchName, BranchReadinessLevel, CurrentBranch, ReleaseType, SyncCurrentVersionOnly, IsStore, ContentType, IsVbsEnabled);
}

private void BuildCTAC(
Expand All @@ -305,7 +306,8 @@ private void BuildCTAC(
string ReleaseType,
bool SyncCurrentVersionOnly,
bool IsStore = false,
string content = "Mainline"
string content = "Mainline",
bool IsVbsEnabled = true
)
{
int flightEnabled = FlightRing == "Retail" ? 0 : 1;
Expand Down Expand Up @@ -398,7 +400,7 @@ private void BuildCTAC(
"InstallLanguage=en-US&" +
"OEMName_Uncleaned=MICROSOFTMDG&" +
$"InstallationType={InstallType}&" +
"AttrDataVer=177&" +
"AttrDataVer=264&" +
"IsEdgeWithChromiumInstalled=1&" +
"TimestampEpochString_20H1=1593425114&" +
$"OSVersion={ReportingVersion}&" +
Expand Down Expand Up @@ -459,7 +461,8 @@ private void BuildCTAC(
"UpgradeEligible=1&" +
"Version_RS5=2000000000&" +
$"IsRetailOS={FlightRing == "Retail"}&" +
$"MediaVersion={ReportingVersion}";
$"MediaVersion={ReportingVersion}" +
$"IsVbsEnabled={(IsVbsEnabled ? 1 : 0)}";

if (ReportingSku is OSSkuId.EnterpriseS or OSSkuId.EnterpriseSN || ReportingSku.ToString().Contains("Server", StringComparison.InvariantCultureIgnoreCase))
{
Expand Down
11 changes: 11 additions & 0 deletions src/Windows.Internal.Flighting/NativeMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Runtime.InteropServices;

namespace Windows.Internal.Flighting
{
internal class NativeMethods
{
[DllImport("wincorlib.dll", CharSet = CharSet.Unicode, EntryPoint = "#129", SetLastError = true)]
internal static extern int GetActivationFactoryByPCWSTR(string typeName, ref Guid typeGuid, out IntPtr ppOut);
}
}
87 changes: 87 additions & 0 deletions src/Windows.Internal.Flighting/PlatformCTAC.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace Windows.Internal.Flighting
{
public class PlatformCTAC : IEquatable<PlatformCTAC>
{
private static ClientAttributes ClientAttributes;

public string JSON
{
get
{
ThrowIfFailed(ClientAttributes.ToJsonString(out string value));
return value;
}
}

public string UriQuery
{
get
{
ThrowIfFailed(ClientAttributes.ToUriQueryString(out string value));
return value;
}
}

public readonly string ApplicationIdentifier;

public readonly string ApplicationVersion;

public IReadOnlyDictionary<string, int> AttributeErrors => ClientAttributes.AttributeErrors;

public PlatformCTAC(string ApplicationIdentifier, string ApplicationVersion)
{
this.ApplicationIdentifier = ApplicationIdentifier;
this.ApplicationVersion = ApplicationVersion;

ClientAttributes = GetCurrentClientAttributes();
}

private ClientAttributes GetCurrentClientAttributes()
{
return new ClientAttributes(ApplicationIdentifier, ApplicationVersion);
}

private static void ThrowIfFailed(int hResult)
{
if (hResult < 0)
{
Marshal.ThrowExceptionForHR(hResult);
}
}

public override bool Equals(object obj)
{
return Equals(obj as PlatformCTAC);
}

public bool Equals(PlatformCTAC other)
{
return other is not null &&
JSON == other.JSON &&
UriQuery == other.UriQuery &&
EqualityComparer<IReadOnlyDictionary<string, int>>.Default.Equals(AttributeErrors, other.AttributeErrors);
}

public override int GetHashCode()
{
int hashCode = 1698843082;
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(JSON);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(UriQuery);
hashCode = hashCode * -1521134295 + EqualityComparer<IReadOnlyDictionary<string, int>>.Default.GetHashCode(AttributeErrors);
return hashCode;
}

public static bool operator ==(PlatformCTAC left, PlatformCTAC right)
{
return EqualityComparer<PlatformCTAC>.Default.Equals(left, right);
}

public static bool operator !=(PlatformCTAC left, PlatformCTAC right)
{
return !(left == right);
}
}
}
28 changes: 28 additions & 0 deletions src/Windows.Internal.Flighting/Windows.Internal.Flighting.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0-windows10.0.22621.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.1" />
</ItemGroup>

<ItemGroup>
<Reference Include="Windows.Internal.Flighting">
<HintPath>..\..\winmds\Windows.Internal.Flighting.winmd</HintPath>
<IsWinMDFile>true</IsWinMDFile>
</Reference>
</ItemGroup>

<!--CsWinRT properties-->
<PropertyGroup>
<!--Specify namespaces to create a C# projection for-->
<CsWinRTIncludes>Windows.Internal.Flighting</CsWinRTIncludes>
<!--Set output path for generated source files/projection dll to OutDir (defined in Directory.Build.props)-->
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
</PropertyGroup>

</Project>
38 changes: 38 additions & 0 deletions winmds/Windows.Internal.Flighting.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import "windowscontracts.idl";
import "Windows.Foundation.idl";

namespace Windows.Internal.Flighting
{
[contractversion(1.0)]
apicontract FlightingContract
{
}

[contract(Windows.Internal.Flighting.FlightingContract, 1.0)]
[exclusiveto(Windows.Internal.Flighting.ClientAttributes)]
[uuid(0723a53d-52e6-453b-9361-7826398f0111)]
interface IClientAttributes : IInspectable
{
Int32 ToJsonString(out String JsonString);
Int32 ToUriQueryString(out String UriQueryString);
Windows.Foundation.Collections.IMapView<String, Int32> AttributeErrors { get; };
}

[contract(Windows.Internal.Flighting.FlightingContract, 1.0)]
[exclusiveto(Windows.Internal.Flighting.ClientAttributes)]
[uuid(41845433-1668-4264-8a63-315eb82ab0d6)]
interface IClientAttributesFactory : IInspectable
{
HRESULT GetClientAttributesForApp([in] HSTRING ApplicationId, [in] HSTRING ApplicationVersion, [out] [retval] Windows.Internal.Flighting.ClientAttributes** ClientAttributes);
HRESULT GetClientAttributesFromList([in] Windows.Foundation.Collections.IIterable<HSTRING>* AttributeList, [out] [retval] Windows.Internal.Flighting.ClientAttributes** ClientAttributes);
HRESULT GetClientAttributesForAppEx([in] HSTRING ApplicationId, [in] HSTRING ApplicationVersion, [in] INT32 ClientAttributeFlags, [out] [retval] Windows.Internal.Flighting.ClientAttributes** ClientAttributes);
}

[activatable(Windows.Internal.Flighting.IClientAttributesFactory, Windows.Internal.Flighting.FlightingContract, 1.0)]
[contract(Windows.Internal.Flighting.FlightingContract, 1.0)]
[marshaling_behavior(agile)]
runtimeclass ClientAttributes
{
[default] interface Windows.Internal.Flighting.IClientAttributes;
}
}
Binary file added winmds/Windows.Internal.Flighting.winmd
Binary file not shown.
1 change: 1 addition & 0 deletions winmds/rebuild.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
midlrt Windows.Internal.Flighting.idl /metadata_dir "C:\Program Files (x86)\Windows Kits\10\References\10.0.22621.0\Windows.Foundation.FoundationContract\4.0.0.0"

0 comments on commit b82fc15

Please sign in to comment.