Page 1 of 1

Batch operations on the command line / script file

Posted: 08 Sep 2021 11:12
by SysVR
General binary operations commands, script files (* .hxds / *. *)
I want you to be able to execute it with.

For example, if you have a file of 0x2147483647 bytes,

Starting from 0x65535 from the beginning of the file (base offset)
Extract the range of 0x64 for every 0x256 and
Operate up to 0x16384
Write it to the specified file with a CRLF line feed code.

Script example

External argument =% *
Variable = $ *
Label =: *
Function = & *

===== Function =====
&Copy $Select, $Cur

&FileOpen Option (
N = If the file does not exist Create a new one
R = read-only open
C = Read file index (if not specified, next to the last opened number)
W = Wait until the file is closed if it is open
)

&Imput [$Cur]
Write at the cursor position

&Save Option (
[FileOpenIndex] Optional
)
Even if you operate it, it will not be saved in the file unless you save it.
The file is not closed.

&Wait Option (
I = Prompt user for input after waiting
V = Put ​​the value entered by the user in a variable
P = Prompt Message
) Wait for milliseconds.

===== Variable =====
$BaseAddress [FileOpenIndex]
$Cur [FileOpenIndex] Current cursor position (0x0)
$Select [FileOpenIndex] Returns the address of the selection.
$Select [variable name]
Note that the specification is an offset from the cursor position.
$EOF [FileOpenIndex] Returns the end-of-file address of a file

Code: Select all

//HxD Script Ver 1.00
&FileOpen /N '%1'
$BaseAddress0=0x65535
$Cur0=0x0
$FileName=''

&Wait /I /V $FileName /P='Imput File Name' 0

&FileOpen /N /C5 '../result_$FileName'
for (0x16384>$Cur0){
   $Cur0+0x256
   $Select0=$Cur0,0x64
   $Cur5=$EOF
   &Copy $Select0 $Cur5
   &Imput $Cur5 0x0D0A
}
&Save5