My C code has nothing to do with the question I'm asking.
I'll share it anyway to my dismay.

static int raidFillProcessStruct(raidProcess* process)
> {
> process->handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
> if (process->handle == INVALID_HANDLE_VALUE) return 0;
>
> process->entry.dwSize = sizeof(process->entry);
> if (Process32First(process->handle, &process->entry)) {
> do {
> if (!wcscmp(L"Raid.exe", process->entry.szExeFile)) {
> CloseHandle(process->handle);
> return 1;
> }
> } while (Process32Next(process->handle, &process->entry));
> }
>
> CloseHandle(process->handle);
> return 0;
> }
>
>
My C code also doesn't print anything as that's not it's intention.  It
returns with an appropriate exit code which
is all my proof of concept measures.

The above is besides the point however and functions as expected.

I have defined a CStruct that contains 65 non inlined int64's.
Each int64 contains four int16's that I need to extract at the following
bit positions:  [0,15], [16,31], [32, 47], [48, 63]

What method accomplishes this, if any?
I'm ok with no function existing in which case I'll need to roll my own,
but this is the premise for this email.


On Thu, Jan 14, 2021 at 11:00 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 1/14/21 7:38 PM, Paul Procacci wrote:
> > I may have.
> >
> > Regardless, I have written a proof of concept in 'C' which works.
> > My question isn't how to interface with the Windows Operating System
> > because I have already done so in 'C' quite easily.
> >
> > My question pertains to working around the bug as described here:
> > https://github.com/rakudo/rakudo/issues/3633
> > <https://github.com/rakudo/rakudo/issues/3633>
> > Do you have any comments concerning this bug and/or the approach I'm
> taking?
> > Passing a flattened array of 260 int16's doesn't work so my approach is
> > passing 65 non-flattened int64's.
> >
> > The 65 int64's are in fact being utilized by the callee, yet I'm looking
> > for a method to reconstruct this back into 260 wchar_t's (which has a
> > width of 16)  w/ a simple method that doesn't include me walking the
> > int64 and masking the chars out myself.
> > Does this exist.
> >
> > Thanks,
> > ~Paul
> >
> > On Thu, Jan 14, 2021 at 9:58 PM ToddAndMargo via perl6-users
> > <perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote:
> >
> >     On 1/14/21 4:32 PM, Paul Procacci wrote:
> >      >
> >
> https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot
> >     <
> https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot
> >
> >
> >      >
> >     <
> https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot
> >     <
> https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot
> >>
> >      >
> >      > On Thu, Jan 14, 2021 at 7:30 PM ToddAndMargo via perl6-users
> >      > <perl6-us...@perl.org <mailto:perl6-us...@perl.org>
> >     <mailto:perl6-us...@perl.org <mailto:perl6-us...@perl.org>>> wrote:
> >      >
> >      >     On 1/14/21 3:42 PM, Paul Procacci wrote:
> >      >      > Let me preface this by saying if I were using a lower
> >     level language
> >      >      > (like C) I wouldn't have this problem; as I know how to
> >     shift and
> >      >     mask
> >      >      > accordingly.
> >      >      >
> >      >      > On raku however, how to do so *eloquantly* eludes me.
> >      >      >
> >      >      > I've defined a CStruct as follows:
> >      >      >
> >      >      > class test is repr('CStruct') {
> >      >      >
> >      >      >    has int64 $.a1;
> >      >      >
> >      >      >    has int64 $.a2;
> >      >      >
> >      >      >    ...
> >      >      >
> >      >      >    has int64 $.a65;
> >      >      >
> >      >      > }
> >      >      >
> >      >      > Under normal circumstances I would have defined the member
> as:
> >      >      > `HAS int16 @.a[260] is CArray` however that seems to be
> >     broken. See:
> >      >      >
> >      >      > https://github.com/rakudo/rakudo/issues/3633
> >     <https://github.com/rakudo/rakudo/issues/3633>
> >      >     <https://github.com/rakudo/rakudo/issues/3633
> >     <https://github.com/rakudo/rakudo/issues/3633>>
> >      >      > <https://github.com/rakudo/rakudo/issues/3633
> >     <https://github.com/rakudo/rakudo/issues/3633>
> >      >     <https://github.com/rakudo/rakudo/issues/3633
> >     <https://github.com/rakudo/rakudo/issues/3633>>>
> >      >      >
> >      >      > The function that gets called with these members $.a1 ..
> $.a65
> >      >     should
> >      >      > get filled with a wchar_t character array.
> >      >      >
> >      >      > Does raku employ a simple method of decoding the 4
> >     wchar_t's that
> >      >     get
> >      >      > placed into a int64 structure?  The characters I'd like to
> >      >     extract are
> >      >      > at bit positions [15:0], [31.16], [47:32], [63:48]
> >      >      >
> >      >      > I'm imagining something along the lines of:
> >      >      >
> >      >      > buf16.new( $.a1, ... $.a64);
> >      >      >
> >      >      > ... but that doesn't quite work like I would expect.
> >      >      >
> >      >      > Thanks,
> >      >      > ~Paul
> >      >
> >      >     Hi Paul,
> >      >
> >      >     Would you post the system call you are trying to
> >      >     interface with?
> >      >
> >      >     -T
> >
> >
> >     Did you see?
> >
> >
> https://docs.microsoft.com/en-us/windows/win32/toolhelp/taking-a-snapshot-and-viewing-processes
> >     <
> https://docs.microsoft.com/en-us/windows/win32/toolhelp/taking-a-snapshot-and-viewing-processes
> >
>
> I am not following the bug.  :'(
>
> Would you mind posting your C code?
>
> And the output of your C code?
>
>
>

-- 
__________________

:(){ :|:& };:

Reply via email to