-
-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |