$ cat hack_self.imc .include "datatypes.pasm"
.sub _main
new $P1, .PerlArray
push $P1, .DATATYPE_INTVAL
push $P1, 32
push $P1, 0
push $P1, .DATATYPE_FLOATVAL
push $P1, 32
push $P1, 0 .sym pmc Nul
null Nul
getinterp P5
dlfunc P0, Nul, "Parrot_UnManagedStruct_get_pointer", "pIP"
invoke
set $P2, P5
assign $P2, $P1 print I20
print "\n"
print N10
print "\n" set $P2[0;20], 20
set $P2[1;10], 42.0 print I20
print "\n"
print N10
print "\n"
end
.end
$ parrot hack_self.imc
0
0.000000
20
42.000000This is unlimited self-inspection and self-modification :) With little additions (nested structs) one could read/write all Parrot_Interp internals (including possible security bits) and not only registers like above. But current state is already sufficient to seriously damage the interpreter ($P2 above is a struct representing the current interpreter)
leo
