@ToddAndMargo <toddandma...@zoho.com> I'm about to go to sleep for the night. I thought I sent you a link to a role that someone gave me for solving this problem. Please check out this role <https://github.com/Xliff/p6-GLib/blob/master/lib/GLib/Roles/TypedBuffer.pm6#L120>. Please feel free to download the entire file and use it. If you need more help, I should be available sometime in the morning.
Long story short: my $a = GLib::Roles::TypedBuffer[<nameOfCStruct>.new($ppSessionInf); $a.setSize($pCount, :forced); my @sessions = $a.Array; That should return you an array of <nameOfCStruct> objects. Good luck! On Wed, Nov 23, 2022 at 9:46 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > >>> Hi All, > >>> > >>> This is driving me nuts! > >>> > >>> Native Call question. I have a Pointer ($ppSessionInf). > >>> > >>> It points to a structure of $pCount bytes. > >>> > >>> How do I load what $ppSessionInf points to into $Sessions > >>> > >>> # something gets assigned to it from an API call > >>> my Pointer $ppSessionInf = Pointer.new(); > >>> > >>> # length of the data I want also from the API call > >>> my DWORD $pCount; # length of the data I want > >>> > >>> # Buffer I want the data pointer to by > >>> # $ppSessionInf loaded into > >>> my BYTES $Sessions = CArray[BYTE].new( 0xFF xx $pCount ); > >>> > >>> $Sessions = $ppSessionInf.deref; > >>> > >>> Which obviously does not work: > >>> Internal error: unhandled target type > >>> > >>> Many thanks, > >>> -T > >>> > > >> On Wed, Nov 23, 2022 at 9:21 PM Clifton Wood <clifton.w...@gmail.com > >> <mailto:clifton.w...@gmail.com>> wrote: > >> > >> @ToddAndMargo <mailto:toddandma...@zoho.com> - Did you try my > >> suggestion with GLib::Roles::TypedBuffer? > >> > >> The "unhandled target type" occurs when NativeCall can't figure out > >> how to deref the referenced value. In this case, this would be the > >> BYTE of the CArray. > >> > >> What type is BYTE, pray tell? > >> > >> - Cliff > >> > >> On Wed, Nov 23, 2022 at 9:08 PM ToddAndMargo via perl6-users > >> <perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote: > >> > >> removing my typos: > >> > > On 11/23/22 18:22, Clifton Wood wrote: > > @ToddAndMargo <mailto:toddandma...@zoho.com> -- Also, Pointer cannot > > deref a Pointer, which I think is the real error. > > > How do I load what $ppSessionInf points to into $Sessions? > > >