forked from microsoft/devhome
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an NT service to DevHome (microsoft#3706)
* NT service * Maybe fix build break * Potiential build break fix * PR feedback * Updated architecture doc * Fix build breaks? * Build break fix? * Implementation * Functional * Fix build break * Added fast rundown * Updates * Updates * Enabled Fast COM rundown and lifetime management * PR feedback
- Loading branch information
Showing
25 changed files
with
934 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
service/DevHome.Service.Projection/DevHome.Service.Projection.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="$(SolutionDir)ToolingVersions.props" /> | ||
<Import Project="$(SolutionDir)Directory.CppBuild.props" /> | ||
<PropertyGroup> | ||
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<CsWinRTInputs Include="..\DevHome.Service.IDL\Generated Files\DevHome.Service.winmd" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Devhome.Service.IDL\Devhome.Service.IDL.vcxproj" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<CsWinRTIncludes>DevHome.Service</CsWinRTIncludes> | ||
<CsWinRTGeneratedFilesDir>$(SolutionDir)DevHome.Service.Projection\bin\$(Platform)\$(Configuration)\</CsWinRTGeneratedFilesDir> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Runtime.InteropServices; | ||
using DevHome.Service; | ||
using Windows.Win32.Foundation; | ||
using WinRT; | ||
|
||
namespace COMRegistration; | ||
|
||
[ComVisible(true)] | ||
public class BasicClassWinRTFactory<T> : IClassFactory | ||
where T : new() | ||
{ | ||
public BasicClassWinRTFactory() | ||
{ | ||
} | ||
|
||
public int CreateInstance(IntPtr pUnkOuter, ref Guid riid, out IntPtr ppvObject) | ||
{ | ||
ppvObject = IntPtr.Zero; | ||
|
||
if (pUnkOuter != IntPtr.Zero) | ||
{ | ||
Marshal.ThrowExceptionForHR(HRESULT.CLASS_E_NOAGGREGATION); | ||
} | ||
|
||
if (riid == typeof(T).GUID || riid == Guid.Parse(Guids.IUnknown)) | ||
{ | ||
try | ||
{ | ||
// Create the instance of the WinRT object | ||
ppvObject = MarshalInspectable<T>.FromManaged(new T()); | ||
} | ||
catch (Exception) | ||
{ | ||
// We failed creating an object (possibly due to access denied). If we were just spun up | ||
// to handle this (failed) activation, shut down our service. | ||
if (ServiceLifetimeController.CanUnload()) | ||
{ | ||
WindowsBackgroundService.Stop(); | ||
} | ||
|
||
throw; | ||
} | ||
} | ||
else | ||
{ | ||
// The object that ppvObject points to does not support the | ||
// interface identified by riid. | ||
Marshal.ThrowExceptionForHR(HRESULT.E_NOINTERFACE); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int IClassFactory.LockServer(bool fLock) | ||
{ | ||
return 0; | ||
} | ||
} | ||
|
||
internal static class Guids | ||
{ | ||
public const string IClassFactory = "00000001-0000-0000-C000-000000000046"; | ||
public const string IUnknown = "00000000-0000-0000-C000-000000000046"; | ||
} | ||
|
||
// IClassFactory declaration | ||
[ComImport] | ||
[ComVisible(false)] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
[Guid(Guids.IClassFactory)] | ||
internal interface IClassFactory | ||
{ | ||
[PreserveSig] | ||
int CreateInstance(IntPtr pUnkOuter, ref Guid riid, out IntPtr ppvObject); | ||
|
||
[PreserveSig] | ||
int LockServer(bool fLock); | ||
} |
Oops, something went wrong.