C++ COM API IGuest->CreateSession/ProcessCreate

Discussion about using the VirtualBox API, Tutorials, Samples.
syncovery
Posts: 11
Joined: 23. Dec 2016, 11:42

C++ COM API IGuest->CreateSession/ProcessCreate

Post by syncovery »

I'm using C++ COM Vbox API and trying to Create guest session in virtual machine in order to be able to ProcessCreate in guest machine.

Code: Select all

Guest->CreateSession( SysAllocString(L"Administrator"), NULL, NULL, NULL, &GuestSession );
this call is always successful and GuestSession initialized.

BUT.

for some reason GuestSession->get_Status is always returns GuestSessionStatus_Error

IMHO because of that all the rest calls are unsuccessful.

I'm running on VBox 5.1.10 and I was trying to use VBoxGuestAdditions v4.3 as well as latest with no success.

when i call ProcessCreate in getting S_OK while there is no any evidence of created process in guest machine.

can somebody provide example of ProcessCreate ?

Please help to solve this issue. Thanks in advance.
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by noteirak »

Please have a look at these Java code samples, one of them is for running a guest process and reading its stdout which should be a good pointer.
In terms of API calls, the order and the flow, it is exactly the same in C++ so you can check your code and see if you didt forget something.

The example is for VBox 4.3 but the API calls did not change in 5.0 or 5.1, so the steps are exactly the same.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
syncovery
Posts: 11
Joined: 23. Dec 2016, 11:42

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by syncovery »

noteirak wrote: In terms of API calls, the order and the flow, it is exactly the same in C++ so you can check your code and see if you didt forget something.
thank you for the examples, noteirak,
I don't see something special about CreateSession in Java code.
GuestSession->WaitFor( 1L, 30 * 1000, &aReason ); in my code exits immediately with aReason = GuestSessionWaitResult_None
I was trying to CreateSession by standard VboxManage.exe. and the problem still around WaitFor method.

Code: Select all

VBoxManage.exe: error: The specified user was not able to logon on guest
VBoxManage.exe: error: Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component GuestSessionWrap, interface IGuestSession, callee IUnknown
VBoxManage.exe: error: Context: "WaitForArray(ComSafeArrayAsInParam(aSessionWaitFlags), 30 * 1000, &enmWaitResult)" at line 938 of file VBoxManageGuestCtrl.cpp
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by noteirak »

Can you install the matching guest additions (in terms of version) and post the output of the following command with the VM in the same state as if you would run the code (replace VMNAME):

Code: Select all

vboxmanage showvminfo VMNAME
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
syncovery
Posts: 11
Joined: 23. Dec 2016, 11:42

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by syncovery »

noteirak wrote:Can you install the matching guest additions (in terms of version) and post the output of the following command with the VM in the same state as if you would run the code (replace VMNAME):

Code: Select all

vboxmanage showvminfo VMNAME
noteirak, thank you for supporting and Happy New Year!
installed guest additions 5.1.10
vboxmanage output is below

Code: Select all

Name:            IE8 - Win7
Groups:          /
Guest OS:        Windows 7 (32-bit)
UUID:            5c5c7fab-9b29-4b93-a0ae-8f94b32df690
Config file:     C:\Users\dima\VirtualBox VMs\IE8 - Win7\IE8 - Win7.vbox
Snapshot folder: C:\Users\dima\VirtualBox VMs\IE8 - Win7\Snapshots
Log folder:      C:\Users\dima\VirtualBox VMs\IE8 - Win7\Logs
Hardware UUID:   5c5c7fab-9b29-4b93-a0ae-8f94b32df690
Memory size:     2048MB
Page Fusion:     off
VRAM size:       27MB
CPU exec cap:    100%
HPET:            off
Chipset:         piix3
Firmware:        BIOS
Number of CPUs:  1
PAE:             off
Long Mode:       on
Triple Fault Reset: off
APIC:            on
X2APIC:          off
CPUID Portability Level: 0
CPUID overrides: None
Boot menu mode:  message and menu
Boot Device (1): Floppy
Boot Device (2): DVD
Boot Device (3): HardDisk
Boot Device (4): Not Assigned
ACPI:            on
IOAPIC:          off
BIOS APIC mode:  APIC
Time offset:     0ms
RTC:             local time
Hardw. virt.ext: on
Nested Paging:   on
Large Pages:     on
VT-x VPID:       on
VT-x unr. exec.: on
Paravirt. Provider: Legacy
Effective Paravirt. Provider: None
State:           powered off (since 2016-12-30T14:18:26.000000000)
Monitor count:   1
3D Acceleration: off
2D Video Acceleration: off
Teleporter Enabled: off
Teleporter Port: 0
Teleporter Address: 
Teleporter Password: 
Tracing Enabled: off
Allow Tracing to Access VM: off
Tracing Configuration: 
Autostart Enabled: off
Autostart Delay: 0
Default Frontend: 
Storage Controller Name (0):            IDE
Storage Controller Type (0):            PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  2
Storage Controller Port Count (0):      2
Storage Controller Bootable (0):        on
Storage Controller Name (1):            SATA
Storage Controller Type (1):            IntelAhci
Storage Controller Instance Number (1): 0
Storage Controller Max Port Count (1):  30
Storage Controller Port Count (1):      1
Storage Controller Bootable (1):        on
IDE (0, 0): C:\Users\dima\VirtualBox VMs\IE8 - Win7\Snapshots/{5855fc70-673a-478f-acc3-6d01cb7be898}.vmdk (UUID: 5855fc70-673a-478f-acc3-6d01cb7be898)
IDE (1, 0): C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso (UUID: 10d01421-7d76-4519-b498-3bdd0403eaad)
NIC 1:           MAC: 080027A8F811, Attachment: Bridged Interface 'Broadcom NetXtreme 57xx Gigabit Controller', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 2:           disabled
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled
Pointing Device: USB Tablet
Keyboard Device: PS/2 Keyboard
UART 1:          disabled
UART 2:          disabled
UART 3:          disabled
UART 4:          disabled
LPT 1:           disabled
LPT 2:           disabled
Audio:           enabled (Driver: DSOUND, Controller: HDA, Codec: STAC9221)
Clipboard Mode:  HostToGuest
Drag and drop Mode: HostToGuest
VRDE:            disabled
USB:             enabled
EHCI:            disabled
XHCI:            disabled

USB Device Filters:

<none>

Bandwidth groups:  <none>

Shared folders:  

Name: 'local_exchange', Host path: 'C:\local_exchange' (machine mapping), writable

Video capturing:    not active
Capture screens:    0
Capture file:       C:\Users\dima\VirtualBox VMs\IE8 - Win7\IE8 - Win7.webm
Capture dimensions: 1024x768
Capture rate:       512 kbps
Capture FPS:        25

Guest:

Configured memory balloon size:      0 MB

Snapshots:

   Name: Snapshot_29-12-2016 07-00-28 (UUID: 576f7a64-93af-4101-acf0-4eefa64c2772) *
   Description:
snapshot created by COM

noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by noteirak »

Seems like they did not install or you didn't reboot the VM.
You should have somethinf similar to the following at and after the "Guest", around the end of the output.
The red parts are the mandatory requirements.
Guest:

Configured memory balloon size: 0 MB
OS type: Linux26_64
Additions run level: 2
Additions version: 4.3.28 r100309


Guest Facilities:

Facility "VirtualBox Base Driver": active/running (last update: 2016/12/28 08:55:26 UTC)
Facility "VirtualBox System Service": active/running (last update: 2016/12/28 08:55:32 UTC)
Facility "Seamless Mode": not active (last update: 2016/12/28 08:55:26 UTC)
Facility "Graphics Mode": not active (last update: 2016/12/28 08:55:26 UTC)
I will update the code sample later today to check for those requirements so the code can be fast-fail and provide a more meaningful troubleshooting.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
syncovery
Posts: 11
Joined: 23. Dec 2016, 11:42

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by syncovery »

Dear noteirak,
I have completely reinstall Guest OS and Guest additions with the same result - in the vboxmanage showvminfo results there is no
signs of Additions. I'm running VBox 5.1.10 and Guest Additions 5.1.10
Can you please tell what VBox version is workable?
Are there any settings to activate guest additions?
I do Device->Insert Guest Additions.iso - then starting installer from mounted CD and reboot. In OS Control Panel i can see Guest Additions Installed.



thanks in advance,
Happy New Year!
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by noteirak »

Appologies for the delay, got caught up more than I thought in the new year celebrations.
I'll get back to you with the promised improved code sample later in the evening.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by noteirak »

So reading back on your feedback, it is clear that the issue lies somewhere during install/activation of the guest additions and not in your code calling the API.

Could you once again install the guest additions but doing it from the command line and adding the logging flag. So you should have the following command (slash L argument) after moving into the CD/DVD drive of the guest:

Code: Select all

VBoxWindowsAdditions.exe /l
You will find two log files into the install folder, C:\Program Files\Oracle\VirtualBox Guest Additions by default:
- install.log
- install_drivers.log

Please zip them and attach the zip file to this post (Upload attachment under the reply text area) so we can have a look.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
syncovery
Posts: 11
Joined: 23. Dec 2016, 11:42

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by syncovery »

Dear Noreirac,
sorry for delays. Thank you for looking into the problem.
please see log files in attach.
Attachments
Vbox_install.zip
(3.79 KiB) Downloaded 62 times
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by noteirak »

No error... and the plot thickens.

Can you restart the VM after install and then run the following command in an admin prompt and copy/paste the output please:

Code: Select all

sc query vboxservice
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
syncovery
Posts: 11
Joined: 23. Dec 2016, 11:42

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by syncovery »

sc query vboxservice output:

Code: Select all

SERVICE_NAME: vboxservice 
        TYPE               : 10  WIN32_OWN_PROCESS  
        STATE              : 4  RUNNING 
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by noteirak »

After you started the VM and have confirmed the Guest Additions service is running in the guest (last command I gave you), please attach the following info (zip if too big):
- VBox.log located in the Logs subfolder of the VM folder
- Output of vboxmanage showvminfo VMNAME
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
syncovery
Posts: 11
Joined: 23. Dec 2016, 11:42

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by syncovery »

Max thank you for supporting!
in the attach are logs and screenshot of VM.

respectfully,
Attachments
Logs.zip
(180.39 KiB) Downloaded 50 times
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: C++ COM API IGuest->CreateSession/ProcessCreate

Post by noteirak »

I can't see any issue in the logs with the additions, so I'm quite baffled here I must say.
I'll bump this up to the devs and will let you know!

In the meantime, do you have any other VM you can check the output of vboxmanage on? Just to be sure it's not a global issue with your virtualbox installation.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply