[vbox-dev] COM API ProcessCreate and GuestProcess.Write

Magnus Madsen madsen.magnus at gmail.com
Sun Jun 2 14:38:44 GMT 2013

Ivo Smits <Ivo at ...> writes:

> After hours of experimenting (why!?!?!?), I think the problem is 
> somewhere in the IDispatch implementation. The Interop assembly 
> generated by VS2008 appears to use te IDispatch interface to call 
> VirtualBox functions. I think the Interop assembly expects an array of 
> unsigned bytes on the .Net side, while VirtualBox uses signed bytes...
> So, after some crashes of both my own code and the VirtualBox VM, I came 
> up with the attached C# code:
> - Standard output works, although it is ugly and unreliable with the 
> timed wait
> - Standard input hangs the VM process. Be careful with this, you may 
> have to kill the running VM! If VBox hangs here, you may still shut down 
> the guest OS via remote desktop, and VBox will get stuck in the Stopping 
> state. Bug report?
> Ivo

Aha; Thank you for this insight - it enabled me to get rid of the wrapper by
using a custom Interop assembly.

For anyone else who wishes to use it, this is the process I found the 

* Use TlbImp to generate an interop DLL from VirtualBox.tlb
* Use IlDAsm to generate an MSIL source code file from the dll.
* Edit the MSIL and replace "marshal (safearray unsigned int8)" with
  just "(safearray int8)".
* Use IlAsm to generate a new DLL from the edited MSIL.

I haven't tested it thoroughly, but it does seem to work for reading from 
processes and getting screenshots at least - two things that didn't work 
before without using my wrapper.

Kind regards,

More information about the vbox-dev mailing list