[vbox-dev] How to get the current running IMachine instance inside a host service?

Huihong Luo huisinro at yahoo.com
Mon May 11 15:22:30 GMT 2009


Michael,
 
Thanks. This is the info I needed.
 
I was trying not to modify the main line code. If there is no better way, I guess need to modify the host call to pass the vm info I needed.
 
By the way, we have added copy/paste of files between guest and host, so a user can do Control-C/Control-V for file copying, etc. To do this, we added CF_HDROP format support to the shared clipboard. We used our own shared folder additions. if you would like to add this support to the main line of code, pls let me know. (we only did it on windows guest and host).
 
We may add drag-drop support on windows later on
 
Huihong

--- On Mon, 5/11/09, Michael Thayer <Michael.Thayer at Sun.COM> wrote:


From: Michael Thayer <Michael.Thayer at Sun.COM>
Subject: Re: [vbox-dev] How to get the current running IMachine instance inside a host service?
To: "Huihong Luo" <huisinro at yahoo.com>
Cc: "Josh Wright" <jshwright at gmail.com>, vbox-dev at virtualbox.org
Date: Monday, May 11, 2009, 2:10 AM


Hello Huihong,

Huihong Luo wrote:
> take an example, the VBoxSharedFolders.dll is a service between guest and host. This dll is running inside the same process as the VirtualBox.exe launching the vm. I just need to find out the current vm this shared dll is being used.
>  
> I couldn't find any method to do this simple thing: where am I?
HGCM services have no built-in mechanism for getting information about
the VM they are running in and such-like.  This is because they were
originally designed to work in things like VBoxBFE, which is a
simplified frontend where the normal VirtualBox APIs are not available.
What you can do instead is to use the HGCM "host call" functionality to
pass any needed information into the service when it is started.  To see
examples of this, grep for "HostCall" in src/VBox/Main/ConsoleImpl[2].cpp.

If you need to get information or send notifications or whatever while
the service is running, you can also register callbacks ("host service
extensions") with the service.  For an example of this, grep for
"ServiceExtension" in ConsoleImpl2.cpp.

BTW, I haven't forgotten the VbglR3GuestPropWait() issue you mentioned,
but I haven't got round to looking at it yet.  Sorry!

Regards,

Michael
-- 
Sun Microsystems GmbH        Michael Thayer
Werkstrasse 24               VirtualBox engineer
71384 Weinstadt, Germany     mailto:michael.thayer at sun.com

Sitz der Gesellschaft:
Sun Microsystems GmbH, Sonnenallee 1, 85551 Kirchheim-Heimstetten
Amtsgericht Muenchen: HRB 161028
Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin Haering
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20090511/0a13f660/attachment.html>


More information about the vbox-dev mailing list