Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Handling binary files
#7
powershell code: How to get code to its equivalent QM code?
 
Code:
Copy      Help
# Read the content of the binary file
$fileContent = [System.IO.File]::ReadAllBytes("$HOME\desktop\a.bin")

# Find and replace specific bytes
for ($i = 0; $i -lt $fileContent.Length - 1; $i++)
{
    if ($fileContent[$i] -eq 0x55 -and $fileContent[$i + 1] -eq 0xAA)
    {
        $fileContent[$i] = 0xFF
        $fileContent[$i + 1] = 0xFF
    }
}

# Write the modified content back to the file
[System.IO.File]::WriteAllBytes("$HOME\desktop\b.bin", $fileContent)

solved. The QM code looks simpler and more elegant.

Macro Macro18
Code:
Copy      Help
str s.getfile("$desktop$\a.bin")

for(_i 0 s.len)
,if s[_i]=0x55 and s[_i+1]=0xAA
,,s[_i]=0xFF
,,s[_i+1]=0xFF

s.setfile("$desktop$\b3.bin")


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)