Skip to content
Merged
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
19 changes: 1 addition & 18 deletions DistroLauncher/DistributionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,11 @@

#include "stdafx.h"

HRESULT DistributionInfo::ChangeDefaultUserInWslConf(const std::wstring_view userName)
{
DWORD exitCode = 0;

wchar_t commandLine[255];
_swprintf_p(commandLine, _countof(commandLine),
L"if [ $(grep -c \"\\[user\\]\" /etc/wsl.conf) -eq \"0\" ]; then echo -e \"\\n[user]\\ndefault=%1$s\">>/etc/wsl.conf; else sed -i \"s/\\(default=\\)\\(.*\\)/\\1%1$s/\" /etc/wsl.conf ; fi",
std::wstring(userName).c_str());

if (const auto hr = g_wslApi.WslLaunchInteractive(commandLine, true, &exitCode); FAILED(hr) || exitCode != 0)
{
return hr;
}

return 0;
}

bool DistributionInfo::CreateUser(std::wstring_view userName)
{
// Create the user account.
DWORD exitCode;
std::wstring commandLine = L"/usr/sbin/adduser --quiet --gecos '' ";
std::wstring commandLine = L"/usr/sbin/adduser --quiet --comment '' ";
commandLine += userName;
auto hr = g_wslApi.WslLaunchInteractive(commandLine.c_str(), true, &exitCode);
if (FAILED(hr) || exitCode != 0)
Expand Down
6 changes: 2 additions & 4 deletions DistroLauncher/DistributionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace DistributionInfo
//
// WARNING: This value must not change between versions of your app,
// otherwise users upgrading from older versions will see launch failures.
const std::wstring NAME = L"WLinux";
const std::wstring NAME = L"Pengwin";
const std::wstring NAME_OLD = L"WLinux";

// The title bar for the console window while the distribution is installing.
const std::wstring WINDOW_TITLE = L"Pengwin";
Expand All @@ -23,7 +24,4 @@ namespace DistributionInfo

// Query the UID of the user account.
ULONG QueryUid(std::wstring_view userName);

// Changes the default user in /etc/wsl.conf
HRESULT ChangeDefaultUserInWslConf(std::wstring_view userName);
}
41 changes: 18 additions & 23 deletions DistroLauncher/DistroLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using namespace Windows::Storage;
// Helper class for calling WSL Functions:
// https://msdn.microsoft.com/en-us/library/windows/desktop/mt826874(v=vs.85).aspx
// ReSharper disable once CppInconsistentNaming
WslApiLoader g_wslApi(DistributionInfo::NAME);
WslApiLoader g_wslApi(DistributionInfo::NAME, DistributionInfo::NAME_OLD);

static HRESULT InstallDistribution(bool createUser);
static HRESULT SetDefaultUser(std::wstring_view userName);
Expand Down Expand Up @@ -85,20 +85,7 @@ HRESULT SetDefaultUser(std::wstring_view userName)
return E_INVALIDARG;
}

// Set the default user as root, so ChangeDefaultUserInWslConf chan make the change
HRESULT hr = g_wslApi.WslConfigureDistribution(0, WSL_DISTRIBUTION_FLAGS_DEFAULT);
if (FAILED(hr))
{
return hr;
}

hr = DistributionInfo::ChangeDefaultUserInWslConf(userName);
if (FAILED(hr))
{
return hr;
}

hr = g_wslApi.WslConfigureDistribution(uid, WSL_DISTRIBUTION_FLAGS_DEFAULT);
HRESULT hr = g_wslApi.WslConfigureDistribution(uid, WSL_DISTRIBUTION_FLAGS_DEFAULT);
if (FAILED(hr))
{
return hr;
Expand Down Expand Up @@ -172,6 +159,17 @@ fire_and_forget ShowPengwinUi()
}
}

static bool is_current_dir_not_system32()
{
wchar_t system_32dir[MAX_PATH];
GetSystemDirectoryW(system_32dir, MAX_PATH);

wchar_t current_dir[MAX_PATH];
GetCurrentDirectoryW(MAX_PATH, current_dir);

return _wcsicmp(system_32dir, current_dir) != 0;
}

// ReSharper disable once IdentifierTypo
int wmain(const int argc, const wchar_t* argv[])
{
Expand Down Expand Up @@ -201,13 +199,6 @@ int wmain(const int argc, const wchar_t* argv[])
// Install the distribution if it is not already.
const auto installOnly = arguments.size() > 0 && arguments[0] == ARG_INSTALL;
auto hr = S_OK;
/*

if (!g_wslApi.WslIsDistributionRegistered())
{
g_wslApi.SetDistributionName(L"Pengwin");
}
*/

if (!g_wslApi.WslIsDistributionRegistered())
{
Expand Down Expand Up @@ -246,7 +237,11 @@ int wmain(const int argc, const wchar_t* argv[])

if (arguments.empty())
{
hr = g_wslApi.WslLaunchInteractive(L"", false, &exitCode);
/* If the current working dir is not System32 then it was called from Open with Terminal
option or from command line. In this case is better to start the distro in the current directory */
const bool useCurrentWorkingDirectory = is_current_dir_not_system32();

hr = g_wslApi.WslLaunchInteractive(L"", useCurrentWorkingDirectory, &exitCode);

// Check exitCode to see if wsl.exe returned that it could not start the Linux process
// then prompt users for input so they can view the error message.
Expand Down
18 changes: 14 additions & 4 deletions DistroLauncher/WslApiLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#include "stdafx.h"
#include "WslApiLoader.h"

WslApiLoader::WslApiLoader(const std::wstring& distributionName) :
_distributionName(distributionName)
WslApiLoader::WslApiLoader(const std::wstring& distributionName, const std::wstring& distributionNameOld) :
_distributionName(distributionName),
_distributionNameOld(distributionNameOld)
{
_wslApiDll = LoadLibraryEx(L"wslapi.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (_wslApiDll != nullptr)
Expand Down Expand Up @@ -40,9 +41,18 @@ BOOL WslApiLoader::WslIsOptionalComponentInstalled() const
_launch != nullptr;
}

BOOL WslApiLoader::WslIsDistributionRegistered() const
BOOL WslApiLoader::WslIsDistributionRegistered()
{
return _isDistributionRegistered(_distributionName.c_str());
if (!_isDistributionRegistered(_distributionName.c_str()))
{
if (!_isDistributionRegistered(_distributionNameOld.c_str()))
{
return FALSE;
}
_distributionName = _distributionNameOld;
return TRUE;
}
return TRUE;
}

HRESULT WslApiLoader::WslRegisterDistribution() const
Expand Down
5 changes: 3 additions & 2 deletions DistroLauncher/WslApiLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ using WSL_LAUNCH = HRESULT(STDAPICALLTYPE*)(PCWSTR, PCWSTR, BOOL, HANDLE, HANDLE
class WslApiLoader
{
public:
WslApiLoader(const std::wstring& distributionName);
WslApiLoader(const std::wstring& distributionName, const std::wstring& distributionNameOld);
~WslApiLoader();

BOOL WslIsOptionalComponentInstalled() const;

BOOL WslIsDistributionRegistered() const;
BOOL WslIsDistributionRegistered();

HRESULT WslRegisterDistribution() const;

Expand All @@ -52,6 +52,7 @@ class WslApiLoader

private:
std::wstring _distributionName;
std::wstring _distributionNameOld;
HMODULE _wslApiDll;
WSL_IS_DISTRIBUTION_REGISTERED _isDistributionRegistered;
WSL_REGISTER_DISTRIBUTION _registerDistribution;
Expand Down
Binary file modified Pengwin/Assets/background1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Assets/background2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Assets/pengwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/LargeTile.scale-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/LargeTile.scale-125.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/LargeTile.scale-150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/LargeTile.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/LargeTile.scale-400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/SmallTile.scale-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/SmallTile.scale-125.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/SmallTile.scale-150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/SmallTile.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/SmallTile.scale-400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/SplashScreen.scale-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/SplashScreen.scale-125.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/SplashScreen.scale-150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/SplashScreen.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/SplashScreen.scale-400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/Square150x150Logo.scale-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/Square150x150Logo.scale-125.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/Square150x150Logo.scale-150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/Square150x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/Square150x150Logo.scale-400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Pengwin/Images/Square44x44Logo.altform-unplated_targetsize-32.png
Binary file modified Pengwin/Images/Square44x44Logo.altform-unplated_targetsize-48.png
Binary file modified Pengwin/Images/Square44x44Logo.scale-100.png
Binary file modified Pengwin/Images/Square44x44Logo.scale-125.png
Binary file modified Pengwin/Images/Square44x44Logo.scale-150.png
Binary file modified Pengwin/Images/Square44x44Logo.scale-200.png
Binary file modified Pengwin/Images/Square44x44Logo.scale-400.png
Binary file modified Pengwin/Images/Square44x44Logo.targetsize-16.png
Binary file modified Pengwin/Images/Square44x44Logo.targetsize-24.png
Binary file modified Pengwin/Images/Square44x44Logo.targetsize-24_altform-unplated.png
Binary file modified Pengwin/Images/Square44x44Logo.targetsize-256.png
Binary file modified Pengwin/Images/Square44x44Logo.targetsize-32.png
Binary file modified Pengwin/Images/Square44x44Logo.targetsize-48.png
Binary file modified Pengwin/Images/StoreLogo.scale-100.png
Binary file modified Pengwin/Images/StoreLogo.scale-125.png
Binary file modified Pengwin/Images/StoreLogo.scale-150.png
Binary file modified Pengwin/Images/StoreLogo.scale-200.png
Binary file modified Pengwin/Images/StoreLogo.scale-400.png
Binary file modified Pengwin/Images/Wide310x150Logo.scale-100.png
Binary file modified Pengwin/Images/Wide310x150Logo.scale-125.png
Binary file modified Pengwin/Images/Wide310x150Logo.scale-150.png
Binary file modified Pengwin/Images/Wide310x150Logo.scale-200.png
Binary file modified Pengwin/Images/Wide310x150Logo.scale-400.png
4 changes: 2 additions & 2 deletions Pengwin/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Identity
Name="WhitewaterFoundryLtd.Co.16571368D6CFF"
Publisher="CN=9879127B-9E92-4DE5-9C32-0B1F09F95DCF"
Version="25.11.0.0" />
Version="26.2.1.0" />

<Properties>
<DisplayName>Pengwin</DisplayName>
Expand All @@ -36,7 +36,7 @@
<uap:VisualElements
DisplayName="Pengwin"
Description="The bespoke WSL distro."
BackgroundColor="white"
BackgroundColor="black"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png"
Expand Down
18 changes: 13 additions & 5 deletions x64/pengwin.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"profiles": [
{
"updates": "{7f586916-8357-53d4-bb2b-ca96f639898a}",
"commandline": "\"%ProgramFiles%\\WindowsApps\\WhitewaterFoundryLtd.Co.16571368D6CFF_22.11.0.0_x64__kd1vv0z0vy70w\\DistroLauncher\\pengwin.exe\"",
"icon": "%ProgramFiles%\\WindowsApps\\WhitewaterFoundryLtd.Co.16571368D6CFF_22.11.0.0_x64__kd1vv0z0vy70w\\Assets\\pengwin.png",
"hidden": true,
"updates": "{7f586916-8357-53d4-bb2b-ca96f639898a}"
},
{
"commandline": "\"%ProgramFiles%\\WindowsApps\\WhitewaterFoundryLtd.Co.16571368D6CFF_25.11.0.0_x64__kd1vv0z0vy70w\\DistroLauncher\\pengwin.exe\"",
"icon": "%ProgramFiles%\\WindowsApps\\WhitewaterFoundryLtd.Co.16571368D6CFF_25.11.0.0_x64__kd1vv0z0vy70w\\Assets\\pengwin.png",
"name": "Pengwin",
"acrylicOpacity": 0.9,
"backgroundImage": "%ProgramFiles%\\WindowsApps\\WhitewaterFoundryLtd.Co.16571368D6CFF_22.11.0.0_x64__kd1vv0z0vy70w\\Assets\\background1.png",
"backgroundImage": "%ProgramFiles%\\WindowsApps\\WhitewaterFoundryLtd.Co.16571368D6CFF_25.11.0.0_x64__kd1vv0z0vy70w\\Assets\\background1.png",
"backgroundImageAlignment": "bottomRight",
"backgroundImageOpacity": 0.2,
"backgroundImageStretchMode": "none",
Expand All @@ -16,7 +19,12 @@
"fontFace": "Cascadia Code",
"useAcrylic": true,
"startingDirectory": null,
"closeOnExit": "never"
"closeOnExit": "never",
"showMarksOnScrollbar": true,
"autoMarkPrompts": true,
"pathTranslationStyle": "wsl",
"wsl.distribution-type": "debian",
"wsl.distribution-version": "13.0"
}
],
"schemes": [
Expand Down