Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-03 Thread ToddAndMargo via perl6-users
On 1/3/21 10:40 AM, Paul Procacci wrote: Irrelevant musings: -- A windows handle is a pointer. A handle is an abstraction to a memory location that can be used in subsequent api calls. Declaring it as any incarnation of an int is a mistake and will not function properly across all machines. H

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-03 Thread ToddAndMargo via perl6-users
On 1/3/21 6:46 PM, Paul Procacci wrote: Todd, I know what 'is rw' is for.  This isn't at all related to the problem I'm having. Hi Paul, I seems to be only annoying you, so I will stop here. Good luck with your project. Is sounds fun. -T

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-03 Thread Paul Procacci
Todd, I know what 'is rw' is for. This isn't at all related to the problem I'm having. On Sun, Jan 3, 2021 at 9:43 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 1/3/21 10:40 AM, Paul Procacci wrote: > > Furthermore you can't pass a naked $entry to like so: > > Process32Fir

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-03 Thread ToddAndMargo via perl6-users
On 1/3/21 10:40 AM, Paul Procacci wrote: Furthermore you can't pass a naked $entry to like so: Process32First($handle, $entry) It has to be a pointer;  had you tried what you suggested, raku would have thrown errors and for good reason. Do you understand about "is rw" now? Process32Firs

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-03 Thread Paul Procacci
No, it doesn't work. The inline statically defined array in Raku never gets filled with any data from the win32 function call. On Sun, Jan 3, 2021 at 9:37 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 1/3/21 12:00 PM, Paul Procacci wrote: > > Todd, > > > > I've made a mistak

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-03 Thread ToddAndMargo via perl6-users
On 1/3/21 12:00 PM, Paul Procacci wrote: Todd, I've made a mistake. Raku does ensure a pointer gets passed to the function transparently when referencing a structure and doesn't require one to be explicit. I stand corrected. ~Paul Did you get it working?

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-03 Thread Paul Procacci
Todd, I've made a mistake. Raku does ensure a pointer gets passed to the function transparently when referencing a structure and doesn't require one to be explicit. I stand corrected. ~Paul On Sun, Jan 3, 2021 at 1:40 PM Paul Procacci wrote: > Todd, > > Nothing you stated addresses my initial

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-03 Thread Paul Procacci
To expand further on the problem I'm running into, take the following C function: #include typedef struct T { char a[260]; int32_t b; } T; void setTest(T *t) { (void)memset(t->a, 'T', 260); t->b = 1; } - gcc -c -O3 -Wext

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-03 Thread Paul Procacci
Todd, Nothing you stated addresses my initial question nor subsequent findings. My question is simply how to retrieve the value that gets stored in the CArray; nothing more. My subsequent findings included the following as I believe I'm running into it: https://github.com/rakudo/rakudo/issues/3633

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-03 Thread ToddAndMargo via perl6-users
On 1/2/21 11:38 PM, Paul Procacci wrote: I don't have a C string that's terminated by null. I have a CArray[int16] of length 260 that's passed to and filled in by the windows api. https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-03 Thread Paul Procacci
Hi Fernando, I appreciate your response. The windows api requires that the dwSize member of the structure gets set to the size of the structure. This is the reason why the object is being constructed as I've provided. ~Paul On Sun, Jan 3, 2021 at 4:58 AM Fernando Santagata wrote: > Hi Paul, >

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-03 Thread Fernando Santagata
Hi Paul, I can't help, since I haven't a Windows PC, but I noticed that you initialize your $entry variable like this: my PROCESSENTRY32 $entry .= new(:dwSize(nativesizeof(PROCESSENTRY32))); I don't think the argument to the "new" call is necessary. Try this: my PROCESSENTRY32 $entry .= new; say

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-02 Thread Paul Procacci
I don't have a C string that's terminated by null. I have a CArray[int16] of length 260 that's passed to and filled in by the windows api. https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/n

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-02 Thread ToddAndMargo via perl6-users
On 1/2/21 8:13 PM, Paul Procacci wrote: What I'm trying to attempt to do now is display the contents of that CArray (raku member a).  In my mind, this is an "array of utf16LE byte sequences terminated by 0". Hi Paul, If I understand your problem, you are having trouble extracting something us

Re: Nativecall - Help with converting wchar_t CArray to something printable

2021-01-02 Thread Paul Procacci
A follow-up to my initial message. I think the following is relevant: https://github.com/rakudo/rakudo/issues/3633 I think my inlined array is actually being filled with zero's. say $a.a[0]; say $a.a[1]; Yields: 0 0 I'm using the comma ide: >raku -v Welcome to Rakudo(tm) v2020.12. Implement