With Fasm 1.67, i can move previously declared blocks of code
to a specified location thank to this kind of macro (and the
flexibility of Fasm!):
movc/endc
aBlockList equ
macro realize_item [value] {
value
}
macro realize_rept argList {
match items,argList \{
realize_item items
\}
}
macro movc arg,blockname {
add_to_list aBlockList,blockname
local p1,p2
p1:
jmp p2
mov eax,arg
macro blockname \{
p2:
mov eax,p2-p1
}
endc fix }
start:
nop
nop
movc 1111h,my_blockname
xor eax,eax
xor ecx,ecx
xor edx,edx
ret
endc
nop
nop
movc 2222h,your_blockname
mul eax
mul ecx
mul edx
ret
endc
nop
nop
ret
.block_starts:
realize_rept aBlockList
and the output
Section .code (0x00402000) with PEBrowser
01 0x402000: 90 NOP
02 0x402001: 90 NOP
03 0x402002: EB11 JMP 0x402015 ; (*+0x13)
04 0x402004: B811110000 MOV EAX,0x1111
05 0x402009: 90 NOP
06 0x40200A: 90 NOP
07 0x40200B: EB14 JMP 0x402021 ; (*+0x16)
08 0x40200D: B822220000 MOV EAX,0x2222
09 0x402012: 90 NOP
10 0x402013: 90 NOP
11 0x402014: C3 RET
12 0x402015: B813000000 MOV EAX,0x13 ; <==0x00402002(*-0x13) 19 bytes
13 0x40201A: 31C0 XOR EAX,EAX
14 0x40201C: 31C9 XOR ECX,ECX
15 0x40201E: 31D2 XOR EDX,EDX
16 0x402020: C3 RET
17 0x402021: B816000000 MOV EAX,0x16 ; <==0x0040200B(*-0x16) 22 bytes ?
18 0x402026: F7E0 MUL EAX
19 0x402028: F7E1 MUL ECX
20 0x40202A: F7E2 MUL EDX
21 0x40202C: C3 RET
22 0x40202D: 0000 ADD BYTE PTR [EAX],AL
23 0x40202F: 0000 ADD BYTE PTR [EAX],AL
...
But the one and only question :
Why on line 12 the bytes ar 19 (it is right so!) and
on line 17 the bytes ar 22 for two blocks of code of the same size?
But Fasm is really no limits!
Fasm, NO LIMITS !!!
hopcode[mrk]