flat assembler
Message board for the users of flat assembler.

Index > Windows > align with 00h bytes?

Author
Thread Post new topic Reply to topic
Jibz



Joined: 11 May 2004
Posts: 3
Location: Denmark
Jibz
I am working with in-memory dialog templates, and need to be able to align with 00h bytes instead of the default 90h bytes. The format is MS COFF.

I have tried writing a macro for doing this in a number of ways, but keep on getting errors. Could somebody please enlighten me as to how to do this?
Post 11 May 2004, 10:18
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
try something like this:
Code:
macro zero_align value { times ((value-1)-($+value-1) mod value) db 0 }
    
Post 11 May 2004, 10:49
View user's profile Send private message Visit poster's website Reply with quote
Jibz



Joined: 11 May 2004
Posts: 3
Location: Denmark
Jibz
Code:
format MS COFF

macro zero_align value { times ((value-1)-($+value-1) mod value) db 0 }

section '.text' code readable executable

    nop

zero_align 4

    nop    

gives me

Code:
flat assembler  version 1.52
altest.asm [9]:
zero_align 4
altest.asm [3] zero_align [0]:
macro zero_align value { times ((value-1)-($+value-1) mod value) db 0 }
error: invalid expression.    

Using RVA $ instead gives the same error ..
Post 11 May 2004, 11:05
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Code:
macro align value,fill
{
  if fill eq
   align value
  else
   local ..size
   virtual
     @@: align value
     ..size = $-@b
   end virtual
   times ..size db fill
  end if
}

align 4,0
; or:
align 4,?    
Post 11 May 2004, 11:48
View user's profile Send private message Visit poster's website Reply with quote
Jibz



Joined: 11 May 2004
Posts: 3
Location: Denmark
Jibz
Thanks a lot, that did the job Smile
Post 11 May 2004, 11:57
View user's profile Send private message Visit poster's website Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
Hallo all,
My solution (not fully tested) was already posted ?
Code:
macro @align val,fill { 
  times((($+val-1)and not (val-1))-$) db fill
}
;usage:
@align 4,0
    


does it work ?
Post 03 Jan 2009, 11:49
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: 17279
Location: In your JS exploiting you and your system
revolution
hopcode wrote:
does it work ?
Only if val is a power of two.
Post 03 Jan 2009, 12:00
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.