Skip to content

Commit

Permalink
fix(wsxpacks): don't modify files
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Dec 16, 2023
1 parent 23a4236 commit 7db5539
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ actions:
- !registryValue:
path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer'
value: 'SettingsPageVisibility'
data: 'hide:recovery;autoplay;usb;maps;maps-downloadmaps;findmydevice;privacy;privacy-speechtyping;privacy-speech;privacy-feedback;privacy-activityhistory;search-permissions;privacy-location;privacy-general;sync;printers;cortana-windowssearch;mobile-devices;mobile-devices-addphone;family-group;deviceusage;home;'
data: 'hide:recovery;autoplay;usb;maps;maps-downloadmaps;findmydevice;privacy;privacy-speechtyping;privacy-speech;privacy-feedback;privacy-activityhistory;search-permissions;privacy-location;privacy-general;sync;printers;cortana-windowssearch;mobile-devices;mobile-devices-addphone;family-group;deviceusage;home;account;'
type: REG_SZ
builds: [ '>=22000' ]
69 changes: 60 additions & 9 deletions src/playbook/Executables/CLIENTCBS.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,64 @@
$cbsPublic = "$env:windir\SystemApps\MicrosoftWindows.Client.CBS_cw5n1h2txyewy\Public"

# Remove ads from the 'Accounts' page in Immersive Control Panel
# Made by Xyueta
# --------------------------------------------------------------

# Find feature/velocity IDs to disable for the 'Accounts' page
# This acts as a fallback in case wsxpacks gets updated by Windows Update
# After disabling each one, there's a 'Microsoft account' page that appears (ms-settings:account)

# Finds velocity IDs listed in 'Accounts' wsxpack
$ids = @()
function Find-VelocityID($Node) {
if ($Node -is [PSCustomObject]) {
# If the node is a PSObject, go through through its properties
foreach ($property in $Node.PSObject.Properties) {
if ($property.Name -eq 'velocityKey' -and $property.Value.id) {
$global:ids += $property.Value.id
}
Find-VelocityID -Node $property.Value
}
} elseif ($Node -is [Array]) {
# If the node is an array, go through its elements
foreach ($element in $Node) {
Find-VelocityID -Node $element
}
}
}
Find-VelocityID -Node $(Get-Content -Path "$cbsPublic\wsxpacks\Account\SettingsExtensions.json" | ConvertFrom-Json)

# Obfuscate velocity IDs
# Rewritten in PowerShell from ViVE
# https://github.com/thebookisclosed/ViVe/blob/master/ViVe/ObfuscationHelpers.cs
class ObfuscationHelpers {
static [uint32] SwapBytes([uint32] $x) {
$x = ($x -shr 16) -bor ($x -shl 16)
return (($x -band 0xFF00FF00) -shr 8) -bor (($x -band 0x00FF00FF) -shl 8)
}

static [uint32] RotateRight32([uint32] $value, [int] $shift) {
return ($value -shr $shift) -bor ($value -shl (32 - $shift))
}

$file = "$env:windir\SystemApps\MicrosoftWindows.Client.CBS_cw5n1h2txyewy\Public\wsxpacks.json"
$content = Get-Content -Path "$file"
$pattern = '^\s*"Windows\.Settings\.Account".*'
$modifiedContent = $content -replace $pattern, ''
$modifiedContent = ($modifiedContent | Where-Object { $_.Trim() -ne "" }) -join "`n"
static [uint32] ObfuscateFeatureId([uint32] $featureId) {
return [ObfuscationHelpers]::RotateRight32(([ObfuscationHelpers]::SwapBytes($featureId -bxor 0x74161A4E) -bxor 0x8FB23D4F), -1) -bxor 0x833EA8FF
}

takeown /f "$file"
icacls "$file" /grant *S-1-3-4:F /t /c /l
static [uint32] DeobfuscateFeatureId([uint32] $featureId) {
return [ObfuscationHelpers]::SwapBytes(([ObfuscationHelpers]::RotateRight32($featureId -bxor 0x833EA8FF, 1) -bxor 0x8FB23D4F)) -bxor 0x74161A4E
}
}

Set-Content -Path "$file" -Value "$modifiedContent"
# Disable velocity IDs
# Applies next reboot
$featureKey = "HKLM:\SYSTEM\CurrentControlSet\Control\FeatureManagement\Overrides\8"
foreach ($id in $($ids | Sort-Object -Unique)) {
$veloId = "$featureKey\$([ObfuscationHelpers]::ObfuscateFeatureId($id))"
Write-Host "Disabling velocity ID '$veloId'..."
New-Item $veloId -Force | Out-Null
Set-ItemProperty -Path $veloId -Name "EnabledStateOptions" -Value 0 -Force
Set-ItemProperty -Path $veloId -Name "EnabledState" -Value 1 -Force
Set-ItemProperty -Path $veloId -Name "VariantPayload" -Value 0 -Force
Set-ItemProperty -Path $veloId -Name "Variant" -Value 0 -Force
Set-ItemProperty -Path $veloId -Name "VariantPayloadKind" -Value 0 -Force
}

0 comments on commit 7db5539

Please sign in to comment.