flat assembler
Message board for the users of flat assembler.

Index > Windows > [FASM1] Setting PE Characteristics from Source Code

Author
Thread Post new topic Reply to topic
nicebyte



Joined: 03 Jun 2022
Posts: 3
nicebyte 10 Feb 2025, 08:40
Hello,

I am writing some position independent code that I am compiling into a PE binary using FASM1.

I currently have to perform additional manipulations with the PE headers in order to make Windows engage ASLR for my binary, which is a bit annoying.

Is there some way to change PE Characteristics and DllCharacteristics from within my .asm file?
Post 10 Feb 2025, 08:40
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: 20517
Location: In your JS exploiting you and your system
revolution 10 Feb 2025, 09:31
Inside the asm file there isn't a way to access the PE header.
Code:
format pe console
load x byte from $$    
Code:
flat assembler  version 1.73.31  (16384 kilobytes memory)
test.asm [2]:
load x byte from $$
processed: load x byte from $$
error: value out of range.    
Post 10 Feb 2025, 09:31
View user's profile Send private message Visit poster's website Reply with quote
Mat Quasar



Joined: 15 Dec 2024
Posts: 87
Mat Quasar 10 Feb 2025, 09:55
If you use fasm2 or fasmg, you can modify from basic.asm in chapter1.zip.

https://board.flatassembler.net/topic.php?t=20690
Post 10 Feb 2025, 09:55
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 10 Feb 2025, 10:07
Mat Quasar wrote:
If you use fasm2 or fasmg, you can modify from basic.asm in chapter1.zip.
Even the standard fasm-compatible PE formatter for fasmg/fasm2 allows to set it up (with "PE.Settings.Characteristics"), like here:
https://github.com/tgrysztar/fasmg/blob/master/packages/aarch64/mixed.asm
Post 10 Feb 2025, 10:07
View user's profile Send private message Visit poster's website Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 772
Ali.Z 10 Feb 2025, 10:26
nicebyte wrote:
Hello,

I am writing some position independent code that I am compiling into a PE binary using FASM1.

I currently have to perform additional manipulations with the PE headers in order to make Windows engage ASLR for my binary, which is a bit annoying.

Is there some way to change PE Characteristics and DllCharacteristics from within my .asm file?


perhaps use a fixups relocation section.

_________________
Asm For Wise Humans
Post 10 Feb 2025, 10:26
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 10 Feb 2025, 11:00
Ali.Z wrote:
perhaps use a fixups relocation section.
ASLR is a bit tricky.
Post 10 Feb 2025, 11: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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.