VBoxNetFltInstall.cpp revision 3331475701a5b12f98b3cfea07d5dca60072530f
/* $Id$ */
/** @file
* NetFltInstall - VBoxNetFlt installer command line tool
*/
/*
* Copyright (C) 2008 Oracle Corporation
*
* 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 (GPL) 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 <VBox/VBoxNetCfg-win.h>
#include <devguid.h>
#include <stdio.h>
#define NETFLT_ID L"sun_VBoxNetFlt"
#define VBOX_NETCFG_APP_NAME L"NetFltInstall"
#define VBOX_NETFLT_PT_INF L".\\VBoxNetFlt.inf"
#define VBOX_NETFLT_MP_INF L".\\VBoxNetFltM.inf"
#define VBOX_NETFLT_RETRIES 10
{
}
/** Wrapper around GetfullPathNameW that will try an alternative INF location.
*
* The default location is the current directory. If not found there, the
* alternative location is the executable directory. If not found there either,
* the first alternative is present to the caller.
*/
{
if(dwSize <= 0)
return dwSize;
/* if it doesn't exist, see if the file exists in the same directory as the executable. */
{
if(cch > 0)
{
cch--;
unsigned i = 0;
{
{
return dwSize;
break;
}
cch++;
}
}
}
/* fallback */
}
static int VBoxNetFltInstall()
{
int r = 1;
{
int i = 0;
do
{
{
if(dwSize > 0)
{
/** @todo add size check for (sizeof(PtInf)/sizeof(PtInf[0])) == dwSize (string length in sizeof(PtInf[0])) */
if(dwSize > 0)
{
/** @todo add size check for (sizeof(MpInf)/sizeof(MpInf[0])) == dwSize (string length in sizeof(MpInf[0])) */
{
wprintf(L"installed successfully\n");
r = 0;
}
else
{
}
}
else
{
}
}
else
{
}
break;
}
{
{
}
else
{
wprintf(L"Error: write lock is owned by another application (%s), close the application and retry installing\n", lpszLockedBy);
r = 1;
break;
}
}
else
{
r = 1;
break;
}
} while(true);
}
else
{
r = 1;
}
return r;
}
{
return VBoxNetFltInstall();
}