<div dir="ltr"><div>Hi Klaus,<br></div><div><br></div><div>Is casting the pointer to a byte (and sending it the same way as T_I8) not a good solution to this? As the Java API already uses the byte type.</div><div>Could it cause issues? (I'm not very experienced with C++.)</div><div>Using the Pointer class in JNA I believe I could work with a byte or int value.</div><div><br></div><div>Thanks,</div><div>Norbert<br></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Date: Mon, 2 Jul 2018 13:46:57 +0200<br>
From: Klaus Espenlaub <<a href="mailto:klaus.espenlaub@oracle.com" target="_blank">klaus.espenlaub@oracle.com</a>><br>
To: <a href="mailto:vbox-dev@virtualbox.org" target="_blank">vbox-dev@virtualbox.org</a><br>
Subject: Re: [vbox-dev] queryBitmapInfo in Java API returns no image<br>
        address<br>
Message-ID: <<a href="mailto:8f996c78-330d-efec-c92c-4e54081decce@oracle.com" target="_blank">8f996c78-330d-efec-c92c-4e540<wbr>81decce@oracle.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi Norbert,<br>
<br>
On 01.07.2018 23:29, Szatm?ri Norbert P?ter wrote:<br>
> Hello,<br>
> I'm developing a Java frontend for VirtualBox machines and I managed<br>
> to set it up to launch the machine inside the process and attach my<br>
> framebuffer to it. It's receiving changes and updates, queryBitmapInfo<br>
> returns all information correctly, except for the address out parameter.<br>
><br>
> The array I'm using to hold the value is large enough for the whole<br>
> screen but all of the values in the array remain 0, even after the<br>
> machine has booted up and is running the guest OS. VirtualBox also<br>
> seems to freeze for some seconds while the machine is running inside<br>
> my application.<br>
> (I'm also running my program as root as I was unable to set the setuid<br>
> bit up correctly, but I don't have any issues running VBox as root, so<br>
> I don't think it's related.)<br>
><br>
> How can I receive images from the machine in Java?<br>
<br>
Right now? You don't. JXPCOM simply can't deal with such parameters.<br>
Possibly fixable, didn't investigate if there are technical issues with<br>
implementing "out" parameters of type "byte ptr". The code for handling<br>
the various 'out' parameter passing cases is in<br>
src/libs/xpcom18a4/java/src/ns<wbr>JavaWrapper.cpp, function FinalizeParams<br>
(which is called from Java through the JNI function callXPCOMMethod in<br>
the same file). The 'in' case is in SetupParams.<br>
<br>
Apparently so far no one needed to call methods with pointer parameters.<br>
<br>
Klaus<br>
<br>
> VirtualBox version: 5.2.12 r122591 (Qt5.9.5)<br>
> VBox API: Java XPCOM 5.2<br>
> OS: Ubuntu 18.04 x64, Java 8<br>
><br>
> My code in notifyChange:<br>
><br>
>     |display.querySourceBitmap(<wbr>0L, holder);<br>
>     byte[] arr = bb.array(); //640 * 480 * 4 bytes backing a ByteBuffer<br>
>     long[] w = new long[1], h = new long[1], bpp = new long[1], bpl =<br>
>     new long[1], pf = new long[1];<br>
>     holder.value.getTypedWrapped(<wbr>).queryBitmapInfo(arr, w, h, bpp,<br>
>     bpl, pf);<br>
>     System.out.println("Arr0:" + arr[0]); //Returns 0<br>
>     System.out.println("whbppbplp<wbr>f: " + w[0] + " " + h[0] + " " +<br>
>     bpp[0] + " " + bpl[0] + " " + pf[0]); //Returns correct values<br>
>     |<br>
><br>
> Regards,<br>
> Norbert <br></blockquote></div></div></div>