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

📄 htscpp.h

📁 WMD驱动编程,本人收集整理的10多个例子和编程环境配置文档,特别是8139驱动,加了许多说明,并测试通过.
💻 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 <ntddk.h>

#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
//
///////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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