#include "assert.h"
#include "util.h"
-extern PULONG InitSafeBootMode;
-
typedef struct _XENVIF_DRIVER {
PDRIVER_OBJECT DriverObject;
HANDLE ParametersKey;
static XENVIF_DRIVER Driver;
+extern PULONG InitSafeBootMode;
+
+static FORCEINLINE BOOLEAN
+__DriverSafeMode(
+ VOID
+ )
+{
+ return (*InitSafeBootMode > 0) ? TRUE : FALSE;
+}
+
+BOOLEAN
+DriverSafeMode(
+ VOID
+ )
+{
+ return __DriverSafeMode();
+}
+
static FORCEINLINE VOID
__DriverSetDriverObject(
IN PDRIVER_OBJECT DriverObject
Trace("====>\n");
- if (*InitSafeBootMode > 0)
- goto done;
-
Driver.NeedReboot = FALSE;
StatusKey = __DriverGetStatusKey();
MONTH,
YEAR);
-done:
__DriverSetDriverObject(NULL);
ASSERT(IsZeroMemory(&Driver, sizeof (XENVIF_DRIVER)));
__DriverSetDriverObject(DriverObject);
- if (*InitSafeBootMode > 0)
- goto done;
-
Driver.DriverObject->DriverUnload = DriverUnload;
Info("XENVIF %d.%d.%d (%d) (%02d.%02d.%04d)\n",
DriverObject->MajorFunction[Index] = Dispatch;
}
-done:
Trace("<====\n");
return STATUS_SUCCESS;
PdoUnplugRequest(Pdo, TRUE);
+ if (DriverSafeMode())
+ goto fail2;
+
status = RegistryOpenSoftwareKey(__PdoGetDeviceObject(Pdo),
KEY_ALL_ACCESS,
&SoftwareKey);
if (!NT_SUCCESS(status))
- goto fail2;
+ goto fail3;
status = RegistryOpenHardwareKey(__PdoGetDeviceObject(Pdo),
KEY_ALL_ACCESS,
&HardwareKey);
if (!NT_SUCCESS(status))
- goto fail3;
+ goto fail4;
(VOID) PdoSetFriendlyName(Pdo,
SoftwareKey,
status = __PdoSetCurrentAddress(Pdo, SoftwareKey);
if (!NT_SUCCESS(status))
- goto fail4;
+ goto fail5;
status = LinkGetRoutineAddress("netio.sys",
"GetIfTable2",
(PVOID *)&__GetIfTable2);
if (!NT_SUCCESS(status))
- goto fail5;
+ goto fail6;
status = LinkGetRoutineAddress("netio.sys",
"FreeMibTable",
(PVOID *)&__FreeMibTable);
if (!NT_SUCCESS(status))
- goto fail6;
+ goto fail7;
status = __GetIfTable2(&Table);
if (!NT_SUCCESS(status))
- goto fail7;
+ goto fail8;
//
// Look for a network interface with the same permanent address
continue;
status = STATUS_UNSUCCESSFUL;
- goto fail8;
+ goto fail9;
}
//
status = PdoD3ToD0(Pdo);
if (!NT_SUCCESS(status))
- goto fail9;
+ goto fail10;
__PdoSetDevicePnpState(Pdo, Started);
return STATUS_SUCCESS;
-fail9:
- Error("fail9\n");
+fail10:
+ Error("fail10\n");
__FreeMibTable(Table);
goto fail6;
-fail8:
- Error("fail8\n");
+fail9:
+ Error("fail9\n");
(VOID) SettingsSave(SoftwareKey,
Row->Alias,
DriverRequestReboot();
__FreeMibTable(Table);
+fail8:
+ Error("fail8\n");
+
fail7:
Error("fail7\n");
fail6:
Error("fail6\n");
+ RtlZeroMemory(&Pdo->CurrentAddress, sizeof (ETHERNET_ADDRESS));
+
fail5:
Error("fail5\n");
- RtlZeroMemory(&Pdo->CurrentAddress, sizeof (ETHERNET_ADDRESS));
+ RegistryCloseKey(HardwareKey);
fail4:
Error("fail4\n");
- RegistryCloseKey(HardwareKey);
+ RegistryCloseKey(SoftwareKey);
fail3:
Error("fail3\n");
- RegistryCloseKey(SoftwareKey);
-
fail2:
Error("fail2\n");