Hi All,
NativeCall question:
I am confused about how to assign an address
to a pointer
[1] > use lib '.'; use NativeCall; use NativeConstants
Nil
[2] > my $x=0xFE45DDCC;
4265991628
[3] > my Pointer $Ptr2Ptr = NativeCall::Types::Pointer[BYTES].new($x);
NativeCall::Types::Pointer<0xfe45ddcc>
[4] > print "x = <" ~ $x ~ "> <0x" ~ $x.base(16) ~ "> Ptr2Ptr <" ~
$Ptr2Ptr ~ ">\n";
x = <4265991628> <0xFE45DDCC> Ptr2Ptr
<NativeCall::Types::Pointer<4852306736864>>
[5] > dd $Ptr2Ptr
Pointer $Ptr2Ptr = NativeCall::Types::Pointer.new(4265991628)
Nil
[6] > say $Ptr2Ptr
NativeCall::Types::Pointer<0xfe45ddcc>
Here is the confusion. In step [3], when
I created the pointer ($Ptr2Ptr), I pre-salted
$Ptr2Ptr with $x (0xFE45DDCC), REPL showed
$Ptr2Ptr was created with the value of $x.
But in step [4], when I printed out the value
of $Ptr2Ptr, is some other number and not $x.
And steps [5] and [6] comes out okay.
What am I missing? What is wrong with step [4]?
Yours in confusion,
-T