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

📄 smappedmemory.h

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

        $Id: SMappedMemory.h,v 1.2 2002/08/06 20:09:34 dallen Exp $
____________________________________________________________________________*/

#ifndef Included_SMappedMemory_h	// [
#define Included_SMappedMemory_h

#include "CErrorState.h"

#include "CDriverSubsystems.h"
#include "CMemoryLocker.h"

_PGP_BEGIN

// Class SMappedMemory

// SMappedMemory is a helper class that wraps calls to lock/unlock memory
// from user mode.

template <typename T> class SMappedMemory : public CErrorState
{
	NOT_COPYABLE(SMappedMemory)

public:
			SMappedMemory(const T *pObject, PGPUInt32 size = sizeof(T));
	virtual	~SMappedMemory();

	PGPUInt32	Size() const {return mSize;}

	T *			MappedAddress() {return const_cast<T *>(mMappedObject);}
	const T *	MappedAddress() const {return mMappedObject;}


private:
	const T	*mObject;
	const T	*mMappedObject;

	PGPUInt32	mSize;
};


// Class SMappedMemory template member functions

template <typename T> 
inline 
SMappedMemory<T>::SMappedMemory(const T *pObject, PGPUInt32 size) 
	: mObject(pObject), mSize(size)
{
	void	*mappedAddress;

	Status() = CDriverSubsystems::MemoryLocker().LockMemory(pObject, size, 
		&mappedAddress);

	if (Status().IsntError())
		mMappedObject = static_cast<const T *>(mappedAddress);
}

template <typename T> 
inline 
SMappedMemory<T>::~SMappedMemory()
{
	if (Status().IsntError())
		CDriverSubsystems::MemoryLocker().UnlockMemory(mObject);
}

_PGP_END

#endif	// Included_SMappedMemory_h

⌨️ 快捷键说明

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