Bug in NativeCall

2022-11-24 Thread ToddAndMargo via perl6-users

Fedora 36
rakudo-pkg-2022.7.0-03.x86_64

say $ppSessionInf.deref.WHAT;
Internal error: unhandled target type


bug in REPL

2022-11-24 Thread ToddAndMargo via perl6-users

Fedora 36
rakudo-pkg-2022.7.0-03.x86_64


> use NativeCall

> $j =6; $k = CArray[uint8].new(0xFF xx $j ); print $j ~ "\n";
Cannot find method 'qast' on object of type NQPMu


REPL does not like the $j.


Re: NativeCall pointer question?

2022-11-24 Thread ToddAndMargo via perl6-users
On Sun, Nov 20, 2022 at 3:48 AM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


Hi All,

In one of my native call, I get returned a
pointer to a DWORD (uint32).

How do I turn that into the actual value
in the DWORD?

Many thanks,
-T


On 11/20/22 16:00, Clifton Wood wrote:

@ToddAndMargo,

Two ways:

  - Use "my CArray[uint32] $p", use $p as your parameter, and access the 
value as "$p[0]"


or

- Use "my Pointer[uint32] $p"  and use "$p.deref"

My personal preference is the former, as it is the best way to access 
AND set the actual former value. The latter can only deref. To my 
knowledge, you cannot set the referenced value of a Pointer type. I do 
reserve the right to be wrong on this, though.



Hi Clifton,

I have a pointer $p (from a Windows API call)
that points to a spot in memory that is 24
bytes long.

# Where do I tell it I want 24 bytes back?
my $ca = CArray[uint8].new( 0xFF ** 24 )
$ca = $p.deref;

Internal error: unhandled target type


Yours in confusion,
-T



Re: Pointer to bug question

2022-11-24 Thread ToddAndMargo via perl6-users

On 11/23/22 20:01, Clifton Wood wrote:

Long story short:

my $a = GLib::Roles::TypedBuffer[.new($ppSessionInf);
$a.setSize($pCount, :forced);
my @sessions = $a.Array;

That should return you an array of  objects.





raku PopUpTest2.pl6
===SORRY!=== Error while compiling K:\Windows\NtUtil/PopUpTest2.pl6
Cannot use variable $a in declaration to initialize itself
at K:\Windows\NtUtil/PopUpTest2.pl6:115
-->$a.setSize( ($pCount* 12 * $Win64bit), :f
expecting any of:
term



   class WTS_SESSION_INFOA is repr {
  has uint16 $.SessionID;
  has LPSTR $.pWinStationName;
  #has WTS_CONNECTSTATE_CLASS $.State
  has DWORD $.State
   }

   my WTS_SESSION_INFOA $SessionInfo;



   #`{
  comment What is PWTS_SESSION_INFOA? was posted by Castorix31 on 
Microsoft Q:

  C++ is 12 bytes in x86, 24 bytes in x64
  It is 3*8 :
  // x64
 int nSize1 = sizeof WTS_SESSION_INFOA; // 24

 int nOffset1 = offsetof(WTS_SESSION_INFOA, SessionId); // 0
 int nOffset2 = offsetof(WTS_SESSION_INFOA, pWinStationName); // 8
 int nOffset3 = offsetof(WTS_SESSION_INFOA, State); // 16

  On 11/23/22 20:01, Clifton Wood wrote:
  my $a = GLib::Roles::TypedBuffer[.new($ppSessionInf);
  $a.setSize($pCount, :forced);
  my @sessions = $a.Array;

   }

113:   # my BYTES  $Sessions = CArray[BYTE].new( 0xFF xx $pCount * 32 );
114:   my $a = 
GLib::Roles::TypedBuffer[.new($ppSessionInf);

115:   $a.setSize( ($pCount * 12 * $Win64bit), :forced );
   # my $Sessions = buf8.new( 0xFF xx (12 * $Win64bit) );
   my @Sessions = $ppSessionInf.deref[BYTES].CArray.buf8;
   print "\@Sessions = <" ~ @Sessions ~ "<\n";