Skip to content

Commit fbafd48

Browse files
committed
Update Script and Fix Errors (Test 1)
1 parent 8a0d86f commit fbafd48

15 files changed

+488
-108
lines changed

.github/FUNDING.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ko_fi: mustardchef
1+
ko_fi: mustardchef

DLL/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# WSAPatch
2+
3+
<https://github.com/cinit/WSAPatch/releases>

DLL/WsaPatch.dll

62.5 KB
Binary file not shown.

DLL/icu.dll

2.46 MB
Binary file not shown.

installer/Run.bat

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
:: Automated Install batch script by Syuugo
2-
31
@echo off
4-
%~d0
52
cd "%~dp0"
63
if not exist Install.ps1 (
74
echo "Install.ps1" is not found.
85
echo Press any key to exit
96
pause>nul
107
exit 1
11-
) else (
12-
start powershell.exe -ExecutionPolicy Bypass -File .\Install.ps1
13-
exit
148
)
9+
start powershell.exe -ExecutionPolicy Bypass -File .\Install.ps1
10+
exit

installer/arm64/Install.ps1

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#
2+
# This file is part of MagiskOnWSALocal.
3+
#
4+
# MagiskOnWSALocal is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU Affero General Public License as
6+
# published by the Free Software Foundation, either version 3 of the
7+
# License, or (at your option) any later version.
8+
#
9+
# MagiskOnWSALocal is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU Affero General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU Affero General Public License
15+
# along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
16+
#
17+
# Copyright (C) 2023 LSPosed Contributors
18+
#
19+
20+
$Host.UI.RawUI.WindowTitle = "Installing MagiskOnWSA..."
21+
22+
function Finish {
23+
Clear-Host
24+
Start-Process "shell:AppsFolder\MicrosoftCorporationII.WindowsSubsystemForAndroid_8wekyb3d8bbwe!SettingsApp"
25+
Start-Process "wsa://com.topjohnwu.magisk"
26+
Start-Process "wsa://com.android.vending"
27+
Start-Process "wsa://com.android.settings"
28+
29+
Write-Output "All Done!`r`nPress any key to exit"
30+
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
31+
exit 0
32+
}
33+
34+
$pwsh = "powershell.exe"
35+
36+
if ((New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -ne $true) {
37+
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force
38+
$Proc = Start-Process -PassThru -Verb RunAs $pwsh -Args "-ExecutionPolicy Bypass -Command Set-Location '$PSScriptRoot'; &'$PSCommandPath' EVAL"
39+
if ($null -ne $Proc) {
40+
$Proc.WaitForExit()
41+
}
42+
if ($null -eq $Proc -or $Proc.ExitCode -ne 0) {
43+
Write-Warning "`r`nFailed to launch start as Administrator`r`nPress any key to exit"
44+
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
45+
}
46+
exit
47+
} elseif (($args.Count -eq 1) -and ($args[0] -eq "EVAL")) {
48+
Start-Process $pwsh -NoNewWindow -Args "-ExecutionPolicy Bypass -Command Set-Location '$PSScriptRoot'; &'$PSCommandPath'"
49+
exit
50+
}
51+
52+
$FileList = Get-Content -Path .\filelist.txt
53+
if (((Test-Path -Path $FileList) -eq $false).Count) {
54+
Write-Error "`r`nSome files are missing in the folder.`r`nPlease try to build again.`r`n`r`nPress any key to exit"
55+
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
56+
exit 1
57+
}
58+
59+
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
60+
61+
if ($(Get-WindowsOptionalFeature -Online -FeatureName 'VirtualMachinePlatform').State -ne "Enabled") {
62+
Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName 'VirtualMachinePlatform'
63+
Write-Warning "`r`nNeed restart to enable virtual machine platform`r`nPress y to restart or press any key to exit"
64+
$Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
65+
if ("y" -eq $Key.Character) {
66+
Restart-Computer -Confirm
67+
} else {
68+
exit 1
69+
}
70+
}
71+
72+
if (((Test-Path -Path "MakePri.ps1") -and (Test-Path -Path "makepri.exe")) -eq $true) {
73+
$ProcMakePri = Start-Process $pwsh -PassThru -NoNewWindow -Args "-ExecutionPolicy Bypass -File MakePri.ps1" -WorkingDirectory $PSScriptRoot
74+
$null = $ProcMakePri.Handle
75+
$ProcMakePri.WaitForExit()
76+
if ($ProcMakePri.ExitCode -ne 0) {
77+
Write-Warning "`r`nFailed to merge resources, WSA Seetings will always be in English`r`nPress any key to continue"
78+
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
79+
}
80+
$Host.UI.RawUI.WindowTitle = "Installing MagiskOnWSA...."
81+
}
82+
83+
if ((Test-Path -Path 'uwp') -eq $true) {
84+
[xml]$Xml = Get-Content ".\AppxManifest.xml";
85+
$Name = $Xml.Package.Identity.Name;
86+
Write-Output "Installing $Name version: $($Xml.Package.Identity.Version)"
87+
$ProcessorArchitecture = $Xml.Package.Identity.ProcessorArchitecture;
88+
$Dependencies = $Xml.Package.Dependencies.PackageDependency;
89+
$Dependencies | ForEach-Object {
90+
$InstalledVersion = Get-AppxPackage -Name $_.Name | ForEach-Object { if ($_.Architecture -eq $ProcessorArchitecture) { $_ } } | Sort-Object -Property Version | Select-Object -ExpandProperty Version -Last 1
91+
if ( $InstalledVersion -lt $_.MinVersion ) {
92+
if ($env:WT_SESSION) {
93+
$env:WT_SESSION = $null
94+
Write-Output "`r`nDependency should be installed but Windows Terminal is in use. Restarting to conhost.exe"
95+
Start-Process conhost.exe -Args "powershell.exe -ExecutionPolicy Bypass -Command Set-Location '$PSScriptRoot'; &'$PSCommandPath'"
96+
exit 1
97+
}
98+
Write-Output "Dependency package $($_.Name) $ProcessorArchitecture required minimum version: $($_.MinVersion). Installing..."
99+
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path "uwp\$($_.Name)_$ProcessorArchitecture.appx"
100+
} else {
101+
Write-Output "Dependency package $($_.Name) $ProcessorArchitecture current version: $InstalledVersion.`r`nNothing to do."
102+
}
103+
}
104+
} else {
105+
Write-Warning "`r`nIgnored install WSA dependencies."
106+
}
107+
108+
$Installed = $null
109+
$Installed = Get-AppxPackage -Name $Name
110+
111+
if (($null -ne $Installed) -and (-not ($Installed.IsDevelopmentMode))) {
112+
Write-Warning "`r`nThere is already one installed WSA.`r`nPlease uninstall it first.`r`n`r`nPress y to uninstall existing WSA or press any key to exit"
113+
$key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
114+
if ("y" -eq $key.Character) {
115+
Clear-Host
116+
Remove-AppxPackage -Package $Installed.PackageFullName
117+
} else {
118+
exit 1
119+
}
120+
}
121+
122+
if ($Installed) {
123+
Write-Output "`r`nShutting down WSA..."
124+
Start-Process WsaClient -Wait -Args "/shutdown"
125+
}
126+
Stop-Process -Name "WsaClient" -ErrorAction SilentlyContinue
127+
128+
Write-Output "`r`nInstalling MagiskOnWSA..."
129+
130+
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml
131+
if ($?) {
132+
Finish
133+
} elseif ($null -ne $Installed) {
134+
Write-Error "`r`nFailed to update.`r`nPress any key to uninstall existing installation while preserving user data.`r`nTake in mind that this will remove the Android apps' icon from the start menu.`r`nIf you want to cancel, close this window now."
135+
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
136+
Clear-Host
137+
Remove-AppxPackage -PreserveApplicationData -Package $Installed.PackageFullName
138+
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml
139+
if ($?) {
140+
Finish
141+
}
142+
}

installer/arm64/MakePri.ps1

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This file is part of MagiskOnWSALocal.
2+
#
3+
# MagiskOnWSALocal is free software: you can redistribute it and/or modify
4+
# it under the terms of the GNU Affero General Public License as
5+
# published by the Free Software Foundation, either version 3 of the
6+
# License, or (at your option) any later version.
7+
#
8+
# MagiskOnWSALocal is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU Affero General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU Affero General Public License
14+
# along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
15+
#
16+
# Copyright (C) 2023 LSPosed Contributors
17+
#
18+
19+
$Host.UI.RawUI.WindowTitle = "Merging resources...."
20+
if (((Test-Path -Path $(Get-Content -Path .\filelist-pri.txt)) -eq $false).Count) {
21+
Write-Error "Some files are missing in the folder. Please try to build again. Press any key to exit"
22+
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
23+
exit 1
24+
} else {
25+
New-Item -Path "." -Name "priinfo" -ItemType "directory" | Out-Null
26+
Copy-Item .\resources.pri -Destination ".\pri\resources.pri" | Out-Null
27+
Clear-Host
28+
$AppxManifestFile = ".\AppxManifest.xml"
29+
$PriItem = Get-Item ".\pri\*" -Include "*.pri"
30+
Write-Output "Dumping resources...."
31+
$i = 0
32+
$Processes = foreach ($Item in $PriItem) {
33+
Start-Process -PassThru -WindowStyle Hidden makepri.exe -Args "dump /if $($Item | Resolve-Path -Relative) /o /es .\pri\resources.pri /of .\priinfo\$($Item.Name).xml /dt detailed"
34+
++$i
35+
$Completed = ($i / $PriItem.count) * 100
36+
Write-Progress -Activity "Dumping resources" -Status "Dumping $($Item.Name):" -PercentComplete $Completed
37+
}
38+
$Processes | Wait-Process
39+
Write-Progress -Activity "Dumping resources" -Status "Ready" -Completed
40+
Clear-Host
41+
Write-Output "Creating pri from dumps...."
42+
$ProcNewFromDump = Start-Process -PassThru -NoNewWindow makepri.exe -Args "new /pr .\priinfo /cf .\xml\priconfig.xml /of .\resources.pri /mn $AppxManifestFile /o"
43+
$null = $ProcNewFromDump.Handle
44+
$ProcNewFromDump.WaitForExit()
45+
Remove-Item 'priinfo' -Recurse
46+
if ($ProcNewFromDump.ExitCode -Ne 0) {
47+
Write-Error "Failed to create resources from priinfos"
48+
exit 1
49+
}
50+
51+
$ProjectXml = [xml](Get-Content $AppxManifestFile)
52+
$ProjectResources = $ProjectXml.Package.Resources;
53+
$(Get-Item .\xml\* -Exclude "priconfig.xml" -Include "*.xml") | ForEach-Object {
54+
$($([xml](Get-Content $_)).Package.Resources.Resource) | ForEach-Object {
55+
$ProjectResources.AppendChild($($ProjectXml.ImportNode($_, $true)))
56+
}
57+
}
58+
$ProjectXml.Save($AppxManifestFile)
59+
Remove-Item 'pri' -Recurse -Force
60+
Remove-Item 'xml' -Recurse -Force
61+
Remove-Item 'makepri.exe' -Force
62+
Remove-Item 'filelist-pri.txt' -Force
63+
Remove-Item $PSCommandPath -Force
64+
exit 0
65+
}

installer/x64/Install.ps1

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#
2+
# This file is part of MagiskOnWSALocal.
3+
#
4+
# MagiskOnWSALocal is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU Affero General Public License as
6+
# published by the Free Software Foundation, either version 3 of the
7+
# License, or (at your option) any later version.
8+
#
9+
# MagiskOnWSALocal is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU Affero General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU Affero General Public License
15+
# along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
16+
#
17+
# Copyright (C) 2023 LSPosed Contributors
18+
#
19+
20+
$Host.UI.RawUI.WindowTitle = "Installing MagiskOnWSA..."
21+
22+
function Finish {
23+
Clear-Host
24+
Start-Process "shell:AppsFolder\MicrosoftCorporationII.WindowsSubsystemForAndroid_8wekyb3d8bbwe!SettingsApp"
25+
Start-Process "wsa://com.topjohnwu.magisk"
26+
Start-Process "wsa://com.android.vending"
27+
Start-Process "wsa://com.android.settings"
28+
29+
Write-Output "All Done!`r`nPress any key to exit"
30+
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
31+
exit 0
32+
}
33+
34+
$pwsh = "powershell.exe"
35+
36+
if ((New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -ne $true) {
37+
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force
38+
$Proc = Start-Process -PassThru -Verb RunAs $pwsh -Args "-ExecutionPolicy Bypass -Command Set-Location '$PSScriptRoot'; &'$PSCommandPath' EVAL"
39+
if ($null -ne $Proc) {
40+
$Proc.WaitForExit()
41+
}
42+
if ($null -eq $Proc -or $Proc.ExitCode -ne 0) {
43+
Write-Warning "`r`nFailed to launch start as Administrator`r`nPress any key to exit"
44+
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
45+
}
46+
exit
47+
} elseif (($args.Count -eq 1) -and ($args[0] -eq "EVAL")) {
48+
Start-Process $pwsh -NoNewWindow -Args "-ExecutionPolicy Bypass -Command Set-Location '$PSScriptRoot'; &'$PSCommandPath'"
49+
exit
50+
}
51+
52+
$FileList = Get-Content -Path .\filelist.txt
53+
if (((Test-Path -Path $FileList) -eq $false).Count) {
54+
Write-Error "`r`nSome files are missing in the folder.`r`nPlease try to build again.`r`n`r`nPress any key to exit"
55+
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
56+
exit 1
57+
}
58+
59+
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
60+
61+
if ($(Get-WindowsOptionalFeature -Online -FeatureName 'VirtualMachinePlatform').State -ne "Enabled") {
62+
Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName 'VirtualMachinePlatform'
63+
Write-Warning "`r`nNeed restart to enable virtual machine platform`r`nPress y to restart or press any key to exit"
64+
$Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
65+
if ("y" -eq $Key.Character) {
66+
Restart-Computer -Confirm
67+
} else {
68+
exit 1
69+
}
70+
}
71+
72+
if ((Test-Path -Path 'uwp') -eq $true) {
73+
[xml]$Xml = Get-Content ".\AppxManifest.xml";
74+
$Name = $Xml.Package.Identity.Name;
75+
Write-Output "Installing $Name version: $($Xml.Package.Identity.Version)"
76+
$ProcessorArchitecture = $Xml.Package.Identity.ProcessorArchitecture;
77+
$Dependencies = $Xml.Package.Dependencies.PackageDependency;
78+
$Dependencies | ForEach-Object {
79+
$InstalledVersion = Get-AppxPackage -Name $_.Name | ForEach-Object { if ($_.Architecture -eq $ProcessorArchitecture) { $_ } } | Sort-Object -Property Version | Select-Object -ExpandProperty Version -Last 1
80+
if ( $InstalledVersion -lt $_.MinVersion ) {
81+
if ($env:WT_SESSION) {
82+
$env:WT_SESSION = $null
83+
Write-Output "`r`nDependency should be installed but Windows Terminal is in use. Restarting to conhost.exe"
84+
Start-Process conhost.exe -Args "powershell.exe -ExecutionPolicy Bypass -Command Set-Location '$PSScriptRoot'; &'$PSCommandPath'"
85+
exit 1
86+
}
87+
Write-Output "Dependency package $($_.Name) $ProcessorArchitecture required minimum version: $($_.MinVersion). Installing..."
88+
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path "uwp\$($_.Name)_$ProcessorArchitecture.appx"
89+
} else {
90+
Write-Output "Dependency package $($_.Name) $ProcessorArchitecture current version: $InstalledVersion.`r`nNothing to do."
91+
}
92+
}
93+
} else {
94+
Write-Warning "`r`nIgnored install WSA dependencies."
95+
}
96+
97+
$Installed = $null
98+
$Installed = Get-AppxPackage -Name $Name
99+
100+
if (($null -ne $Installed) -and (-not ($Installed.IsDevelopmentMode))) {
101+
Write-Warning "`r`nThere is already one installed WSA.`r`nPlease uninstall it first.`r`n`r`nPress y to uninstall existing WSA or press any key to exit"
102+
$key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
103+
if ("y" -eq $key.Character) {
104+
Clear-Host
105+
Remove-AppxPackage -Package $Installed.PackageFullName
106+
} else {
107+
exit 1
108+
}
109+
}
110+
111+
if ($Installed) {
112+
Write-Output "`r`nShutting down WSA..."
113+
Start-Process WsaClient -Wait -Args "/shutdown"
114+
}
115+
Stop-Process -Name "WsaClient" -ErrorAction SilentlyContinue
116+
117+
Write-Output "`r`nInstalling MagiskOnWSA..."
118+
119+
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml
120+
if ($?) {
121+
Finish
122+
} elseif ($null -ne $Installed) {
123+
Write-Error "`r`nFailed to update.`r`nPress any key to uninstall existing installation while preserving user data.`r`nTake in mind that this will remove the Android apps' icon from the start menu.`r`nIf you want to cancel, close this window now."
124+
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
125+
Clear-Host
126+
Remove-AppxPackage -PreserveApplicationData -Package $Installed.PackageFullName
127+
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml
128+
if ($?) {
129+
Finish
130+
}
131+
}

0 commit comments

Comments
 (0)