Hi,
I'm the developer of VBoxHeadlessTray (see here: https://www.toptensoftware.com/vboxheadlesstray). I'm trying to get it working with the latest 6.1 SDK but I'm finding that after calling get_Machines and going through the returned array, the IUnknown for the objects are returned correctly from SafeArrayGetElement, however calling QueryInterface for IMachine fails with E_NOINTERFACE.
The IID_IMachine I'm using is {85632C68-B5BB-4316-A900-5EB28D3413DF}
Has something changed in 6.1 in this area?
Running on Windows 10.
Brad
get_Machines not working in 6.1 API
-
- Posts: 60
- Joined: 28. Dec 2019, 08:58
- Primary OS: MS Windows 7
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: get_Machines not working in 6.1 API
I fished around your source for a bit to give it a second set of eyes but I gave up looking for your QueryInterface call. So I'll just ask the dumb question: You haven't added a call releasing the object before your query, have you? Asking because I've done similar things... it happens.
-
- Posts: 7
- Joined: 11. Aug 2015, 08:31
Re: get_Machines not working in 6.1 API
The interface pointer definitely hasn't been released and the call to QueryInterface is returning E_NOINTERFACE. If the pointer had been released it would probably crash.
The call to get_Machines is here:
https://github.com/toptensoftware/VBoxH ... lg.cpp#L53
Followed by this call to InitFromSafeArray which gets the ptrs out of the returned array and does the QueryInterface calls:
See here for InitFromSafeArray:
https://github.com/toptensoftware/Simpl ... tor.h#L349
Brad
The call to get_Machines is here:
https://github.com/toptensoftware/VBoxH ... lg.cpp#L53
Followed by this call to InitFromSafeArray which gets the ptrs out of the returned array and does the QueryInterface calls:
Code: Select all
CComPtrVector<IMachine*> vecMachines;
vecMachines.InitFromSafeArray(psa);
https://github.com/toptensoftware/Simpl ... tor.h#L349
Brad
-
- Posts: 60
- Joined: 28. Dec 2019, 08:58
- Primary OS: MS Windows 7
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: get_Machines not working in 6.1 API
Sorry about that. I'm more than a decade rusty in C/C++ and I don't have a good compiler to run with. I see what you mean though. I was just running into IMachine attributes that have changed in 6.1 too, and it looks like that's the interface you're talking to. Do you know which attribute is being queried? I admit you lost me there. I didn't finish digging, but here's a few that I found have their own interface and their own attributes now:
IGraphicsAdapter
IBIOSSettings
IRecordingSettings
IVRDEServer
IUSBDeviceFilter
IAudioAdapter
ISharedFolder
I hope that might help. If not, then I hope someone else can.
IGraphicsAdapter
IBIOSSettings
IRecordingSettings
IVRDEServer
IUSBDeviceFilter
IAudioAdapter
ISharedFolder
I hope that might help. If not, then I hope someone else can.
-
- Posts: 7
- Joined: 11. Aug 2015, 08:31
Re: get_Machines not working in 6.1 API
Thanks. Not sure if those other interfaces/objects are relevant since I can't get past the QI for IMachine to know.
Anyway, I've logged a bug report for it: https://www.virtualbox.org/ticket/19224
Anyway, I've logged a bug report for it: https://www.virtualbox.org/ticket/19224
Re: get_Machines not working in 6.1 API
It seems to work on 6.1.2, at least in the context of libvbox:
Although in my experience, the QueryInterface is not actually necessary, since the returned object is already compatible with the IMachine interface (in fact, libvbox's getter omits the QueryInterface and returns a vector of COMPtr<IMachine> objects directly).
Code: Select all
auto client = VBox::virtualBoxClient();
auto vbox = client->virtualBox();
auto machines = vbox->machines();
for (const auto &mach : machines) {
auto qmach = mach->QueryInterface<VBox::IMachine>();
if (!qmach)
throw std::runtime_error("Invalid conversion to IMachine");
}