flat assembler
Message board for the users of flat assembler.

Index > Windows > How load and run ELF code in PE program ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 509
Roman
I write simple fasm PE 32 bit program.
This program load compiled ELF asm code.
And must run ELF code.

How correct load in some place ELF and run in my Fasm PE exe ?

Pseudo code
Code:
format PE GUI 4.0
entry Start

Start:
  MacroLoadELF AdrELF
  Call AdrELF

section '.bss' readable writeable
AdrELF rb 10000
    
Post 13 Aug 2019, 02:46
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 377
Location: Russian Federation, Sochi
ProMiNick
In theory it is easy reading elf headers - according to them allocates pages with apropriate (read, write, execute) permissions. copy content of file to that pages. then reading elf relocs and aply them. then must be resolved imports to their windows analogs. All sounds simple only in theory.

On practice thou have to know elf format deep detail.
thou have to know what api equvalents in both OS, and how from one parameters set wrap to another.
thou have to know how to allocate memory with permissions.
And moreover all of work would be unusefull if in used part of elf code would be even one syscall.

Contrvers task - using PE in ELF looks more simpler due to (PE - is most documented executable format in world),(PE commonly never uses syscalls).
Post 13 Aug 2019, 13:45
View user's profile Send private message Send e-mail Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 449
Location: Czech republic, Slovak republic
Feryno
If your windows supports WSL (Windows Subsystem for Linux), you can run linux binaries natively. There is already WSL 2 in latest windows insiders.
Post 13 Aug 2019, 15:49
View user's profile Send private message Visit poster's website ICQ Number 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-2019, Tomasz Grysztar.

Powered by rwasa.