HtsGlib.h
资源名称:IPbao.rar [点击查看]
上传用户:ykzxjx
上传日期:2022-04-03
资源大小:1175k
文件大小:3k
源码类别:
防火墙与安全工具
开发平台:
Visual C++
- ///////////////////////////////////////////////////////////////////////////////
- //
- // (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
- //
- ///////////////////////////////////////////////////////////////////////////////