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

📄 htsglib.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: /inc/HtsGlib.h 2     4/22/00 9:31p Markr $ 
//
///////////////////////////////////////////////////////////////////////////////

#ifndef HTS_GLIB_H
#define HTS_GLIB_H

#pragma once

#ifdef __cplusplus 
extern "C" {
#endif

#include <ntddk.h>

#ifdef __cplusplus
}
#endif


#define HTS_DEBUG_HIGH 0xff
#define HTS_DEBUG_LOW  0x00
#define HTS_DEBUG_MASK 0xff

//
// you must initialize this in your driver:
//
extern ULONG HtsDebugLevel;

#define HTS_DEBUG_THIS_FILE static PCHAR HtsThisFileName = __FILE__;

void HtsDebugPrint(
		ULONG Level,
		PCHAR Format,
		...);

void HtsBugCheck(PCHAR message, 
				 ULONG line=0, 
				 ULONG param2=0, 
				 ULONG param3=0, 
				 ULONG param4=0);

__inline NTSTATUS HtsIrpReturn(PIRP Irp, 
							   NTSTATUS Status, 
							   ULONG Information = 0, 
							   CCHAR Increment=IO_NO_INCREMENT) 
{
	Irp->IoStatus.Status = Status;
	Irp->IoStatus.Information = Information;

	IoCompleteRequest(Irp, Increment);

	return Status;
}

//
// Win2k Finally Gor Smart with Assertions. They work in the
// Free build and they are Prompted asserts that you can 'ride through'
// from the debugger. So we can turn our own asserts off.
//
#define HtsAssert( x ) ASSERT( x )

ULONG HtsExceptionFilter( ULONG Code, PEXCEPTION_POINTERS pointers);

//
// Religious Assumption: always debug unexpected exceptions
//
// Alternative: if not DBG then define HTS_EXCEPTION_FILTER as EXCEPTION_EXECUTE_HANDLER 
//
#ifdef DBG

#define HTS_EXCEPTION_FILTER HtsExceptionFilter(GetExceptionCode(), GetExceptionInformation()) 

#else

#define HTS_EXCEPTION_FILTER  EXCEPTION_EXECUTE_HANDLER 

#endif

//
// a generic lock - implementation as needed
//
class simpleLock {

private:

	simpleLock& operator=(const simpleLock& lhs);
	simpleLock(const simpleLock& lhs);

public:

	simpleLock() {};	
	~simpleLock() {};	

	virtual lock(PVOID& context)=0;
	virtual unlock(PVOID context)=0;
};

class spinLock : simpleLock {

private:

	KSPIN_LOCK  theLock;


public:

	spinLock() { KeInitializeSpinLock(&theLock); };	
	virtual ~spinLock() {};	

	virtual lock(PVOID& context) {

		KIRQL irql;
		KeAcquireSpinLock(&theLock, &irql); 
		context = reinterpret_cast<PVOID>(irql);

	}

	virtual unlock(PVOID context) { 

		KIRQL irql = reinterpret_cast<KIRQL>(context);
		KeReleaseSpinLock(&theLock, irql); 
	}
};

#endif

///////////////////////////////////////////////////////////////////////////////
// 
// Change History Log
//
// $Log: /inc/HtsGlib.h $
// 
// 2     4/22/00 9:31p Markr
// 
// 1     1/27/00 9:20p Markr
//
///////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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