mirror of
https://github.com/Yamato-Security/WELA.git
synced 2026-10-08 15:25:24 +02:00
Read the owned release pipe with encoding-preamble detection
This commit is contained in:
1 parent
019f13b566
commit
bfbdc6c476
1 file changed
+4
-1
@@ -1,7 +1,10 @@
|
||||
# Fixed locally generated script; no external inputs or configuration writes.
|
||||
$ErrorActionPreference = 'Stop'
|
||||
[Console]::Out.WriteLine(('WELA_SCRIPT_READY___WELA_SCRIPT_NONCE__|' + $ExecutionContext.SessionState.LanguageMode + '|' + $PSVersionTable.PSVersion))
|
||||
$release = [Console]::In.ReadLine()
|
||||
# .NET Framework's redirected-input writer may emit an encoding preamble.
|
||||
# Read the owned pipe through a BOM-aware reader, without changing console state.
|
||||
$pipeReader = [IO.StreamReader]::new([Console]::OpenStandardInput(), [Text.UTF8Encoding]::new($false, $true), $true, 128, $true)
|
||||
try { $release = $pipeReader.ReadLine() } finally { $pipeReader.Dispose() }
|
||||
if ($release -cne 'WELA_SCRIPT_GO___WELA_SCRIPT_NONCE__') { exit 17 }
|
||||
[Console]::Out.WriteLine('WELA_SCRIPT_COMPLETE___WELA_SCRIPT_NONCE__')
|
||||
exit 0
|
||||
Reference in new issue
Block a user