On 11/23/22 20:01, Clifton Wood wrote:
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.




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
------>    $<HERE>a.setSize( ($pCount* 12 * $Win64bit), :f
    expecting any of:
        term



   class WTS_SESSION_INFOA is repr<CStruct> {
      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&A:
      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[<nameOfCStruct>.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[<WTS_SESSION_INFOA>.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";

Reply via email to