flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > macro to detect format

Author
Thread Post new topic Reply to topic
rCX



Joined: 29 Jul 2007
Posts: 172
Location: Maryland, USA
rCX 07 Jul 2021, 01:43
Is there a way to write a macro that conditionally generates code based on the format eg, ELF, PE?
Post 07 Jul 2021, 01:43
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 07 Jul 2021, 07:02
Thought about suggesting format detection feature like a month ago. Decided that it’s not worth even asking (for my case) since one can easily override the format directive with a macro, parse its parameters, write down the information needed and pass the parameters to the original directive. Although this may definitely get quite messy.
Post 07 Jul 2021, 07:02
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: 20448
Location: In your JS exploiting you and your system
revolution 07 Jul 2021, 08:19
if we can make it a narrow test to detect just an executable variant of PE or ELF and assume it is just using the default settings then I think this might work:
Code:
format pe
;format elf executable

if rva $$ and 0xfff = 0
        display 'is pe',13,10
else
        display 'is elf',13,10
end if    
Although there are probably lots of ways to trick this into getting it wrong. Sad
Post 07 Jul 2021, 08:19
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.