📄 ndisnewdelete.h
字号:
/*____________________________________________________________________________
Copyright (C) 2002 PGP Corporation
All rights reserved.
$Id: ndisNewDelete.h,v 1.3 2002/08/06 20:10:27 dallen Exp $
____________________________________________________________________________*/
// Since NDIS driver use platform independent NDIS memory functions.
// We want take advantage of that.
#ifndef _H_NDISNEWDELETE_
#define _H_NDISNEWDELETE_
//
// Always allocate from the top memory space for software driver
//
#ifdef __cplusplus
extern "C" {
#endif
extern NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress;
#ifdef __cplusplus
}
#endif
const unsigned int NDIS_NEW_DELETE_POOL_MEMORY_FLAG = 0;
inline
void *
__cdecl
operator new(unsigned int nSize)
{
NDIS_STATUS status;
PGPUInt32 poolSize;
PGPByte * poolHandle;
if (nSize == 0)
nSize = 1;
poolSize = nSize + sizeof(PGPUInt32);
status = NdisAllocateMemory((void**)&poolHandle,
poolSize,
NDIS_NEW_DELETE_POOL_MEMORY_FLAG,
HighestAcceptableAddress);
if (status != NDIS_STATUS_SUCCESS)
return 0;
NdisZeroMemory(poolHandle, poolSize);
if (status != NDIS_STATUS_SUCCESS)
return 0;
else
{
*(PGPUInt32 *)poolHandle = nSize;
return poolHandle + sizeof(PGPUInt32);
}
}
////////////////
// Placement New
////////////////
inline
void *
__cdecl
operator new(unsigned int nSize, void *pMem)
{
return pMem;
}
inline
void
__cdecl
operator delete(void *pMem)
{
PGPByte * poolHandle;
PGPUInt32 poolSize;
if (pMem != 0)
{
poolHandle= (PGPByte*)pMem - sizeof(PGPUInt32);
poolSize = *(PGPUInt32*)poolHandle;
NdisFreeMemory(poolHandle, poolSize, NDIS_NEW_DELETE_POOL_MEMORY_FLAG);
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -