[feature] ms-wubi-no-shift
This commit is contained in:
parent
7829c4d789
commit
9ee9afb76e
|
@ -1,3 +1,8 @@
|
||||||
|
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||||
|
Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
Set-ExecutionPolicy RemoteSigned
|
Set-ExecutionPolicy RemoteSigned
|
||||||
|
|
||||||
# link config files
|
# link config files
|
||||||
|
@ -11,5 +16,9 @@ if (Test-Path $sshconf -PathType Leaf) {
|
||||||
New-Item -ItemType SymbolicLink -Target $sshconf -Path $home\.ssh\config -Force
|
New-Item -ItemType SymbolicLink -Target $sshconf -Path $home\.ssh\config -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
# disable Shift key toggling CN/EN
|
# fix Shift key toggling Cn/En fro MS wubi
|
||||||
Install-Module -Name PSReflect-Functions
|
$wubiAction = New-ScheduledTaskAction -Execute 'Powershell.exe' `
|
||||||
|
-Argument "-NoProfile -WindowStyle Hidden -File $PSScriptRoot\wubi-no-shift.ps1"
|
||||||
|
$wubiTrigger = New-ScheduledTaskTrigger -AtLogOn
|
||||||
|
$wubiTrigger.Delay = 'PT3S'
|
||||||
|
Register-ScheduledTask -Action $wubiAction -Trigger $wubiTrigger -TaskName "Wubi No Shift" -Description "Disable Shift key toggling CN/EN" -RunLevel Highest
|
|
@ -1,6 +1,8 @@
|
||||||
#Requires -RunAsAdministrator
|
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||||
|
Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
Import-Module PSReflect-Functions
|
|
||||||
|
|
||||||
$Supported = @{
|
$Supported = @{
|
||||||
"B3448BF077665F2E1CA67094BCF2A7C5" = 0x14DE1;
|
"B3448BF077665F2E1CA67094BCF2A7C5" = 0x14DE1;
|
||||||
|
@ -18,53 +20,31 @@ $offsetAddr = $Supported[$ChsIMEHash]
|
||||||
if (-not $offsetAddr) {
|
if (-not $offsetAddr) {
|
||||||
throw [System.Exception] "Unsupported ChsIme.exe"
|
throw [System.Exception] "Unsupported ChsIme.exe"
|
||||||
}
|
}
|
||||||
echo "Offset Address: $offsetAddr"
|
|
||||||
|
|
||||||
# reference
|
Add-Type -MemberDefinition @'
|
||||||
<#
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
public enum ProcessAccessFlags : uint
|
public static extern bool WriteProcessMemory(
|
||||||
{
|
IntPtr hProcess,
|
||||||
All = 0x001F0FFF,
|
IntPtr lpBaseAddress,
|
||||||
Terminate = 0x00000001,
|
byte[] lpBuffer,
|
||||||
CreateThread = 0x00000002,
|
Int32 nSize,
|
||||||
VirtualMemoryOperation = 0x00000008,
|
out IntPtr lpNumberOfBytesWritten);
|
||||||
VirtualMemoryRead = 0x00000010,
|
'@ -Name Kernel32 -Namespace Pinvoke
|
||||||
VirtualMemoryWrite = 0x00000020,
|
|
||||||
DuplicateHandle = 0x00000040,
|
|
||||||
CreateProcess = 0x000000080,
|
|
||||||
SetQuota = 0x00000100,
|
|
||||||
SetInformation = 0x00000200,
|
|
||||||
QueryInformation = 0x00000400,
|
|
||||||
QueryLimitedInformation = 0x00001000,
|
|
||||||
Synchronize = 0x00100000
|
|
||||||
}
|
|
||||||
public enum SnapshotFlags : uint
|
|
||||||
{
|
|
||||||
HeapList = 0x00000001,
|
|
||||||
Process = 0x00000002,
|
|
||||||
Thread = 0x00000004,
|
|
||||||
Module = 0x00000008,
|
|
||||||
Module32 = 0x00000010,
|
|
||||||
All = (HeapList | Process | Thread | Module),
|
|
||||||
Inherit = 0x80000000,
|
|
||||||
NoHeaps = 0x40000000
|
|
||||||
|
|
||||||
}
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
$ps = Get-Process -Name $ChsIME
|
$ps = Get-Process -Name $ChsIME
|
||||||
foreach ($p in $ps) {
|
foreach ($p in $ps) {
|
||||||
$hProcess = Get-Process -Name $ChsIme
|
$hModule = $p.Modules | Where-Object {$_.ModuleName -eq $ChsIMEExe}
|
||||||
if (!$hProcess) {
|
|
||||||
throw [System.Exception] "Unable to open process $pid";
|
|
||||||
}
|
|
||||||
$hModule = $hProcess.Modules | Where-Object {$_.ModuleName -eq $ChsIMEExe}
|
|
||||||
if (!$hModule) {
|
if (!$hModule) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
$hModule = $hModule[0]
|
$hModule = $hModule[0]
|
||||||
$addr = [IntPtr]::Add($hModule.BaseAddress, $offsetAddr)
|
$addr = [IntPtr]::Add($hModule.BaseAddress, $offsetAddr)
|
||||||
[Int32]$n = 0
|
[Int32]$n = 0
|
||||||
[PSReflectFunctions.kernel32]::WriteProcessMemory($hProcess.Handle[0], $addr, @(0x31, 0xc0), 2, [ref]$n)
|
$pidd = $p.id
|
||||||
|
if ([Pinvoke.Kernel32]::WriteProcessMemory($p.Handle[0], $addr, @(0x31, 0xc0), 2, [ref]$n)) {
|
||||||
|
echo "$pidd is patched"
|
||||||
|
} else {
|
||||||
|
throw [System.Exception] "Failed to patch $pidd"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user