Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

How to get the (CPU) stack address ?

by arhuman (Vicar)
on Jan 15, 2002 at 13:15 UTC ( #138857=perlquestion: print w/ replies, xml ) Need Help??
arhuman has asked for the wisdom of the Perl Monks concerning the following question:

Despite my searchs on the monastery, I didn't manage to find a precise answer.

So I turn to you enlighten monks :
How could I retrieve the cpu stack address ?
(In last resort, I think I could use INLINE::Asm to do the trick,
but I'd prefer pure Perl or standard module based solutions)

Any (clever) Idea ?
TIA

NOTE : For those of you, who may wonder why I'd need such info, I'd just say that I'm "working" on buffer overflows ;-)


"Only Bad Coders Code Badly In Perl" (OBC2BIP)

Comment on How to get the (CPU) stack address ?
Re: How to get the (CPU) stack adress ?
by Zaxo (Archbishop) on Jan 15, 2002 at 14:22 UTC

    Inline::ASM would be the best way I know.

    #!/usr/src/perl -w use strict; use Inline ASM => 'DATA', AS => 'as', PROTO => {sptr => 'unsigned long()'}; print 0 | sptr(),$/; # ... __END__ __ASM__ .text .globl sptr sptr: movl %esp,%eax ret

    After Compline,
    Zaxo

      Thanx for your answer !

      But I still hope for another solution,
      as I said in my initial post, pure Perl or standard module based solutions
      (if available) are most welcome !


      "Only Bad Coders Code Badly In Perl" (OBC2BIP)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://138857]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2015-07-03 03:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls