📄 drivermain.cpp
字号:
/*____________________________________________________________________________
Copyright (C) 2002 PGP Corporation
All rights reserved.
$Id: DriverMain.cpp,v 1.4 2002/08/06 20:09:32 dallen Exp $
____________________________________________________________________________*/
#include "pgpClassesConfig.h"
#include "UDebug.h"
#include "UStaticCpp.h"
#include "CPFLImpFactoryDrvNT.h"
#include "CUnicodeString.h"
#include "CDriverImpFactoryDrvNT.h"
#include "CDriverSubsystemsDrvNT.h"
#include "DriverMain.h"
#include "pgpBuild.h"
#include "UMessageLog.h"
_USING_PGP
_UNNAMED_BEGIN
// Static variables
CUnicodeString RegistryPath;
PDRIVER_OBJECT DriverObject = NULL;
PDRIVER_UNLOAD UnloadRoutine = NULL;
_UNNAMED_END
// Functions for setting and returning initialization parameters
PDRIVER_OBJECT
DriverMain::GetDriverObjectInitParam()
{
return DriverObject;
}
CComboError
DriverMain::GetRegistryPathInitParam(CUnicodeString& registryPath)
{
return registryPath.Assign(RegistryPath);
}
PDRIVER_UNLOAD
DriverMain::GetUnloadRoutineInitParam()
{
return UnloadRoutine;
}
// Driver load and unload functions
void
DriverUnload(PDRIVER_OBJECT pDriverObject)
{
__try
{
UDebug::DebugOut("PGPdisk:: Unloading PGPdisk driver.");
// Destroy PGPdisk driver subsystems.
CDriverSubsystemsDrvNT::DestroySubsystems();
CDriverSubsystemsDrvNT::DestroyInstance();
CDriverImpFactoryDrvNT::DestroyInstance();
CPFLImpFactoryDrvNT::DestroyInstance();
// Must destruct global static C++ objects.
UStaticCpp::CallGlobalDestructors();
UDebug::DebugOut("PGPdisk: PGPdisk driver unloaded successfully.");
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
UDebug::DebugOut("PGPdisk: Kernel-mode exception while unloading "
"PGPdisk driver.");
UMessageLog::Output("Exception caught");
}
}
NTSTATUS
DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING registryPath)
{
NTSTATUS status = STATUS_SUCCESS;
__try
{
CComboError error;
UDebug::DebugOut("PGPdisk: Loading PGPdisk driver.");
UDebug::DebugOut("PGPdisk: PGPdisk driver v%s loaded.",
PGPVERSIONSTRING);
UDebug::DebugOut(PGPCOPYRIGHT);
UDebug::DebugOut("\n");
pgpAssertAddrValid(pDriverObject, PDRIVER_OBJECT);
pgpAssertAddrValid(registryPath, PUNICODE_STRING);
// Must construct global static C++ objects.
UStaticCpp::CallGlobalConstructors();
error = RegistryPath.Status();
if (error.IsntError())
{
// Set some parameters for retrieval by the driver.
DriverObject = pDriverObject;
UnloadRoutine = DriverUnload;
RegistryPath = *registryPath;
error = RegistryPath.Status();
}
// Create PGPdisk driver subsystems.
if (error.IsntError())
{
error = CPFLImpFactoryDrvNT::CreateInstance();
if (error.IsntError())
{
error = CDriverImpFactoryDrvNT::CreateInstance();
if (error.IsntError())
{
error = CDriverSubsystemsDrvNT::CreateInstance();
if (error.IsntError())
{
error = CDriverSubsystemsDrvNT::CreateSubsystems();
if (error.IsntError())
{
UDebug::DebugOut("PGPdisk: PGPdisk driver "
"loaded successfully.");
}
if (error.IsError())
CDriverSubsystemsDrvNT::DestroyInstance();
}
if (error.IsError())
CDriverImpFactoryDrvNT::DestroyInstance();
}
if (error.IsError())
CPFLImpFactoryDrvNT::DestroyInstance();
}
}
if (error.IsError())
{
UDebug::DebugOut("PGPdisk: PGPdisk driver failed to load!");
UStaticCpp::CallGlobalDestructors();
status = STATUS_DRIVER_INTERNAL_ERROR;
}
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
status = STATUS_DRIVER_INTERNAL_ERROR;
UDebug::DebugOut("PGPdisk: Kernel-mode exception while loading "
"PGPdisk driver.");
UMessageLog::Output("Exception caught");
}
return status;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -