I'm experimenting with pe.inc. I've tried to rename the PE address space and encountered a strange error, and I can't understand what's wrong.
How to reproduce (or you can get premodified pe.inc):
1. Open pe.inc
2. Replace PE:: to XXX::
3. Replace PE: to XXX: everywhere (but don't replace where it is not a whole word, like here: load TYPE:word).
4. Replace "define CheckSumBlocks XXX,0,HeadersEnd" to "define CheckSumBlocks PE,0,HeadersEnd".
5. Try to compile win32.asm example. Error:
Quote: |
win32.asm [25]:
section '.idata' import data readable writeable
macro section [3] macro section [14]:
store SECTION_SIZE at XXX:SectionTable.VirtualSize+SECTION_INDEX*SectionTable.ENTRY_LENGTH
Processed: store SECTION_SIZE at XXX:SectionTable.VirtualSize+SECTION_INDEX*SectionTable.ENTRY_LENGTH
Error: address out of range.
|
|
Trying to debug it...
1. Replace:
Code: |
if DEFINED_SECTION | SECTION_SIZE > 0
SECTION_INDEX = SECTION_INDEX + 1
end if
|
|
to
Code: |
if DEFINED_SECTION | SECTION_SIZE > 0
SECTION_INDEX = SECTION_INDEX + 1
repeat 1, n:SECTION_INDEX
display 'section: ', `n, 0x0A
end repeat
end if
|
|
2. Replace:
Code: |
NUMBER_OF_SECTIONS := SECTION_INDEX
|
|
to
Code: |
NUMBER_OF_SECTIONS := SECTION_INDEX
repeat 1, n:SECTION_INDEX
display 'postpone: ', `n, 0x0A
end repeat
|
|
3. The result:
Code: |
section: 1
section: 2
section: 3
section: 1
postpone: 1
|
|
What's wrong? Why SECTION_INDEX resets to the 0 before the last section?