flat assembler
Message board for the users of flat assembler.

Index > Heap > "Discussion" from the "fixups?" thread

Goto page 1, 2, 3  Next
Author
Thread Post new topic Reply to topic
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
chaoscode wrote:
When an File is loaded into Ram for execution it gets relocated (did i spell it right?)
and every address in the Programm is not right
and "fixups" tells fasm to create automatically a Section which is interpreted by windows.
in this section is where the adresses are and how they have to be manipulated before the Programm can be executed.
Usually exe files don't need to be relocated, but DLL-Files often need.
Why make a whole 512 byte section to do something so trivial when you can just do it yourself?

call @f
@@:
pop [pointer]



OS-independent code FTW!



p.s. if either of these are needed, why is virtual memory also needed? I thought it was supposed to make this kind of stuff unnecessary, and that that was the justification for such a performance killer.

_________________
Post 12 Nov 2009, 22:59
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Virtual memory is for multiple processes at the same time. DLLs are shared and accessed by multiple processes, not "unique" to each process. If 100 processes load the same DLL they will only load the DLL once.

I don't understand your code example though.
Post 12 Nov 2009, 23:54
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
Borsuc wrote:
I don't understand your code example though.
It does the same thing as the fixups but in only like 10 bytes and works on any OS.

_________________
Post 12 Nov 2009, 23:56
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
Quote:
I don't understand your code example though.


PIC

position independent code
Post 15 Nov 2009, 10:46
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Azu wrote:
Borsuc wrote:
I don't understand your code example though.
It does the same thing as the fixups but in only like 10 bytes and works on any OS.
Your code misses the "sub reg, label", and you fail to mention that any access to global variables then has to be done by offset through a register, rather than a simple static-address mov.

Fixups are done once at program load-time (and can be done without marking pages as dirty), whereas your PIC method has runtime overhead implications.

_________________
Image - carpe noctem
Post 16 Nov 2009, 09:37
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
f0dder wrote:
Azu wrote:
Borsuc wrote:
I don't understand your code example though.
It does the same thing as the fixups but in only like 10 bytes and works on any OS.
Your code misses the "sub reg, label", and you fail to mention that any access to global variables then has to be done by offset through a register, rather than a simple static-address mov.

Fixups are done once at program load-time (and can be done without marking pages as dirty), whereas your PIC method has runtime overhead implications.
Oh no, you have to add another dozen bytes or so to make a loop that does that, once, at startup. Such awful overhead! Thank god we have OS-dependent inventions like the Windows fixup section to save us! Rolling Eyes

_________________
Post 16 Nov 2009, 09:42
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 693
Location: Adelaide
sinsi
position independent code <> position independent data

jumps/calls are usually not fixed (eip+x) -> no fixups needed
global data are fixed -> needs a fixup (delta) added

exe's start at 00400000, not usually relocated (except for win32s Very Happy )
dll's start all over the place and usually need relocated.


Last edited by sinsi on 16 Nov 2009, 09:52; edited 2 times in total
Post 16 Nov 2009, 09:45
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
sinsi wrote:
position independent code <> position independent data
There is no difference whatsoever.

_________________
Post 16 Nov 2009, 09:48
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
Code:
call @f 
@@: 
pop [pointer]
    


BTW, the "code" is strange, first, I personally completely avoid pointer's in FASM code, second, to get it "working" at all, you would have to define your "pointer" as "ebp-8" or some other ESP or EBP (or other reg) based thing Wink
Post 16 Nov 2009, 09:48
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
DOS386 wrote:
Code:
call @f 
@@: 
pop [pointer]
    


BTW, the "code" is strange, first, I personally completely avoid pointer's in FASM code, second, to get it "working" at all, you would have to define your "pointer" as "ebp-8" or some other ESP or EBP (or other reg) based thing Wink


Whatever. Write your code in org 0, pop into eax instead, and loop through adding eax to each label. What's the big deal?

_________________
Post 16 Nov 2009, 09:49
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 693
Location: Adelaide
sinsi
see edit
Post 16 Nov 2009, 09:53
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
see my replies to DOS386 and f0dder
Post 16 Nov 2009, 09:57
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Azu wrote:
DOS386 wrote:
Code:
call @f 
@@: 
pop [pointer]
    


BTW, the "code" is strange, first, I personally completely avoid pointer's in FASM code, second, to get it "working" at all, you would have to define your "pointer" as "ebp-8" or some other ESP or EBP (or other reg) based thing Wink


Whatever. Write your code in org 0, pop into eax instead, and loop through adding eax to each label. What's the big deal?
...and what's the big deal with using an industry standard OS-supplied method of doing this, that handle code as well as data fixups, don't (necessarily - don't know about windows' implementation) cause pages to be flagged as dirty, and don't take up an x86 register for delta-position?

_________________
Image - carpe noctem
Post 16 Nov 2009, 10:06
View user's profile Send private message Visit poster's website Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 693
Location: Adelaide
sinsi
call @f
@@:
pop [pointer]

Then what?
mov eax, [pointer]
add eax,globalvar1+[pointer]-pointer-globalvar
mov eax,[eax]

What about
call [GetCurrentProcess]

For windows (at least) global vars are at a fixed address, so we need to do a lot of maths to get its final address using [pointer].
They even used it for MZ exes ffs
Post 16 Nov 2009, 10:16
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
f0dder wrote:
Azu wrote:
DOS386 wrote:
Code:
call @f 
@@: 
pop [pointer]
    


BTW, the "code" is strange, first, I personally completely avoid pointer's in FASM code, second, to get it "working" at all, you would have to define your "pointer" as "ebp-8" or some other ESP or EBP (or other reg) based thing Wink


Whatever. Write your code in org 0, pop into eax instead, and loop through adding eax to each label. What's the big deal?
...and what's the big deal with using an industry standard OS-supplied
Do you know what an oxymoron is?

OS-specific non-portable code is the exact opposite of standardized.

f0dder wrote:
method of doing this, that handle code as well as data fixups, don't (necessarily - don't know about windows' implementation) cause pages to be flagged as dirty, and don't take up an x86 register for delta-position?
Huh? Who said anything about taking up a register (besides you)?


sinsi wrote:
call @f
@@:
pop [pointer]

Then what?
mov eax, [pointer]
add eax,globalvar1+[pointer]-pointer-globalvar
mov eax,[eax]
???



sinsi wrote:
What about
call [GetCurrentProcess]

For windows (at least) global vars are at a fixed address, so we need to do a lot of maths to get its final address using [pointer].
They even used it for MZ exes ffs

Screw that!
Put the address in there at startup and call it directly. Why do people like this indirect call shit so much??? Sad

_________________
Post 16 Nov 2009, 10:33
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 693
Location: Adelaide
sinsi
Quote:
???
That's right, it is a nightmare
Quote:
Put the address in there at startup

A BLOODY FIXUP DOES IT FOR YOU AT STARTUP AUTOMAGICALLY.

define:irony
Post 16 Nov 2009, 10:39
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
sinsi wrote:
Quote:
???
That's right, it is a nightmare
What is "it"? You posted random code with no indication of wtf it is supposed to do.


sinsi wrote:
Quote:
Put the address in there at startup

A BLOODY FIXUP DOES IT FOR YOU AT STARTUP AUTOMAGICALLY.

define:irony
They turn call [func] into call func? I doubt that. Not that it matters, since they only exist for one single OS, and require adding at least 512 extra bytes to your executable.

Why would you want to write code that will only work in one OS and is bloated too?

_________________
Post 16 Nov 2009, 10:44
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 693
Location: Adelaide
sinsi
Do you use global variables in your code?
Post 16 Nov 2009, 10:54
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
Yes.

And when I need to inject my code into another process I use the method I mentioned above, not this bloated OS-specific DLL/fixup crud.



p.s.
Again, I ask, what is the excuse of all the overhead from virtual memory when address independent code is needed anyways? (whether from this fixup bloat or by doing it yourself like I do)
=/

I think it's because this is only needed for injecting code into another process, and if you're doing that you should have no problem fixing the locations yourself.

_________________
Post 16 Nov 2009, 10:59
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 693
Location: Adelaide
sinsi
Quote:
And when I need to inject my code into another process

OK see ya
Post 16 Nov 2009, 11:10
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3  Next

< 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 can 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.