📄 hnuserfilter.h
字号:
/****************************************************************************
** **
** PSSDK HNUserFilter module **
** Copyright (c) 1997 - 2006 microOLAP Technologies LTD, **
** Khalturin A.P., Naumov D.A. **
** Header File **
** **
****************************************************************************/
//---------------------------------------------------------------------------
#ifndef __HN_PSSDK_USERFILTER_H__
#define __HN_PSSDK_USERFILTER_H__
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Class CHNUserFilter
//---------------------------------------------------------------------------
class CHNUserFilter
{
private:
HANDLE hFtr;
public:
//###########################################################################
// Create & Destroy
//###########################################################################
//---------------------------------------------------------------------------
// BpfCreate - Creates HNUserFilter object.
CHNUserFilter() { hFtr = BpfCreate(); }
//---------------------------------------------------------------------------
// BpfDestroy - Destroys HNUserFilter object.
~CHNUserFilter() { BpfDestroy(hFtr); }
public:
//###########################################################################
// Additionals methods
//###########################################################################
BOOL IsValid() { return (hFtr != NULL); }
HANDLE Get_Handle() { return hFtr; }
operator HANDLE() { return hFtr; }
public:
//###########################################################################
// Methods of redirect
//###########################################################################
//---------------------------------------------------------------------------
// BpfGetInstructionsCount - Returns the total number of instructions in the user-settable packet filtering program.
DWORD GetInstructionsCount()
{ return BpfGetInstructionsCount(hFtr); }
//---------------------------------------------------------------------------
// BpfClear - Clears the user-settable packet filtering program.
DWORD Clear()
{ return BpfClear(hFtr); }
//---------------------------------------------------------------------------
// BpfAddCmd - Adds an instruction to the user-settable packet filtering program.
DWORD AddCmd(SHORT Code, DWORD k)
{ return BpfAddCmd(hFtr,Code,k); }
//---------------------------------------------------------------------------
// BpfAddJmp - Adds JMP instruction to the user-settable packet filtering program.
DWORD AddJmp(SHORT Code, DWORD k, SHORT TrueOffset, SHORT FalseOffset)
{ return BpfAddJmp(hFtr,Code,k,TrueOffset,FalseOffset); }
//---------------------------------------------------------------------------
// BpfCheckFilter - Checks the BPF program code accuracy.
DWORD CheckFilter() { return BpfCheckFilter(hFtr); }
//---------------------------------------------------------------------------
// BpfGetErrInstruction - Returns the number of the first erroneous instruction in the user-settable packet filtering program.
DWORD GetErrInstruction()
{ return BpfGetErrInstruction(hFtr); }
//---------------------------------------------------------------------------
// BpfCheckPacket - Checks the packet by the user-settable packet filtering program.
DWORD CheckPacket(LPVOID pPacket, DWORD PacketSize)
{ return BpfCheckPacket(hFtr,pPacket,PacketSize); }
//---------------------------------------------------------------------------
// BpfLoadFromFile - Loads the BPF program from the file.
DWORD LoadFromFile(LPCTSTR lpFileName)
{ return BpfLoadFromFile(hFtr,lpFileName); }
//---------------------------------------------------------------------------
// BpfSaveToFile - Saves the BPF program to the file.
DWORD SaveToFile(LPCTSTR lpFileName)
{ return BpfSaveToFile(hFtr,lpFileName); }
//---------------------------------------------------------------------------
// BpfLoadFromMemory - Loads the BPF program from the memory block.
DWORD LoadFromMemory(HN_BPF_PROGRAMM *pProgramm, DWORD Size)
{ return BpfLoadFromMemory(hFtr,pProgramm,Size); }
//---------------------------------------------------------------------------
// BpfSaveToMemory - Saves the BPF program to memory.
DWORD SaveToMemory(HN_BPF_PROGRAMM *pProgramm, DWORD Size)
{ return BpfSaveToMemory(hFtr,pProgramm,Size); }
//---------------------------------------------------------------------------
// BpfGetProgrammSize - Returns the size of the user-settable packet filtering program in bytes.
DWORD GetProgrammSize()
{ return BpfGetProgrammSize(hFtr); }
//#######################################################################
// Added to 2.2
//---------------------------------------------------------------------------
// v2.2 - BpfGetUseFastBPF - Returns the status flag of the FastBPF using.
BOOL Get_UseFastBPF()
{ return BpfGetUseFastBPF(hFtr); }
//---------------------------------------------------------------------------
// v2.2 - BpfSetUseFastBPF - Turns on/off FastBPF.
BOOL Set_UseFastBPF(BOOL bUseFastBpf)
{ return BpfSetUseFastBPF(hFtr,bUseFastBpf); }
//---------------------------------------------------------------------------
// v2.2 - BpfCompileToFastBPF - Compiles BPF filter in a 32-bit optimized CPU code.
DWORD CompileToFastBPF()
{ return BpfCompileToFastBPF(hFtr); }
//---------------------------------------------------------------------------
// v2.2 - BpfCompileBPFDefinesFromFile - Compiles constants definitions from a file.
DWORD CompileBPFDefinesFromFile(LPCTSTR lpFileName)
{ return BpfCompileBPFDefinesFromFile(hFtr,lpFileName); }
//---------------------------------------------------------------------------
// v2.2 - BpfCompileBPFDefinesFromStr - Compiles constants definitions from an ASCIIZ string.
DWORD CompileBPFDefinesFromStr(LPCSTR Str)
{ return BpfCompileBPFDefinesFromStr(hFtr,Str); }
//---------------------------------------------------------------------------
// v2.2 - BpfCompileBPFAsmFromFile - Compiles the BPF filtering program written in BPF assembler from a specified file.
DWORD CompileBPFAsmFromFile(LPCTSTR lpFileName)
{ return BpfCompileBPFAsmFromFile(hFtr,lpFileName); }
//---------------------------------------------------------------------------
// v2.2 - BpfCompileBPFAsmFromStr - Compiles the BPF filtering program written in BPF assembler from a string.
DWORD CompileBPFAsmFromStr(LPCSTR Str)
{ return BpfCompileBPFAsmFromStr(hFtr,Str); }
//---------------------------------------------------------------------------
// v2.2 - BpfDecompileBPFAsmToFile - Decompiles BPF program into BPF assembler source and saves it in a file.
DWORD DecompileBPFAsmToFile(LPCTSTR lpFileName, BOOL StrLabels)
{ return BpfDecompileBPFAsmToFile(hFtr,lpFileName,StrLabels);}
//---------------------------------------------------------------------------
// v2.2 - BpfDecompileBPFAsmToStr - Decompiles BPF program into BPF assembler source and saves it in the memory allocated by application.
DWORD DecompileBPFAsmToStr(LPSTR Str, DWORD *pSize, BOOL StrLabels)
{return BpfDecompileBPFAsmToStr(hFtr,Str,pSize,StrLabels); }
//---------------------------------------------------------------------------
// v2.2 - BpfSetOnBPFAsmError - Sets the OnBPFAsmError event.
FARPROC Set_OnBPFAsmError(FARPROC pfOnBPFAsmError, DWORD_PTR Param)
{ return BpfSetOnBPFAsmError(hFtr,pfOnBPFAsmError,Param); }
};
//---------------------------------------------------------------------------
#endif // __HN_PSSDK_USERFILTER_H__
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -