Replies: 1 comment
-
Another example adapted from Tomasz Grysztar's Learning binary file formats: if definite FILE
file FILE
load STUB_SIGNATURE:2 from 0
load PE_OFFSET:4 from 0x3C
load PE_SIGNATURE:4 from PE_OFFSET
if STUB_SIGNATURE = "MZ" & PE_SIGNATURE = "PE"
CHECKSUM_OFFSET = PE_OFFSET + 24 + 64
CHECKSUM = 0
store CHECKSUM:4 at CHECKSUM_OFFSET
repeat $% shr 1, POSITION:0
load H:word from :POSITION shl 1
CHECKSUM = CHECKSUM + H
end repeat
while CHECKSUM shr 16
CHECKSUM = CHECKSUM shr 16 + CHECKSUM and 0FFFFh
end while
CHECKSUM = CHECKSUM + $%
store CHECKSUM:4 at CHECKSUM_OFFSET
else
err 'PE format not recognized'
end if
else
display 'usage: fasmg -i "define FILE ''<filename>''" ',__FILE__,' <outfile>'
end if In contrast this example patches the existing file, whereas the prior produces an alternate output. Both templates are infinitely useful for creating small tools. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Note the need for double quotes around the "-i" option value under windows. Which forces single quotes around the FILE value.
Beta Was this translation helpful? Give feedback.
All reactions