www.pudn.com > IpFilter.rar > htscpp.h


/////////////////////////////////////////////////////////////////////////////// 
// 
//	(C) Copyright 1999 - 2000 Mark Roddy 
//	All Rights Reserved 
// 
//	Hollis Technology Solutions 
//	94 Dow Road 
//	Hollis, NH 03049 
//	info@hollistech.com 
// 
//	Synopsis:  
//  
// 
//	Version Information: 
// 
//	$Header: /cpprun/inc/htscpp.h 2     12/31/99 4:29p Markr $  
// 
/////////////////////////////////////////////////////////////////////////////// 
#pragma once 
 
// 
// add externally visible runtime constructs here 
// 
#ifdef __cplusplus  
extern "C" { 
#endif 
 
#include  
 
#ifdef __cplusplus 
} 
#endif 
 
 
 
// 
// memory allocation support 
// 
typedef unsigned int size_t; 
 
#ifdef __cplusplus  
 
void * __cdecl operator new(size_t size); 
 
void * __cdecl operator new(size_t size, void *location); 
 
void *__cdecl operator new( size_t size, ULONG tag, POOL_TYPE pool= NonPagedPool); 
 
void __cdecl operator delete(void * pVoid); 
 
#endif 
 
PVOID __cdecl malloc(ULONG x,  ULONG id= 'ppcO', POOL_TYPE pool = NonPagedPool); 
 
void __cdecl free(PVOID x); 
 
 
__inline PVOID __cdecl malloc(ULONG size,  ULONG id, POOL_TYPE pool) 
{ 
    PVOID buffer = ExAllocatePoolWithTag(pool, size, id); 
 
    if (buffer) { 
        // 
        // clear our buffer to zero 
        // 
        RtlZeroMemory(buffer, size); 
    } 
 
    return buffer; 
} 
 
 
__inline void __cdecl free(PVOID buffer) 
{ 
    if (buffer != NULL) { 
 
        ExFreePool(buffer); 
    } 
} 
 
#ifdef __cplusplus  
 
__inline void * __cdecl operator new(size_t size) 
{ 
    return malloc(size, 'ppcO', NonPagedPool); 
} 
 
 
__inline void * __cdecl operator new(size_t size,  void *location) 
{ 
    return location; 
} 
 
__inline void *__cdecl operator new( size_t size, ULONG tag, POOL_TYPE pool) 
{ 
    return malloc(size, tag, pool); 
} 
 
__inline void __cdecl operator delete(void * pVoid) 
{ 
    free(pVoid); 
} 
 
#endif 
 
// 
// runtime linkage support: 
// 
 
// 
// All you have to do to get C++ runtime support is 
// replace *your* driver entry routine with this one, as in: 
//  
// CPP_DRIVER_ENTRY(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) 
// 
// And link your driver with our C++ runtime library! 
// 
 
#define CPP_DRIVER_ENTRY(Do, Rp) extern "C" NTSTATUS Cp_DriverEntry(Do, Rp) 
 
// 
// and finally, as this might be generally useful: 
// 
typedef void (__cdecl *PVFV)(void); 
 
// 
// this is the standard ANSI atexit function. You can register 
// any arbitrary void function with no parameters through this interface. 
// 
// Registered functions will be called in LIFO order on termination. 
// 
// Termination is defined here as DriverUnload. 
// 
int __cdecl atexit ( 
        PVFV func 
        ); 
 
 
/////////////////////////////////////////////////////////////////////////////// 
//  
// Change History Log 
// 
// $Log: /cpprun/inc/htscpp.h $ 
//  
// 2     12/31/99 4:29p Markr 
//  
// 1     12/17/99 8:12a Markr 
// 
///////////////////////////////////////////////////////////////////////////////