Jump to content

Help Translating Powershell version Win10 login BG Tool to AutoIt


czyt
 Share

Recommended Posts

I'm not familar with popweshell ,could someone help me translate the code below to autoit ? thanks in advance.

$priPath = $args[0]
$outputPath = $args[1]
$replacementPath = $args[2]
$ErrorActionPreference = "Stop"

$inputStream = [System.IO.File]::OpenRead($priPath)
$outputStream = [System.IO.File]::Create($outputPath)
$replacementStream = [System.IO.File]::OpenRead($replacementPath)

$inputReader = New-Object System.IO.BinaryReader -ArgumentList $inputStream
$outputWriter = New-Object System.IO.BinaryWriter -ArgumentList $outputStream
 
$inputStream.CopyTo($outputStream)

$replacementLengthAligned = ([Math]::Ceiling($replacementStream.Length / 8) * 8)

# header
$inputStream.Seek(0x14, "Begin") | Out-Null
$headerLength = $inputReader.ReadUInt32()
$inputStream.Seek(0xB8, "Begin") | Out-Null
$dataitemOffset = $inputReader.ReadUInt32()
$origDataitemLength = $inputReader.ReadUInt32()
$dataitemLength = $origDataitemLength + $replacementLengthAligned
$outputStream.Seek(0xBC, "Begin") | Out-Null
$outputWriter.Write([int]$dataitemLength)

# dataitem
$outputStream.Seek($headerLength + $dataitemOffset + 0x18, "Begin") | Out-Null
$outputWriter.Write([int]$dataitemLength)
$inputStream.Seek($headerLength + $dataitemOffset + 0x24, "Begin") | Out-Null
$stringCount = $inputReader.ReadUInt16()
$blobCount = $inputReader.ReadUInt16()
$origDataLength = $inputReader.ReadUInt32()
$outputStream.Seek(0xC, "Current") | Out-Null
$outputWriter.Write([int]($origDataLength + $replacementLengthAligned))
$outputStream.Seek($stringCount * 4, "Current") | Out-Null
for ($i = 0; $i -lt 10; $i++)
{
    $outputWriter.Write($origDataLength)
    $outputWriter.Write([int]$replacementStream.Length)
}
$outputStream.Seek(($blobCount - 10) * 8, "Current") | Out-Null

# data
$outputStream.Seek($origDataLength, "Current") | Out-Null
if ($outputStream.Length - $outputStream.Position -ne 0x18)
{
    Write-Error "Not compatible with this PRI file."
}
$replacementStream.CopyTo($outputStream)

# footer
$outputStream.Seek($replacementLengthAligned - $replacementStream.Length, "Current") | Out-Null
$outputWriter.Write(0xDEF5FADE)
$outputWriter.Write([int]$dataitemLength)
$outputWriter.Write(0xDEFFFADE)
$outputWriter.Write(0x00000000)
$outputWriter.Write([char[]]"mrm_pri2")

$outputStream.Seek(0xC, "Begin") | Out-Null
$outputWriter.Write([int]$outputStream.Length)
$outputStream.Seek(-0xC, "End") | Out-Null
$outputWriter.Write([int]$outputStream.Length)

$inputReader.Close()
$outputWriter.Close()
$replacementStream.Close()

 

董小姐,你微笑的时候很美,就像安河桥下,清澈的水...

Link to comment
Share on other sites

Hi.

Perhaps you could describe what you want to achieve?

Requests like "who could pls. help to translate <other-lang-code> to autoit?" without a single line of self written autoit code aren't served here on a quite regular basis.

 

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...