Skip to content

Instantly share code, notes, and snippets.

@UserUnknownFactor
Last active January 19, 2023 18:35
Show Gist options
  • Save UserUnknownFactor/68c0bc3f6cc4c5df030ed3eef4981b25 to your computer and use it in GitHub Desktop.
Save UserUnknownFactor/68c0bc3f6cc4c5df030ed3eef4981b25 to your computer and use it in GitHub Desktop.
Kill that windows language switcher floaty thingy (Windows 10)
@echo off
cd /d "%~dp0"
Title "Reverting input layout popup to Windows 10 default..."
::filedll
set filedll=%windir%\system32\InputSwitch.dll
takeown /F %filedll% /A
icacls %filedll% /grant:r "*S-1-5-32-544":f
icacls %filedll% /setowner "*S-1-5-32-544" /C /L /Q
icacls %filedll% /grant:r "*S-1-5-32-545":rx
icacls %filedll% /grant:r "*S-1-5-18":f
icacls %filedll% /inheritance:r
taskkill /f /im explorer.exe
PING -n 2 -w 1000 127.0.0.1 > nul
copy ".\InputSwitch.dll.undo" %filedll% /Y
PING -n 2 -w 1000 127.0.0.1 > nul
start "" %windir%\explorer.exe
@pause
goto :eof
@echo off
cd /d "%~dp0"
Title "Disabling language/keyboard layout selection popup..."
::filedll
set filedll=%windir%\system32\InputSwitch.dll
takeown /F %filedll% /A
icacls %filedll% /grant:r "*S-1-5-32-544":f
icacls %filedll% /setowner "*S-1-5-32-544" /C /L /Q
icacls %filedll% /grant:r "*S-1-5-32-545":rx
icacls %filedll% /grant:r "*S-1-5-18":f
icacls %filedll% /inheritance:r
taskkill /f /im explorer.exe
PING -n 2 -w 1000 127.0.0.1 > nul
copy %filedll% ".\InputSwitch.dll" /Y
powershell.exe -ExecutionPolicy Bypass -Command "$_=((Get-Content \"%~f0\") -join \"`n\");iex $_.Substring($_.IndexOf(\"goto :\"+\"EOF\")+9)"
PING -n 2 -w 1000 127.0.0.1 > nul
copy ".\InputSwitch.dll" %filedll% /Y
PING -n 2 -w 1000 127.0.0.1 > nul
start "" %windir%\explorer.exe
icacls %filedll% /setowner "NT SERVICE\TrustedInstaller" /C /L /Q
icacls %filedll% /grant:r "NT SERVICE\TrustedInstaller":rx
icacls %filedll% /grant:r "*S-1-5-18":f
icacls %filedll% /grant:r "*S-1-5-32-544":rx
rem Run the layout configuration applet afterwards
rem "C:\Windows\system32\rundll32.exe" Shell32.dll,Control_RunDLL input.dll,,{C07337D3-DB2C-4D0B-9A93-B722A6C106E2}{HOTKEYS}
@pause
@goto :EOF
Function Find-Bytes([byte[]]$Bytes, [byte[]]$Search, [int]$Start, [Switch]$All) {
If (!$Start) { $Start = 0 }
For ($Index = $Start; $Index -le $Bytes.Length - $Search.Length ; $Index++) {
For ($i = 0; $i -lt $Search.Length -and $Bytes[$Index + $i] -eq $Search[$i]; $i++) {}
If ($i -ge $Search.Length) {
$Index
If (!$All) { Return }
}
}
}
$inputDLL = ".\InputSwitch.dll"
Write-Output "Patching $($inputDLL)...`r"
$marker = [byte[]] (0x74, 0x1F, 0x48, 0x63, 0xD0)
$bytes = [System.IO.File]::ReadAllBytes($inputDLL)
$offset = Find-Bytes $bytes $marker
if ($offset -is [int]) {
#Write-Output $offset
for ($num = 0; $num -le 32 ; $num++) {
$bytes[$offset + $num] = 0x90
}
if (-not [System.IO.File]::Exists("$inputDLL.undo")) {
Rename-Item -Path $inputDLL -NewName "$inputDLL.undo"
}
[System.IO.File]::WriteAllBytes($inputDLL, $bytes)
Write-Output "Patching OK! "
}
else {
Write-Output "Patching FAILED, the marker wasn't found! "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment