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

Staging - 4/10/24 #2583

Merged
merged 22 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8faf847
Add Hyper-V settings card styled adaptive cards (#2489)
bbonaby Apr 5, 2024
584e038
Add SupportedInteraces back into CoreExtension (#2542)
krschau Apr 5, 2024
2e53127
switch classIds to point to correct extension (#2543)
bbonaby Apr 5, 2024
0db3cfb
Add initial environments creation flow to the machine configuration t…
bbonaby Apr 5, 2024
886ec80
Workaround on accessibility bug on SettingsCard (#2525)
guimafelipe Apr 5, 2024
3e77990
Use Package and Extension display names (#2544)
krschau Apr 8, 2024
bbd93a0
Announcing removing widgets from dashboard (#2537)
guimafelipe Apr 8, 2024
efdffbc
Adding AutomationProperties.Name string to dashboard page (#2545)
guimafelipe Apr 8, 2024
cfd0cb0
Finish UI for environments creation (#2539)
bbonaby Apr 9, 2024
601cc3b
Modify all projects to use new RID definition (#2531)
jaholme Apr 9, 2024
78fde75
Making icon text AccessibilityView raw (#2564)
guimafelipe Apr 9, 2024
a4c1829
Fix timestamp log format (#2568)
dkbennett Apr 9, 2024
13fe40e
Changing Select to Invoke button action (#2555)
guimafelipe Apr 9, 2024
690127e
Fix DevSetupAgent logging and some other fixes. (#2566)
sshilov7 Apr 9, 2024
b747810
Correctly show/hide experimental features in stable builds (#2572)
EricJohnson327 Apr 10, 2024
05ddcd8
Using Content in SecondaryWindow (#2571)
dhoehna Apr 10, 2024
79ed0a9
Fix exception logging (#2578)
dkbennett Apr 10, 2024
f8e0dc4
Handle a missing PropertySet gracefully (#2579)
krschau Apr 10, 2024
ebfbe69
Adding tooltip to config buttons (#2559)
dhoehna Apr 10, 2024
d272c99
Edit dialog's "Browse" button works at 225% text scaling. (#2562)
dhoehna Apr 10, 2024
48d70f2
More caches added, other improvements (#2551)
SohamDas2021 Apr 10, 2024
449ae55
Adding Azure extension package (#2580)
dhoehna Apr 10, 2024
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
5 changes: 3 additions & 2 deletions .github/policies/moderatorTriggers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ configuration:
reply: >-
Hi @${issueAuthor}. It would be helpful for us if you could share your Dev Home logs.
These logs can be found at
`%LOCALAPPDATA%\Packages\Microsoft.Windows.DevHome_8wekyb3d8bbwe\TempState` and
`%LOCALAPPDATA%\Packages\Microsoft.Windows.DevHomeGitHubExtension_8wekyb3d8bbwe\TempState`.
`%LOCALAPPDATA%\Packages\Microsoft.Windows.DevHome_8wekyb3d8bbwe\TempState`,
`%LOCALAPPDATA%\Packages\Microsoft.Windows.DevHomeGitHubExtension_8wekyb3d8bbwe\TempState`, and
`%LOCALAPPDATA%\Packages\Microsoft.Windows.DevHomeAzureExtension_8wekyb3d8bbwe\TempState`.
You can share these folders via a OneDrive link or zip them and attach them to a
comment here. If you share this way, you may want to look through the logs in case
there are any details included that you would like to remove (for example, private
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/DevHome-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Compress_DevSetupAgent_x86
if: ${{ matrix.platform != 'arm64' }}
shell: pwsh
run: Compress-Archive -Force -Path HyperVExtension\src\DevSetupAgent\bin\x86\${{ matrix.configuration }}\net8.0-windows10.0.22621.0\win10-x86\* -DestinationPath "HyperVExtension\src\DevSetupAgent\bin\x86\${{ matrix.configuration }}\DevSetupAgent_x86.zip"
run: Compress-Archive -Force -Path HyperVExtension\src\DevSetupAgent\bin\x86\${{ matrix.configuration }}\net8.0-windows10.0.22621.0\win-x86\* -DestinationPath "HyperVExtension\src\DevSetupAgent\bin\x86\${{ matrix.configuration }}\DevSetupAgent_x86.zip"

- name: Build_DevSetupAgent_arm64
if: ${{ matrix.platform == 'arm64' }}
Expand All @@ -81,7 +81,7 @@ jobs:
- name: Compress_DevSetupAgent_arm64
if: ${{ matrix.platform == 'arm64' }}
shell: pwsh
run: Compress-Archive -Force -Path HyperVExtension\src\DevSetupAgent\bin\arm64\${{ matrix.configuration }}\net8.0-windows10.0.22621.0\win10-arm64\* -DestinationPath "HyperVExtension\src\DevSetupAgent\bin\arm64\${{ matrix.configuration }}\DevSetupAgent_arm64.zip"
run: Compress-Archive -Force -Path HyperVExtension\src\DevSetupAgent\bin\arm64\${{ matrix.configuration }}\net8.0-windows10.0.22621.0\win-arm64\* -DestinationPath "HyperVExtension\src\DevSetupAgent\bin\arm64\${{ matrix.configuration }}\DevSetupAgent_arm64.zip"

- name: Build_DevHome
run: cmd /c "$env:VSDevCmd" "&" msbuild /p:Configuration=${{ matrix.configuration }},Platform=${{ matrix.platform }} DevHome.sln
Expand Down
10 changes: 2 additions & 8 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>Recommended</AnalysisMode>
<PlatformTarget>$(Platform)</PlatformTarget>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

<!--
Expand All @@ -38,12 +39,5 @@
<Compile Condition="$(MSBuildProjectName) == 'DevHomeStub'" Include="$(MSBuildThisFileDirectory)\codeAnalysis\StubSuppressions.cs" Link="GlobalSuppressions.cs" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\codeAnalysis\StyleCop.json" Link="StyleCop.json" />
</ItemGroup>
<!-- Needed for reverting back to pre-.NET 8 method of Host using the RID graph to determine assets -->
<!-- https://learn.microsoft.com/en-us/dotnet/core/compatibility/deployment/8.0/rid-asset-list -->
<PropertyGroup>
<UseRidGraph>true</UseRidGraph>
</PropertyGroup>
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Runtime.Loader.UseRidGraph" Value="true" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion HyperVExtension/BuildDevSetupAgentHelper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Try {
& $msbuildPath $msbuildArgs

# SDK version and .NEt version needs to stay in sync with ToolingVersion.props, DevSetupEngineIdl.vcxproj, and DevHome-CL.yaml
$binariesOutputPath = (Join-Path $env:Build_RootDirectory "HyperVExtension\src\DevSetupAgent\bin\$Platform\$Configuration\net8.0-windows10.0.22621.0\win10-$Platform\*")
$binariesOutputPath = (Join-Path $env:Build_RootDirectory "HyperVExtension\src\DevSetupAgent\bin\$Platform\$Configuration\net8.0-windows10.0.22621.0\win-$Platform\*")
$zipOutputPath = (Join-Path $env:Build_RootDirectory "HyperVExtension\src\DevSetupAgent\bin\$Platform\$Configuration\DevSetupAgent_$Platform.zip")

Compress-Archive -Force -Path $binariesOutputPath $zipOutputPath
Expand Down
4 changes: 2 additions & 2 deletions HyperVExtension/src/DevSetupAgent/DevAgentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ protected async override Task ExecuteAsync(CancellationToken stoppingToken)
}
catch (Exception ex)
{
_log.Error($"Exception in DevAgentService.", ex);
_log.Error(ex, $"Exception in DevAgentService.");
}
}
}
catch (Exception ex)
{
_log.Error($"Failed to run DevSetupAgent.", ex);
_log.Error(ex, $"Failed to run DevSetupAgent.");
throw;
}
finally
Expand Down
4 changes: 2 additions & 2 deletions HyperVExtension/src/DevSetupAgent/DevSetupAgent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<UserSecretsId>dotnet-DevSetupAgent-674f51cd-70a6-4b78-8376-66efbf84c412</UserSecretsId>
<BuildRing Condition="'$(BuildRing)'==''">Dev</BuildRing>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile Condition="'$(BuildingInsideVisualStudio)' != 'True'">Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<PublishProfile Condition="'$(BuildingInsideVisualStudio)' != 'True'">Properties\PublishProfiles\win-$(Platform).pubxml</PublishProfile>
<SelfContained>true</SelfContained>
</PropertyGroup>

Expand Down
8 changes: 4 additions & 4 deletions HyperVExtension/src/DevSetupAgent/HostRegistryChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ await Task.Run(
}
catch (Exception ex)
{
_log.Error($"Could not write host message. Response ID: {responseMessage.ResponseId}", ex);
_log.Error(ex, $"Could not write host message. Response ID: {responseMessage.ResponseId}");
}
},
stoppingToken);
Expand All @@ -130,7 +130,7 @@ await Task.Run(
}
catch (Exception ex)
{
_log.Error($"Could not delete host message. Response ID: {responseId}", ex);
_log.Error(ex, $"Could not delete host message. Response ID: {responseId}");
}
},
stoppingToken);
Expand Down Expand Up @@ -207,7 +207,7 @@ private RequestMessage TryReadMessage()
}
catch (Exception ex)
{
_log.Error($"Could not read host message {valueName}", ex);
_log.Error(ex, $"Could not read host message {valueName}");
}

MessageHelper.DeleteAllMessages(_registryHiveKey, _fromHostRegistryKeyPath, s[0]);
Expand All @@ -218,7 +218,7 @@ private RequestMessage TryReadMessage()
}
catch (Exception ex)
{
_log.Error("Could not read host message.", ex);
_log.Error(ex, "Could not read host message.");
}

return requestMessage;
Expand Down
21 changes: 21 additions & 0 deletions HyperVExtension/src/DevSetupAgent/Logging.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Windows.Storage;

namespace HyperVExtension.DevSetupAgent;

public class Logging
{
public static readonly string LogExtension = ".dhlog";

public static readonly string LogFolderName = "Logs";

public static readonly string AppName = "DevSetupAgent";

public static readonly string DefaultLogFileName = "hyperv_setup";

private static readonly Lazy<string> _logFolderRoot = new(() => Path.Combine(Path.GetTempPath(), AppName, LogFolderName));

public static readonly string LogFolderRoot = _logFolderRoot.Value;
}
6 changes: 6 additions & 0 deletions HyperVExtension/src/DevSetupAgent/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ CLSCTX
WIN32_ERROR
S_OK
E_FAIL
E_UNEXPECTED
LsaEnumerateLogonSessions
LsaGetLogonSessionData
Windows.Win32.Security.Authentication.Identity.LsaFreeReturnBuffer
SECURITY_LOGON_TYPE
STATUS_SUCCESS
MakeAbsoluteSD
ConvertStringSecurityDescriptorToSecurityDescriptor
LocalAlloc
LocalFree
SDDL_REVISION_1
108 changes: 88 additions & 20 deletions HyperVExtension/src/DevSetupAgent/Program.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,109 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.ComponentModel;
using System.Runtime.InteropServices;
using HyperVExtension.DevSetupAgent;
using HyperVExtension.HostGuestCommunication;
using Serilog;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.Security;
using Windows.Win32.System.Com;

unsafe
{
// TODO: Set real security descriptor to allow access from System+Admns+Interactive Users
var hr = PInvoke.CoInitializeSecurity(
new(null),
-1,
null,
null,
RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_DEFAULT,
RPC_C_IMP_LEVEL.RPC_C_IMP_LEVEL_IDENTIFY,
null,
EOLE_AUTHENTICATION_CAPABILITIES.EOAC_NONE);

if (hr < 0)
{
Marshal.ThrowExceptionForHR(hr);
}
}

// Set up Logging
Environment.SetEnvironmentVariable("DEVHOME_LOGS_ROOT", Path.Join(HyperVExtension.DevSetupEngine.Logging.LogFolderRoot, "HyperV"));
Environment.SetEnvironmentVariable("DEVHOME_LOGS_ROOT", Path.Join(Logging.LogFolderRoot, "HyperV"));
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings_hypervsetupagent.json")
.Build();
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.CreateLogger();

unsafe
{
PSECURITY_DESCRIPTOR absolutSd = new(null);
PSID ownerSid = new(null);
PSID groupSid = new(null);
ACL* dacl = default;
ACL* sacl = default;

try
{
// O:PSG:BU Owner Principal Self, Group Built-in Users
// (A;;0x3;;;SY) Allow Local System
// (A;;0x3;;;IU) Allow Interactive User
var accessPermission = "O:PSG:BUD:(A;;0x3;;;SY)(A;;0x3;;;IU)";
uint securityDescriptorSize;
PInvoke.ConvertStringSecurityDescriptorToSecurityDescriptor(accessPermission, PInvoke.SDDL_REVISION_1, out var securityDescriptor, &securityDescriptorSize);

uint absoluteSdSize = default;
uint daclSize = default;
uint saclSize = default;
uint ownerSize = default;
uint groupSize = default;

if (PInvoke.MakeAbsoluteSD(securityDescriptor, absolutSd, ref absoluteSdSize, null, ref daclSize, null, ref saclSize, ownerSid, ref ownerSize, groupSid, ref groupSize))
{
throw new HResultException(HRESULT.E_UNEXPECTED);
}

var error = Marshal.GetLastWin32Error();
if (error != (int)WIN32_ERROR.ERROR_INSUFFICIENT_BUFFER)
{
throw new Win32Exception(error);
}

absolutSd = new(PInvoke.LocalAlloc(Windows.Win32.System.Memory.LOCAL_ALLOC_FLAGS.LPTR, absoluteSdSize));
dacl = (ACL*)PInvoke.LocalAlloc(Windows.Win32.System.Memory.LOCAL_ALLOC_FLAGS.LPTR, daclSize);
sacl = (ACL*)PInvoke.LocalAlloc(Windows.Win32.System.Memory.LOCAL_ALLOC_FLAGS.LPTR, saclSize);
ownerSid = new(PInvoke.LocalAlloc(Windows.Win32.System.Memory.LOCAL_ALLOC_FLAGS.LPTR, ownerSize));
groupSid = new(PInvoke.LocalAlloc(Windows.Win32.System.Memory.LOCAL_ALLOC_FLAGS.LPTR, groupSize));

if (!PInvoke.MakeAbsoluteSD(securityDescriptor, absolutSd, ref absoluteSdSize, dacl, ref daclSize, sacl, ref saclSize, ownerSid, ref ownerSize, groupSid, ref groupSize))
{
throw new HResultException(Marshal.GetLastWin32Error());
}

var hr = PInvoke.CoInitializeSecurity(
absolutSd,
-1,
null,
null,
RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_DEFAULT,
RPC_C_IMP_LEVEL.RPC_C_IMP_LEVEL_IDENTIFY,
null,
EOLE_AUTHENTICATION_CAPABILITIES.EOAC_NONE);

if (hr < 0)
{
Marshal.ThrowExceptionForHR(hr);
}
}
finally
{
if (sacl != default)
{
PInvoke.LocalFree((HLOCAL)sacl);
}

if (dacl != default)
{
PInvoke.LocalFree((HLOCAL)dacl);
}

if (groupSid != default)
{
PInvoke.LocalFree((HLOCAL)groupSid.Value);
}

if (ownerSid != default)
{
PInvoke.LocalFree((HLOCAL)ownerSid.Value);
}
}
}

var host = Host.CreateDefaultBuilder(args)
.UseWindowsService(options =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>arm64</Platform>
<RuntimeIdentifier>win10-arm64</RuntimeIdentifier>
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x64</Platform>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x86</Platform>
<RuntimeIdentifier>win10-x86</RuntimeIdentifier>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
Expand Down
4 changes: 2 additions & 2 deletions HyperVExtension/src/DevSetupAgent/RegistryWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ public void Start()
}
catch (Exception ex)
{
_log.Error("RegistryChanged delegate failed.", ex);
_log.Error(ex, "RegistryChanged delegate failed.");
}
}
}
}
catch (Exception ex)
{
_log.Error("Registry Watcher thread failed.", ex);
_log.Error(ex, "Registry Watcher thread failed.");
}
});
_log.Information("Registry Watcher thread started.");
Expand Down
2 changes: 1 addition & 1 deletion HyperVExtension/src/DevSetupAgent/RequestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void ProcessRequestQueue(CancellationToken stoppingToken)
}
catch (Exception ex)
{
_log.Error($"Failed to execute request.", ex);
_log.Error(ex, $"Failed to execute request.");
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions HyperVExtension/src/DevSetupAgent/Requests/ErrorRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ namespace HyperVExtension.DevSetupAgent;
/// </summary>
internal class ErrorRequest : IHostRequest
{
public ErrorRequest(IRequestMessage requestMessage)
public ErrorRequest(IRequestMessage requestMessage, Exception? ex = null)
{
Timestamp = DateTime.UtcNow;
RequestId = requestMessage.RequestId!;
Error = ex;
}

public virtual uint Version { get; set; } = 1;
Expand All @@ -27,6 +28,8 @@ public ErrorRequest(IRequestMessage requestMessage)

public virtual IHostResponse Execute(ProgressHandler progressHandler, CancellationToken stoppingToken)
{
return new ErrorResponse(RequestId);
return new ErrorResponse(RequestId, Error);
}

private Exception? Error { get; }
}
3 changes: 1 addition & 2 deletions HyperVExtension/src/DevSetupAgent/Requests/RequestFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public IHostRequest CreateRequest(IRequestContext requestContext)
{
if (_requestFactories.TryGetValue(requestType, out var createRequest))
{
// TODO: Try/catch error.
requestContext.JsonData = requestJson!;
return createRequest(requestContext);
}
Expand All @@ -65,7 +64,7 @@ public IHostRequest CreateRequest(IRequestContext requestContext)
{
var messageId = requestContext.RequestMessage.RequestId ?? "<unknown>";
var requestData = requestContext.RequestMessage.RequestData ?? "<unknown>";
_log.Error($"Error processing message. Message ID: {messageId}. Request data: {requestData}", ex);
_log.Error(ex, $"Error processing message. Message ID: {messageId}. Request data: {requestData}");
return new ErrorRequest(requestContext.RequestMessage);
}
}
Expand Down
Loading
Loading