flat assembler
Message board for the users of flat assembler.

Index > Main > Struc array

Author
Thread Post new topic Reply to topic
Jin X



Joined: 06 Mar 2004
Posts: 133
Location: Russia
Jin X 17 Aug 2018, 13:20
Hello!

1. How can I define array of uninitialized structures?
Code:
struc POINT
{
  .x dd ?
  .y dd ?
}

Points POINT 10 dup (?)  ; error!!!    

And then use mov eax,[Points.y+edx*8]

2. Can I define structure without label name?
Code:
POINT ; error    


Last edited by Jin X on 17 Aug 2018, 13:25; edited 1 time in total
Post 17 Aug 2018, 13:20
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20515
Location: In your JS exploiting you and your system
revolution 17 Aug 2018, 13:25
1. Your POINT structure doesn't define its size so it will be tricky, but it can be done like this:
Code:
Points POINT ; the first POINT structure
rept 9 {
 local .dummy_label
 .dummy_label POINT
}    
2. Macros and Strucs are the same thing except that struc requires a label name. If you want to place structures without a label then you can define a macro of the same name. Macros and Strucs are kept in separate places so you can define both in same code with the same name.
Post 17 Aug 2018, 13:25
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20515
Location: In your JS exploiting you and your system
revolution 17 Aug 2018, 13:28
Jin X wrote:
And then use mov eax,[Points.y+edx*8]
Ideally you would define the size of the structure so that changes will be applied to any code that uses it.
Code:
mov eax,[Points.y+edx*sizeof.POINT]    


Last edited by revolution on 17 Aug 2018, 16:46; edited 1 time in total
Post 17 Aug 2018, 13:28
View user's profile Send private message Visit poster's website Reply with quote
Jin X



Joined: 06 Mar 2004
Posts: 133
Location: Russia
Jin X 17 Aug 2018, 15:10
How can I access some scturture field relative to some address. Something like:
Code:
mov eax,[edx+POINT.y]  ; mov eax,[edx+4]    

???
Post 17 Aug 2018, 15:10
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20515
Location: In your JS exploiting you and your system
revolution 17 Aug 2018, 16:08
Jin X wrote:
How can I access some scturture field relative to some address. Something like:
Code:
mov eax,[edx+POINT.y]  ; mov eax,[edx+4]    

???
You have to define POINT.y as a label
Code:
struc POINT {
y dd ?
}
POINT POINT ;define POINT.y label    
Post 17 Aug 2018, 16:08
View user's profile Send private message Visit poster's website Reply with quote
Jin X



Joined: 06 Mar 2004
Posts: 133
Location: Russia
Jin X 17 Aug 2018, 16:42
Something like this? Smile
Else I will get addressing relative to POINT (label definition) offset.
Code:
virtual at 0
  POINT POINT
end virtual    
Post 17 Aug 2018, 16:42
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20515
Location: In your JS exploiting you and your system
revolution 17 Aug 2018, 16:45
Yes, if you don't need the memory allocated, and only want the label values.
Post 17 Aug 2018, 16:45
View user's profile Send private message Visit poster's website 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.