Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

WSLApiLoader to expose missing function #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions DistroLauncher/WslApiLoader.cpp
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ WslApiLoader::WslApiLoader(const std::wstring& distributionName) :
_isDistributionRegistered = (WSL_IS_DISTRIBUTION_REGISTERED)GetProcAddress(_wslApiDll, "WslIsDistributionRegistered");
_registerDistribution = (WSL_REGISTER_DISTRIBUTION)GetProcAddress(_wslApiDll, "WslRegisterDistribution");
_configureDistribution = (WSL_CONFIGURE_DISTRIBUTION)GetProcAddress(_wslApiDll, "WslConfigureDistribution");
_getDistributionConfiguration = (WSL_GET_DISTRIBUTION_CONFIGURATION)GetProcAddress(_wslApiDll, "WslGetDistributionConfiguration");
_launchInteractive = (WSL_LAUNCH_INTERACTIVE)GetProcAddress(_wslApiDll, "WslLaunchInteractive");
_launch = (WSL_LAUNCH)GetProcAddress(_wslApiDll, "WslLaunch");
}
@@ -32,6 +33,7 @@ BOOL WslApiLoader::WslIsOptionalComponentInstalled()
(_isDistributionRegistered != nullptr) &&
(_registerDistribution != nullptr) &&
(_configureDistribution != nullptr) &&
(_getDistributionConfiguration != nullptr) &&
(_launchInteractive != nullptr) &&
(_launch != nullptr));
}
@@ -61,6 +63,20 @@ HRESULT WslApiLoader::WslConfigureDistribution(ULONG defaultUID, WSL_DISTRIBUTIO
return hr;
}

HRESULT WslApiLoader::WslGetDistributionConfiguration(ULONG* distributionVersion,
ULONG* defaultUID,
WSL_DISTRIBUTION_FLAGS* wslDistributionFlags,
PSTR** defaultEnvironmentVariables,
ULONG* defaultEnvironmentVariableCount)
{
return _getDistributionConfiguration(_distributionName.c_str(),
distributionVersion,
defaultUID,
wslDistributionFlags,
defaultEnvironmentVariables,
defaultEnvironmentVariableCount);
}

HRESULT WslApiLoader::WslLaunchInteractive(PCWSTR command, BOOL useCurrentWorkingDirectory, DWORD *exitCode)
{
HRESULT hr = _launchInteractive(_distributionName.c_str(), command, useCurrentWorkingDirectory, exitCode);
8 changes: 8 additions & 0 deletions DistroLauncher/WslApiLoader.h
Original file line number Diff line number Diff line change
@@ -33,6 +33,13 @@ class WslApiLoader
HRESULT WslConfigureDistribution(ULONG defaultUID,
WSL_DISTRIBUTION_FLAGS wslDistributionFlags);

HRESULT WslGetDistributionConfiguration(ULONG* distributionVersion,
ULONG* defaultUID,
WSL_DISTRIBUTION_FLAGS* wslDistributionFlags,
PSTR** defaultEnvironmentVariables,
ULONG* defaultEnvironmentVariableCount
);

HRESULT WslLaunchInteractive(PCWSTR command,
BOOL useCurrentWorkingDirectory,
DWORD *exitCode);
@@ -50,6 +57,7 @@ class WslApiLoader
WSL_IS_DISTRIBUTION_REGISTERED _isDistributionRegistered;
WSL_REGISTER_DISTRIBUTION _registerDistribution;
WSL_CONFIGURE_DISTRIBUTION _configureDistribution;
WSL_GET_DISTRIBUTION_CONFIGURATION _getDistributionConfiguration;
WSL_LAUNCH_INTERACTIVE _launchInteractive;
WSL_LAUNCH _launch;
};