Re: Pointer to bug question

2022-11-28 Thread ToddAndMargo via perl6-users

On 11/27/22 19:13, Clifton Wood wrote:
ToddAndMargo: Why are you referencing NativeHelpers::Blob when I've 
linked to the code you need. The bug was in the code snippet I've sent. 
NONE of my stuff is available via zef because CURI (and hence zef) have 
problems with large scale code that I am still trying to resolve.


You should be able to get a clean copy of the role from here 
. You should be able to download it, copy it to your project directory and execute it.


No zef necessary.


Hi Clifton,

I have been looking over the code.  I am not sure what
I am looking at.

Would you give me a brief summary of what it is
suppose to do?

Many thanks,
-T



Re: Pointer to bug question

2022-11-28 Thread ToddAndMargo via perl6-users

On 11/27/22 19:13, Clifton Wood wrote:
ToddAndMargo: Why are you referencing NativeHelpers::Blob when I've 
linked to the code you need. The bug was in the code snippet I've sent. 
NONE of my stuff is available via zef because CURI (and hence zef) have 
problems with large scale code that I am still trying to resolve.


You should be able to get a clean copy of the role from here 
. You should be able to download it, copy it to your project directory and execute it.


No zef necessary.

Sorry.  I did not realize it was there.

Is it supporting Win32 yet?


Re: Pointer to bug question

2022-11-27 Thread Clifton Wood
ToddAndMargo: Why are you referencing NativeHelpers::Blob when I've linked
to the code you need. The bug was in the code snippet I've sent. NONE of my
stuff is available via zef because CURI (and hence zef) have problems with
large scale code that I am still trying to resolve.

You should be able to get a clean copy of the role from here
.
You should be able to download it, copy it to your project directory and
execute it.

No zef necessary.

On Fri, Nov 25, 2022 at 4:50 PM ToddAndMargo  wrote:

> On 11/24/22 20:55, Clifton Wood wrote:
> > Heh!  I had a bug in my code and you pretty much mimic'd it. That's on
> > me. Line 114 should read:
> >
> > "my $a = GLib::Roles::TypedBuffer[WTS_SESSION_INFOA].new($ppSessionInf);"
> >
> > Let me know how it works out.
> >
>
>
>
> zef uninstall NativeHelpers::Blob
> ===> Uninstalled from C:\Users\tony\.raku
> NativeHelpers::Blob:ver<0.1.12>:auth
>
> K:\Windows\NtUtil>zef install NativeHelpers::Blob
> ===> Searching for: NativeHelpers::Blob
> ===> Updating fez mirror: https://360.zef.pm/
> ===> Updated fez mirror: https://360.zef.pm/
> ===> Updating rea mirror:
> https://raw.githubusercontent.com/Raku/REA/main/META.json
> ===> Updated rea mirror:
> https://raw.githubusercontent.com/Raku/REA/main/META.json
> ===> Testing: NativeHelpers::Blob:ver<0.1.12>:auth
> [NativeHelpers::Blob] ===SORRY!=== Error while compiling
>
> C:\Users\tony\.zef\tmp\NativeHelpers%3A%3ABlob%3Aver%3C0.1.12%3E%3Aauth%3Cgithub%3Asalortiz%3E.tar.gz\NativeHelpers-Blob-master/t\02-cstruct.t
> [NativeHelpers::Blob] Failed to open file
> C:\Users\tony\.zef\tmp\NativeHelpers%3A%3ABlob%3Aver%3C0.1.12%3E%3Aauth%3Cgithub%3Asalortiz%3E.tar.gz\NativeHelpers-Blob-master\t\.precomp\BE04B1FADFC312E3411CB403B43E629B7AED3ADC\27\27F410113BBD23B298581F9F713FBCFB39C1584E.repo-id.2BAIB5TQR7KNKMX1796GKOJF6.tmp:
>
> No such file or directory
> [NativeHelpers::Blob] at
>
> C:\Users\tony\.zef\tmp\NativeHelpers%3A%3ABlob%3Aver%3C0.1.12%3E%3Aauth%3Cgithub%3Asalortiz%3E.tar.gz\NativeHelpers-Blob-master/t\02-cstruct.t:3
> [NativeHelpers::Blob] Actually thrown at:
> [NativeHelpers::Blob]   in any statement_control at C:\Program
> Files\Rakudo\bin\..\share\perl6\lib/Perl6/Grammar.moarvm line 1
> [NativeHelpers::Blob] ===SORRY!=== Error while compiling
>
> C:\Users\tony\.zef\tmp\NativeHelpers%3A%3ABlob%3Aver%3C0.1.12%3E%3Aauth%3Cgithub%3Asalortiz%3E.tar.gz\NativeHelpers-Blob-master/t\99-my-meta.t
> [NativeHelpers::Blob] Failed to open file
> C:\Users\tony\.zef\tmp\NativeHelpers%3A%3ABlob%3Aver%3C0.1.12%3E%3Aauth%3Cgithub%3Asalortiz%3E.tar.gz\NativeHelpers-Blob-master\lib\.precomp\BE04B1FADFC312E3411CB403B43E629B7AED3ADC\27\27F410113BBD23B298581F9F713FBCFB39C1584E.repo-id.2Q72L8EJX9FJGLKXVSQOGR36G.tmp:
>
> No such file or directory
> [NativeHelpers::Blob] at
>
> C:\Users\tony\.zef\tmp\NativeHelpers%3A%3ABlob%3Aver%3C0.1.12%3E%3Aauth%3Cgithub%3Asalortiz%3E.tar.gz\NativeHelpers-Blob-master/t\99-my-meta.t:3
> [NativeHelpers::Blob] Actually thrown at:
> [NativeHelpers::Blob]   in any statement_control at C:\Program
> Files\Rakudo\bin\..\share\perl6\lib/Perl6/Grammar.moarvm line 1
> ===> Testing [FAIL]: NativeHelpers::Blob:ver<0.1.12>:auth
> Aborting due to test failure:
> NativeHelpers::Blob:ver<0.1.12>:auth (use --force-test
> to override)
>
>


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";



Re: Pointer to bug question

2022-11-23 Thread Clifton Wood
@ToddAndMargo 

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
.
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[.new($ppSessionInf);
$a.setSize($pCount, :forced);
my @sessions = $a.Array;

That should return you an array of  objects.

Good luck!



On Wed, Nov 23, 2022 at 9:46 PM ToddAndMargo via perl6-users <
perl6-users@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  >> > wrote:
> >>
> >> @ToddAndMargo  - 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
> >> mailto:perl6-users@perl.org>> wrote:
> >>
> >> removing my typos:
> >>
>
> On 11/23/22 18:22, Clifton Wood wrote:
> > @ToddAndMargo  -- Also, Pointer cannot
> > deref a Pointer, which I think is the real error.
>
>
> How do I load what $ppSessionInf points to into $Sessions?
>
>
>


Re: Pointer to bug question

2022-11-23 Thread ToddAndMargo via perl6-users

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 > wrote:


@ToddAndMargo  - 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
mailto:perl6-users@perl.org>> wrote:

removing my typos:



On 11/23/22 18:22, Clifton Wood wrote:
@ToddAndMargo  -- Also, Pointer cannot 
deref a Pointer, which I think is the real error.



How do I load what $ppSessionInf points to into $Sessions?




Re: Pointer to bug question

2022-11-23 Thread ToddAndMargo via perl6-users

On 11/23/22 18:21, Clifton Wood wrote:

What type is BYTE, pray tell?



constant BYTE := uint8;



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~



Re: Pointer to bug question

2022-11-23 Thread ToddAndMargo via perl6-users

On 11/23/22 18:07, ToddAndMargo via perl6-users wrote:

removing my typos:


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




ppSessionInf = >
pCount = <2>

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~



Re: Pointer to bug question

2022-11-23 Thread Clifton Wood
@ToddAndMargo  -- Also, Pointer cannot deref a
Pointer, which I think is the real error.


On Wed, Nov 23, 2022 at 9:21 PM Clifton Wood  wrote:

> @ToddAndMargo  - 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-users@perl.org> wrote:
>
>> removing my typos:
>>
>>
>> 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
>>
>>


Re: Pointer to bug question

2022-11-23 Thread Clifton Wood
@ToddAndMargo  - 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-users@perl.org> wrote:

> removing my typos:
>
>
> 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
>
>


Re: Pointer to bug question

2022-11-23 Thread ToddAndMargo via perl6-users

removing my typos:


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



Pointer to bug question

2022-11-23 Thread ToddAndMargo via perl6-users

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 read that into a Buf of $ my DWORD   $pCount   = 0;  bytes?

   my Pointer $ppSessionInf = Pointer.new();
   my DWORD   $pCount   = 32 times something bytes long;
   my BYTES  $Sessions  = CArray[BYTE].new( 0xFF xx $pCount );

How do I load what $ppSessionInf points to into $Sessions

   $Sessions = $ppSessionInf.deref;

Which obviously does not work.

"Internal error: unhandled target type"

  

Many thanks,
-T

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~