VBoxControl.cpp revision c98fb3e16fcd571a790eab772c0c66173d225205
/** @file
*
* VBoxControl - Guest Additions Utility
*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include <windows.h>
#include <stdio.h>
void printHelp()
{
printf("VBoxControl getvideoacceleration\n"
"\n"
"VBoxControl setvideoacceleration <on|off>\n"
"\n"
"VBoxControl listcustommodes\n"
"\n"
"VBoxControl addcustommode <width> <height> <bpp>\n"
"\n"
"VBoxControl removecustommode <width> <height> <bpp>\n");
}
{
HKEY hkeyDeviceMap = 0;
status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\VIDEO", 0, KEY_READ, &hkeyDeviceMap);
{
printf("Error opening video device map registry key!\n");
return 0;
}
char szVideoLocation[256];
szVideoLocation[0] = 0;
status = RegQueryValueExA(hkeyDeviceMap, "\\Device\\Video0", NULL, &dwKeyType, (LPBYTE)szVideoLocation, &len);
/*
* This value will start with a weird value: \REGISTRY\Machine
* Make sure this is true.
*/
if ( (status == ERROR_SUCCESS)
{
/* open that branch */
status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, &szVideoLocation[18], 0, KEY_READ | (writable ? KEY_WRITE : 0), &hkeyVideo);
}
else
{
}
return hkeyVideo;
}
{
if (hkeyVideo)
{
/* query the actual value */
status = RegQueryValueExA(hkeyVideo, "EnableVideoAccel", NULL, &dwKeyType, (LPBYTE)&fAcceleration, &len);
if (status != ERROR_SUCCESS)
printf("Video acceleration: default\n");
else
}
}
{
/* must have exactly one argument: the new offset */
if ( (argc != 1)
{
printf("Error: invalid video acceleration status!\n");
return;
}
hkeyVideo = getVideoKey(true);
if (hkeyVideo)
{
int fAccel = 0;
fAccel = 1;
/* set a new value */
status = RegSetValueExA(hkeyVideo, "EnableVideoAccel", 0, REG_DWORD, (LPBYTE)&fAccel, sizeof(fAccel));
if (status != ERROR_SUCCESS)
{
}
}
}
#define MAX_CUSTOM_MODES 128
/* the table of custom modes */
struct
{
} customModes[MAX_CUSTOM_MODES] = {0};
{
int curMode = 0;
/* null out the table */
do
{
char valueName[20];
if (status != ERROR_SUCCESS)
break;
if (status != ERROR_SUCCESS)
break;
if (status != ERROR_SUCCESS)
break;
/* check if the mode is OK */
&& ( (bpp != 16)
|| (bpp != 24)
|| (bpp != 32)))
break;
/* add mode to table */
++curMode;
if (curMode >= MAX_CUSTOM_MODES)
break;
} while(1);
}
{
int tableIndex = 0;
int modeIndex = 0;
/* first remove all values */
for (int i = 0; i < MAX_CUSTOM_MODES; i++)
{
char valueName[20];
}
do
{
if (tableIndex >= MAX_CUSTOM_MODES)
break;
/* is the table entry present? */
{
tableIndex++;
continue;
}
printf("writing mode %d (%dx%dx%d)\n", modeIndex, customModes[tableIndex].xres, customModes[tableIndex].yres, customModes[tableIndex].bpp);
char valueName[20];
modeIndex++;
tableIndex++;
} while(1);
}
{
if (argc != 0)
{
printf("Error: too many parameters!");
return;
}
if (hkeyVideo)
{
for (int i = 0; i < (sizeof(customModes) / sizeof(customModes[0])); i++)
{
if ( !customModes[i].xres
|| !customModes[i].yres
|| !customModes[i].bpp)
continue;
printf("Mode: %d x %d x %d\n",
}
}
}
{
if (argc != 3)
{
printf("Error: not enough parameters!\n");
return;
}
/** @todo better check including xres mod 8 = 0! */
&& ( (bpp != 16)
|| (bpp != 24)
|| (bpp != 32)))
{
printf("Error: invalid mode specified!\n");
return;
}
if (hkeyVideo)
{
for (int i = 0; i < MAX_CUSTOM_MODES; i++)
{
/* item free? */
if (!customModes[i].xres)
{
break;
}
}
}
}
{
if (argc != 3)
{
printf("Error: not enough parameters!\n");
return;
}
if (hkeyVideo)
{
for (int i = 0; i < MAX_CUSTOM_MODES; i++)
{
/* correct item? */
{
printf("found mode at index %d\n", i);
break;
}
}
}
}
/**
* Main function
*/
{
if (argc < 2)
{
printHelp();
return 1;
}
/* determine which command */
{
}
{
}
{
}
{
}
{
}
else
{
printHelp();
return 1;
}
return 0;
}