⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 driverapi.h

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 H
字号:
/*____________________________________________________________________________
		Copyright (C) 2002 PGP Corporation
        All rights reserved.

        $Id: DriverAPI.h,v 1.9 2002/08/06 20:10:18 dallen Exp $
____________________________________________________________________________*/

#ifndef Included_DriverAPI_h	// [
#define Included_DriverAPI_h

#if defined(PGP_DRIVER98) || defined(PGP_DRIVERNT)
#include <devioctl.h>
#elif defined(PGP_WIN32)
#include <winioctl.h>
#endif	// PGP_DRIVER98 || PGP_DRIVERNT

#include "pgpDiskPubTypes.h"

_PGP_BEGIN

// Align to 1.
#if PGP_WIN32
#pragma pack(push, 1)
#endif

namespace DriverAPI
{
	// Constants

	enum
	{
		kIoctlBase		= 0x800, 
		kCommandMagic	= 0x820F7353, 
		kVersion		= 0x01000000, 

	#if defined(PGP_WIN32)
		kSendPacketIoctl	= CTL_CODE(FILE_DEVICE_DISK, kIoctlBase, 
			METHOD_NEITHER, FILE_ANY_ACCESS) | 0x40000000
	#endif	// PGP_WIN32
	};

	static const WCHAR	*kPGPdiskDriverNameW	= L"PGPdisk";
	static const char	*kPGPdiskDriverNameA	= "PGPdisk";
	static const char	*kPGPdiskDeviceDir		= "PGPdisks";

	enum CommandId
	{
		kNoOpCmdId				= 1, 
		kQueryVersionCmdId		= 2, 
		kQueryMountedCmdId		= 3, 
		kQueryAllMountedCmdId	= 4, 
		kNotifyUserLogoffCmdId	= 5, 
		kSetTimeoutCmdId		= 6, 
		kAreDisksTimedOutCmdId	= 7, 
		kResetTimedOutCmdId		= 8, 
		kMountCmdId				= 9, 
		kUnmountCmdId			= 10, 
		kLockVolumeCmdId		= 11, 
		kUnlockVolumeCmdId		= 12, 
		kIOVolumeCmdId			= 13
	};
		
	inline 
	PGPUInt32 
	MajorVersion(PGPUInt32 v)
	{
		return ((v & 0xFF000000) >> 24);
	}

	inline 
	PGPUInt32 
	MinorVersion(PGPUInt32 v)
	{
		return ((v & 0x00FFF000) >> 16);
	}

	inline 
	PGPUInt32 
	RevVersion(PGPUInt32 v)
	{
		return ((v & 0x00000FF0) >> 4);
	}
	
	// Macros

	#define DECLARE_HEADER()												\
		public:																\
			CCommandHeader	mHeader;										\
			CCommandHeader&	Header() {return mHeader;}

	// Class CCommandHeader

	class CCommandHeader
	{
	public:
		CCommandHeader(CommandId command) : mMagic(kCommandMagic), 
			mCommand(command)
		{
		}

		CComboError		VerifyMagic() const 
		{
			CComboError	error;

			if (mMagic != kCommandMagic)
				error.pgpErr = kPGPError_BadParams;

			return error;
		}

		CommandId		Command() const {return mCommand;}		// in
		CComboError&	DriverError() {return mDriverError;}	// out

	private:
		const PGPUInt32	mMagic;

		CommandId	mCommand;
		CComboError	mDriverError;
	};


	// Class CCommandNoOp

	class CCommandNoOp
	{
		DECLARE_HEADER();

	public:
		CCommandNoOp() : mHeader(kNoOpCmdId) { }
	};


	// Class CCommandQueryVersion

	class CCommandQueryVersion
	{
		DECLARE_HEADER();

	public:
		CCommandQueryVersion(PGPUInt32 userApiVersion) : 
		  mHeader(kQueryVersionCmdId), mDriverApiVersion(userApiVersion)
		{
		}

		PGPUInt32	UserApiVersion() const {return mUserApiVersion;}	// in
		PGPUInt32&	DriverApiVersion() {return mDriverApiVersion;}		// out

	private:
		PGPUInt32	mUserApiVersion;
		PGPUInt32	mDriverApiVersion;
	};


	// Class CCommandQueryMounted

	class CCommandQueryMounted
	{
		DECLARE_HEADER();

	public:
		CCommandQueryMounted(const char *pathOrRoot, PGPBoolean trueIfPath) : 
			mHeader(kQueryMountedCmdId), mTrueIfPath(trueIfPath)
		{
			pgpAssertStrValid(pathOrRoot);
			strcpy(mPathOrRoot, pathOrRoot);
		}

		const char *	PathOrRoot() const {return mPathOrRoot;}		// in
		PGPBoolean		TrueIfPath() const {return mTrueIfPath;}		// in
		PGPBoolean&		IsMountedPGPdisk() {return mIsMountedPGPdisk;}	// out

	private:
		char		mPathOrRoot[kPGPdiskMaxPathLength];
		PGPBoolean	mTrueIfPath;

		PGPBoolean	mIsMountedPGPdisk;
	};


	// Class CCommandQueryAllMounted

	class CCommandQueryAllMounted
	{
		DECLARE_HEADER();

	public:
		CCommandQueryAllMounted(PGPdiskInfo *pInfoArray, 
			PGPUInt32 elemsArray) : 
		
			mHeader(kQueryAllMountedCmdId), mInfoArray(pInfoArray), 
				mElemsArray(elemsArray)
		{
			pgpAssertAddrValid(pInfoArray, PGPdiskInfo);
		}

		PGPdiskInfo&	GetElem(PGPUInt32 numElem) const 		// out
		{
			return mInfoArray[numElem];
		}

		PGPUInt32	ElemsArray() const {return mElemsArray;}	// in
		PGPUInt32&	ElemsFilled() {return mElemsFilled;}		// out

	private:
		PGPdiskInfo	*mInfoArray;

		PGPUInt32	mElemsArray;
		PGPUInt32	mElemsFilled;
	};


	// Class CCommandNotifyUserLogoff

	class CCommandNotifyUserLogoff
	{
		DECLARE_HEADER();

	public:
		CCommandNotifyUserLogoff() : mHeader(kNotifyUserLogoffCmdId)
		{
		}
	};


	// Class CCommandSetTimeout

	class CCommandSetTimeout
	{
		DECLARE_HEADER();

	public:
		CCommandSetTimeout(const char *root, PGPUInt32 seconds) : 
			mHeader(kSetTimeoutCmdId), mSeconds(seconds)
		{
			pgpAssertStrValid(root);
			strcpy(mRoot, root);
		}

		const char *	Root() const {return mRoot;}		// in
		PGPUInt32		Seconds() const {return mSeconds;}	// in

	private:
		char		mRoot[kPGPdiskMaxPathLength];
		PGPUInt32	mSeconds;
	};


	// Class CCommandAreDisksTimedOut

	class CCommandAreDisksTimedOut
	{
		DECLARE_HEADER();

	public:
		CCommandAreDisksTimedOut() : mHeader(kAreDisksTimedOutCmdId)
		{
		}

		PGPBoolean&	AreDisksTimedOut() {return mAreDisksTimedOut;}	// out

	private:
		PGPBoolean	mAreDisksTimedOut;
	};


	// Class CCommandResetTimedOut

	class CCommandResetTimedOut
	{
		DECLARE_HEADER();

	public:
		CCommandResetTimedOut(const char *root) : 
		  mHeader(kResetTimedOutCmdId)
		{
			pgpAssertStrValid(root);
			strcpy(mRoot, root);
		}

		const char *	Root() const {return mRoot;}	// in

	private:
		char	mRoot[kPGPdiskMaxPathLength];
	};


	// Class CCommandMount

	class CCommandMount
	{
		DECLARE_HEADER();

	public:
		CCommandMount(const char *path, const char *root, 
			PGPdiskEncryptionAlgorithm algorithm, 
			const void *exportedContext, PGPUInt32 sizeContext, 
			PGPUInt64 firstDataBlock, PGPUInt64 numDataBlocks, 
			PGPBoolean readOnly = FALSE) : 
		
			mHeader(kMountCmdId), mAlgorithm(algorithm), 
			mExportedContext(exportedContext), mSizeContext(sizeContext), 
			mFirstDataBlock(firstDataBlock), mNumDataBlocks(numDataBlocks), 
			mIsReadOnly(readOnly)
		{
			pgpAssertStrValid(path);
			pgpAssertStrValid(root);
			pgpAssertAddrValid(exportedContext, VoidAlign);

			strcpy(mPath, path);
			strcpy(mRoot, root);
		}

		const char *	Path() const {return mPath;}		// in
		const char *	Root() {return mRoot;}				// in
		char *			DeviceName() {return mDeviceName;}	// out

		PGPBoolean	IsReadOnly() const {return mIsReadOnly;}	// in
		PGPdiskEncryptionAlgorithm	Algorithm() const {return mAlgorithm;}

		const void	*ExportedContext() const {return mExportedContext;}	// in
		PGPUInt32	SizeContext() const {return mSizeContext;}			// in
		PGPUInt64	FirstDataBlock() const {return mFirstDataBlock;}	// in
		PGPUInt64	NumDataBlocks() const {return mNumDataBlocks;}		// in

	private:
		char	mPath[kPGPdiskMaxPathLength];
		char	mRoot[kPGPdiskMaxPathLength];
		char	mDeviceName[kPGPdiskMaxDeviceNameLength];

		PGPBoolean	mIsReadOnly;

		PGPdiskEncryptionAlgorithm	mAlgorithm;
		const void	*mExportedContext;
		PGPUInt32	mSizeContext;
		PGPUInt64	mFirstDataBlock;
		PGPUInt64	mNumDataBlocks;
	};


	// Class CCommandUnmount

	class CCommandUnmount
	{
		DECLARE_HEADER();

	public:
		CCommandUnmount(const char *root, PGPBoolean isForced) : 
		  mHeader(kUnmountCmdId), mIsForced(isForced)
		{
			pgpAssertStrValid(root);
			strcpy(mRoot, root);
		}

		const char *	Root() const {return mRoot;}			// in
		PGPBoolean		IsForced() const {return mIsForced;}	// in

	private:
		char		mRoot[kPGPdiskMaxPathLength];
		PGPBoolean	mIsForced;
	};


	// Class CCommandLockVolume
	//
	// NOTE: FOR SECURITY REASONS THE BELOW API IS NOT ENABLED UNDER NT.

	class CCommandLockVolume
	{
		DECLARE_HEADER();

	public:
		CCommandLockVolume(const char *root, PGPBoolean forFormat) : 
		  mHeader(kLockVolumeCmdId), mForFormat(forFormat)
		{
			pgpAssertStrValid(root);
			strcpy(mRoot, root);
		}

		const char *	Root() const {return mRoot;}			// in
		PGPBoolean		ForFormat() const {return mForFormat;}	// in
		PGPUInt32&		Handle() {return mHandle;}				// out

	private:
		char		mRoot[kPGPdiskMaxPathLength];
		PGPBoolean	mForFormat;
		PGPUInt32	mHandle;
	};


	// Class CCommandUnlockVolume
	//
	// NOTE: FOR SECURITY REASONS THE BELOW API IS NOT ENABLED UNDER NT.

	class CCommandUnlockVolume
	{
		DECLARE_HEADER();

	public:
		CCommandUnlockVolume(PGPUInt32 handle) : 
		  mHeader(kUnlockVolumeCmdId), mHandle(handle)
		{
		}

		PGPUInt32	Handle() const {return mHandle;}	// in

	private:
		PGPUInt32	mHandle;
	};


	// Class CCommandIOVolume
	//
	// NOTE: FOR SECURITY REASONS THE BELOW API IS NOT ENABLED UNDER NT.

	class CCommandIOVolume
	{
		DECLARE_HEADER();

	public:
		CCommandIOVolume(PGPUInt32 handle, PGPBoolean trueIfRead, 
			void *buffer, PGPUInt64 blockPos, PGPUInt32 blocksLength) : 
		
			mHeader(kIOVolumeCmdId), mHandle(handle), 
			mTrueIfRead(trueIfRead), mBuffer(buffer), mBlockPos(blockPos), 
			mBlocksLength(blocksLength)
		{
			pgpAssertAddrValid(buffer, VoidAlign);
		}

		PGPUInt32	Handle() const {return mHandle;}				// in
		PGPBoolean	TrueIfRead() const {return mTrueIfRead;}		// in

		void *		Buffer() const {return mBuffer;}				// in
		PGPUInt64	BlockPos() const {return mBlockPos;}			// in
		PGPUInt32	BlocksLength() const {return mBlocksLength;}	// in

	private:
		PGPUInt32	mHandle;
		PGPBoolean	mTrueIfRead;

		void		*mBuffer;
		PGPUInt64	mBlockPos;
		PGPUInt32	mBlocksLength;
	};
}

// Restore alignment.
#if PGP_WIN32
#pragma pack(pop)
#endif

_PGP_END

#endif	// ] Included_DriverAPI_h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -