flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Access keytable

Author
Thread Post new topic Reply to topic
kingjojo



Joined: 01 Nov 2013
Posts: 2
kingjojo 02 Nov 2013, 00:28
Code:
format PE GUI 4.0
entry start

macro testMacro arg1, keyTable
{
        count = (keyTable#.end - keyTable#.begin)
        repeat count
                load key byte from keyTable#.begin+%-1
        end repeat
}

section '.data' data readable writeable
        keyTableTest.begin:
                db 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
        keyTableTest.end:

        
section '.code' code readable executable
        start:
        push ebp
        mov ebp, esp
        
        xor eax, eax
        mov esp, ebp
        pop ebp
        ret
        
        testMacro testArg, keyTableTest
    


I always get the error and I have no clue what im doing wrong. I would really appreciate it if somebody could help me with that.
Quote:

load key byte from keyTable#.begin+%-1
error: value out of range.
Post 02 Nov 2013, 00:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
revolution 02 Nov 2013, 02:06
Because the data being loaded is in a different section you need to define an addressing space label with the double colon (::)
Code:
format PE GUI 4.0
entry start

macro testMacro arg1, keyTable
{
        count = (keyTable#.end - keyTable#.begin)
        repeat count
                load key byte from keyTable:keyTable#.begin+%-1
        end repeat
}

section '.data' data readable writeable
        keyTableTest::
        keyTableTest.begin:
                db 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
        keyTableTest.end:


section '.code' code readable executable
        start:
        testMacro testArg, keyTableTest    
Post 02 Nov 2013, 02:06
View user's profile Send private message Visit poster's website Reply with quote
kingjojo



Joined: 01 Nov 2013
Posts: 2
kingjojo 02 Nov 2013, 15:45
Thank you very much, it works!
Post 02 Nov 2013, 15:45
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.