📄 cdrivercommimp.cpp
字号:
/*____________________________________________________________________________
Copyright (C) 2002 PGP Corporation
All rights reserved.
$Id: CDriverCommImp.cpp,v 1.10 2002/08/06 20:09:36 dallen Exp $
____________________________________________________________________________*/
#include "pgpClassesConfig.h"
#include "pgpClientErrors.h"
#include "CPGPContext.h"
#include "CDriverCommImp.h"
_USING_PGP
// Class CDriverCommImp member functions
void
CDriverCommImp::Startup()
{
try
{
OpenDriver();
PGPUInt32 driverApiVersion;
QueryVersion(driverApiVersion);
if (DriverAPI::MajorVersion(driverApiVersion) !=
DriverAPI::MajorVersion(DriverAPI::kVersion))
{
THROW_PGPERROR(kPGPClientError_DiskDriverIncompat);
}
}
catch (CComboError&)
{
#if !PGP_DEBUG
throw;
#endif // !PGP_DEBUG
}
}
void
CDriverCommImp::Shutdown()
{
if (IsDriverOpened())
CloseDriver();
}
void
CDriverCommImp::QueryVersion(PGPUInt32& driverApiVersion) const
{
#if PGP_DEBUG
if (!IsDriverOpened())
{
driverApiVersion = DriverAPI::kVersion;
return;
}
#endif // PGP_DEBUG
DriverAPI::CCommandQueryVersion QV(DriverAPI::kVersion);
SendPacket(&QV.Header(), sizeof(QV));
driverApiVersion = QV.DriverApiVersion();
}
void
CDriverCommImp::QueryMountedPath(
const char *path,
PGPBoolean& isMounted) const
{
pgpAssertStrValid(path);
#if PGP_DEBUG
if (!IsDriverOpened())
{
isMounted = FALSE;
return;
}
#endif // PGP_DEBUG
DriverAPI::CCommandQueryMounted QM(path, TRUE);
SendPacket(&QM.Header(), sizeof(QM));
isMounted = QM.IsMountedPGPdisk();
}
void
CDriverCommImp::QueryMountedRoot(
const char *root,
PGPBoolean& isMounted) const
{
pgpAssertStrValid(root);
#if PGP_DEBUG
if (!IsDriverOpened())
{
isMounted = FALSE;
return;
}
#endif // PGP_DEBUG
DriverAPI::CCommandQueryMounted QM(root, FALSE);
SendPacket(&QM.Header(), sizeof(QM));
isMounted = QM.IsMountedPGPdisk();
}
void
CDriverCommImp::QueryAllMounted(
PGPdiskInfo *pInfoArray,
PGPUInt32 elemsArray,
PGPUInt32& elemsFilled) const
{
pgpAssertAddrValid(pInfoArray, PGPdiskInfo);
#if PGP_DEBUG
if (!IsDriverOpened())
{
elemsFilled = 0;
return;
}
#endif // PGP_DEBUG
DriverAPI::CCommandQueryAllMounted QAM(pInfoArray, elemsArray);
try
{
SendPacket(&QAM.Header(), sizeof(QAM));
elemsFilled = QAM.ElemsFilled();
}
catch (CComboError&)
{
elemsFilled = QAM.ElemsFilled(); // space needed if not enough
throw;
}
}
void
CDriverCommImp::NotifyUserLogoff() const
{
#if PGP_DEBUG
if (!IsDriverOpened())
return;
#endif // PGP_DEBUG
DriverAPI::CCommandNotifyUserLogoff NUL;
SendPacket(&NUL.Header(), sizeof(NUL));
}
void
CDriverCommImp::SetTimeout(const char *root, PGPUInt32 seconds) const
{
#if PGP_DEBUG
if (!IsDriverOpened())
return;
#endif // PGP_DEBUG
// driver wants this in seconds
DriverAPI::CCommandSetTimeout ST(root, seconds * 60);
SendPacket(&ST.Header(), sizeof(ST));
}
PGPBoolean
CDriverCommImp::AreDisksTimedOut() const
{
#if PGP_DEBUG
if (!IsDriverOpened())
return FALSE;
#endif // PGP_DEBUG
DriverAPI::CCommandAreDisksTimedOut ADTO;
SendPacket(&ADTO.Header(), sizeof(ADTO));
return ADTO.AreDisksTimedOut();
}
void
CDriverCommImp::ResetTimedOutDisk(const char *root) const
{
pgpAssertStrValid(root);
#if PGP_DEBUG
if (!IsDriverOpened())
return;
#endif // PGP_DEBUG
DriverAPI::CCommandResetTimedOut RTO(root);
SendPacket(&RTO.Header(), sizeof(RTO));
}
void
CDriverCommImp::Mount(
const char *path,
const char *root,
PGPdiskEncryptionAlgorithm algorithm,
const void *exportedContext,
PGPUInt32 sizeContext,
PGPUInt64 firstDataBlock,
PGPUInt64 numDataBlocks,
CString& deviceName,
PGPBoolean readOnly) const
{
pgpAssertStrValid(path);
#if PGP_DEBUG
if (!IsDriverOpened())
{
deviceName = "homeyclown";
return;
}
#endif // PGP_DEBUG
DriverAPI::CCommandMount M(path, root, algorithm, exportedContext,
sizeContext, firstDataBlock, numDataBlocks, readOnly);
SendPacket(&M.Header(), sizeof(M));
deviceName = M.DeviceName();
}
void
CDriverCommImp::Unmount(const char *root, PGPBoolean isForced) const
{
pgpAssertStrValid(root);
#if PGP_DEBUG
if (!IsDriverOpened())
return;
#endif // PGP_DEBUG
DriverAPI::CCommandUnmount U(root, isForced);
SendPacket(&U.Header(), sizeof(U));
}
PGPUInt32
CDriverCommImp::LockVolume(const char *root, PGPBoolean forFormat) const
{
pgpAssertStrValid(root);
#if PGP_DEBUG
if (!IsDriverOpened())
return 0;
#endif // PGP_DEBUG
DriverAPI::CCommandLockVolume LV(root, forFormat);
SendPacket(&LV.Header(), sizeof(LV));
return LV.Handle();
}
void
CDriverCommImp::UnlockVolume(PGPUInt32 handle) const
{
#if PGP_DEBUG
if (!IsDriverOpened())
return;
#endif // PGP_DEBUG
DriverAPI::CCommandUnlockVolume ULV(handle);
SendPacket(&ULV.Header(), sizeof(ULV));
}
void
CDriverCommImp::IOVolume(
PGPUInt32 handle,
PGPBoolean trueIfRead,
void *buffer,
PGPUInt64 blockPos,
PGPUInt32 blocksLength) const
{
pgpAssertAddrValid(buffer, VoidAlign);
#if PGP_DEBUG
if (!IsDriverOpened())
return;
#endif // PGP_DEBUG
DriverAPI::CCommandIOVolume IOV(handle, trueIfRead, buffer, blockPos,
blocksLength);
SendPacket(&IOV.Header(), sizeof(IOV));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -