Skip to content
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
64 changes: 64 additions & 0 deletions msipackage/package.wix.in
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,70 @@
</RegistryKey>
</RegistryKey>

<!-- IWSLCSDKTerminationCallback-->
<RegistryKey Root="HKCR" Key="Interface\{86A807EA-F2A1-4382-93E5-09FB5F2F4A31}">

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove once #40767 is merged

<RegistryValue Value="IWSLCSDKTerminationCallback" Type="string" />
<RegistryKey Key="ProxyStubClsid32">
<RegistryValue Value="{4EA0C6DD-E9FF-48E7-994E-13A31D10DC60}" Type="string" />
</RegistryKey>
</RegistryKey>

<!-- IWSLCSDKCrashDumpCallback-->
<RegistryKey Root="HKCR" Key="Interface\{EAA15E20-7FCC-485B-B798-ED4095DBACA5}">
<RegistryValue Value="IWSLCSDKCrashDumpCallback" Type="string" />
<RegistryKey Key="ProxyStubClsid32">
<RegistryValue Value="{4EA0C6DD-E9FF-48E7-994E-13A31D10DC60}" Type="string" />
</RegistryKey>
</RegistryKey>

<!-- IWSLCSDKProgressCallback-->
<RegistryKey Root="HKCR" Key="Interface\{06154F2A-ACA7-461E-94FC-92781BA1F6F6}">
<RegistryValue Value="IWSLCSDKProgressCallback" Type="string" />
<RegistryKey Key="ProxyStubClsid32">
<RegistryValue Value="{4EA0C6DD-E9FF-48E7-994E-13A31D10DC60}" Type="string" />
</RegistryKey>
</RegistryKey>

<!-- IWSLCSDKWarningCallback-->
<RegistryKey Root="HKCR" Key="Interface\{290C58A1-328C-4E90-B09B-0A9D32C40074}">
<RegistryValue Value="IWSLCSDKWarningCallback" Type="string" />
<RegistryKey Key="ProxyStubClsid32">
<RegistryValue Value="{4EA0C6DD-E9FF-48E7-994E-13A31D10DC60}" Type="string" />
</RegistryKey>
</RegistryKey>

<!-- IWSLCSDKProcess-->
<RegistryKey Root="HKCR" Key="Interface\{AC69DD0D-6616-4C4F-91F2-C39D6034EA82}">
<RegistryValue Value="IWSLCSDKProcess" Type="string" />
<RegistryKey Key="ProxyStubClsid32">
<RegistryValue Value="{4EA0C6DD-E9FF-48E7-994E-13A31D10DC60}" Type="string" />
</RegistryKey>
</RegistryKey>

<!-- IWSLCSDKContainer-->
<RegistryKey Root="HKCR" Key="Interface\{8C3C91FA-D550-41B9-AD9D-23DCBF96F549}">
<RegistryValue Value="IWSLCSDKContainer" Type="string" />
<RegistryKey Key="ProxyStubClsid32">
<RegistryValue Value="{4EA0C6DD-E9FF-48E7-994E-13A31D10DC60}" Type="string" />
</RegistryKey>
</RegistryKey>

<!-- IWSLCSDKSession-->
<RegistryKey Root="HKCR" Key="Interface\{DD7B2EF9-AA01-4F21-8A3A-29D394CBB579}">
<RegistryValue Value="IWSLCSDKSession" Type="string" />
<RegistryKey Key="ProxyStubClsid32">
<RegistryValue Value="{4EA0C6DD-E9FF-48E7-994E-13A31D10DC60}" Type="string" />
</RegistryKey>
</RegistryKey>

<!-- IWSLCSDKSessionManager-->
<RegistryKey Root="HKCR" Key="Interface\{279F2047-DA35-45A3-B671-AFD2302D5D16}">
<RegistryValue Value="IWSLCSDKSessionManager" Type="string" />
<RegistryKey Key="ProxyStubClsid32">
<RegistryValue Value="{4EA0C6DD-E9FF-48E7-994E-13A31D10DC60}" Type="string" />
</RegistryKey>
</RegistryKey>

<File Id="wslcsession.exe" Source="${BIN}/wslcsession.exe" />
</Component>
<Component Id="wslg" Guid="F0C8D6BA-1502-41E7-BF72-D93DFA134731" UninstallWhenSuperseded="yes" DisableRegistryReflection="yes" Bitness="always64">
Expand Down
2 changes: 1 addition & 1 deletion src/windows/WslcSDK/CrashDumpCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Module Name:
Abstract:
Implementation of a type that implements ICrashDumpCallback.
Implementation of a type that implements IWSLCCompatCrashDumpCallback.
--*/
#include "precomp.h"
Expand Down
10 changes: 5 additions & 5 deletions src/windows/WslcSDK/CrashDumpCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ Module Name:

Abstract:

Header for a type that implements ICrashDumpCallback. Bridges the COM
ICrashDumpCallback interface back to the C-style SDK callback registered
Header for a type that implements IWSLCCompatCrashDumpCallback. Bridges the COM
IWSLCCompatCrashDumpCallback interface back to the C-style SDK callback registered
via WslcRegisterSessionCrashDumpCallback.

--*/
#pragma once
#include "wslc.h"
#include "WSLCCompat.h"
#include "wslcsdkprivate.h"
#include <winrt/base.h>

struct CrashDumpCallback : public winrt::implements<CrashDumpCallback, ICrashDumpCallback>
struct CrashDumpCallback : public winrt::implements<CrashDumpCallback, IWSLCCompatCrashDumpCallback>
{
CrashDumpCallback(WslcSessionCrashDumpCallback callback, PVOID context);

// ICrashDumpCallback
// IWSLCCompatCrashDumpCallback
HRESULT STDMETHODCALLTYPE OnCrashDump(_In_ LPCWSTR DumpPath, _In_opt_ LPCSTR ProcessName, _In_ ULONGLONG Pid, _In_ ULONG Signal, _In_ ULONGLONG Timestamp) override;

private:
Expand Down
15 changes: 8 additions & 7 deletions src/windows/WslcSDK/IOCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Module Name:
#include "precomp.h"
#include "WslcsdkPrivate.h"

IOCallback::IOCallback(IWSLCProcess* process, const WslcContainerProcessIOCallbackOptions& options) :
IOCallback::IOCallback(IWSLCCompatProcess* process, const WslcContainerProcessIOCallbackOptions& options) :
m_process(process), m_callbackOptions(std::make_unique<WslcContainerProcessIOCallbackOptions>(options))
{
using namespace wsl::windows::common::io;
Expand Down Expand Up @@ -55,7 +55,7 @@ IOCallback::IOCallback(IWSLCProcess* process, const WslcContainerProcessIOCallba

if (runResult && m_process && m_callbackOptions && m_callbackOptions->onExit)
{
WSLCProcessState state{};
WSLCCompatProcessState state{};
int exitCode = -1;

// Prefer to make the callback even if we don't properly retrieve the exit code.
Expand All @@ -66,7 +66,7 @@ IOCallback::IOCallback(IWSLCProcess* process, const WslcContainerProcessIOCallba
}
else
{
WI_ASSERT(state == WslcProcessStateExited);
WI_ASSERT(state == WSLCCompatProcessStateExited);
}

// Regardless of our ability to get the proper exit code, inform the caller that the process
Expand Down Expand Up @@ -119,11 +119,12 @@ bool IOCallback::HasIOCallback(const WslcContainerProcessIOCallbackOptions& opti
return options.onStdOut || options.onStdErr || options.onExit;
}

wil::unique_handle IOCallback::GetIOHandle(IWSLCProcess* process, WslcProcessIOHandle ioHandle)
wil::unique_handle IOCallback::GetIOHandle(IWSLCCompatProcess* process, WslcProcessIOHandle ioHandle)
{
wsl::windows::common::wslutil::COMOutputHandle handle;
WSLCCompatHandle handle{};

THROW_IF_FAILED(process->GetStdHandle(static_cast<WSLCFD>(static_cast<std::underlying_type_t<WslcProcessIOHandle>>(ioHandle)), &handle));
THROW_IF_FAILED(process->GetStdHandle(static_cast<WSLCCompatFD>(static_cast<std::underlying_type_t<WslcProcessIOHandle>>(ioHandle)), &handle));

return handle.Release();
// The handle value is the same regardless of the union member that was populated.
return wil::unique_handle{handle.Handle.File};
}
8 changes: 4 additions & 4 deletions src/windows/WslcSDK/IOCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Module Name:

--*/
#pragma once
#include "wslc.h"
#include "WSLCCompat.h"
#include "relay.hpp"
#include <thread>

Expand All @@ -21,7 +21,7 @@ struct WslcContainerProcessOptionsInternal;

struct IOCallback
{
IOCallback(IWSLCProcess* process, const WslcContainerProcessIOCallbackOptions& options);
IOCallback(IWSLCCompatProcess* process, const WslcContainerProcessIOCallbackOptions& options);
~IOCallback();

void Cancel();
Expand All @@ -32,10 +32,10 @@ struct IOCallback
static bool HasIOCallback(const WslcContainerProcessOptionsInternal* options);
static bool HasIOCallback(const WslcContainerProcessIOCallbackOptions& options);

static wil::unique_handle GetIOHandle(IWSLCProcess* process, WslcProcessIOHandle ioHandle);
static wil::unique_handle GetIOHandle(IWSLCCompatProcess* process, WslcProcessIOHandle ioHandle);

private:
wil::com_ptr<IWSLCProcess> m_process;
wil::com_ptr<IWSLCCompatProcess> m_process;
std::unique_ptr<WslcContainerProcessIOCallbackOptions> m_callbackOptions;
std::thread m_thread;
wsl::windows::common::io::MultiHandleWait m_io;
Expand Down
2 changes: 1 addition & 1 deletion src/windows/WslcSDK/ProgressCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Module Name:
Abstract:
Implementation of a type that implements IProgressCallback.
Implementation of a type that implements IWSLCCompatProgressCallback.
--*/
#include "precomp.h"
Expand Down
8 changes: 4 additions & 4 deletions src/windows/WslcSDK/ProgressCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ Module Name:

Abstract:

Header for a type that implements IProgressCallback.
Header for a type that implements IWSLCCompatProgressCallback.

--*/
#pragma once
#include "wslc.h"
#include "WSLCCompat.h"
#include "wslcsdkprivate.h"
#include <winrt/base.h>

struct ProgressCallback : public winrt::implements<ProgressCallback, IProgressCallback>
struct ProgressCallback : public winrt::implements<ProgressCallback, IWSLCCompatProgressCallback>
{
ProgressCallback(WslcContainerImageProgressCallback callback, PVOID context);

// IProgressCallback
// IWSLCCompatProgressCallback
HRESULT STDMETHODCALLTYPE OnProgress(LPCSTR Status, LPCSTR Id, ULONGLONG Current, ULONGLONG Total) override;

// Creates a ProgressCallback if the options provides a callback.
Expand Down
10 changes: 5 additions & 5 deletions src/windows/WslcSDK/TerminationCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ Module Name:

Abstract:

Implementation of a type that implements ITerminationCallback.
Implementation of a type that implements IWSLCCompatTerminationCallback.

--*/
#include "precomp.h"
#include "TerminationCallback.h"

namespace {
WslcSessionTerminationReason ConvertReason(WSLCVirtualMachineTerminationReason Reason)
WslcSessionTerminationReason ConvertReason(WSLCCompatVirtualMachineTerminationReason Reason)
{
switch (Reason)
{
case WSLCVirtualMachineTerminationReasonShutdown:
case WSLCCompatVirtualMachineTerminationReasonShutdown:
return WSLC_SESSION_TERMINATION_REASON_SHUTDOWN;
case WSLCVirtualMachineTerminationReasonCrashed:
case WSLCCompatVirtualMachineTerminationReasonCrashed:
return WSLC_SESSION_TERMINATION_REASON_CRASHED;
default:
return WSLC_SESSION_TERMINATION_REASON_UNKNOWN;
Expand All @@ -35,7 +35,7 @@ TerminationCallback::TerminationCallback(WslcSessionTerminationCallback callback
}

// TODO: Details from the runtime are dropped; should the SDK callback function be updated to include the reasons string?
HRESULT STDMETHODCALLTYPE TerminationCallback::OnTermination(WSLCVirtualMachineTerminationReason Reason, LPCWSTR)
HRESULT STDMETHODCALLTYPE TerminationCallback::OnTermination(WSLCCompatVirtualMachineTerminationReason Reason, LPCWSTR)
{
if (m_callback)
{
Expand Down
10 changes: 5 additions & 5 deletions src/windows/WslcSDK/TerminationCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ Module Name:

Abstract:

Header for a type that implements ITerminationCallback.
Header for a type that implements IWSLCCompatTerminationCallback.

--*/
#pragma once
#include "wslc.h"
#include "WSLCCompat.h"
#include "wslcsdkprivate.h"
#include <winrt/base.h>

struct TerminationCallback : public winrt::implements<TerminationCallback, ITerminationCallback>
struct TerminationCallback : public winrt::implements<TerminationCallback, IWSLCCompatTerminationCallback>
{
TerminationCallback(WslcSessionTerminationCallback callback, PVOID context);

// ITerminationCallback
HRESULT STDMETHODCALLTYPE OnTermination(WSLCVirtualMachineTerminationReason Reason, LPCWSTR Details) override;
// IWSLCCompatTerminationCallback
HRESULT STDMETHODCALLTYPE OnTermination(WSLCCompatVirtualMachineTerminationReason Reason, LPCWSTR Details) override;

// Creates a TerminationCallback if the options provides a callback.
static winrt::com_ptr<TerminationCallback> CreateIf(const WslcSessionOptionsInternal* options);
Expand Down
12 changes: 6 additions & 6 deletions src/windows/WslcSDK/WslcsdkPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Module Name:
#pragma once
#include <windows.h>
#include "wslcsdk.h"
#include "wslc.h"
#include "WSLCCompat.h"
#include "IOCallback.h"
#include <stdint.h>
#include <wil/com.h> // COM helpers
Expand Down Expand Up @@ -106,8 +106,8 @@ const WslcContainerOptionsInternal* GetInternalType(const WslcContainerSettings*
// Use to allocate the actual objects on the heap to keep it alive.
struct WslcSessionImpl
{
wil::com_ptr<IWSLCSession> session;
wil::com_ptr<ITerminationCallback> terminationCallback;
wil::com_ptr<IWSLCCompatSession> session;
wil::com_ptr<IWSLCCompatTerminationCallback> terminationCallback;
};

WslcSessionImpl* GetInternalType(WslcSession handle);
Expand All @@ -116,15 +116,15 @@ WslcSessionImpl* GetInternalType(WslcSession handle);
// subscription whose release unregisters the callback.
struct WslcCrashDumpSubscriptionImpl
{
wil::com_ptr<ICrashDumpCallback> callback;
wil::com_ptr<IWSLCCompatCrashDumpCallback> callback;
wil::com_ptr<IUnknown> subscription;
};

WslcCrashDumpSubscriptionImpl* GetInternalType(WslcCrashDumpSubscription handle);

struct WslcContainerImpl
{
wil::com_ptr<IWSLCContainer> container;
wil::com_ptr<IWSLCCompatContainer> container;
WslcContainerProcessIOCallbackOptions ioCallbackOptions{};
std::atomic<std::shared_ptr<IOCallback>> ioCallbacks;
};
Expand All @@ -133,7 +133,7 @@ WslcContainerImpl* GetInternalType(WslcContainer handle);

struct WslcProcessImpl
{
wil::com_ptr<IWSLCProcess> process;
wil::com_ptr<IWSLCCompatProcess> process;
std::shared_ptr<IOCallback> ioCallbacks;
};

Expand Down
Loading