📄 smappedmemory.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 + -