flat assembler
Message board for the users of flat assembler.

Index > Main > Getting value of EIP

Author
Thread Post new topic Reply to topic
ronware



Joined: 08 Jan 2004
Posts: 179
Location: Israel
ronware
Is there any faster way (on Pentium and above, in protected mode) to get EIP than the standard:

Code:
     call .a
.a: pop eax
    


I can't think of one, but maybe some guru out there has a better way. Thanks!
Post 07 Jul 2005, 16:43
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Code:
mov eax, .label
.label:
    

Very Happy
Post 07 Jul 2005, 18:00
View user's profile Send private message Visit poster's website Reply with quote
ronware



Joined: 08 Jan 2004
Posts: 179
Location: Israel
ronware
Cute; but this is a piece of 'template' code which will be moved into place; it needs to be position independent
Post 07 Jul 2005, 18:10
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius
I don't think there is any other way, at least no shorter way. This is the easiest and fastest way. If you CALL FAR remember to clean up the stack.
This is the shortest amount of code; I don't know if there is any faster way. I don't think there is any way to do it without CALL or unless you use f0dder's code.
Post 07 Jul 2005, 18:17
View user's profile Send private message AIM Address Reply with quote
ronware



Joined: 08 Jan 2004
Posts: 179
Location: Israel
ronware
Yes, it works fine -- but I am manually constructing the code in the space it needs to go, now. Much, much faster than what was happening before.
Post 07 Jul 2005, 18:33
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Quote:

Cute; but this is a piece of 'template' code which will be moved into place; it needs to be position independent

I know, I was just doing a bit of fun-poking Smile

There are other ways, but this is the shortest and fastest (at least what I know of) - other methods are usually employed by evil people who want to circumvent heuristic antivirus scanners.

If you have speed problems, you need to look for them elsewhere. Construction + executing code has quite some penalty in itself, especially if you need to call the code short after you construct it. On modern processors, you only want to do code construction or self-modifying code if the modifications are few and the executions are many.
Post 07 Jul 2005, 18:43
View user's profile Send private message Visit poster's website Reply with quote
ronware



Joined: 08 Jan 2004
Posts: 179
Location: Israel
ronware
Hi, f0dder -

This is my Forth system, Reva, which interprets code into a compiled form for execution. So indeed, the modifications are few compared to the execution of the code.
Post 07 Jul 2005, 19:00
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Do you have to make PIC code anyway? Wouldn't it be possible to apply relocations?
Post 07 Jul 2005, 19:59
View user's profile Send private message Visit poster's website Reply with quote
ronware



Joined: 08 Jan 2004
Posts: 179
Location: Israel
ronware
Actually I am applying relocations, because otherwise I wouldn't be able to use the label method here. If I could have PIC code, I wouldn't have to do any tricks.
Post 07 Jul 2005, 20:04
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger 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 GitHub, YouTube, Twitter.

Website powered by rwasa.