Hello VirtualBox Developers,
I'm testing out the C++ COM API and when I use the takeScreenShot
method over COM the VirtualBox crashes. Please correct me if my code
is wrong. Although, bad pointers alone shouldn't crash the VM. I'm
aware that this is the raw COM and not the GLUE methods nor does the
memory buffer use a COM interface (for reference counting). The source
code is below.
Thanks,
Robert Ramsay
int testTakeScreenShot(ISession *session)
{
IConsole *console = NULL;
IDisplay *display = NULL;
unsigned long width, height, bpp;
SIZE_T buffersize;
BYTE* databuff;
HRESULT rc;
if (session == NULL)
return 1;
/* Get console object. */
session->get_Console(&console);
console->get_Display(&display);
display->GetScreenResolution(0,&width,&height,&bpp);
printf("Width: %ul Height: %ul Bits Per Pixel: %ul. ",
width,height,bpp);
buffersize = width*height*bpp/8;
databuff = (BYTE*)CoTaskMemAlloc(buffersize);
// Test databuffer
if (databuff != NULL)
{
rc = display->TakeScreenShot(0,databuff,width,height);
if (SUCCEEDED(rc))
{
printf("Took a screenshot! %d\n", rc);
}
else
{
printf("Error taking screen shot! rc = 0x%x\n", rc);
return rc;
}
CoTaskMemFree(databuff);
}
return 0;
}
_______________________________________________
vbox-dev mailing list
[email protected]
http://vbox.innotek.de/mailman/listinfo/vbox-dev