[misc] improve ime process detection logic
This commit is contained in:
parent
9ee9afb76e
commit
d51340686f
|
@ -20,5 +20,4 @@ if (Test-Path $sshconf -PathType Leaf) {
|
||||||
$wubiAction = New-ScheduledTaskAction -Execute 'Powershell.exe' `
|
$wubiAction = New-ScheduledTaskAction -Execute 'Powershell.exe' `
|
||||||
-Argument "-NoProfile -WindowStyle Hidden -File $PSScriptRoot\wubi-no-shift.ps1"
|
-Argument "-NoProfile -WindowStyle Hidden -File $PSScriptRoot\wubi-no-shift.ps1"
|
||||||
$wubiTrigger = New-ScheduledTaskTrigger -AtLogOn
|
$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
|
Register-ScheduledTask -Action $wubiAction -Trigger $wubiTrigger -TaskName "Wubi No Shift" -Description "Disable Shift key toggling CN/EN" -RunLevel Highest
|
|
@ -32,19 +32,27 @@ Add-Type -MemberDefinition @'
|
||||||
'@ -Name Kernel32 -Namespace Pinvoke
|
'@ -Name Kernel32 -Namespace Pinvoke
|
||||||
|
|
||||||
|
|
||||||
$ps = Get-Process -Name $ChsIME
|
$i = 0
|
||||||
foreach ($p in $ps) {
|
while ($i++ -lt 10) {
|
||||||
$hModule = $p.Modules | Where-Object {$_.ModuleName -eq $ChsIMEExe}
|
|
||||||
if (!$hModule) {
|
$ps = Get-Process -Name $ChsIME
|
||||||
continue
|
foreach ($p in $ps) {
|
||||||
|
$hModule = $p.Modules | Where-Object {$_.ModuleName -eq $ChsIMEExe}
|
||||||
|
if (!$hModule) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
$hModule = $hModule[0]
|
||||||
|
$addr = [IntPtr]::Add($hModule.BaseAddress, $offsetAddr)
|
||||||
|
[Int32]$n = 0
|
||||||
|
$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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$hModule = $hModule[0]
|
if ($ps) {
|
||||||
$addr = [IntPtr]::Add($hModule.BaseAddress, $offsetAddr)
|
break
|
||||||
[Int32]$n = 0
|
|
||||||
$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"
|
|
||||||
}
|
}
|
||||||
|
Start-Sleep -Milliseconds 100
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user