NetFltInstall.cpp revision 6db9d06c6fa69e8513eb2771726a90c18f603edd
/* $Id$ */
/** @file
* NetFltInstall - VBoxNetFlt installer command line tool
*/
/*
* Copyright (C) 2008 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include <vbox/WinNetConfig.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".\\VBoxNetFlt_m.inf"
#define VBOX_NETFLT_RETRIES 10
{
}
/** Wrapper aroung GetfullPathNameW that will try an alternative INF location.
*
* The default location is the current directory. If not found there, the
* alternative locatoin is the executable directory. If not found there either,
* the first alternative is present to the caller.
*/
{
#ifdef DEBUG_bird /** @todo make this default behavior after 3.1. */
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;
{
{
if( dwSize > 0
return dwSize;
break;
}
cch++;
}
}
}
/* fallback */
#endif
}
static int InstallNetFlt()
{
int r = 1;
{
#if 0
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);
#endif
}
else
{
r = 1;
}
return r;
}
{
return InstallNetFlt();
}