Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^4: Perl 6: Static/Dynamic Strong/Weak Type Systems

by diotalevi (Canon)
on Apr 17, 2006 at 04:51 UTC ( [id://543756]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Perl 6: Static/Dynamic Strong/Weak Type Systems
in thread Perl 6: Static/Dynamic Strong/Weak Type Systems

You're just missing a few pointer dereferences. The pack("j",...) does the int->ptr conversion. The first unpack does SvANY( $p ) to find $a. The next one doesSvANY( $a ) to find its xpv struct. The next and final unpack is dereffing the xpv_pv pointer to read the C string.

$x = unpack "P9", unpack "P4", unpack "P4", pack "j", $p;

This is all *reading* addressable memory. Writing back to it is a completely different trick involving faking structs for B to convince perl that strings that you control are real perl structures. You can then fake up a perl string where the pointer goes to any arbitrary location.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://543756]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-24 01:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found